#100DaysOfWeb in Python Transcripts
Chapter: Days 97-100: Docker and Docker Compose
Lecture: Docker nomenclature

Login or purchase this course to watch this video and the rest of the course contents.
0:00 Let's talk about some Docker terminology. There are few core concepts and words that you need to learn to work in the Docker space.
0:10 So the most fundamental one the starting point is going to be what's called an image. An image is basically as what you think of as the hard drive
0:18 of what would be the virtual machine that's going to run your system. You're going to start out with some kind of base image
0:25 like Ubuntu or something maybe built on top of that. Then your going to configure it like I want to copy these files here
0:30 and I want to set up this service and I want to set these config files over here. Then when its all ready that's your image
0:37 but that's not actually the execution of it this is just the structure of it on disk, right. This is what would run. So then when we run it
0:45 it's going to run in a container. Kind of like a virtual machine but it starts in millisecond instead of minutes or seconds depending on
0:53 what kind of machine you've got. It takes that image and it virtualize that on top of the regular operating system its running on.
1:02 All those changes you made to the image they are going to affect how this container runs but it's not a full featured
1:08 full virtual machine that's running its just a little tiny process. So for example if we are running uWSGI to serve up some web content
1:16 maybe the only thing running in that container literally is uWSGI. That's it, could be something else but probably not actually
1:24 but it was configured when we built our image. Okay so we have our image and we run those and we create instances of containers
1:31 these are much like processes but isolated. One of the challenges of containers is they are stateless. They are little virtualized operating system
1:39 which is great because they can't get to anything else and the changes they make affect nothing but when they go away, guess what? So does their data
1:46 and imagine that this container is the web server and the database. Maybe it's okay if the web server goes away
1:53 you might loose the logs but you that's up to you. But you definitely cannot loose the changes the users made to the database
2:00 like creating accounts and buying stuff. That needs to stay. So what you can do is map folders inside of the container
2:09 actually to real folders on the host. That means changes to that particular folder or that volume will stay across executions of the containers.
2:19 These are ways for you to add little persistent file locations for your containers. We also have ports just like the file system is isolated
2:27 so is the networking around these containers. Typically they can talk out to the network but they can't listen on a port.
2:34 Those are not exposed, think of them as kind of like blocked with a firewall or something. But if you have a web server or a database
2:42 it only makes since if people can connect to it, right. So you might want to expose some ports which we'll see that that's super easy to do.
2:51 Also this idea of what's called an entry point when I run the container what does it do? I described the uWSGI example before
2:59 well maybe the entry point is to run uWSGI pointed at your app files and configurations and stuff so it served your web app.
3:06 That would be the entry point into our container. Finally the way we build the image and bring this full circle
3:14 is we create what's called a Dockerfile. The Dockerfile is very much like a series of commands that you would do to the Linux machine starting from
3:22 the base image to the configured image that you want. So maybe you start with Ubuntu and your like well I'm going to apt install the latest updates
3:30 then I'm going to apt install Nginx and then I'm going to copy this Nginx configuration file
3:35 over here then I'm going to copy my source files over there. All those steps would be put into the Dockerfile and they'll be layered.
3:42 So if you make a change to like the fifth step the first four will be cache, you won't have to rebuild. So the first time it can be kind of slow
3:49 but after that typically its really, really fast and of course you only build the images when you need to make changes
3:56 typically you have the image prebuilt and you just run the containers. So that brinDockerfilegs us full circle to our Docker nomenclature

Talk Python's Mastodon Michael Kennedy's Mastodon