I have a .dockerignore file, but for one use case, I want to specify the contents of .dockerignore at the command line, something like:
docker build --ignore="node_modules" -t foo .
is there a way to do this from the command line? I am not seeing this in the docs: https://docs.docker.com/engine/reference/commandline/build/#build-with--
No,
docker build
does not offer an alternative to the.dockerignore
file.That is why I usually keep a symbolic link
.dockerignore
pointing to the actual.dockerignore_official
, except for certain case, where I switch the symlink to.dockerignore_module
.This is a workaround, but that allows me to version the different version of dockerignore I might need, and choose between the two.
Update April 2019: as mentioned by Alba Mendez in the comments, PR 901 should help:
See
moby/buildkit
commit b9db1d2.It is in Docker v19.03.0 beta1, and Alba has posted an example here: