Ignoring Unnecessary Files
You may remember that there’s a separation between the Docker CLI that we use to run commands, and the Docker daemon that does most of the actual work (as we saw in the architecture diagrams for Docker for Linux and Docker for Mac/Windows). Building an image is no different—it’s the Docker daemon that actually builds the image.
How does this work in practice?
When the docker build command is run, the CLI tool takes all the files in the build directory specified—which collectively are known as the build context—and sends them to the Docker daemon. The daemon is then able to process the Dockerfile and carry out the instructions in it to generate the image.
We need a way to restrict which files are sent as part of the ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access