CompTIA XK0-006 (CompTIA Linux+) Practice Test 30

Question 290

A container's mounts, image identity and networking metadata must be inspected in structured form. Which operation fits?

  1. docker run -d -p 8080:80 nginx
  2. docker inspect web01
  3. docker start web01
  4. docker rm test01

Explanation

Correct Answer

B:

docker inspect produces structured JSON details including container mounts, network attachments and image references. It reads Docker object state rather than capturing traffic.

Incorrect Answers

A:

The -p mapping publishes the chosen container TCP port on the host, while -d detaches the process; the administrator instead needs inspecting structured container configuration; this option serves a different purpose.

C:

docker start restarts a previously created container without creating a new image or container definition; that changes a different part of the system; the requested outcome is inspecting structured container configuration.

D:

docker rm removes the container object after it has stopped unless force is used; this does not achieve inspecting structured container configuration on the system described.

Question 291

A container must always run a specific wrapper executable while accepting additional arguments from docker run. Which directive is most suitable?

  1. USER 10001
  2. docker images
  3. CMD ["python", "app.py"]
  4. ENTRYPOINT ["/usr/local/bin/wrapper"]
  5. docker image prune

Explanation

Correct Answer

D:

ENTRYPOINT sets the main executable while command arguments can be supplied separately. It is appropriate for images acting like command-line tools.

Incorrect Answers

A:

USER sets the user or UID for subsequent build steps and the default container process; using it would leave anchoring a container's startup executable unresolved.

B:

docker images lists locally known image references and sizes; the requirement is anchoring a container's startup executable, outside the effect of this choice.

C:

CMD supplies a default command or arguments for container startup and can be overridden at run time; it does not deliver anchoring a container's startup executable, which is decisive in this scenario.

E:

docker image prune removes dangling images by default, subject to prompts and filters; the task involves anchoring a container's startup executable, whereas this addresses another subsystem.

Question 292

Two containers must communicate over a user-defined isolated layer-2-like virtual segment on a host. Which network driver is common?

  1. Bind mount of a host path
  2. Overlay network
  3. --network none
  4. Bridge container network

Explanation

Correct Answer

D:

A bridge network connects containers on a host through a virtual Linux bridge. User-defined bridges can provide name-based container discovery in supported runtimes.

Incorrect Answers

A:

A bind mount exposes a specified host path inside the container; its scope differs from interconnecting same-host containers on an isolated bridge, so it cannot meet the stated requirement.

B:

Overlay networks encapsulate communication across multiple hosts in supported orchestrators; that is not equivalent to interconnecting same-host containers on an isolated bridge.

C:

The none mode avoids attaching the container to a normal bridge or external network; the administrator instead needs interconnecting same-host containers on an isolated bridge; this option serves a different purpose.

Question 293

A rootless runtime is preferred to avoid a long-lived root-owned Docker daemon for a user's containers. Which engine is commonly appropriate?

  1. docker run -d -p 8080:80 nginx
  2. docker inspect web01
  3. Rootless Podman
  4. docker exec -it web01 sh

Explanation

Correct Answer

C:

Podman supports rootless operation using user namespaces on configured systems. Rootless containers still require careful volume, network and privilege configuration.

Incorrect Answers

A:

The -p mapping publishes the chosen container TCP port on the host, while -d detaches the process; this does not achieve running containers without a root-owned daemon on the system described.

B:

docker inspect produces structured JSON details including container mounts, network attachments and image references; it will not provide running containers without a root-owned daemon under these conditions.

D:

docker exec launches a new process in an already running container; the requirement is running containers without a root-owned daemon, outside the effect of this choice.

Question 294

A containerized service should run under a non-root identity declared in the built image. Which instruction controls the runtime identity by default?

  1. USER 10001
  2. docker build -t app:v1 .
  3. docker image prune
  4. FROM ubuntu:24.04

Explanation

Correct Answer

A:

USER sets the user or UID for subsequent build steps and the default container process. It is not equivalent to host UID namespace isolation.

Incorrect Answers

B:

docker build executes build instructions from the chosen context and records a tag for the resulting image; the task involves selecting an image's default execution user, whereas this addresses another subsystem.

C:

docker image prune removes dangling images by default, subject to prompts and filters; its scope differs from selecting an image's default execution user, so it cannot meet the stated requirement.

D:

FROM selects a base stage or image for Dockerfile instructions; that is not equivalent to selecting an image's default execution user.

Question 295

An application container should stop gracefully by requesting its main process to terminate. Which command is suitable?

  1. docker stop web01
  2. docker inspect web01
  3. Rootless Podman
  4. docker logs web01

Explanation

Correct Answer

A:

docker stop signals the container process and waits before a forced termination timeout. Proper signal handling is needed for graceful cleanup.

Incorrect Answers

B:

docker inspect produces structured JSON details including container mounts, network attachments and image references; that changes a different part of the system; the requested outcome is asking a container process to terminate cleanly.

