Reputation: 915
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?
Upvotes: 65
Views: 93531
Reputation: 25410
For me, I had to update docker compose from 2.18.1 to latest (2.29.1).
Sidenote: the official instructions for removing the existing plugin didn't remove it for me, I did:
rm ~/.docker/cli-plugins/docker-compose
Once updated, it gave me an actual error message about the issue causing it to hang. A simple docker container prune
was all that was needed to fix the issue.
Upvotes: 1
Reputation: 695
In my case, docker compose
was not able to synchronize file shares (possibly related to https://github.com/docker/for-mac/issues/7281)
Shutting down all containers and deleting the file shares caused them to be recreated, and then docker compose up
would succeed.
You can delete the file shares by going to Settings > Resources > File sharing > Synchronized file shares
and deleting all of those
Upvotes: 0
Reputation: 370
Maybe it is too basic, but I ran into this problem with my MacBook Pro and the reason why docker-compose was hanging was because Docker desktop was paused. I don't know why is paused, but restarting it fixed the issue.
Upvotes: 1
Reputation: 973
In my case it was just a wrong path set as context
in the build
section of one service.
I would have hoped for an error message like "path/file not found". Clearly my own fault, but not the greatest developer experience from docker-compose.
Upvotes: 1
Reputation: 195
On my side, I encountered this issue because several of my Docker Compose recipes where all residing in a directory structure like this one:
/srv/cloud.example.org
/srv/cloud.example.org/docker-compose/docker-compose.yml
/srv/foo.example.org
/srv/foo.example.org/docker-compose/docker-compose.yml
Meaning when I was restarting the Docker Compose recipe for cloud.example.org for example, Docker Compose thought the request concerned also the other Docker Compose recipe.
This is due to the fact, Docker Compose considers the project name as, by default, the name of the parent directory where reside the .yml file, here the directory docker-compose
.
To avoid this issue, we can override the Docker Compose project name via the COMPOSE_PROJECT_NAME
env variable. More recently (src., src.), directly from the recipe under the top level name:
key.
Forcing a project name in each of my recipes fixed my issue and Docker Compose doesn't infinitely hang.
Upvotes: 0
Reputation: 2194
If Docker Compose is hanging unexpectedly:
apt install haveged
if it's low.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.
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.
Upvotes: 153
Reputation: 157
I ran into the same issue (but on "docker compose" (V2)).
The problem was because I was running the same services (with the same names) on a different project (folder);
So I stopped their containers from running, and the problem was solved.
Upvotes: 1
Reputation: 1059
My issue was docker was created multiple networks with the same name:
So run: docker network ls
you'll get the networks list:
d77315668c70 my_network bridge local
42db8739a34a my_network bridge local
307198de8065 my_network bridge local
217b7c68c345 none null local
So try to delete the unused and duplicated networks by their ID:
docker network rm d77315668c70
Upvotes: 2
Reputation: 51
Sometimes, the problem is only about your environment...
Check if there are any containers running on a port that you might be using in your application.
Just use docker ps
(as we are interested only in running containers)
Check the ports in use
If any of them was used by the application
try using docker stop [CONTAINER_ID]
Upvotes: 2
Reputation: 6629
If you have image builds in docker-compose (not only pulling images) it might be a case when you have too big docker context.
Just add .dockerignore
and review all unnecessary folders and exclude them.
Upvotes: 0
Reputation: 1744
If you are in a country like Iran probably the problem is sanction you can fix it using VPN or custom anti sanction DNS like
178.22.122.100
185.51.200.2
OR
185.55.225.25
185.55.226.26
or you can use unofficial docker registries built for crossing sanction limits like https://docker-registry.ir/
Upvotes: 3
Reputation: 4064
I have recently faced that issue this is how I fixed it. There can be multiple reasons for it. But in my case it was because of RAM and memory issue this is how I fixed it
If you don't have any such problem, better to verbose it. That will show you the interactive logs on the console
Or you can see the logs of the container
docker logs --tail=200 bootcamp
Upvotes: 2
Reputation: 261
I ran into this problem last night, the problem for me was a large sub directory of images, 66GB. Adding the sub directory to .dockerignore file resolved the issue
Upvotes: 16
Reputation: 1914
Try to run it with this option and see if helps:
docker-compose --verbose up
*Note: If you haven't build your container, run the same command with the option --build
Upvotes: 36