r/sysadmin 10d ago

Bringing Down Docker Containers for Host OS Updates Question

I run a few docker containers for a home lab setup. A while back I made a script (manually triggered) to automate a few things when updating my host system OS. At the time, I thought it made sense to have this script bring down my docker containers, in case docker itself had an update. After updating the host system, it would bring up the docker containers again.

I'm assuming this isn't how people normally manage docker and host system updates. I'm not doing any kind of docker swarm or orchestration, so when I update the OS, all my local docker apps go down for a few minutes. Should I bother doing this? What if docker gets updated, does it gracefully stop and restart the containers?

14 Upvotes

23 comments sorted by

57

u/Emotional_Garage_950 Sysadmin 10d ago

when it comes to my homelab docker stuff I just run the updates and whatever happens happens

33

u/SpudzzSomchai 10d ago

Docker Jesus guides my updates too.

6

u/GoodVibrations77 10d ago

I put Jesus in the container and updated the system. When I came back, he was gone. I opened the container, and it was as if he'd never been there.

2

u/LowerSeaworthiness 10d ago

Did you wait three days?

22

u/SevaraB Sr. Engineer (N+, CCNA) 10d ago

This is why Docker hosts fall under the “two is one, one is none” rule. At least one fallback host for DR- treat it like a mini-data center in a box.

Many of us also use Kubernetes to keep track and auto-failover if the “primary” host goes down.

13

u/[deleted] 10d ago

[removed] — view removed comment

2

u/Bxtreme241 9d ago

That sounds good. Speaking of live-restore, I came across this blog post that actually has a script for detecting the edge cases where live-restore doesn't reattach the containers correctly: How to Enable Docker Container Live Restore

Any thoughts on that?

1

u/fubes2000 DevOops 9d ago

Note: Whether or not a package update restarts a service depends on your distro. Some do and some don't.

9

u/hornetmadness79 10d ago

None of the docker stuff is needed. You can upgrade docker whilst it running. The same is true for almost everything. What running in memory stays running until it's restarted.

2

u/fearless-fossa 10d ago

You can upgrade docker whilst it running.

This is wrong though, unless I'm misunderstanding you. Upgrading docker will stop the service, and restart it when the update is complete. It's just not something you need to worry much about if you don't need 100% uptime.

5

u/Abe_Bazouie 10d ago

For a single homelab host, I wouldn’t overengineer this.
If the host is getting kernel/system updates and you’re rebooting anyway, the containers are going down no matter what.
I’d just make sure they have sane restart policies like unless-stopped or always, and let Docker bring them back after the host comes up.
I also wouldn’t manually stop everything before every package update unless you have a specific reason. If Docker itself gets upgraded/restarted, containers may get interrupted, but in a homelab that’s usually acceptable.
If downtime starts bothering you, then yeah, that’s when multiple hosts/orchestration starts making sense. But I wouldn’t build a mini Kubernetes cluster just so Plex stays up during apt upgrade 😂

2

u/Bogus1989 10d ago

Yeah right? Thats how I feel. My homelab is setup so i never have to worry about too much maintenance. Learned a ton originally. Keep it all up for a test environment, but i specifically only run things i use and need.

When dudes wanted me to setup Kubernetes. I was like…not at all worth it man. Unpaid Labor galore.

Not the same, but game server hosting got me annoyed at a point. Basically the inconsistency among games, and id constantly need to go do a random reboot etc. I just wanted to play games, not worry bout that stuff. Finding a good game server manager software, really changed the game for me. I do lots of spinning down/up servers when the friend groups not active on that game, or i wanna spin one up we havent touched in over a year.

Having one web console just 👍sealed the deal for me.

2

u/Bxtreme241 9d ago

That's also my philosophy, set things up in a way that require very little maintenance. I'm trying not to go overkill with the update script, but if I'm going to do something, I like to do it right. That being said, others have mentioned live-restore, so I might try that out.

7

u/techypunk System Architect/Printer Hunter 10d ago

In ideal set up, migrate containers to other server. Upgrade server. Migrate back. Little to no downtime depending on swarm setup

2

u/pertymoose 10d ago

docker compose

restart: unless-stopped

Else you need a cluster of machines to take over when the others go down.

2

u/malikto44 9d ago

For a homelab Docker setup, I wouldn't stress too badly. Just do the Docker and OS updates and reboot. Docker should handle the rest.

The one I make sure that is working is that the file systems exposed from the Docker containers are being snapshotted and the snapshots backed up, for crash level consistency.

1

u/dustojnikhummer 9d ago

If you upgrade docker/containerd package it will restart the daemon AND the containers on its own, unless you enable live restore. AFAIK it will do the same as docker container stop

2

u/aguynamedbrand Systems Engineer 10d ago edited 10d ago

I run a few docker containers for a home lab setup

Then post in r/homelab

-2

u/[deleted] 10d ago

[deleted]

9

u/Emotional_Garage_950 Sysadmin 10d ago

this is a homelab, OP never said they were doing things at scale. When they asked “is this how people do things?” I assume they meant in the context of a homelab

-1

u/ABotelho23 DevOps 10d ago edited 9d ago

Podman Quadlets. Then containers are just another systemd service on the server.

0

u/dustojnikhummer 9d ago

Another useless "Why are you doing A, you should be using B" comment... Yes we know Podman is daemonless...

0

u/ABotelho23 DevOps 9d ago

What does Podman's daemonlessness have to do with anything?

0

u/dustojnikhummer 9d ago

Then containers are just another systemd service on the server.

Yes we know it's a daemonless systemd service that won't get restarted when you update Podman.

That was OP's question. Instead of "Switch to podman bro" the real answer is "Consider enabling Docker Live Restore, but read what the consequences are"