The .dockerignore file

In the Docker's integrated image building system section, you learned that the docker build process will send the complete build context to the daemon. In a practical environment, the docker build context will contain many other working files and directories, which would never be built into the image. Nevertheless, the docker build system will still send those files to the daemon. So, you may be wondering how you can optimize the build process by not sending these working files to the daemon. Well, the folks behind Docker too have thought about that and have given a very simple solution, using a .dockerignore file.

The .dockerignore file is a newline-separated TEXT file, wherein you can provide the files and the directories which are to be excluded from the build process. The exclusion list in the file can have both the fully specified file/directory name and the wildcards.

The following snippet is a sample .dockerignore file through which the build system has been instructed to exclude the .git directory and all the files that have the .tmp extension:

.git 
*.tmp
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset