Welcome back, and in this part of the course I want to step through how we create Docker images. Now this means becoming familiar with Docker files and their syntax. I'll be covering the theory now, and then you'll get the chance to experience this practically when you create your own Docker image. So let's get started. So far in the course you've had some practical experience in taking a Docker image on a public registry, for example Docker Hub, and downloading or pulling this to your local Docker host. Then either as part of the same command or an extra step you've run this image to launch a container. Now this is a Docker file. Docker files contain a set of steps, instructions, or directives, which are used via the Docker build command to create a Docker image. And just as with the Docker image that you pulled down to your local Docker host, this can also be used to run a container. And in this part of the course you're going to learn the theory of Docker files, as well as gain some practical experience of creating them and using them to make Docker images. Now before you actually get to work and do this, you need to understand what it is that you're doing. So let's cover the structure and functionality of Docker files. Now we're going to have a few bullet points here. Sorry in advance, I want to get through this part as quickly as I can and move onto where you'll be creating a Docker image, so let's just power through these as efficiently as possible. Now I want to explain each of the elements that you'll commonly find within a Docker file. The structure is that comments start with a hash or a pound symbol. And then you have lines, and each of these lines has an instruction and arguments. Now it's convention to have instructions in all caps to distinguish them from arguments. So these are the instructions that you'll generally find within a Docker file. First we've got FROM, and this FROM instruction configures what base image is used as the foundation for the image that you're going to create. An example is Alpine, which is a lightweight Linux distribution ideal for Docker usage. It's only five MB in size, so it's perfect for efficient Docker images. Now you can specify an image name and a version tag, for example, Alpine colon latest. And Docker files must have a FROM instruction contained within them. Next we got LABEL and this can be used to add metadata to an image. So things such as descriptions or who maintains the image. Next we have some instructions which all create new layers in your Docker image, so each of the next three instructions will create a new layer. One layer per instruction. And I'm stressing this because I like to keep my Docker images as efficient as possible, and there are says to minimize the number of layers, but that's a more advanced topic. For now just be aware that each of these instructions creates a new layer. First we have RUN, and RUN executes commands within a new layer of the image, and this is typically used to install packages, applications, test suites, or to perform other configuration. Any output of this RUN instruction will be stored on a new layer within the Docker image. Now next we have two instructions which do almost the same thing. We have COPY, and we have ADD. Now what's common between them both is that they can take new files from a source location, and copy them to a destination location within a Docker image, specifically a new layer in that image. Now these are typically used to copy applications or application files from wherever you're running the Docker build command, and these files are copied into the image. The functionality gained using ADD versus COPY is that ADD can ADD things from remote URLs and do some forms of extraction, otherwise they both do the same thing, they add files to a new layer within your image. Now don't worry if this seems complex, or confusing. I promise you it's not and you're going to get practical experience of working with this very soon. Let's move on. Now these next three instructions aren't about what is on the image, instead they relate to what the image does, and how it's run. The first instruction is the command, or CMD instruction. Now this defines the default executable of a container. So if you create container you can state using CMD that you want it to run a certain web server or game server. When you run a container from an image you don't specify any arguments on the command line and this default is chosen and used. But it can be overridden if you use CMD. Now ENTRYPOINT does much the same thing as CMD only it can't be overridden in the same way. So as a general rule you would use CMD when you're creating a more general purpose container image where you might when to allow different executables to be run within the container, whereas you would use ENTRYPOINT when you're creating a very specific single purpose container image. Otherwise they're very similar, and they can be used together with CMD providing default options to the executable specified in the ENTRYPOINT instruction. Now lastly we have EXPOSE, and this informs Docker what port your container app is running on. So if you have a web app running via a web server on port TCP80, then that app would be running in the container on that port. And EXPOSE is a way of telling Docker or whoever is running the container what port that application is running on. Now it's important to remember this instruction does not perform any network configuration, it just informs Docker and anyone using it what port a containerized application is running on inside the container. Okay so that's the basic theory and structure of Docker files. Elsewhere I'll go into more detail likely within my more in depth Docker courses. For now though, this is all the theory that you need to know. What I think will help is for you to get some practical experience in working with Docker files, and that's coming up next. At this point that's everything I wanted to cover. When you're ready go ahead and move on to the next part of the course, where you'll actually work with Docker files and Docker Build to build a container image.