I have a few containers on one host and a script that stops them before OS updates, then starts them again. Is that necessary, especially if Docker itself gets updated?
Do I need to stop Docker containers before updating the host?
Answers
For a single host where a few minutes of downtime is fine, I wouldn't stop everything for every package update. If the update needs a reboot, the containers will go down anyway.
Set appropriate restart policies, such as unless-stopped or always, and check that the apps come back after the host and Docker start. A planned stop can still be useful if an application needs a particular shutdown order or extra time to clean up.
Reply to this answer
Docker updates are the part to watch. A package upgrade may restart the Docker daemon, which normally stops running containers and then brings eligible ones back according to their restart policies. The exact behavior depends on how the package and service are managed.
Docker's live-restore setting can keep containers running while the daemon is unavailable during a supported daemon upgrade. It won't keep them running through a host reboot, and it has limitations, so check the Docker documentation and test it with your setup before depending on it.
x.384~ferrulepocket:
So live-restore could help with a Docker daemon restart, but it doesn't avoid downtime when the host itself reboots.
Reply to this answer
If downtime stops being acceptable, a second host is the bigger change, not a more elaborate shutdown script. You can move workloads or use orchestration to help manage failover, though that adds complexity and doesn't automatically make every application seamless.
Reply to this answer
Add your answer
Answers are reviewed before publication.
Mika:
With unless-stopped, a container you deliberately stopped may stay stopped after Docker restarts, so check the behavior you want before relying on it.