Posted by Arjun Arjun on Saturday 14th October 2017, 1 minute read

.dockerignore

Docker dockerignore

In this post will show you how to use the .dockerignore. It will help reducing Docker image size, speedup docker build and avoid unintended secret exposure. .dockerignore behaviors same as .gitignore, it removes the extra unwanted files from your image, so you only end up with the files you need for running your application.

The COPY command in a .dockerfile will blindly copy everything from a folder, to image. If you add .dockerignore file to your project. This file will instruct the COPY command of your Dockerfile, to ignore certain files and folders.

NodeJs- .dockerignore

Here is my .dockerignore file for one of my node project.

node_modules
.dockerignore
Dockerfile
npm-debug.log
.git
.hg
.svn
...
Arjun

I am Arjun from Hyderabad (India). I have been working as a software engineer from the last 7+ years, and it is my passion to learn new things and implement them as a practice. Aside from work, I like gardening and spending time with pets.