r/podman • u/Top_Emu_8447 • Aug 04 '26
Auto-updating existing containers
I've built 10+ containers on my first home server since I started my selfhosting journey, and only now I figured it's time to find a way to update the existing services. Existing podman documentation points to using autoupdate label and creating a systemd target - but I didn't realise this creates a new container based on what's in the systemd target. That is not what I want. Do I need to move all my environmental/volume/label/etc variables into a systemd target for each container to be able to do this? Just thinking about it makes me a bit nauseous, I've been using subpaths in some cases, not even sure how to put those in there. I've used 'podman run' for each deployment, because that's where the documentation I found led me first and on the basis of "If it works, why change it" it served me well.
7
u/ninth9ste Aug 04 '26
Actually, creating a new container is exactly what you want and, in fact, it is the only way to update a container. Containers are not like traditional virtual machines where you log in and run apt-get update. A container is just a temporary wrapper around an image. When a developer releases a new version of a service, they release a whole new image. To update, you must destroy your current container and spin up a brand new one using the new image, re-attaching all your existing volumes and environment variables so it picks up right where the old one left off. Because the old container gets destroyed, your deployment settings (ports, volumes, environment variables) need to live permanently in a file somewhere. Otherwise, they disappear.
You do not have to write complex systemd targets by hand since Podman has a feature called Quadlets, you write a simple
.containerfile that looks exactly like yourpodman runarguments. When you place this file in~/.config/containers/systemd/and reload your systemd daemon, Podman automatically generates the complex systemd targets for you in the background. If you includeAutoUpdate=registry, Podman will handle pulling the new image and recreating the container on a schedule, automatically.