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

Question 280

A container needs read/write access to an existing host directory rather than a Docker-managed data area. Which mount style fits?

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

Explanation

Correct Answer

B:

A bind mount exposes a specified host path inside the container. Host-side ownership, labels and security policy determine actual accessibility.

Incorrect Answers

A:

The none mode avoids attaching the container to a normal bridge or external network; its scope differs from exposing an explicit host directory into a container, so it cannot meet the stated requirement.

C:

A bridge network connects containers on a host through a virtual Linux bridge; the administrator instead needs exposing an explicit host directory into a container; this option serves a different purpose.

D:

Overlay networks encapsulate communication across multiple hosts in supported orchestrators; it answers a neighboring question rather than exposing an explicit host directory into a container.

Question 281

A stopped container should resume with its previous configuration and writable layer. Which command does this?

  1. docker stop web01
  2. docker start web01
  3. docker logs web01
  4. docker inspect web01

Explanation

Correct Answer

B:

docker start restarts a previously created container without creating a new image or container definition. Persistent state depends on the container and its mounted volumes.

Incorrect Answers

A:

docker stop signals the container process and waits before a forced termination timeout; this does not achieve restarting an existing stopped container on the system described.

C:

docker logs retrieves captured output streams for a container using its logging driver; using it would leave restarting an existing stopped container unresolved.

D:

docker inspect produces structured JSON details including container mounts, network attachments and image references; the requirement is restarting an existing stopped container, outside the effect of this choice.

Question 282

A background web container must map host port 8080 to its internal port 80. Which run argument is appropriate?

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

Explanation

Correct Answer

A:

The -p mapping publishes the chosen container TCP port on the host, while -d detaches the process. Firewall and bind-address settings still govern exposure.

Incorrect Answers

B:

docker inspect produces structured JSON details including container mounts, network attachments and image references; the task involves mapping a host TCP port to a container port, whereas this addresses another subsystem.

C:

docker rm removes the container object after it has stopped unless force is used; its scope differs from mapping a host TCP port to a container port, so it cannot meet the stated requirement.

D:

docker logs retrieves captured output streams for a container using its logging driver; that is not equivalent to mapping a host TCP port to a container port.

Question 283

A container must have no configured external or local network interfaces aside from loopback. Which network option fits?

  1. Named container volume
  2. Host networking
  3. --network none
  4. Overlay network

Explanation

Correct Answer

C:

The none mode avoids attaching the container to a normal bridge or external network. It is useful for workloads that do not require networking.

Incorrect Answers

A:

A named volume has a lifecycle separate from an individual container and can be remounted by a replacement container; it answers a neighboring question rather than disabling ordinary container networking.

B:

Host network mode places the container's sockets in the host network namespace; that changes a different part of the system; the requested outcome is disabling ordinary container networking.

D:

Overlay networks encapsulate communication across multiple hosts in supported orchestrators; it will not provide disabling ordinary container networking under these conditions.

Question 284

A network-intensive container must share the host's network namespace rather than use a virtual port mapping. Which mode is appropriate?

  1. Host networking
  2. Bridge container network
  3. Named container volume
  4. --network none
  5. Bind mount of a host path

Explanation

Correct Answer

A:

Host network mode places the container's sockets in the host network namespace. It reduces network isolation and port conflicts need special consideration.

Incorrect Answers

B:

A bridge network connects containers on a host through a virtual Linux bridge; it does not deliver sharing the host network namespace, which is decisive in this scenario.

C:

A named volume has a lifecycle separate from an individual container and can be remounted by a replacement container; the evidence calls for sharing the host network namespace, not merely this separate operation.

D:

The none mode avoids attaching the container to a normal bridge or external network; the task involves sharing the host network namespace, whereas this addresses another subsystem.

E:

A bind mount exposes a specified host path inside the container; its scope differs from sharing the host network namespace, so it cannot meet the stated requirement.

Question 285

An image name app:stable must refer to an existing image digest without rebuilding its layers. Which command applies the additional name?

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

Explanation

Correct Answer

