RHCSA RHCSA Containers and Podman 2 — Questions and Answers
Question 1: Which Podman command maps host port 8080 to container port 80 when running an nginx image?
- podman run --map 8080:80 nginx
- podman run -p 8080:80 nginx (Correct answer)
- podman run --port host=8080,container=80 nginx
- podman run -P 8080:80 nginx
Correct answer: podman run -p 8080:80 nginx
The '-p host_port:container_port' flag publishes the container port to the specified host port.
Question 2: Which command lists all locally stored container images in Podman?
- podman images (Correct answer)
- podman list images
- podman show images
- podman image find
Correct answer: podman images
'podman images' displays all images stored in the local image cache, including their tags and sizes.
Question 3: What command generates a systemd unit file for an existing Podman container named 'myapp'?
- podman systemd generate myapp
- podman generate systemd myapp (Correct answer)
- podman unit create myapp
- systemctl generate podman myapp
Correct answer: podman generate systemd myapp
'podman generate systemd myapp' outputs a systemd service unit file that can manage the container lifecycle.
Question 4: Which command runs the 'bash' shell inside a running container named 'myapp'?
- podman shell myapp bash
- podman attach myapp bash
- podman run myapp bash
- podman exec -it myapp bash (Correct answer)
Correct answer: podman exec -it myapp bash
'podman exec -it myapp bash' opens an interactive terminal session running bash inside the running container.
Question 5: How do you mount the host directory '/data' to '/mnt/data' inside a Podman container?
- podman run --bind /data:/mnt/data nginx
- podman run -m /data:/mnt/data nginx
- podman run -v /data:/mnt/data nginx (Correct answer)
- podman run --mount-dir /data:/mnt/data nginx
Correct answer: podman run -v /data:/mnt/data nginx
The '-v host_path:container_path' (volume) flag bind-mounts a host directory into the container.
Question 6: Which command removes a local container image named 'myimage:latest' from Podman storage?
- podman image delete myimage:latest
- podman remove image myimage:latest
- podman rmi myimage:latest (Correct answer)
- podman image rm --force myimage:latest
Correct answer: podman rmi myimage:latest
'podman rmi myimage:latest' removes the specified image from local storage; mirrors the 'docker rmi' command.
Question 7: Which command displays detailed configuration and state information for a container named 'db'?
- podman info db
- podman inspect db (Correct answer)
- podman details db
- podman status db
Correct answer: podman inspect db
'podman inspect db' returns a JSON object with full container metadata including mounts, networking, and environment.
Which Podman command maps host port 8080 to container port 80 when running an nginx image?