return to main page
graph TB
a1[curl localhost:80] -.->a2[nginx container in systemd system service]
Set up a systemd system service example2.service where rootful podman is running the container image docker.io/library/nginx. Configure socket activation for TCP port 80.
The instructions are similar to Example 1.
- Create the file /etc/containers/systemd/example2.container with the contents
[Unit] Requires=example2.socket After=example2.socket [Container] Image=docker.io/library/nginx Environment=NGINX=3; [Install] WantedBy=default.target
- Optional step for improved security: Edit the file /etc/containers/systemd/example2.container
and add this line below the line
[Container]
For details, see section Possibility to restrict the network in the containerNetwork=none
- Create the file /etc/systemd/system/example2.socket that defines the sockets that the container should use
[Unit] Description=Example 2 [Socket] ListenStream=0.0.0.0:80 [Install] WantedBy=sockets.target
- Reload the systemd configuration
$ sudo systemctl daemon-reload
- Start the socket
$ sudo systemctl start example2.socket
- Test the web server
$ curl -s localhost:80 | head -4 <!DOCTYPE html> <html> <head> <title>Welcome to nginx!</title>