Run a docker build on an EC2 instance (let’s say the docker build hangs)
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?
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.
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.:
I was running around this issue for a round a week. Most of the solutions found online proposed to delete the container. But I had a project code in the container. So I need to recover docker without deleting the container. You saved my day.
I was facing a similar issue and the mentioned steps did not works for me, my issue was removing /var/lib/docker/ and /var/run/docker/ I was getting some errors looking like :
rm: cannot remove /var/lib/docker/some/sub/path/ Device or resource busy
solution was to unmount these device and I could then properly remove the folders.
I used to run a (volume) plugin that was implemented as docker container. After a reboot, the docker engine wouldn’t start as the plugin was not available, and the plugin container was not started because the docker engine didn’t finish starting. After some minutes the plugin was skipped and the docker engine started, and the plugin container could be started… it was a terrible circular dependency.
Check sudo systemctl status docker while docker is hanging. If it’s caused by a plugin, you should see errors in the output.