9

The docker daemon isn't starting anymore on my computer (Linux / Centos 7), and I strongly suspect that a container that is set to auto-restart is to blame in this case. If I start the daemon manually, the last line I see is "Loading containers: start", and then it just hangs.

What I'd like to do is to start the daemon without starting any containers. But I can't find any option to do that. Is there any option in docker to start the daemon without also starting containers set to automatically restart? If not, is there a way to remove the containers manually that doesn't require the docker daemon running?

Mad Scientist
  • 18,090
  • 12
  • 83
  • 109
  • 2
    If you know the id of the container, you can try to "manually" change its restart policy at `/var/lib/docker/containers/CONTAINER_ID/hostconfig.json`. This was proposed [here](https://stackoverflow.com/a/29841146/1561148). – tgogos Apr 03 '18 at 09:25

2 Answers2

2

I wrote this little script to stop all the containers before docker is started. It requires to have jq installed.

for i in /var/lib/docker/containers/*/config.v2.json; do
  touch "$i.new" && getfacl -p "$i" | setfacl --set-file=- "$i.new"
  cat "$i" | jq -c '.State.Running = false' > "$i.new" && mv -f "$i.new" "$i"
done
cdauth
  • 6,171
  • 3
  • 41
  • 49
2

I think we need to verify the storage driver for docker that you are using. Devicemapper is known to have some issues similar to what you are describing. I would suggest moving to overlay2 as a storage driver.

If you are not running this on a prod system, you can try to do below steps to see if the daemon is coming up or not,

  1. Stop the daemon process
  2. Clean the docker home directory, default is /var/lib/docker/*
  3. You may not be able to remove everything, in that case safe bet is to stop docker from autostart ,systemctl disable docker and restart the system
  4. Once system is up, execute step-2 again and try to restart the daemon. Hopefully everything will come up.
Shivam Singh
  • 108
  • 10