What is the purpose of the Docker build context? What is the purpose of the Docker build context? docker docker

What is the purpose of the Docker build context?


TL;DR: "because the client and daemon may not even run on the same machine"

The docker command is the docker client of the dockerd that is the service that can run directly in your PC (linux) or under a Linux VM under OSX or Windows.

Q: What is the purpose of the Docker build context?

From here:

Would probably be good to also mention that this has to happen this way because the client and daemon may not even run on the same machine, so without this "context" the daemon machine wouldn't have any other way to get files for ADD or otherwise


Q: If the build process compresses the current directory contents and sends it to the daemon, where does it go?

The docker daemon receives the compressed directory and process it on the fly; does not matter where it is stored in that moment.

Q: Why doesn't it make that content available for use in the image?

Think this: How can docker know where do you want to put each file/directory in the target image? With COPY/ADD directives you can control where put each one. The case that you've mentioned is only a trivial example where you have a single directory and a single target.