Courseiva
Manage containers →easyMultiple Select

EX200 Manage containers Practice Question

Which TWO options correctly describe the use of 'podman exec'? (Choose TWO.)

⚠ Common exam trap

A common mix-up: candidates confuse `podman exec` (which runs a new process in an existing running container) with `podman attach` (which connects to an existing process) or `podman run` (which creates a new container), leading candidates to incorrectly select options about attaching to existing shells or starting stopped containers.

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

✓

podman exec <container> ls / runs the ls command inside the running container.

`podman exec <container> ls /` executes the `ls /` command directly inside the specified running container, using the container's filesystem and environment. This is the primary purpose of `podman exec`: to run a new process in an already running container without creating a new container.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • ✓

    podman exec <container> ls / runs the ls command inside the running container.

    Why this is correct

    The `podman exec` command takes a container name or ID followed by a command, then runs that command as a new process inside the already running container's namespaces and root filesystem. Here, `ls /` is executed directly by the container's runtime, not through a shell unless explicitly wrapped, so the output is the contents of the container's root directory. This is the core purpose of `exec`: to run a one-off command in an existing, running container without creating a new container.

  • ✓

    podman exec can run commands as a different user with --user.

    Why this is correct

    With `podman exec --user <username_or_UID> <container> <command>`, the command is executed with the specified user's security context instead of the container's default user. This is done by setting the process credentials in the namespaces, and it is particularly useful for troubleshooting or automation that must run as a non-root user or as a specific service account. The user must exist in the container's user database (or the raw UID can be used) and must have the necessary permissions on the target files or processes.

  • ✗

    podman exec -it <container> /bin/bash attaches to an existing shell process.

    Why it's wrong here

    This statement confuses `exec` with `attach`. `podman attach` connects your terminal's standard input/output/error to the container's primary process (PID 1), i.e., the process that was started with `podman run`. In contrast, `podman exec -it <container> /bin/bash` spawns a brand-new `/bin/bash` process inside the container, which has its own PID and is neither the main container process nor an already-existing shell. The `-it` flags allocate a pseudo-TTY and keep stdin open for the new process, but they do not attach to an existing process.

  • ✗

    podman exec can start a stopped container.

    Why it's wrong here

    `podman exec` explicitly requires the target container to be in the running state; if the container is stopped or paused, `exec` returns an error such as "container is not running" or "cannot exec into a stopped container". The command is executed by the container's runtime within the existing container, so there is no mechanism in `exec` to start the container first. To run a command in a stopped container, you must first use `podman start` to transition it to the running state, after which `exec` can be used.

  • ✗

    podman exec -it <container> /bin/bash runs an interactive shell in a new container.

    Why it's wrong here

    The syntax `podman exec -it <container> /bin/bash` operates on an existing, running container identified by its name or ID; it does not create any new container. For launching a new interactive container from an image, the correct command is `podman run -it <image> /bin/bash`, where `<image>` is an image reference, not a container ID. The confusion arises because both `run` and `exec` can start a shell, but `exec` targets an existing container's runtime environment, whereas `run` creates a fresh container from an image and starts it.

About these practice questions

One of 427 original EX200 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This EX200 practice question is part of Courseiva's free Red Hat certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the EX200 exam.