Debugging why docker-compose takes a long time to get to step 1

I have a docker-compose file that starts 5 different containers however, I only have this problem with 1 container.

When I execute:

docker-compose build my_container

it will display:

Building my_container

After this it will wait for around 5-10 minutes before proceeding with the build process (Step 1, 2, 3, etc…). This wait will occur even if I make no changes to the container (i.e. it can load the entire container from cache)

I am running this inside a VM (my dev server - Ubuntu 18.04). When I build this container on my production server is DOES NOT wait and proceeds as fast as I expect. This leads me to believe it has something to do with my local configuration on my dev server but I am at a loss as to how I can go about finding what is causing the hangup.

I’ve tried running strace which shows that it hangs at the following step:

wait4(14640, Building my_container

Running sudo ps-a shows:

14640 pts/0    00:01:16 docker-compose

Is there a way I can better understand what is causing this hang up?

Can you try to add .dockerignore that look like your .gitignore. High chance your local files (like node_modules) being scan and send to build

1 Like

This worked like a charm for me. Took infinitely less time to start building, exactly because my node modules weren’t being scanned in.