Color theme Dark mode Font size Content width


This article is over 4 years old, it may be outdated!

Gotcha: dockerignore

Published on 12/21/2016

Today I was caught off-guard by a docker “bug” - or so I thought at first. I tried to boot up a project with docker-compose up like I do since switching to a Mac. Unusual was that docker-compose stopped at the build step and would not finish the boot. After some confusion and after checking the projects docker-compose.yml configuration file I went to GitHub to see the newest docker for mac issues because I was using the beta release and thought a recent update might broke a thing or two. Looking at the issues I found a similar issue in docker/for-mac and commented with my setup and output of docker-compose --verbose up only to realize a good 30 minutes later my setup was the problem all along.

While the configuration files were all correct, I made a mistake and did not provide a .dockerignore file. Without the .dockerignore two 6GB SQL dumps in the same directory which were mounted into the docker container which made the docker daemon crash / hang up. The simple solution was to create the following .dockerignore file.

# database directory on the host
# all sql and gz files

Afterwards the docker-compose started without any issues because it now had a build context of around 400MB instead of 13GB.

Lesson learned: Always make sure your .dockerignore is setup right and ignores all big files! The full file looks as follows:




Like this?

If this content has helped you or your company, consider making a donation to a good cause.

For example, consider donating to the following causes:

A Selfie of me

Kevin Gimbel

is a DevOps Engineer and avid (Video) Gamer. He’s also interested in Sci-Fi, Cyberpunk, and dystopian books.

Wearing a mask is a good idea!

You can find out more about me if you wish.