{"id":663,"date":"2015-11-27T11:22:22","date_gmt":"2015-11-27T11:22:22","guid":{"rendered":"http:\/\/www.mirageglobe.com\/wp\/?p=663"},"modified":"2018-11-09T11:31:20","modified_gmt":"2018-11-09T11:31:20","slug":"getting-started-with-docker","status":"publish","type":"post","link":"https:\/\/pages.alldaycity.com\/mirageglobe\/getting-started-with-docker\/","title":{"rendered":"Getting started with Docker (docker-toolbox)"},"content":{"rendered":"<p><a href=\"https:\/\/pages.alldaycity.com\/mirageglobe\/wp-content\/uploads\/sites\/2\/2015\/11\/docker201511.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-665\" src=\"https:\/\/pages.alldaycity.com\/mirageglobe\/wp-content\/uploads\/sites\/2\/2015\/11\/docker201511.png\" alt=\"docker201511\" width=\"2466\" height=\"1002\"><\/a><br \/>\nIf you are in software development and web development, you are likely to have come across Docker as well as Vagrant. These are the two important Virtualisation tools that you will use for your development\/production workflows.<br \/>\nFor MacOSX you can install via Dockertoolbox:&nbsp;<a href=\"http:\/\/docs.docker.com\/mac\/started\/\">http:\/\/docs.docker.com\/mac\/started\/<\/a>&nbsp;. The Mac version is quite straightforward; either you can download the docker toolbox image (which consists of docker-compose, docker, docker-machine) or install it via brew if you have homebrew installed.<\/p>\n<blockquote><p>$brew cask install docker-toolbox<\/p><\/blockquote>\n<p>For Linux Ubuntu, you can install via apt-get. Note that the version in apt-get repository is quite dated. The recommended Ubuntu version is 14.04 Trusty (LTS &#8211; Long Term Support). Full detailed instructions can be found:&nbsp;<a href=\"https:\/\/docs.docker.com\/engine\/installation\/ubuntulinux\/\">https:\/\/docs.docker.com\/engine\/installation\/ubuntulinux\/<\/a>&nbsp;.<br \/>\nThe summarise version as follows:<\/p>\n<ul>\n<li>Open up terminal (if you are running desktop version); and run the follow statement to add the gpg key:<\/li>\n<\/ul>\n<blockquote><p>$ sudo apt-key adv &#8211;keyserver hkp:\/\/p80.pool.sks-keyservers.net:80 &#8211;recv-keys 58118E89F3A912897C070ADBF76221572C52609D<\/p><\/blockquote>\n<ul>\n<li>Then edit the repo source list:<\/li>\n<\/ul>\n<blockquote><p>$ touch&nbsp;\/etc\/apt\/sources.list.d\/docker.list<br \/>\n$ nano&nbsp;\/etc\/apt\/sources.list.d\/docker.list<\/p><\/blockquote>\n<ul>\n<li>Add the following line if it does not exists:<\/li>\n<\/ul>\n<blockquote><p><span class=\"hljs-keyword\">deb<\/span> http<span class=\"hljs-variable\">s:<\/span>\/\/apt.dockerproject.org\/repo ubuntu-trusty main<\/p><\/blockquote>\n<p>Now save the file and close. Next run the following:<\/p>\n<blockquote><p>$ apt-<span class=\"hljs-built_in\">get<\/span> <span class=\"hljs-keyword\">update<\/span><br \/>\n$&nbsp;apt-<span class=\"hljs-keyword\">get<\/span> purge lxc-docker<br \/>\n$&nbsp;sudo apt-<span class=\"hljs-built_in\">get<\/span> <span class=\"hljs-keyword\">update<\/span><br \/>\n$&nbsp;sudo apt-get install linux-image-extra-<span class=\"hljs-variable\">$(<\/span>uname -r)<br \/>\n$&nbsp;sudo apt-<span class=\"hljs-built_in\">get<\/span> install linux-<span class=\"hljs-built_in\">image<\/span>-generic-lts-trusty<br \/>\n$ sudo reboot<\/p><\/blockquote>\n<p>The machine should be rebooting now.<\/p>\n<blockquote><p>$&nbsp;sudo apt-get <span class=\"hljs-operator\"><span class=\"hljs-keyword\">install<\/span> docker-<span class=\"hljs-keyword\">engine<\/span><\/span><br \/>\n$ sudo service docker start<br \/>\n$&nbsp;sudo docker <span class=\"hljs-built_in\">run<\/span> hello-world<\/p><\/blockquote>\n<p>At this point, there is a tool docker-compose which is not installed by default. You can build from github:&nbsp;https:\/\/github.com\/docker\/compose or i recommend from python.<br \/>\nNow to setup docker-compose.<\/p>\n<blockquote><p>$ python -V # this should print out python version number<br \/>\n$ sudo apt-get install python-setuptools<br \/>\n$ sudo apt-get install pip<br \/>\n$ sudo pip install docker-compose<\/p><\/blockquote>\n<p>Why should we install docker-compose? If you look at some docker projects, they have a docker compose file. This will allow you to pretty much start the service via:<\/p>\n<blockquote><p>$ sudo docker-compose up<\/p><\/blockquote>\n<p>Pretty nifty, as this will run the application based on how the author intended. If you have a look at the docker-compose yml file, it is pretty much self explanatory.<br \/>\nOkay, now to docker. Two key concepts of docker are containers and images. Using Jenkins (a build management tool) as an example. We can download the image Jenkins using the following command:<\/p>\n<blockquote><p>$ sudo docker pull jenkins<\/p><\/blockquote>\n<p>To run it:<\/p>\n<blockquote><p>$ sudo docker run -d -p 8080:8080 &#8211;name myjenkins jenkins<\/p><\/blockquote>\n<p>wow. so what is that? basically, -d flag is running it in detached mod (running in background), -p is the forwarding port 8080(to) : 8080(from), &#8211;name as the custom running container name and finally jenkins is the images to look for.<br \/>\nIf you do the following, you can now see the running processes.<\/p>\n<blockquote><p>$ sudo docker ps<\/p><\/blockquote>\n<p>If you add in -a, you can see all inactive processes as well.<\/p>\n<blockquote><p>$ sudo docker ps -a<\/p><\/blockquote>\n<p>If you wish to delete a container, you can either use the &#8211;name you declared or the container ID.<\/p>\n<blockquote><p>$ sudo docker rm my jenkins<\/p><\/blockquote>\n<p>Finally, you can backup running containers via:<\/p>\n<blockquote><p>$ sudo&nbsp;docker export myjenkins&nbsp;&gt; jenkins-backup.tar<\/p><\/blockquote>\n<p>You can also restore containers. But I will leave this up to you to do a bit of research homework.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>If you are in software development and web development, you are likely to have come across Docker as well as Vagrant. These are the two important Virtualisation tools that you will use for your development\/production workflows. For MacOSX you can install via Dockertoolbox:&nbsp;http:\/\/docs.docker.com\/mac\/started\/&nbsp;. The Mac version is quite straightforward; either you can download the docker [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-663","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/pages.alldaycity.com\/mirageglobe\/wp-json\/wp\/v2\/posts\/663","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/pages.alldaycity.com\/mirageglobe\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/pages.alldaycity.com\/mirageglobe\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/pages.alldaycity.com\/mirageglobe\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/pages.alldaycity.com\/mirageglobe\/wp-json\/wp\/v2\/comments?post=663"}],"version-history":[{"count":1,"href":"https:\/\/pages.alldaycity.com\/mirageglobe\/wp-json\/wp\/v2\/posts\/663\/revisions"}],"predecessor-version":[{"id":918,"href":"https:\/\/pages.alldaycity.com\/mirageglobe\/wp-json\/wp\/v2\/posts\/663\/revisions\/918"}],"wp:attachment":[{"href":"https:\/\/pages.alldaycity.com\/mirageglobe\/wp-json\/wp\/v2\/media?parent=663"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/pages.alldaycity.com\/mirageglobe\/wp-json\/wp\/v2\/categories?post=663"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/pages.alldaycity.com\/mirageglobe\/wp-json\/wp\/v2\/tags?post=663"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}