How to specify different .dockerignore files for different builds in the same project?
I used to list the
tests directory in
.dockerignore so that it wouldn’t get included in the image, which I used to run a web service.
Now I’m trying to use Docker to run my unit tests, and in this case I want the
tests directory included.
docker build -h and found no option related.
How can I do this?
One Solution collect form web for “How to specify different .dockerignore files for different builds in the same project?”
At the moment, there is no way to do this. There is a lengthy discussion about adding an
--ignore flag to Docker to provide the ignore file to use – please see here.
The options you have at the moment are mostly ugly:
- Split your project into subdirectories that each have their own
.dockerignore, which might not work in your case.
- Create a script that copies the relevant files into a temporary directory and run the Docker build there.