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.
Here is my
.dockerignore file for one of my node project.
I hope you like this Post, Please feel free to comment below, your suggestion and problems if you face - we are here to solve your problems.