Docker-compose up hangs forever. How to debug

dockerdocker-compose

I have a project with a dockerfile and a docker-compose.yml for deploying it. But if I run docker-compose up, the command prints Building app and hangs forever. I do not see any steps being performed. It isn't downloading images either since there's no network traffic, and the images used are available in the cache.

How can I go about debugging and fixing this issue on my machine? Is there a verbose option for docker(-compose) that I could use?

Best Answer

As this is the top hit for "docker-compose hangs", I'll post the solution for my problem that would have saved me 30 minutes of searching. If even docker-compose --version hangs, this might be your fix.

Docker-compose seems to hang indefinitely when the system has low entropy. You can check this by running:

cat /proc/sys/kernel/random/entropy_avail

If the output is less than 1000, that is almost certainly why it's hanging. I was experiencing this on a VPS, where the available entropy was less than 10.

The fix for me was to install haveged, which immediately increased my available entropy to over 2500, and caused docker compose to work normally.