{"id":1557,"date":"2019-03-06T02:45:44","date_gmt":"2019-03-06T02:45:44","guid":{"rendered":"http:\/\/kusuaks7\/?p=1162"},"modified":"2023-08-08T11:07:39","modified_gmt":"2023-08-08T11:07:39","slug":"learn-enough-docker-to-be-useful-part1-the-conceptual-landscape","status":"publish","type":"post","link":"https:\/\/www.experfy.com\/blog\/bigdata-cloud\/learn-enough-docker-to-be-useful-part1-the-conceptual-landscape\/","title":{"rendered":"Learn Enough Docker to be Useful &#8211; Part 1: The Conceptual Landscape"},"content":{"rendered":"<p id=\"2b6e\">Containers are hugely helpful for improving security, reproducibility, and scalability in software development and data science. Their rise is one of the most important trends in technology today.<\/p>\n<p id=\"39bb\">Docker is a platform to develop, deploy, and run applications inside containers. Docker is essentially synonymous with containerization. If you\u2019re a current or aspiring software developer or data scientist, Docker is in your future.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*EJx9QN4ENSPKZuz51rC39w.png\" data-height=\"64\" data-image-id=\"1*EJx9QN4ENSPKZuz51rC39w.png\" data-width=\"200\" \/><\/p>\n<p id=\"fd8e\">Don\u2019t fret if you aren\u2019t yet up to speed \u2014 this article will help you understand the conceptual landscape \u2014 and you\u2019ll get to make some pizza along the way.<\/p>\n<p id=\"a9a5\">In the next five articles in this series we\u2019ll jump into Docker terms, Dockerfiles, Docker images, Docker commands, and data storage.\u00a0By the end of the series (and with a little practice) you should know enough Docker to be useful.<\/p>\n<h3 id=\"3cdb\">Docker Metaphors<\/h3>\n<p id=\"34fd\">First, I\u2019m going to shed some light on Docker metaphors.<\/p>\n<p style=\"text-align: center;\"><a href=\"https:\/\/www.goodreads.com\/book\/show\/34459.Metaphors_We_Live_By\" target=\"_blank\" rel=\"noopener noreferrer\" data-action=\"image-link\" data-action-observe-only=\"true\" data-href=\"https:\/\/www.goodreads.com\/book\/show\/34459.Metaphors_We_Live_By\" data-><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*poqn_j2R9xTk940n9wE9Lw.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*poqn_j2R9xTk940n9wE9Lw.jpeg\" \/><\/a><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px;\"><a href=\"https:\/\/www.goodreads.com\/book\/show\/34459.Metaphors_We_Live_By\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/www.goodreads.com\/book\/show\/34459.Metaphors_We_Live_By\" data->They\u2019re everywhere! Just check out this\u00a0book<\/a>.<\/span><a style=\"font-size: 11px; background-color: rgba(0, 0, 0, 0.05);\" href=\"https:\/\/www.goodreads.com\/book\/show\/34459.Metaphors_We_Live_By\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/www.goodreads.com\/book\/show\/34459.Metaphors_We_Live_By\" data->.<\/a><\/p>\n<p id=\"f6c6\"><a href=\"https:\/\/www.google.com\/search?q=metaphor+definition&amp;oq=metaphor+defini&amp;aqs=chrome.0.0j69i57j0l4.2999j1j4&amp;sourceid=chrome&amp;ie=UTF-8\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/www.google.com\/search?q=metaphor+definition&amp;oq=metaphor+defini&amp;aqs=chrome.0.0j69i57j0l4.2999j1j4&amp;sourceid=chrome&amp;ie=UTF-8\" data->Google\u2019s second definition for Metaphor<\/a>\u00a0is what we want:<\/p>\n<blockquote id=\"df33\"><p>a thing regarded as representative or symbolic of something else, especially something abstract.<\/p><\/blockquote>\n<p id=\"cd29\">Metaphors help us make sense of new things. For example, the metaphor of a physical container helps us quickly grasp the essence of a virtual container.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*ndncU4a3uNsQ_oy2YrNLBA.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*ndncU4a3uNsQ_oy2YrNLBA.jpeg\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px;\">A physical container<\/span><\/p>\n<h4>Container<\/h4>\n<p id=\"9f70\">Like a physical plastic container, a Docker container:<\/p>\n<ol>\n<li id=\"5098\"><strong>Holds things <\/strong>\u2014 Something is either inside the container or outside the container.<\/li>\n<li id=\"3f14\"><strong>Is portable <\/strong>\u2014 It can be used on your local machine, your coworker\u2019s machine, or a cloud provider\u2019s servers (e.g. AWS). Sort of like that box of childhood knickknacks you keep moving with you from home to home.<\/li>\n<li id=\"4726\"><strong>Has clear interfaces for access<\/strong> \u2014 Our physical container has a lid for opening and putting things in and taking things out. Similarly, a Docker container has several mechanisms for interfacing with the outside world. It has ports that can be opened for interacting through the browser. You can configure it to interact with data through the command line.<\/li>\n<li id=\"d4a7\"><strong>Can be obtained from a remote location <\/strong>\u2014 You can get another empty plastic container from Amazon.com when you need it. Amazon gets its plastic containers from manufacturers who stamp them out by the thousands from a single mold. In the case of a Docker container, an offsite registry keeps an image, which is like a mold, for your container. Then when you need a container you can make one from the image.<\/li>\n<\/ol>\n<p id=\"2736\">Unlike a virtual Docker container, a new plastic container from Amazon will cost you money and won\u2019t come with a copy of your goods inside. .<\/p>\n<h4 id=\"1e17\">Living Instance<\/h4>\n<p id=\"1dcb\">A second way you can think of a Docker container is as<strong>\u00a0an instance of a living thing<\/strong>. An instance is something that exists in some form. It\u2019s not just code. It\u2019s code that has brought something to life. Like other living things, the instance will eventually die \u2014 meaning the container will shut down.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*t-uVUfbywQsDnwQoYAEbgA.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*t-uVUfbywQsDnwQoYAEbgA.jpeg\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; text-align: center;\">An instance of a\u00a0monster<\/span><\/p>\n<p id=\"9f17\">A Docker container is a Docker image brought to life.<\/p>\n<h4 id=\"57c4\">Software<\/h4>\n<p id=\"47a9\">In addition to the container metaphor and the living instance metaphor, you can think of a Docker container as\u00a0<strong>a software program<\/strong>. After all, it is software. At its most basic level, a container is a set of instructions that manipulate other bits.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*0D45gdLlWgvMBu9Xwr0RrA.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*0D45gdLlWgvMBu9Xwr0RrA.jpeg\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; text-align: center;\">Containers are\u00a0code<\/span><\/p>\n<p id=\"28ba\">While a Docker container is running, it generally has programs running inside it. The programs in a container perform actions so your application will do something.<\/p>\n<p id=\"6dc7\">For example, the code in a Docker container might have sent you the content you are reading on this webpage right now. Or it might take your voice command to Amazon Alexa and decode it into instructions another program in a different container will use.<\/p>\n<p id=\"6f76\">With Docker you can run multiple containers simultaneously on a host machine. And like other software programs, Docker containers can be run, inspected, stopped, and deleted.<\/p>\n<h3 id=\"bf16\">Concepts<\/h3>\n<h4 id=\"dfe2\">Virtual Machines<\/h4>\n<p id=\"f388\">Virtual machines are the precursors to Docker containers. Virtual machines also isolate an application and its dependencies. However, Docker containers are superior to virtual machines because they take fewer resources, are very portable, and are faster to spin up. Check out\u00a0<a href=\"https:\/\/medium.freecodecamp.org\/a-beginner-friendly-introduction-to-containers-vms-and-docker-79a9e3e119b\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/medium.freecodecamp.org\/a-beginner-friendly-introduction-to-containers-vms-and-docker-79a9e3e119b\" data->this article<\/a>\u00a0for a great discussion of the similarities and differences.<\/p>\n<h4 id=\"b488\">Docker Image<\/h4>\n<p id=\"d708\">I mentioned images above. What\u2019s an image? I\u2019m glad you asked! The meaning of the term\u00a0<em>image<\/em>\u00a0in the context of Docker doesn\u2019t map all that well to a physical image.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*Wv9nvbm0XRLSGQ9nqTzpdA.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*Wv9nvbm0XRLSGQ9nqTzpdA.jpeg\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; text-align: center;\">Images<\/span><\/p>\n<p id=\"ace0\">Docker images are more like blueprints, cookie cutters, or molds. Images are the immutable master template that is used to pump out containers that are all exactly alike.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*n53WlDyD9mxVcOu17Rj86Q.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*n53WlDyD9mxVcOu17Rj86Q.jpeg\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px; text-align: center;\">Cookie cutters<\/span><\/p>\n<p id=\"23cd\">An image contains the Dockerfile, libraries, and code your application needs to run, all bundled together.<\/p>\n<h4 id=\"a837\">Dockerfile<\/h4>\n<p id=\"dc58\">A\u00a0<a href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/docs.docker.com\/engine\/reference\/builder\/\" data->Dockerfile<\/a>\u00a0is a file with instructions for how Docker should build your image.<\/p>\n<p id=\"dad7\">The Dockerfile refers to a base image that is used to build the initial image layer. Popular official base images include\u00a0<a href=\"https:\/\/hub.docker.com\/_\/python\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/hub.docker.com\/_\/python\/\" data->python<\/a>,\u00a0<a href=\"https:\/\/hub.docker.com\/_\/ubuntu\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/hub.docker.com\/_\/ubuntu\" data->ubuntu<\/a>, and\u00a0<a href=\"https:\/\/hub.docker.com\/_\/alpine\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/hub.docker.com\/_\/alpine\" data->alpine<\/a>.<\/p>\n<p id=\"79aa\">Additional layers can then be stacked on top of the base image layers, according to the instructions in the Dockerfile. For example, a Dockerfile for a machine learning application could tell Docker to add NumPy, Pandas, and Scikit-learn in an intermediate layer.<\/p>\n<p id=\"2fec\">Finally, a thin, writable layer is stacked on top of the other layers according to the Dockerfile code. (You understand that a thin layer is small in size because you intuitively understand the\u00a0<em>thin<\/em>\u00a0metaphor, right?)<\/p>\n<p id=\"d5b6\">I\u2019ll explore Dockerfiles in more depth in future articles in this series.<\/p>\n<h4 id=\"4495\">Docker Container<\/h4>\n<p id=\"ddbb\">A Docker image plus the command\u00a0<code>docker run image_name<\/code>\u00a0creates and starts a container from an image.<\/p>\n<h4 id=\"8e37\">Container Registry<\/h4>\n<p id=\"967b\">If you want other people to be able to make containers from your image, you send the image to a container registry.\u00a0<a href=\"https:\/\/hub.docker.com\/\" target=\"_blank\" rel=\"noopener noreferrer\" data-href=\"https:\/\/hub.docker.com\/\" data->Docker Hub<\/a>\u00a0is the largest registry and the default.<\/p>\n<p id=\"985f\">Phew! That\u2019s a lot of pieces. Let\u2019s put this all together in terms of making a pizza.<\/p>\n<h3 id=\"3a83\">Cooking with\u00a0Docker<\/h3>\n<h3 style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*v6WWacmOsrPYtkGXUu-cbA.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/800\/1*v6WWacmOsrPYtkGXUu-cbA.jpeg\" \/><\/h3>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px;\">Landscape Metaphor<\/span><\/p>\n<ul>\n<li id=\"ef96\">The recipe is like the\u00a0<em>Dockerfile<\/em>. It tells you what to do to get to your end goal.<\/li>\n<li id=\"6a06\">The ingredients are the\u00a0<em>layers<\/em>. You\u2019ve got crust, sauce, and cheese for this pizza.<\/li>\n<\/ul>\n<p id=\"9e0e\">Think of the recipe and the ingredients combined as an all-in-one pizza-making-kit. It\u2019s the\u00a0<em>Docker image<\/em>.<\/p>\n<p id=\"da88\">The recipe (Dockerfile) tells us what we\u2019re going to do. Here\u2019s the plan:<\/p>\n<ul>\n<li id=\"e0db\">The crust is preformed and immutable, it\u2019s like a basic ubuntu parent image. It\u2019s the\u00a0<em>bottom layer<\/em>\u00a0and gets built first.<\/li>\n<li id=\"69d9\">Then you\u2019ll add some cheese. Adding this second layer to the pizza is like\u00a0<em>installing an external library <\/em>\u2014 for example NumPy.<\/li>\n<li id=\"e169\">Then you\u2019ll sprinkle on some basil. The basil is like the\u00a0<em>code in a file<\/em>\u00a0that you wrote to run your app.<\/li>\n<\/ul>\n<p id=\"e46c\">Alright, let\u2019s get cooking.<\/p>\n<p style=\"text-align: center;\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*rihuhM7hCvWaJhuw7Hjvzg.jpeg\" data-src=\"https:\/\/cdn-images-1.medium.com\/max\/640\/1*rihuhM7hCvWaJhuw7Hjvzg.jpeg\" \/><\/p>\n<p style=\"text-align: center;\"><span style=\"font-size: 11px;\">Oven<\/span><\/p>\n<p>The oven that bakes the pizza is like the Docker platform. You installed the oven into your house when you moved in so you could make things with it. Similarly, you installed Docker onto your computer so you could cook up containers.<\/p>\n<ul>\n<li id=\"18ec\">You start your oven by turning a knob. The\u00a0<code>docker run image_name<\/code>command is like your knob \u2014 it creates and starts your container.<\/li>\n<li id=\"edca\">The cooked pizza is like a Docker container.<\/li>\n<li id=\"2359\">Eating pizza is like using your app.<\/li>\n<\/ul>\n<p id=\"3444\">Like making a pizza, making an app in a Docker container takes some work, but in the end, you have something great.<\/p>\n<h3 id=\"5176\">Wrap<\/h3>\n<p id=\"0be5\">That\u2019s the conceptual framework. In Part 2 of this series, I clarify some of the terms you\u2019ll see in the Docker ecosystem. Follow me to make sure you don\u2019t miss it!<\/p>\n<p id=\"11d3\">Hopefully, this overview has helped you better understand the Docker landscape. I also hope it has also opened your eyes to the value of metaphors in understanding new technologies.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Docker is a platform to develop, deploy, and run applications inside containers. Docker is essentially synonymous with containerization. If you&rsquo;re a current or aspiring software developer or data scientist, Docker is in your future. Don&rsquo;t fret if you aren&rsquo;t yet up to speed\u200a&mdash;\u200athis article will help you understand the conceptual landscape\u200a&mdash;\u200aand you&rsquo;ll get to make some pizza along the way. By the end of the series (and with a little practice) you should know enough Docker to be useful.<\/p>\n","protected":false},"author":369,"featured_media":4058,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","footnotes":""},"categories":[187],"tags":[94],"ppma_author":[2134],"class_list":["post-1557","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bigdata-cloud","tag-data-science"],"authors":[{"term_id":2134,"user_id":369,"is_guest":0,"slug":"jeff-hale","display_name":"Jeff Hale","avatar_url":"https:\/\/secure.gravatar.com\/avatar\/?s=96&d=mm&r=g","user_url":"","last_name":"Hale","first_name":"Jeff","job_title":"","description":"Jeff Hale is a co-founder of Rebel Desk, where he oversees technology, finance, and operations for this company. He&nbsp;is an experienced entrepreneur who has managed technology, operations, and finances for several companies.&nbsp;"}],"_links":{"self":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/1557","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/users\/369"}],"replies":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/comments?post=1557"}],"version-history":[{"count":4,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/1557\/revisions"}],"predecessor-version":[{"id":30016,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/posts\/1557\/revisions\/30016"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/media\/4058"}],"wp:attachment":[{"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/media?parent=1557"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/categories?post=1557"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/tags?post=1557"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.experfy.com\/blog\/wp-json\/wp\/v2\/ppma_author?post=1557"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}