D:

docker tag creates another local image reference pointing at the same image. It does not alter the underlying layers.

Incorrect Answers

A:

docker build executes build instructions from the chosen context and records a tag for the resulting image; that is not equivalent to adding an alternate image reference.

B:

ENTRYPOINT sets the main executable while command arguments can be supplied separately; the administrator instead needs adding an alternate image reference; this option serves a different purpose.

C:

CMD supplies a default command or arguments for container startup and can be overridden at run time; it answers a neighboring question rather than adding an alternate image reference.

Question 286

A deployed container exits immediately; the engineer needs its stdout and stderr history. Which command is appropriate?

  1. docker inspect web01
  2. docker stop web01
  3. docker start web01
  4. docker logs web01
  5. docker rm test01
  6. docker exec -it web01 sh

Explanation

Correct Answer

D:

docker logs retrieves captured output streams for a container using its logging driver. It does not require the application process still to be running.

Incorrect Answers

A:

docker inspect produces structured JSON details including container mounts, network attachments and image references; it will not provide reading a container's recorded output under these conditions.

B:

docker stop signals the container process and waits before a forced termination timeout; using it would leave reading a container's recorded output unresolved.

C:

docker start restarts a previously created container without creating a new image or container definition; the requirement is reading a container's recorded output, outside the effect of this choice.

E:

docker rm removes the container object after it has stopped unless force is used; the evidence calls for reading a container's recorded output, not merely this separate operation.

F:

docker exec launches a new process in an already running container; the task involves reading a container's recorded output, whereas this addresses another subsystem.

Question 287

Container application data must survive replacement of an ephemeral container. Which storage type should be attached?

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

Explanation

Correct Answer

A:

A named volume has a lifecycle separate from an individual container and can be remounted by a replacement container. Files stored only in the writable container layer may disappear on removal.

Incorrect Answers

B:

A bind mount exposes a specified host path inside the container; its scope differs from persisting application state across container replacement, so it cannot meet the stated requirement.

C:

A bridge network connects containers on a host through a virtual Linux bridge; that is not equivalent to persisting application state across container replacement.

D:

The none mode avoids attaching the container to a normal bridge or external network; the administrator instead needs persisting application state across container replacement; this option serves a different purpose.

Question 288

A container image must be built from a chosen Ubuntu base and should use a non-root UID for its default process. Which TWO Dockerfile directives cover these distinct requirements? Choose TWO.

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

Explanation

Correct Answers

A:

The Dockerfile USER directive selects the default UID or username for subsequent build steps and the eventual container process. Combined with FROM, it permits an image to choose its base and avoid root as the default identity.

E:

FROM selects a base stage or image for Dockerfile instructions. Image pinning practices affect build reproducibility and security.

Incorrect Answers

B:

CMD supplies a default command or arguments for container startup and can be overridden at run time; this does not achieve selecting a Dockerfile base image and a default non-root user on the system described.

C:

docker tag creates another local image reference pointing at the same image; it will not provide selecting a Dockerfile base image and a default non-root user under these conditions.

D:

docker image prune removes dangling images by default, subject to prompts and filters; using it would leave selecting a Dockerfile base image and a default non-root user unresolved.

Question 289

Containers on different physical swarm nodes require an orchestrated virtual network. Which driver family supports this?

  1. --network none
  2. Host networking
  3. Overlay network
  4. Bridge container network

Explanation

Correct Answer

C:

Overlay networks encapsulate communication across multiple hosts in supported orchestrators. Their control plane and transport configuration require functioning inter-host networking.

Incorrect Answers

A:

The none mode avoids attaching the container to a normal bridge or external network; it does not deliver linking container networks across hosts, which is decisive in this scenario.

B:

Host network mode places the container's sockets in the host network namespace; the evidence calls for linking container networks across hosts, not merely this separate operation.

D:

A bridge network connects containers on a host through a virtual Linux bridge; its scope differs from linking container networks across hosts, so it cannot meet the stated requirement.

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.

CompTIA Linux+ (XK0-006) Practice Tests