In a typical Docker build, the .dockerignore file affects the "build context", which is packaged and sent to the .dockerignore server at the start of the build. If the "build context" does not contain files, you cannot reference them, so files are excluded. They do not "exist" for assembly.
Rocker claims it works differently without sending the build context to the server. The code looks like this: every step of ADD / COPY consists of a tar file that ignores the files . In addition, .dockerignore is read once at startup and caching .
Since Rocker does not send an assembly context before each assembly, but only filtering for each ADD / COPY , there is hope. But due to ignoring data that is read only once at startup, you cannot do something scared, for example, copy different .dockerignore files at different stages of assembly.
Use MOUNT
One option is to continue using .dockerignore as is and use the Rocker MOUNT command to manually copy the ignored directories. Their latest example in the mount section demonstrates:
FROM debian:jessie ADD . /app # assets/ in .dockerignore WORKDIR /app MOUNT .:/context RUN cp -r /context/assets /app # include assets/
Change application structure
The only other useful parameter that I can think of is to split your ADD or COPY into several commands so that you don't rely on .dockerignore to filter files on the other 3 images. This will probably require your assets directory to be stored outside of your application root.
source share