To achieve auto-update functionality with Podman and a docker-compose.yml file like the one you're using, you'll need to follow a few steps. The key here is utilizing Podman's auto-update feature, which can detect when an image used by a container has been updated in the registry and then automatically recreate the container with the new image. Note that your docker-compose.yml already includes an essential label for enabling auto-updates: io.containers.autoupdate: image. This is a good start.
However, Podman's auto-update feature is based on systemd services to manage the lifecycle of containers and pods. Therefore, direct integration with podman-compose and the docker-compose.yml file might not be entirely straightforward because you'd typically need to create a systemd service for your container. Here's an outline of what you can do to set up auto-updates with Podman, leveraging systemd.
1. Ensure Your Container Configuration Supports Auto-update
Your docker-compose.yml includes the label io.containers.autoupdate: image, which is required for Podman's auto-update feature. This means your setup is ready in this aspect.
2. Convert Your Compose File to systemd Services
Since you're using podman-compose, you can generate systemd units from your docker-compose.yml file:
podman-compose up -t systemd
This command should generate .service files for your compose setup. You might need to adjust the generated services if you plan to ensure they fit your requirements, such as custom dependencies or start conditions.
3. Enable the Services
Once you have your systemd unit files, enable them to start at boot:
sudo systemctl enable <your-service-name>.service
And start the service:
sudo systemctl start <your-service-name>.service
4. Use Podman's Auto-update Mechanism
Now that your container is managed by systemd, you can leverage Podman's auto-update feature. Check your current auto-update policy with:
podman auto-update --dry-run
And to actually run an auto-update:
podman auto-update
5. Automate the Auto-update Process
To fully automate the process, you could set up a cron job or a systemd timer that periodically runs podman auto-update.
For example, creating a systemd timer:
- Create a systemd service file (
podman-auto-update.service):
[Unit]
Description=Podman auto-update
[Service]
Type=oneshot
ExecStart=/usr/bin/podman auto-update
- Create a systemd timer file (
podman-auto-update.timer):
[Unit]
Description=Run Podman auto-update daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
- Enable and start the timer:
sudo systemctl enable --now podman-auto-update.timer
This setup should ensure your containers are automatically updated when a new image version is available. Remember, the effectiveness of this setup depends on properly versioned images in the registry and might require some manual intervention for major updates or when migration steps are involved.