Creating Docker Images

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.

In this chapter, we will cover the following topics:

  • What is a Dockerfile?
  • All of the instructions that can be used in a Dockerfile
  • When to use either the COPY or the ADD instruction
  • The difference between the ENV and ARG variables
  • Why you use the CMD and ENTRYPOINT instructions
  • The importance of the build context
  • Building Docker images using a Dockerfile
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.116.60.251