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.
I've checked docker build -h
and found no option related.
How can I do this?
dockerignore file is on the root directory of your context, it will ignore it if it is somewhere in the subfolder.
Change App Structure. The only other useful option I can think of is to split out your ADD or COPY into multiple commands so that you don't rely on the the . dockerignore to filter files to the other 3 images. This would probably require your assets directory to be stored outside of your application root.
Yes, the Dockerfile , docker-compose. yml , and . dockerignore are all used to build the image and spin up a container, however, that's where the purpose of these files stop.
Docker 19.03 shipped a solution for this.
The Docker client tries to load
<dockerfile-name>.dockerignore
first and then falls back to.dockerignore
if it can't be found. Sodocker build -f Dockerfile.foo .
first tries to loadDockerfile.foo.dockerignore
.
Setting the DOCKER_BUILDKIT=1
environment variable is currently required to use this feature. This flag can be used with docker compose
since 1.25.0-rc3 by also specifying COMPOSE_DOCKER_CLI_BUILD=1
.
See also:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With