Override .dockerignore file when using ADD

J Young picture J Young · Jan 31, 2017 · Viewed 7.4k times · Source

I have one Rockerfile that builds 4 images; I also have one central .dockerignore file. For one of the images I require assets that are blocked by the .dockerignore file -- is there a way when doing ADD or COPY to force add / ignore this list?

It'll be a lot easier to do this in one file as opposed to three separate...!

Answer

Lucas dos Santos Abreu picture Lucas dos Santos Abreu · Jan 31, 2017

In a simple way no.

The .dockerignore file is used to filter what will be used in the build before even reading the Dockerfile.

The docker daemon does not see your build folder, when the build starts, all the files in the context build folder are compressed (or just packed) and send to the daemon and only then it will read your Dockerfile to build the container with the files it received.

More content about .dockerignore: https://docs.docker.com/engine/reference/builder/#/dockerignore-file