{"id":736,"date":"2022-06-03T15:08:52","date_gmt":"2022-06-03T15:08:52","guid":{"rendered":"https:\/\/www.darmain.co.uk\/darmainworld\/?p=736"},"modified":"2022-06-03T15:16:40","modified_gmt":"2022-06-03T15:16:40","slug":"docker","status":"publish","type":"post","link":"https:\/\/www.darmain.co.uk\/darmainworld\/index.php\/2022\/06\/03\/docker\/","title":{"rendered":"Home Lab Cloud &#8211; Docker"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">So my quest brings me to understanding &#8220;Docker&#8221;, running on Linux.  What is Docker?<\/p>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\"><p><strong>Docker<\/strong>&nbsp;is a set of&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/Platform_as_a_service\">platform as a service<\/a>&nbsp;(PaaS) products that use&nbsp;<a href=\"https:\/\/en.wikipedia.org\/wiki\/OS-level_virtualization\">OS-level virtualization<\/a>&nbsp;to deliver software in packages called&nbsp;<em>containers<\/em>.<sup><a href=\"https:\/\/en.wikipedia.org\/wiki\/Docker_(software)#cite_note-SYS-CON_Media-5\">[5]<\/a><\/sup>&nbsp; The software that hosts the containers is called&nbsp;<strong>Docker Engine<\/strong>.<sup><a href=\"https:\/\/en.wikipedia.org\/wiki\/Docker_(software)#cite_note-what-is-a-container-6\">[6]<\/a><\/sup><\/p><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">So I will cut a long story short.  Taking a standard installation of Linux server, in this case a Ubuntu 22.04 VM, I installed the Docker engine.  Then I use Command Line instructions to build containers of functionality.  These pull in &#8220;images&#8221;, which could be Containers in their own right but can also be pulled together as a collective into one container.  I&#8217;ll get to an example of that in a moment.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What are these containers then?  Well, they are an isolated bundles of software functionality, which include all their dependent libraries.  This forms the layer 2 of the operating system, but does not include layer 1, which is the Kernel.  The Container has connectors that allow it to interface with the host machine, via the Docker Engine.  It is not quite a virtual machine, more like a virtual application.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Example, the Apache2 Web Server, known as HTTPD, can be pulled in from the Docker library of containers.  It is already configured, has all the dependencies it needs.  All that is needed is to feed it the website configuration and the content.  This can been done very quickly.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The reason for doing this?  Take building a Website.  We will need a web server, maybe a file system, possibly a Sequal database.  Well, we could install a virtual machine platform on our server, build and configuring Virtual Servers on that for each function we require, and then connecting them all together.  Spend ages getting it all to work.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Alternatively we use Docker, build the whole system in a configuration file, a &#8220;docker-compose.yml&#8221; file to be exact.  Then we build the complete image.  Finally we run the image, upon which it becomes a container.  It holds everything and is pretested.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Another good reason for doing this is that the software stack is smaller and hence faster.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full is-style-default\"><img decoding=\"async\" width=\"817\" height=\"340\" data-src=\"https:\/\/www.darmain.co.uk\/darmainworld\/wp-content\/uploads\/2022\/06\/Demystifying-containers_image1.png\" alt=\"\" class=\"wp-image-745 lazyload\" data-srcset=\"https:\/\/www.darmain.co.uk\/darmainworld\/wp-content\/uploads\/2022\/06\/Demystifying-containers_image1.png 817w, https:\/\/www.darmain.co.uk\/darmainworld\/wp-content\/uploads\/2022\/06\/Demystifying-containers_image1-300x125.png 300w, https:\/\/www.darmain.co.uk\/darmainworld\/wp-content\/uploads\/2022\/06\/Demystifying-containers_image1-768x320.png 768w, https:\/\/www.darmain.co.uk\/darmainworld\/wp-content\/uploads\/2022\/06\/Demystifying-containers_image1-600x250.png 600w\" data-sizes=\"(max-width: 817px) 100vw, 817px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 817px; --smush-placeholder-aspect-ratio: 817\/340;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">There is only one Kernel.  To build containers is easy compared to building VMs and connecting them together.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Okay, a frustrating example.  With my VM server, pre-installed with Docker.  I create a folder called &#8220;wordpress&#8221; and enter it.  Then I create the file called &#8220;docker-compose.yml&#8221; and I enter the following &#8211;<\/p>\n\n\n\n<pre class=\"wp-block-code has-vivid-cyan-blue-color has-light-green-cyan-background-color has-text-color has-background\"><code>version: '3.3'\nservices:\n    db:\n      image: mysql:5.7\n      volumes:\n        - db_data:\/var\/lib\/mysql\n      restart: always\n      environment:\n      MYSQL_ROOT_PASSWORD: catsrule\n      MYSQL_DATABASE: CATDATA\n      MYSQL_USER: dave\n      MYSQL_PASSWORD: catsrule\n    wordpress:\n      depends_on:\n         - db\n      image: wordpress:latest\n      ports:\n        - \"8000:80\"\n      restart: always\n      environment:\n         WORDPRESS_DB_HOST: db:3306\n         WORDPRESS_DB_USER: dave\n         WORDPRESS_DB_PASSWORD: catsrule\n         WORDPRESS_DB_NAME: CATDATA\nvolumes:\n    db_data: {}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Okay, so then I save this file and then run the following command &#8211;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&gt;docker-compose up -d<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">What does this do?<\/p>\n\n\n\n<blockquote class=\"wp-block-quote has-vivid-red-color has-cyan-bluish-gray-background-color has-text-color has-background is-layout-flow wp-block-quote-is-layout-flow\"><p>Builds, (re)creates, starts, and attaches to containers for a service. Unless they are already running, this command also starts any linked services.<\/p><\/blockquote>\n\n\n\n<p class=\"wp-block-paragraph\">Then I point a web browser to the VMs IP address at Port 8000.  http:\/\/192.168.1.121:8000<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">And I have the start up screen for WordPress.  This site runs on WordPress and took several days to build.  For what I did above, ten minutes!<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">I created the site and called it &#8220;Crumbles Pong Box&#8221;!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large is-style-default\"><img decoding=\"async\" width=\"1024\" height=\"842\" data-src=\"https:\/\/www.darmain.co.uk\/darmainworld\/wp-content\/uploads\/2022\/06\/Screenshot-from-2022-06-03-16-04-45-1024x842.png\" alt=\"\" class=\"wp-image-737 lazyload\" data-srcset=\"https:\/\/www.darmain.co.uk\/darmainworld\/wp-content\/uploads\/2022\/06\/Screenshot-from-2022-06-03-16-04-45-1024x842.png 1024w, https:\/\/www.darmain.co.uk\/darmainworld\/wp-content\/uploads\/2022\/06\/Screenshot-from-2022-06-03-16-04-45-300x247.png 300w, https:\/\/www.darmain.co.uk\/darmainworld\/wp-content\/uploads\/2022\/06\/Screenshot-from-2022-06-03-16-04-45-768x632.png 768w, https:\/\/www.darmain.co.uk\/darmainworld\/wp-content\/uploads\/2022\/06\/Screenshot-from-2022-06-03-16-04-45-600x494.png 600w, https:\/\/www.darmain.co.uk\/darmainworld\/wp-content\/uploads\/2022\/06\/Screenshot-from-2022-06-03-16-04-45.png 1093w\" data-sizes=\"(max-width: 1024px) 100vw, 1024px\" src=\"data:image\/svg+xml;base64,PHN2ZyB3aWR0aD0iMSIgaGVpZ2h0PSIxIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjwvc3ZnPg==\" style=\"--smush-placeholder-width: 1024px; --smush-placeholder-aspect-ratio: 1024\/842;\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">And there it is, ready to role.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">More to follow.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So my quest brings me to understanding &#8220;Docker&#8221;, running on Linux. What is Docker? Docker&nbsp;is a set of&nbsp;platform as a service&nbsp;(PaaS) products that use&nbsp;OS-level virtualization&nbsp;to deliver software in packages called&nbsp;containers.[5]&nbsp; The software that hosts the containers is called&nbsp;Docker Engine.[6] So I will cut a long story short. Taking a standard installation of Linux server, in [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":739,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[],"class_list":["post-736","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-cloud-servers"],"_links":{"self":[{"href":"https:\/\/www.darmain.co.uk\/darmainworld\/index.php\/wp-json\/wp\/v2\/posts\/736","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.darmain.co.uk\/darmainworld\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.darmain.co.uk\/darmainworld\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.darmain.co.uk\/darmainworld\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.darmain.co.uk\/darmainworld\/index.php\/wp-json\/wp\/v2\/comments?post=736"}],"version-history":[{"count":4,"href":"https:\/\/www.darmain.co.uk\/darmainworld\/index.php\/wp-json\/wp\/v2\/posts\/736\/revisions"}],"predecessor-version":[{"id":746,"href":"https:\/\/www.darmain.co.uk\/darmainworld\/index.php\/wp-json\/wp\/v2\/posts\/736\/revisions\/746"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.darmain.co.uk\/darmainworld\/index.php\/wp-json\/wp\/v2\/media\/739"}],"wp:attachment":[{"href":"https:\/\/www.darmain.co.uk\/darmainworld\/index.php\/wp-json\/wp\/v2\/media?parent=736"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.darmain.co.uk\/darmainworld\/index.php\/wp-json\/wp\/v2\/categories?post=736"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.darmain.co.uk\/darmainworld\/index.php\/wp-json\/wp\/v2\/tags?post=736"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}