How we ignored docker

Visakh Vijayan
1 min readApr 9, 2021

--

Docker was giving us a hard time for several days now. It was taking way too long to rebuild our container with the changed files. Even though most of the things were from the cache, it was still taking a lot of time.

That is when we find out our mistake. We saw during our build that the COPY command was the trouble maker. It was taking a huge amount of time (approx 3 minutes) to build the container. It went on to the state where our system was flooded with images and we faced a space not left on the disk issue too.

So here is what we were doing wrong. We had the .git folder in our root directory and two of our volumes were also in the same directory. So every time we rebuilt it, all those files were getting copied by docker.

The simplest solution was to add a .dockerignore file in the root. And add all the folders we wanted docker to not copy during the build process into it.

.dockerignore
— — — — —
.git
folder1
folder2

Now our containers rebuild in seconds. We built it twice as we write this line. LOL.

Happy programming!

--

--

Visakh Vijayan
Visakh Vijayan

Written by Visakh Vijayan

Techie from Kerala, India. Days are for coding, nights for weaving tales of tech, travel, and finance. Join me in exploring this multifaceted journey

Responses (1)