Gotcha: dockerignore

Published on 12/21/2016 | 21.12.12016 HE

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?

This website contains no advertisement, no tracking, no paid articles, and no shady-things-whatsoever. It is just content, provided free of charge and with accessibility in mind.

If you would like to support me in providing content - and code - for free or if this page has helped you or your company, consider supporting me directly.

You can support me via:

A colorful image of me wearing my DIY mask. The image has a colorful glitch effect.

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.