How can I shutdown Docker as if live-restore was not set?

404 views Asked by At

I have set live-restore for most Docker hosts to support smooth minor version upgrades, but the documentation states that this feature is not suitable for major version upgrades. So the question is how to shut down dockerd and all containers, as if live-restore was not set?

Of course I can loop over all containers to shut them down one-by-one, but I would guess that dockerd uses a different procedure. Surely it can avoid starting new containers once it has received the signal to shutdown. The external loop cannot. Not to mention that the next Docker version might introduce new features/integrations that have to be taken into account. There has to be some "docker-style" way to do this.

2

There are 2 answers

0
Harri On

I guess I figured it out myself:

  • edit /etc/docker/daemon.json to set live-restore to false
  • run "systemctl reload docker" or send a SIGHUP to dockerd
  • run "systemctl stop docker docker.socket" or similar to shutdown docker as usual

Correct me if I am wrong.

0
Scott Carey On

I would like to have some sort of systemctl stopall docker that stopped the daemon and the containers when live-restore is active. It certainly would be useful in some situations. Unfortunately there does not appear to be a way to opt-in to non-live-restore behavior temporarily. Instead I use:

docker ps -q | xargs docker kill && systemctl stop docker

There is a very small window of time between killing all the containers and stopping docker that a container can be started, so its not perfect.