1.

When is .dockerignore file used?

Answer»

A typical Dockerfile CONTAINS one or more COPY commands to copy files and/or FOLDERS from the developer machine to the docker image, which eventually become part of the container. While copying folders to a docker image, it is quite possible that some unwanted files are also copied to the image. This may create a bulky image and hence cause performance issues in the container.

In ORDER to avoid this, we can create a file named .dockerignore along with Dockerfile in the same DIRECTORY. This file is used to list all the files and directories that need to be excluded while copying folders onto the image. It contains a pattern and none of the files matching it is added to the image. This helps to avoid unnecessarily sending large or sensitive files and directories to the daemon and potentially adding them to images.



Discussion

No Comment Found