1 00:00:00,346 --> 00:00:05,836 ‫Well, hello, or should I say whalecome ‫to the future of software management 2 00:00:06,106 --> 00:00:08,146 ‫with Docker and container tooling. 3 00:00:08,656 --> 00:00:10,936 ‫This video is specifically about Docker. 4 00:00:11,356 --> 00:00:16,096 ‫It had lots of tools over the years, ‫but this video is about the three 5 00:00:16,246 --> 00:00:22,291 ‫major innovations that started the ‫Docker whole evolution of software 6 00:00:22,291 --> 00:00:25,711 ‫in 2013, that is mainly three things. 7 00:00:26,071 --> 00:00:31,831 ‫The Docker image, that Docker registry, ‫and then the Docker container. 8 00:00:31,921 --> 00:00:34,951 ‫Most of us, when we think of Docker, ‫we think of the container, but 9 00:00:34,951 --> 00:00:39,751 ‫these three innovations go together ‫like bread and butter and they 10 00:00:40,051 --> 00:00:43,471 ‫call it at Docker build ship run. 11 00:00:43,681 --> 00:00:45,001 ‫Those are the three steps. 12 00:00:45,766 --> 00:00:50,806 ‫To take previously non containerd ‫software, turn it into a Docker 13 00:00:50,806 --> 00:00:54,526 ‫image, put it on a registry, get ‫it to wherever you need to run it. 14 00:00:54,706 --> 00:00:56,296 ‫And then finally create ‫a container from it. 15 00:00:57,019 --> 00:01:02,209 ‫In fact, the CNCF or the Cloud ‫Native Computing Foundation, which 16 00:01:02,239 --> 00:01:05,389 ‫a lot of the tools we'll talk ‫about throughout all my videos. 17 00:01:05,779 --> 00:01:09,949 ‫Those products and tools and ‫workflows make the assumption, in 18 00:01:09,949 --> 00:01:15,289 ‫most cases, that you are using a ‫container workflow of build ship run. 19 00:01:15,479 --> 00:01:18,539 ‫So let's break these down and ‫exactly what the three are. 20 00:01:18,938 --> 00:01:21,638 ‫First up the container image. 21 00:01:22,150 --> 00:01:27,290 ‫And I like to think of it as a universal ‫app packager, And we've had lots 22 00:01:27,290 --> 00:01:28,820 ‫of package managers over the years. 23 00:01:28,820 --> 00:01:31,850 ‫In fact, I've lost count, ‫and I've been around a while, 24 00:01:32,270 --> 00:01:33,980 ‫of all the package managers. 25 00:01:34,370 --> 00:01:38,990 ‫But there's never been anything that ‫I can recall, that's been cross OS, 26 00:01:39,290 --> 00:01:44,440 ‫cross platform, and application ‫language agnostic, meaning it will run 27 00:01:44,440 --> 00:01:47,840 ‫everywhere, and it runs on anything, as ‫long as it's running Linux or Windows. 28 00:01:48,106 --> 00:01:53,028 ‫Now let's take a real quick look at a ‫Dockerfile, which is the recipe or set 29 00:01:53,028 --> 00:01:58,578 ‫of instructions to make a container ‫image, Docker image and container image 30 00:01:58,608 --> 00:02:00,228 ‫are the same term for the same thing. 31 00:02:00,228 --> 00:02:05,238 ‫In fact, the Docker image specification ‫was so popular it's now a standard 32 00:02:05,238 --> 00:02:07,638 ‫known as the OCI image standard. 33 00:02:07,878 --> 00:02:13,188 ‫So you see a set of instructions and every ‫Dockerfile needs a FROM, to start with, 34 00:02:13,518 --> 00:02:16,008 ‫we can start from someone else's image. 35 00:02:16,128 --> 00:02:20,388 ‫We can have many images from many ‫FROMs, so we'll get into all that 36 00:02:20,388 --> 00:02:26,088 ‫complexity later, but we're starting with ‫Python here and we work our way down. 37 00:02:26,298 --> 00:02:30,921 ‫In fact, we start with these as ‫layers each one of these commands 38 00:02:31,341 --> 00:02:35,571 ‫in the Dockerfile, sometimes called ‫a stanza, with capital letters. 39 00:02:35,700 --> 00:02:39,540 ‫Including the, FROM, and then the ‫RUN and working their way down 40 00:02:39,540 --> 00:02:43,890 ‫because it processes them from ‫the top down, will create layers. 41 00:02:44,070 --> 00:02:48,630 ‫Which get moved around servers ‫as tarballs and inside those 42 00:02:48,630 --> 00:02:54,210 ‫layers are files, directories and ‫file permissions, and sometimes 43 00:02:54,210 --> 00:02:56,310 ‫metadata that we'll get into later. 44 00:02:56,730 --> 00:03:02,395 ‫When I start building this image, it ‫will start that first line and go find 45 00:03:02,425 --> 00:03:07,465 ‫the Python image from Docker Hub or ‫wherever I told it to get the image from. 46 00:03:07,648 --> 00:03:11,878 ‫and that includes just Python ‫its binaries and its libraries. 47 00:03:12,028 --> 00:03:16,828 ‫It doesn't contain host drivers ‫or the Linux Kernel, or anything 48 00:03:16,888 --> 00:03:19,438 ‫outside of what Python needs to run. 49 00:03:19,588 --> 00:03:24,418 ‫If Python needs OpenSSL, then that's ‫included in that layer of the image. 50 00:03:24,778 --> 00:03:27,578 ‫Then we can move on to the ‫next line of the Dockerfile. 51 00:03:27,598 --> 00:03:31,678 ‫That's a PIP command for a ‫Python dependency installer, 52 00:03:31,888 --> 00:03:33,178 ‫and it's installing flask. 53 00:03:33,208 --> 00:03:37,768 ‫So that will start a new layer ‫that adds flask just like you would 54 00:03:37,768 --> 00:03:39,508 ‫with a normal PIP install command. 55 00:03:39,748 --> 00:03:43,518 ‫In fact, what's happening in the ‫background is we're executing quick 56 00:03:43,548 --> 00:03:47,868 ‫little containers for each of these ‫layers, running the commands or 57 00:03:47,868 --> 00:03:51,708 ‫doing whatever you need to do inside ‫those layers, and then storing them 58 00:03:51,708 --> 00:03:54,428 ‫as their own distinct location. 59 00:03:54,556 --> 00:03:56,566 ‫On the Linux host, that's building this. 60 00:03:56,566 --> 00:03:58,816 ‫So we're stacking up layers here. 61 00:03:59,056 --> 00:04:01,786 ‫And then we go to the next ‫line, the COPY command. 62 00:04:02,026 --> 00:04:04,936 ‫The WORKDIR there is just a ‫metadata change, it just changes 63 00:04:04,936 --> 00:04:06,316 ‫locations in the file system. 64 00:04:06,496 --> 00:04:07,276 ‫No big deal. 65 00:04:07,576 --> 00:04:13,156 ‫The COPY command copies our source code ‫from the host we're building on into its 66 00:04:13,156 --> 00:04:15,616 ‫own layer, stacked on top of the others. 67 00:04:17,156 --> 00:04:22,239 ‫These together form an image ‫using the command Docker build. 68 00:04:22,569 --> 00:04:26,949 ‫This is one of those things about Docker ‫that became so easy to use because we 69 00:04:26,949 --> 00:04:32,769 ‫only needed this simple Docker build ‫command to take a bunch of complex things 70 00:04:32,769 --> 00:04:37,299 ‫going on in the Dockerfile and turn it ‫into a single image that is just our 71 00:04:37,299 --> 00:04:42,069 ‫application and only the dependencies ‫that it needs and nothing else. 72 00:04:42,651 --> 00:04:45,321 ‫That's the first part ‫of the build ship run. 73 00:04:46,086 --> 00:04:46,936 ‫Being Docker build. 74 00:04:47,256 --> 00:04:49,206 ‫Next up, let's talk about the registry. 75 00:04:50,646 --> 00:04:53,826 ‫The Docker registry is for ‫application distribution. 76 00:04:54,186 --> 00:05:00,456 ‫Every application packaging system has ‫a way to get those packages around and 77 00:05:00,636 --> 00:05:02,256 ‫the Docker registry is no different. 78 00:05:02,466 --> 00:05:06,006 ‫Now it's just known as the ‫OCI distribution spec or 79 00:05:06,006 --> 00:05:07,996 ‫OCI registry specification. 80 00:05:08,046 --> 00:05:11,526 ‫So it's a standard again in ‫the whole industry for how to 81 00:05:11,526 --> 00:05:13,116 ‫move container images around. 82 00:05:13,344 --> 00:05:14,724 ‫and it is everywhere. 83 00:05:14,724 --> 00:05:16,254 ‫Every cloud has one. 84 00:05:16,254 --> 00:05:19,494 ‫Docker Hub is the default and ‫probably the most popular. 85 00:05:19,814 --> 00:05:21,234 ‫GitHub has one. 86 00:05:21,234 --> 00:05:25,884 ‫Bitbucket, GitLab, they all ‫have their own image registries, 87 00:05:25,884 --> 00:05:27,084 ‫and you could run your own. 88 00:05:27,144 --> 00:05:31,974 ‫There's probably at least a dozen ‫projects of free open source and 89 00:05:31,974 --> 00:05:36,184 ‫paid software that allow you to ‫store your Docker images in them. 90 00:05:36,384 --> 00:05:38,924 ‫so let's break down how that works. 91 00:05:39,314 --> 00:05:39,764 ‫First. 92 00:05:39,764 --> 00:05:45,794 ‫We have our image that we just built ‫and that image has a unique SHA hash 93 00:05:45,824 --> 00:05:50,144 ‫that identifies all those layers ‫together in a way that we can guarantee, 94 00:05:50,894 --> 00:05:54,644 ‫that if we look at the hash on two ‫different systems, we can be certain 95 00:05:54,824 --> 00:05:59,114 ‫that it's the exact same files, the ‫exact same metadata that we just built. 96 00:05:59,424 --> 00:06:02,484 ‫Those image layers go together ‫and distribute themselves. 97 00:06:02,514 --> 00:06:06,804 ‫We can use something like Docker ‫push to take those image layers 98 00:06:06,804 --> 00:06:08,514 ‫and push them up to a registry. 99 00:06:08,714 --> 00:06:13,354 ‫You can use one of many registries, like ‫I mentioned, But once it's there, you 100 00:06:13,354 --> 00:06:19,428 ‫can then go to another machine and do a ‫Docker pull, which will pull an identical 101 00:06:19,428 --> 00:06:22,638 ‫copy of that image down on that machine. 102 00:06:22,848 --> 00:06:25,068 ‫Just like we had built ‫it on the first machine. 103 00:06:25,269 --> 00:06:29,859 ‫And this is one of the core principles ‫of Docker is that we're able to take 104 00:06:29,859 --> 00:06:35,169 ‫the software that we made on one machine ‫with all of its dependencies and run it 105 00:06:35,169 --> 00:06:40,529 ‫exactly that same way on another system ‫that might be completely different 106 00:06:40,979 --> 00:06:43,229 ‫distributions of Linux or Windows. 107 00:06:43,529 --> 00:06:47,699 ‫If you're on Linux and you build a ‫Linux image, which has to run on Linux 108 00:06:47,699 --> 00:06:52,319 ‫since it's running Linux binaries, if ‫you built it on CentOS and you ran 109 00:06:52,319 --> 00:06:56,579 ‫it on Ubuntu, it would be the exact ‫same application and dependencies, 110 00:06:56,819 --> 00:06:58,309 ‫regardless of that distrobution. 111 00:06:58,541 --> 00:07:01,561 ‫Finally, we get to the Docker ‫container itself . Once we've done 112 00:07:01,561 --> 00:07:04,711 ‫all those steps of building the ‫image, putting it in a location, we 113 00:07:04,711 --> 00:07:08,491 ‫can access it from our servers and ‫then downloading it into our servers. 114 00:07:08,641 --> 00:07:09,361 ‫We can run it. 115 00:07:09,601 --> 00:07:11,911 ‫Let's imagine we have ‫a server running Linux. 116 00:07:11,971 --> 00:07:14,701 ‫It might be running Windows, but in ‫this case, we'll just focus on Linux. 117 00:07:15,271 --> 00:07:17,521 ‫It's going to have Docker ‫running in the background. 118 00:07:17,521 --> 00:07:21,691 ‫That's known as the Docker Engine and ‫the engine on this single machine will 119 00:07:21,691 --> 00:07:26,491 ‫orchestrate or manage all the different ‫things that need to happen in order to 120 00:07:26,611 --> 00:07:30,646 ‫download images, verify that they're ‫the exact thing that was meant to be 121 00:07:30,646 --> 00:07:32,986 ‫downloaded, and then finally run them. 122 00:07:33,496 --> 00:07:37,396 ‫Then we got the image, we just ‫downloaded with a Docker pull, and 123 00:07:37,396 --> 00:07:38,956 ‫then we're gonna run a command. 124 00:07:38,956 --> 00:07:40,846 ‫It's not really important to ‫you learn the command yet, 125 00:07:41,026 --> 00:07:42,646 ‫but it's a Docker run command. 126 00:07:42,946 --> 00:07:45,672 ‫This is the run part of build ship run. 127 00:07:46,092 --> 00:07:49,152 ‫And in this case, we're running that ‫Python app in its own container. 128 00:07:49,482 --> 00:07:53,172 ‫That container is known as a namespace. 129 00:07:53,202 --> 00:07:56,922 ‫That's that Linux feature that ‫prevents the application running 130 00:07:56,922 --> 00:08:00,282 ‫in this container from seeing ‫the rest of the operating system. 131 00:08:00,522 --> 00:08:04,722 ‫It gets its own blank file system, ‫and it will only include the files 132 00:08:04,962 --> 00:08:07,062 ‫that were in that image we just built. 133 00:08:07,272 --> 00:08:12,072 ‫It'll get its own IP address and its own ‫virtual NIC and its own process list. 134 00:08:12,252 --> 00:08:16,152 ‫And basically looks like ‫its own system inside there. 135 00:08:16,557 --> 00:08:20,487 ‫Then, if we run that Docker, run ‫command again with our image name or 136 00:08:20,487 --> 00:08:25,797 ‫image hash, then we get an identical ‫container running side by side. 137 00:08:26,007 --> 00:08:29,097 ‫Now these two processes are ‫isolated from each other. 138 00:08:29,307 --> 00:08:33,267 ‫So the Python app in container one can't ‫see the Python app in container two. 139 00:08:33,507 --> 00:08:36,867 ‫And if you change a file in ‫container two, container one 140 00:08:36,867 --> 00:08:38,607 ‫won't see that file by default. 141 00:08:39,016 --> 00:08:43,366 ‫If we added a second server with a ‫second instance of the Docker Engine 142 00:08:43,366 --> 00:08:48,046 ‫running and did the same thing, we ‫could have a highly available setup 143 00:08:48,256 --> 00:08:52,786 ‫with our application running many times ‫for redundancy or better performance 144 00:08:52,786 --> 00:08:55,846 ‫or whatever our reason might be ‫for running more than one of them. 145 00:08:56,146 --> 00:09:00,556 ‫They will be identical from the ‫point of view of the file system, 146 00:09:00,646 --> 00:09:03,756 ‫the permissions and the metadata. 147 00:09:04,157 --> 00:09:08,477 ‫Now there's a ton more that we can ‫learn about this stuff, which is why 148 00:09:08,477 --> 00:09:11,267 ‫the course that I have is so long now. 149 00:09:11,517 --> 00:09:15,957 ‫But these are still the three ‫things that haven't changed after 150 00:09:15,957 --> 00:09:17,637 ‫Docker first conceptualized them. 151 00:09:17,877 --> 00:09:22,317 ‫The build ship run idea is ‫one of the core principles of 152 00:09:22,317 --> 00:09:25,737 ‫container, and Kubernetes, Helm. 153 00:09:25,887 --> 00:09:30,207 ‫You name the project in the cloud native ‫ecosystem, and it probably assumes you 154 00:09:30,207 --> 00:09:34,477 ‫have this typical kind of workflow for ‫getting your apps out of your developers 155 00:09:34,497 --> 00:09:38,697 ‫hands, into the testing systems, and ‫then finally into production servers. 156 00:09:38,907 --> 00:09:40,857 ‫It's these same three steps. 157 00:09:41,007 --> 00:09:44,097 ‫So, hopefully it's starting to ‫sink in just a little bit that you 158 00:09:44,097 --> 00:09:48,627 ‫get why these are the three key ‫components, even today, many, many 159 00:09:48,627 --> 00:09:50,577 ‫years after all this was invented. 160 00:09:51,047 --> 00:09:52,247 ‫Let's find out what's next.