In this chapter, we will learn how to create enterprise-grade Docker images. We will start off by learning about the main building block of Docker images, specifically the Dockerfile. Then, we will explore all the instructions available to use in a Dockerfile. There are some instructions that on the surface seem very similar. We will uncover what the differences are between the COPY and ADD instructions, the ENV and ARG instructions, and most importantly between the CMD and ENTRYPOINT instructions. Next, we will find out what the build context is and why it is important. Finally, we will cover the actual image build command.
If well-maintained, the average shipping container has a lifespan of around 20 years, whereas the average lifespan of a Docker container is 2.5 days.