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/user
cd $HOME/.config/systemd/user
podman generate systemd --new --files --name cagw

See 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.service
Documentation=man:podman-generate-systemd(1)
Wants=network-online.target
After=network-online.target
RequiresMountsFor=%t/containers
 
[Service]
Environment=PODMAN_SYSTEMD_UNIT=%n
Restart=always
TimeoutStopSec=70
ExecStart=/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:latest
ExecStop=/usr/bin/podman stop \
--ignore -t 10 \
--cidfile=%t/%n.ctr-id
ExecStopPost=/usr/bin/podman rm \
-f \
--ignore -t 10 \
--cidfile=%t/%n.ctr-id
Type=simple
NotifyAccess=all
 
[Install]
WantedBy=default.target

Starting the systemd service

Run the following commands to start the systemd service managing the cagw container.

systemctl --user daemon-reload
systemctl --user enable container-cagw
systemctl --user start container-cagw.service

Checking the systemd service status

Run the following command to check the service status (it must be running).

systemctl --user status container-cagw.service