C:

Podman supports rootless operation using user namespaces on configured systems; this does not achieve asking a container process to terminate cleanly on the system described.

D:

docker logs retrieves captured output streams for a container using its logging driver; it will not provide asking a container process to terminate cleanly under these conditions.

Question 296

Unused dangling image layers should be removed while keeping images referenced by containers. Which command is a conservative option?

  1. docker build -t app:v1 .
  2. docker image prune
  3. CMD ["python", "app.py"]
  4. ENTRYPOINT ["/usr/local/bin/wrapper"]

Explanation

Correct Answer

B:

docker image prune removes dangling images by default, subject to prompts and filters. More aggressive pruning options can affect other unused images.

Incorrect Answers

A:

docker build executes build instructions from the chosen context and records a tag for the resulting image; the requirement is cleaning dangling image data, outside the effect of this choice.

C:

CMD supplies a default command or arguments for container startup and can be overridden at run time; the evidence calls for cleaning dangling image data, not merely this separate operation.

D:

ENTRYPOINT sets the main executable while command arguments can be supplied separately; the task involves cleaning dangling image data, whereas this addresses another subsystem.

Question 297

A one-off test container is no longer needed and should be deleted after stopping. Which command fits?

  1. docker start web01
  2. docker stop web01
  3. docker exec -it web01 sh
  4. docker run -d -p 8080:80 nginx
  5. docker rm test01

Explanation

Correct Answer

E:

docker rm removes the container object after it has stopped unless force is used. Removing a container differs from deleting its underlying image or named volumes.

Incorrect Answers

A:

docker start restarts a previously created container without creating a new image or container definition; that is not equivalent to deleting an unused container object.

B:

docker stop signals the container process and waits before a forced termination timeout; the administrator instead needs deleting an unused container object; this option serves a different purpose.

C:

docker exec launches a new process in an already running container; it answers a neighboring question rather than deleting an unused container object.

D:

The -p mapping publishes the chosen container TCP port on the host, while -d detaches the process; that changes a different part of the system; the requested outcome is deleting an unused container object.

Question 298

A running container needs a one-time interactive shell for diagnosis without replacing PID 1. Which command works?

  1. docker exec -it web01 sh
  2. docker inspect web01
  3. docker start web01
  4. docker run -d -p 8080:80 nginx

Explanation

Correct Answer

A:

docker exec launches a new process in an already running container. The image must contain the requested shell.

Incorrect Answers

B:

docker inspect produces structured JSON details including container mounts, network attachments and image references; using it would leave running a diagnostic shell inside an existing container unresolved.

C:

docker start restarts a previously created container without creating a new image or container definition; the requirement is running a diagnostic shell inside an existing container, outside the effect of this choice.

D:

The -p mapping publishes the chosen container TCP port on the host, while -d detaches the process; it does not deliver running a diagnostic shell inside an existing container, which is decisive in this scenario.

Question 299

A container image must be built from a Dockerfile in the current directory and tagged app:v1. Which command fits?

  1. ENTRYPOINT ["/usr/local/bin/wrapper"]
  2. docker image prune
  3. docker build -t app:v1 .
  4. docker tag app:v1 app:stable
  5. FROM ubuntu:24.04
  6. USER 10001

Explanation

Correct Answer

C:

docker build executes build instructions from the chosen context and records a tag for the resulting image. The context determines which local files can be copied.

Incorrect Answers

A:

ENTRYPOINT sets the main executable while command arguments can be supplied separately; the task involves building and tagging an image from local instructions, whereas this addresses another subsystem.

B:

docker image prune removes dangling images by default, subject to prompts and filters; its scope differs from building and tagging an image from local instructions, so it cannot meet the stated requirement.

D:

docker tag creates another local image reference pointing at the same image; the administrator instead needs building and tagging an image from local instructions; this option serves a different purpose.

E:

FROM selects a base stage or image for Dockerfile instructions; it answers a neighboring question rather than building and tagging an image from local instructions.

F:

USER sets the user or UID for subsequent build steps and the default container process; that changes a different part of the system; the requested outcome is building and tagging an image from local instructions.

Question 300

An image needs a default command that operators can replace when invoking docker run. Which Dockerfile instruction suits it?

  1. docker tag app:v1 app:stable
  2. FROM ubuntu:24.04
  3. CMD ["python", "app.py"]
  4. docker image prune

Explanation

Correct Answer

C:

CMD supplies a default command or arguments for container startup and can be overridden at run time. ENTRYPOINT has different override semantics.

Incorrect Answers

A:

docker tag creates another local image reference pointing at the same image; that changes a different part of the system; the requested outcome is supplying an overridable container default command.

B:

FROM selects a base stage or image for Dockerfile instructions; this does not achieve supplying an overridable container default command on the system described.

D:

docker image prune removes dangling images by default, subject to prompts and filters; using it would leave supplying an overridable container default command unresolved.

CompTIA Linux+ (XK0-006) Practice Tests