tl;dr
If Docker Compose is hanging unexpectedly:
- Make sure you're using Docker Compose v2.
- Check your system entropy and
apt install haveged
if it's low.
- Expect low entropy on cloud / virtualized hardware.
Update (February 2023)
Docker Compose v2 has been rewritten in Go.
I'm still seeing reports of people experiencing hangs within the last 12 months, but I can't verify that those reports are from people running Compose v1 or v2.
My understanding is that Compose v1 hangs for all commands due to a core dependency that needs entropy to initialize, preventing even --help
and --version
from running.
Contrast that with v2, which only appears to use randomness when generating container names.
Docker itself uses randomness more, so I would imagine it is more likely to hang at this point than Compose.
So - haveged
is still your friend if you're running on any virtualized hardware or are experiencing entropy-related hangs, as described below - but if you're experiencing this in 2023, make sure you're using Compose v2.
Note that Docker Compose v1 is now unsupported as of July 2023. It also hasn't received security updates since May 2021, so start migrating now.
Original (June 2021):
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.
Just run apt install haveged
or your distro's equivalent and you're good to go.