Docker Community Forums

Share and learn in the Docker community.

Is .dockerignore used for ADD/COPY as well?

docker

(James) #1

Wanted to double check my interpretation…

  1. Are the .dockerignore only used when sending the context as a whole?

  2. Can .dockerignore files be placed in subfolders?

Thanks everyone!


(Maiermic) #2

Yes, .dockerignore is used for ADD/COPY as well, see documentation:

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.

Can .dockerignore files be placed in subfolders?

See documentation:

Before the docker CLI sends the context to the docker daemon, it looks for a file named .dockerignore in the root directory of the context

It doesn’t look in subfolders. I checked it (using Docker version 17.12.0-ce, build c97c6d6).