When using Podman instead of Docker, generate a systemd service as explained below.
Generating the systems service file
Run the following commands to generate the user's systemd service file.
mkdir -p $HOME/.config/systemd/usercd $HOME/.config/systemd/userpodman generate systemd --new --files --name cagwSee below for a container-cagw.service sample file generated with these commands.
# container-cagw.service# autogenerated by Podman 4.4.1# Wed Sep 20 03:47:02 EDT 2023[Unit]Description=Podman container-cagw.serviceDocumentation=man:podman-generate-systemd(1)Wants=network-online.targetAfter=network-online.targetRequiresMountsFor=%t/containers[Service]Environment=PODMAN_SYSTEMD_UNIT=%nRestart=alwaysTimeoutStopSec=70ExecStart=/usr/bin/podman run \ --cidfile=%t/%n.ctr-id \ --cgroups=no-conmon \ --rm \ --sdnotify=conmon \ --replace \ -d \ --name cagw \ -p 8444:8080 \ -p 9444:9090 \ -e LOADER_PATH=/etc/cagw/config/plugins \ -v /home/myuser/cagw/config:/etc/cagw/config:Z localhost/cagw/api:latestExecStop=/usr/bin/podman stop \ --ignore -t 10 \ --cidfile=%t/%n.ctr-idExecStopPost=/usr/bin/podman rm \ -f \ --ignore -t 10 \ --cidfile=%t/%n.ctr-idType=simpleNotifyAccess=all[Install]WantedBy=default.targetStarting the systemd service
Run the following commands to start the systemd service managing the cagw container.
systemctl --user daemon-reloadsystemctl --user enable container-cagwsystemctl --user start container-cagw.serviceChecking the systemd service status
Run the following command to check the service status (it must be running).
systemctl --user status container-cagw.service