Red Hat Certified System Administrator RHCSA · Free Practice Question Hard
Question 22
On rhel.server.com, as a system administrator on a RHEL 9 system, you are tasked with deploying a static website using Podman in rootless mode. Create a rootless Podman container as user john (create if not already existing) that meets the following requirements:
Uses a publicly available, lightweight
nginximage.Exposes port
8080on the host to serve the website.Mounts
/var/www/htmlon the host as/usr/share/nginx/htmlinside the container.Is managed by
systemdfor persistence and auto-start.Has correct SELinux context for the mounted directory.
Note: You can pull the nginx image from any of the following repositories:
registry.access.redhat.com/nginx:latestregistry.redhat.io/nginx:latestdocker.io/library/nginx:latest
-
A
Pass
-
B
Fail
Reveal correct answer
Correct answer: A
Explanation
Answer (Two Methods)
Step 1: Create the User john (if not existing)
- sudo useradd john
- sudo passwd john
Step 2: Enable Session Persistence for john
- sudo loginctl enable-linger john
Step 3: Prepare the Host Directory
- sudo mkdir -p /var/www/html
- sudo chown john:john /var/www/html
Method 1: Using Deprecated podman generate systemd
Step 4A: Run the Container Manually (Rootless)
Switch to user john:
- ssh john@localhost
- podman pull docker.io/library/nginx:latest
- podman run -d -p 8080:80 -v /var/www/html:/usr/share/nginx/html:Z --name my-nginx nginx
Step 5A: Generate and Enable systemd Service
- mkdir -p ~/.config/systemd/user/
- podman generate systemd --name my-nginx > ~/.config/systemd/user/my-nginx.service
- systemctl --user daemon-reload
- systemctl --user enable --now my-nginx
- systemctl --user status my-nginx
Note: The podman generate systemd command is deprecated. It will receive only critical bug fixes, with no new features. For long-term use, the Quadlet method below is recommended.
Method 2: Recommended — Using Quadlet (Declarative Approach)
Step 4B: Create Quadlet Configuration
Switch to user john:
- ssh john@localhost
- mkdir -p ~/.config/containers/systemd/
- nano ~/.config/containers/systemd/my-nginx.container
File Content:
- [Container]
- Image=docker.io/library/nginx:latest
- Name=my-nginx
- PublishPort=8080:80
- Volume=/var/www/html:/usr/share/nginx/html:Z
- [Service]
- Restart=always
Step 5B: Enable Quadlet Service
- systemctl --user daemon-reload
- systemctl --user enable --now my-nginx.container
- systemctl --user status my-nginx.container
Verification
Test website deployment:
- curl http://localhost:8080
Summary
The deprecated method using
podman generate systemdis functional but no longer enhanced.The Quadlet method is the preferred, future-proof solution, offering a declarative and maintainable setup similar to Kubernetes or Compose.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
