{"id":867,"date":"2014-12-23T03:47:43","date_gmt":"2014-12-23T08:47:43","guid":{"rendered":"http:\/\/blogs.law.harvard.edu\/acts\/?p=867"},"modified":"2019-02-26T16:32:47","modified_gmt":"2019-02-26T21:32:47","slug":"road-to-docker-part-1","status":"publish","type":"post","link":"https:\/\/archive.blogs.harvard.edu\/acts\/2014\/12\/23\/road-to-docker-part-1\/","title":{"rendered":"Road to Docker Part 1"},"content":{"rendered":"<p><em>Let me be perfectly honest, there will probably not be a part 2.<\/em> Easy as docker is, there&#8217;s still a bit of a barrier to entry. I&#8217;m a software dev, I don&#8217;t really want to configure vms, but, well, devops. I don&#8217;t need to know how to do everything, but I want some understanding of how these pieces fit together. So I took one of our projects and spent some time yesterday to containerized it. I&#8217;m going to go through how I went about it.<\/p>\n<h2>Step 1. The Search for Tutorials<\/h2>\n<p>I spent a while looking through tutorials. Trying to find a good one. Spoiler: I didn&#8217;t. I was able to make use of this one mostly: <a href=\"https:\/\/www.digitalocean.com\/community\/tutorials\/docker-explained-how-to-containerize-python-web-applications\">https:\/\/www.digitalocean.com\/community\/tutorials\/docker-explained-how-to-containerize-python-web-applications<\/a> It\u2019s a very long tutorial that I was able to pick and choose some things out of. I\u2019m really sad there isn\u2019t a better tutorial. (That 5 minute docker tutorial is cute, but ultimately worthless.)<\/p>\n<h2>Step 2. Installing Docker on a Mac<\/h2>\n<p>I wanted to create docker containers on my laptop. It didn\u2019t take long to discover this isn\u2019t really something you can do directly. I wanted to avoid creating a vagrant-virtualbox just to create docker images, so I searched for the standard of what people do. The answer is they use something called boot2docker (<a href=\"https:\/\/github.com\/boot2docker\/osx-installer\/releases\/tag\/v1.4.1\">https:\/\/github.com\/boot2docker\/osx-installer\/releases\/tag\/v1.4.1<\/a>), which, as it turns out, just just a linux virtualbox to run docker on. Go figure.<\/p>\n<h2>Step 3. Creating a Container &#8212; Dockerfile<\/h2>\n<p>Upon reading how to create a container manually, it seemed silly to not just create a Dockerfile. A Dockerfile is just a config file that allows docker to create the image. Having mild familiarity with vagrant configs and puppet, the Dockerfile is a way to keep a simple, replicable record of the docker image being created. And simple it is. The format is more readable than it\u2019s cousin, Vagrantfile. It was a simple thing to create the Dockerfile for my Django app. (<a href=\"https:\/\/gist.github.com\/jazahn\/aca49f3e3f9a5b819bce\">https:\/\/gist.github.com\/jazahn\/aca49f3e3f9a5b819bce<\/a>) It uses only a few simple keywords. The most useful being RUN.<\/p>\n<h2>Step 4. Creating the Image &#8212; build<\/h2>\n<p>This was just a simple docker build command<\/p>\n<pre>docker build -t docker_image_label .<\/pre>\n<p>This creates a new image, labelled with the -t param.<\/p>\n<h2>Step 4.5. Finding and Removing Images<\/h2>\n<pre>docker images<\/pre>\n<p>This will list all images (on the boot2docker vm) which you can choose to<\/p>\n<pre>docker rm &lt;name&gt;<\/pre>\n<h2>Step 5. Running the Image &#8212; run<\/h2>\n<p>This was just a simple docker run command. There are several ways to run, I went with the following:<\/p>\n<pre>docker run -d -p 8080:8080 --name docker_instance_name docker_image_label<\/pre>\n<p>This just uses -d to run it as a daemon, -p to forward the ports* *It must be noted that \u201cforwarding the ports\u201d is only relevant to the boot2docker virtualbox. To see the result, you should make use of the built in ip reporting for boot2docker.<\/p>\n<pre>boot2docker ip<\/pre>\n<p><a href=\"http:\/\/viget.com\/extend\/how-to-use-docker-on-os-x-the-missing-guide\">http:\/\/viget.com\/extend\/how-to-use-docker-on-os-x-the-missing-guide<\/a><\/p>\n<h2>Step 5.5. Stopping Docker, Killing Docker<\/h2>\n<pre>docker ps<\/pre>\n<p>This will give a listing of the running docker instances, so you can<\/p>\n<pre>docker kill &lt;name&gt;<\/pre>\n<h2>Step 6. Docker Hub<\/h2>\n<p>One thing that was neato to discover is that knowledge of github \/ git was translatable to docker. They have designed the usage of Docker Hub around \u201cpush\u201d and \u201cpull\u201d concepts. It\u2019s just a matter of pushing images up so they can be pulled down later. What I wasn\u2019t able to find was how to actually send the Dockerfile along with the image. It\u2019s not strictly necessary, but I\u2019ve seen it on other projects, so I know it\u2019s possible&#8230;<\/p>\n<h2>Conclusion<\/h2>\n<p>Getting the container up and running and distributable was no big deal, but this was not enough. Next steps would be to grab a mysql docker image from the hub and have the two communicate with each other. Right now I&#8217;m really just using the container as a VM, which isn&#8217;t really the point of docker.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Let me be perfectly honest, there will probably not be a part 2. Easy as docker is, there&#8217;s still a bit of a barrier to entry. I&#8217;m a software dev, I don&#8217;t really want to configure vms, but, well, devops. I don&#8217;t need to know how to do everything, but I want some understanding of [&hellip;]<\/p>\n","protected":false},"author":4571,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[111284,64049,111283,59088],"class_list":["post-867","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-continuous-delivery","tag-continuous-integration","tag-docker","tag-tutorial"],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/posts\/867","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/users\/4571"}],"replies":[{"embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/comments?post=867"}],"version-history":[{"count":3,"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/posts\/867\/revisions"}],"predecessor-version":[{"id":870,"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/posts\/867\/revisions\/870"}],"wp:attachment":[{"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/media?parent=867"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/categories?post=867"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/archive.blogs.harvard.edu\/acts\/wp-json\/wp\/v2\/tags?post=867"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}