podman generate systemd --new generates a systemd unit that runs, stops, and removes a container instead of managing a pre-existing container. This avoids detached podman run commands that can make systemd misinterpret service completion. section 7.3.2 section 7.3.3
The generated unit coordinates the container lifecycle through systemd:
- ExecStart runs the original image and container configuration through podman run, using a cidfile and systemd-oriented options such as --rm, --replace, and --sdnotify=conmon. section 7.3.3
- ExecStop stops the container through its cidfile, while ExecStopPost removes it after shutdown. section 7.3.3
- Reload the systemd user-unit database before starting the generated service with systemctl --user. section 7.3.2
- Share the unit without first creating the container; starting it can pull the image and create a fresh container on another system. section 7.3.3
Generate and start a portable unit
podman generate systemd --new myapp > $HOME/.config/systemd/user/myapp-new.service systemctl --user daemon-reload systemctl --user start myapp-new systemctl --user status myapp-new section 7.3.3
Adding io.containers.autoupdate=registry enables podman auto-update to detect a changed registry image and restart the generated unit, which recreates the container from the updated image. section 7.3.4
