0

I created an unit file, with the following lines to start-up a podman container. Unfortunately, right after starting up, journalctl -xe tells me service not needed, shutting down, service shuts down. podman ps --all says exited (0), hence, it is a regular stop.

[Unit]
Description=Service for auto-start the Podman NGINX Container
After=syslog.target
After=network.target

[Service]
Type=simple
User=root
Group=root

ExecStart=podman start nginx
ExecStop=podman stop nginx

[Install]
WantedBy=multi-user.target

I tried also some variants with StopWhenUnneeded=false, which made no difference.

System is RedHat8. The official RedHat-description to solve this didn't work.

1 Answer 1

1

There is a Podman command for creating a systemd service unit file

podman generate systemd --name --new nginx.

See the podman generate systemd man page.

Here is an example:

[root@asus ~]# podman create --name nginx -p 80:80 docker.io/library/nginx
7844db33bf66233f71c74ce0d43e590a8478b087198dfc276477baaf20a9b503
[root@asus ~]# podman generate systemd --name --new nginx > /etc/systemd/system/nginx.service
[root@asus ~]# systemctl daemon-reload
[root@asus ~]# systemctl start nginx.service
[root@asus ~]# curl localhost:80
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
html { color-scheme: light dark; }
body { width: 35em; margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif; }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>
[root@asus ~]# podman --version
podman version 3.4.4
[root@asus ~]# cat /etc/fedora-release 
Fedora release 35 (Thirty Five)
[root@asus ~]#
1
  • A colleague told me that finally (after I forgot about my question). But it's always usefull to have questions answered here => +1 Mar 21, 2022 at 8:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.