Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override .dockerignore file when using ADD

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...!

like image 461
J Young Avatar asked Jan 31 '17 06:01

J Young


People also ask

What is the use of .dockerignore file?

The . dockerignore file is very similar to the . gitignore file in that it allows you to specify a list of files or directories that Docker is to ignore during the build process. This can come in really handy in certain instances.

What do you add to Dockerignore?

Dockerignore files allows you to mention a list of files and/or directories which you might want to ignore while building the image. This would definitely reduce the size of the image and also help to speed up the docker build process.

Where is .dockerignore file located?

dockerignore in the root directory of the context. If this file exists, the CLI modifies the context to exclude files and directories that match patterns in it. This helps to avoid unnecessarily sending large or sensitive files and directories to the daemon and potentially adding them to images using ADD or COPY .


1 Answers

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

like image 50
Lucas dos Santos Abreu Avatar answered Sep 20 '22 12:09

Lucas dos Santos Abreu