RHCE Containers and Podman 2 — Questions and Answers
Question 1: What command builds a container image from a `Containerfile` in the current directory?
- podman create -f Containerfile
- podman build -t myimage . (Correct answer)
- podman compile -t myimage .
- podman make myimage
Correct answer: podman build -t myimage .
`podman build -t myimage .` builds an image named `myimage` from the Containerfile in the current directory.
Question 2: Which command generates a systemd unit file to run a Podman container as a service?
- podman systemd-generate mycontainer
- podman generate systemd mycontainer (Correct answer)
- systemctl enable podman-mycontainer
- podman service create mycontainer
Correct answer: podman generate systemd mycontainer
`podman generate systemd` creates a systemd unit file for a container that can be enabled to start at boot.
Question 3: What does the `podman inspect` command return?
- Runtime logs of a container
- Detailed JSON metadata about a container or image (Correct answer)
- Network traffic of a running container
- CPU/memory usage of a container
Correct answer: Detailed JSON metadata about a container or image
`podman inspect` outputs detailed JSON metadata including configuration, mounts, network settings, and state of a container or image.
Question 4: Which file is the Podman/OCI equivalent of a Dockerfile?
- Podfile
- Containerfile (Correct answer)
- BuildSpec
- PodSpec
Correct answer: Containerfile
A `Containerfile` is the OCI standard equivalent of a `Dockerfile`, supported natively by Podman and Buildah.
Question 5: What command stops and removes a running container named `webserver` in one step?
- podman delete webserver
- podman rm -f webserver (Correct answer)
- podman stop webserver && podman rm webserver
- podman kill --rm webserver
Correct answer: podman rm -f webserver
`podman rm -f` force-stops and removes a running container in a single command.
Question 6: Which command mounts a host directory `/data` into a container at `/app/data`?
- podman run -v /data:/app/data myimage (Correct answer)
- podman run --mount /data:/app/data myimage
- podman run -b /data:/app/data myimage
- podman run --bind /data:/app/data myimage
Correct answer: podman run -v /data:/app/data myimage
The `-v host_path:container_path` flag creates a bind mount between the host and container directories.
What command builds a container image from a `Containerfile` in the current directory?