Docker Community Forums

Share and learn in the Docker community.

What to do when all docker commands hang?

Steps to reproduce the behavior

Running Docker 1.12.6

  1. Run a docker build on an EC2 instance (let’s say the docker build hangs)
  2. Reboot EC2 instance

After the instance reboots, whenever I try to run ANY docker command (e.g., docker info), it just hangs and doesn’t return.

I tried to restart docker, but same problem. I tried to uninstall docker (yum remove docker) and remove /var/lib/docker and reinstall, but even then it still hangs. I have to delete the EC2 instance and start all over again. How do I fix this?

Can you please open an issue with as many details on the system and on how to reproduce on the Docker repo?

A better place for a Docker for AWS issue is probably https://github.com/docker/for-aws

Please make sure to include docker-diagnose output

Thanks!

Please follow the below steps to solve this issue

Step 1 : Uninstall docker “sudo yum remove docker"
Step 2 : remove all docker folder
"sudo rm -rf /var/lib/docker”
“sudo rm -rf /var/run/docker”
“sudo rm /var/run/docker.*” (remove docker.sock, docker.pid files)

Step 3 : Reinstall docker "sudo yum install docker"
Step 4 : Start docker “sudo service docker start”

3 Likes

You don’t need to reinstall or delete the container image data. Simply do below :slight_smile: slight_smile:

Stop the service first

sudo service docker stop

Clean up some of the files as mentioned in above post from Sam.

sudo rm -rf /var/run/docker
sudo rm /var/run/docker.*"

Start service now

sudo service docker start

Start your docker image

docker start <container-name>

You will receive an error when you run the docker run at first try:

Error response from daemon: invalid header field value "oci runtime error: container with id exists: 7a244b8f5d07081538042ff64aebfe11fac1a36731526e77be53db7d94dca44d\n"
Error: failed to start containers:

Try running docker start command again. You will have your container up and running magically without any errors.

5 Likes

What would you suggest if

sudo service docker stop

Hangs? Can i go ahead delete those files? And is everything self there to remove?

If service command hangs than you should kill the PID and delete the files.
After you can try to restart using service command.

I KILLED docker via the system monitor, and removed said files, but sudo service docker start produces absolutely not output and the problem persists

This worked for me. Thanks

Thank you, really helpful. In case someone is using Alpine Linux like me: apk del docker instead of yum remove docker

I had docker stuck in the same way, but for me the solution of @tmcconechy did not work.

because my Linux did not recognize the service command.

So I did a ps followed by grep (In the following I abbreviated the output)

BA92-C02VP224HTDF:Ampersand stefjoosten$ ps -A | grep docker
30249 ??         0:01.26 /Applications/Visual Studio Code.app/Contents/Fram...
62743 ??         0:00.01 /Library/PrivilegedHelperTools/com.docker.vmnetd
62753 ??         0:00.07 /Applications/Docker.app/Contents/MacOS/com.dock...
62754 ??         0:00.06 com.docker.osxfs serve --address fd:3 --connect vm...
62755 ??         0:34.23 com.docker.vpnkit --ethernet fd:3 --port vpnkit.p...
62756 ??         0:39.43 com.docker.driver.amd64-linux -addr fd:3 -debug
62761 ??        14:28.52 com.docker.hyperkit -A -u -F vms/0/hyperkit.pi...
76926 ttys004    0:00.00 grep docker
BA92-C02VP224HTDF:Ampersand stefjoosten$ 

Then I selected the right processes and killed them

kill -9 30249 62743 62753 62754 62755 62756 62761

Then docker came back up again, asking a few questions along the way. And everything was fine.

1 Like

This didn’t work for me. Both sudo service docker start and sudo service docker stop hang, regardless if I kill the PID and try again.

Cleaning up and restarting docker has had no effect. Is the only option to delete Docker at this point?

Thanks

I had a similar problem, docker commands would hang. I had modified /etc/docker/daemon.json to specify host information (related) so now e.g. docker info could no longer find the daemon.

Fix was simply to set DOCKER_HOST environment variable to point to the same address e.g.:

export DOCKER_HOST="tcp://127.0.0.1:2375"