Courseiva

CCNA Container Virtualization Questions

75 of 84 questions · Page 1/2 · Container Virtualization · Answers revealed

1
MCQmedium

A system administrator is troubleshooting a container that cannot resolve DNS names for other containers on the same user-defined Docker bridge network. The container's /etc/resolv.conf points to 127.0.0.11. Which Docker feature is responsible for providing this DNS resolution?

A.The Docker daemon's --dns flag
B.A DNS server running in a separate container
C.Docker's embedded DNS server
D.The host's systemd-resolved service
AnswerC

Docker runs an embedded DNS server for user-defined networks, which listens on 127.0.0.11 and resolves container names and aliases. It allows containers on the same network to communicate using their names. This server is automatically configured in the container's /etc/resolv.conf. It is the correct mechanism for service discovery within a user-defined bridge network.

Why this answer

Docker's embedded DNS server provides name resolution for containers on user-defined networks. It listens on 127.0.0.11 and resolves container names and aliases, enabling service discovery. This is automatically configured and does not require an external DNS server.

The host's resolver or a separate DNS container would not be used by default in this scenario.

Exam trap

The trap here is assuming that the host's DNS resolver or an external DNS server is used for container name resolution, overlooking Docker's built-in DNS for user-defined networks.

2
Multi-Selecthard

Which TWO of the following are true regarding the differences between rkt (Rocket) and Docker?

Select 2 answers
A.rkt only supported binary images
B.Docker is a sub-project of rkt
C.Docker never had a daemon
D.rkt utilized a daemonless architecture
E.rkt natively supported Kubernetes Pods
AnswersD, E

Rocket's daemonless design removes the long-running central daemon that Docker relied on, so containers launch directly via the rkt CLI without a persistent broker process. This satisfies the stem's architectural difference: no privileged daemon means a reduced attack surface and independent container lifecycle management.

Why this answer

Option D is correct because rkt was designed with a daemonless architecture, meaning containers were launched directly by the rkt CLI process without a long-running central daemon like Docker's dockerd. Option E is correct because rkt natively understood the concept of a Pod (a group of co-located containers sharing namespaces), which aligned with Kubernetes' Pod abstraction and allowed rkt to run Kubernetes Pods directly via its pod manifest support. Options A, B, and C are incorrect: rkt supported multiple image formats (including Docker images and ACI), Docker is not a sub-project of rkt (they are independent, competing container runtimes), and Docker has always relied on a daemon (dockerd) to manage containers.

Exam trap

The trap is mixing up which runtime had which feature — candidates often assume Docker was always daemonless or that rkt was Docker-based, but the exam tests the specific architectural contrast between the two.

3
MCQhard

In a FreeBSD Jail, how can you ensure the jail starts automatically at boot?

A.Set jail_enable=YES in /etc/rc.conf
B.Create a symlink in /etc/init.d
C.Use systemd
D.Add a cron job
AnswerA

Setting `jail_enable=YES` in `/etc/rc.conf` activates FreeBSD's `rc.d/jail` framework, which reads the `jail_list` variable and starts each named jail during the multi-user boot phase. This satisfies the stem's boot-persistence constraint directly, without requiring manual `jail` invocations or external schedulers.

Why this answer

On FreeBSD, the rc system reads /etc/rc.conf at boot, and setting `jail_enable="YES"` activates the jail subsystem so that jails defined in /etc/jail.conf (or jail_* variables) are started by the rc.d/jail script. Without this flag, jails must be started manually with `service jail start` or `jexec`.

Exam trap

The trap is assuming FreeBSD uses Linux-style init mechanisms (systemd, /etc/init.d), when in fact FreeBSD's rc.conf/rc.d system is entirely different and is the only correct answer.

How to eliminate wrong answers

Option B is wrong because /etc/init.d is a SysV-style init directory used on Linux distributions, not FreeBSD, which uses /etc/rc.d and rc.conf. Option C is wrong because systemd is a Linux init system and is not present on FreeBSD, which uses the BSD rc system. Option D is wrong because a cron job would only start the jail at a scheduled time, not at boot, and is not the idiomatic or reliable mechanism for boot-time jail startup.

4
MCQmedium

A Docker host runs a container with the default bridge network. The container needs to resolve external DNS names, but `docker exec mycontainer ping example.com` fails with 'unknown host'. The host itself resolves names correctly. Which Docker daemon configuration should you check first?

A.The `--iptables` flag in the Docker daemon configuration
B.The `--userland-proxy` setting in the Docker daemon
C.The `--dns` flag or `dns` setting in `/etc/docker/daemon.json`
D.The `--bridge` flag specifying a custom bridge interface
AnswerC

Containers on the default bridge receive DNS configuration from the Docker daemon unless overridden per container. If the daemon's `dns` setting points to an unreachable resolver, name resolution fails inside the container even though the host resolves fine. Checking `/etc/docker/daemon.json` for a `dns` entry or the `--dns` daemon flag is the correct first step.

Why this answer

Containers using the default bridge network inherit DNS resolver settings from the Docker daemon. When the host resolves names but the container does not, the daemon's DNS configuration is the prime suspect. Inspecting `/etc/docker/daemon.json` for a `dns` key or the daemon's `--dns` flag reveals whether an unreachable or incorrect resolver was injected into the container.

Exam trap

The trap here is assuming that a working host resolver automatically means the container uses the same resolver, when Docker may inject its own DNS settings.

5
MCQmedium

Which Docker network driver should you use if you want containers to have their own IP addresses on the physical network, as if they were physically connected to the network?

A.bridge
B.overlay
C.ipvlan
D.macvlan
AnswerD

macvlan assigns each container its own MAC and IP address on the parent interface, making it appear directly attached to the physical network. This satisfies the stem's requirement for containers to hold their own IPs on the physical network, unlike bridge, which uses NAT.

Why this answer

The macvlan driver assigns each container a unique MAC address and IP address on the physical network, making containers appear as physical devices to the network. This is exactly the behavior described — containers get their own IPs on the physical network.

Exam trap

The trap is confusing macvlan with ipvlan; candidates see 'own IP addresses' and pick ipvlan, but the key differentiator is that macvlan gives each container a unique MAC address on the physical network, while ipvlan shares the MAC.

How to eliminate wrong answers

Option A is wrong because the bridge driver creates an internal virtual network with NAT, so containers do not appear on the physical network with their own IPs. Option B is wrong because overlay is for multi-host container communication across hosts, not for direct physical network presence. Option C is wrong because ipvlan shares the parent interface's MAC address and is used for L2/L3 mode routing, not for giving each container a distinct MAC on the physical network.

6
MCQeasy

When building a Dockerfile, which instruction should be used to define the user context for subsequent RUN, CMD, and ENTRYPOINT instructions?

A.USER
B.WORKDIR
C.RUN useradd
D.AS
AnswerA

USER sets the runtime user for all subsequent RUN, CMD and ENTRYPOINT instructions in the Dockerfile, satisfying the stem's user-context constraint. It changes the UID/GID used during build and at container start, unlike WORKDIR, which only alters the working directory.

Why this answer

The USER instruction in a Dockerfile sets the user (and optionally group) that subsequent RUN, CMD, and ENTRYPOINT instructions will execute as. It changes the runtime identity inside the image for all following instructions and for the container's default process. This is the standard way to drop root privileges in a container image.

Exam trap

The trap is confusing USER with WORKDIR or with RUN useradd — candidates assume creating a user is enough, forgetting that only USER actually switches the execution identity for subsequent instructions.

How to eliminate wrong answers

Option B is wrong because WORKDIR sets the working directory for subsequent instructions, not the user identity. Option C is wrong because RUN useradd creates a user account but does not switch the execution context — you would still need a USER instruction afterward to actually run as that user. Option D is wrong because AS is used with multi-stage builds (FROM ...

AS name) to name a build stage, not to set a user context.

7
MCQhard

When configuring a systemd-nspawn container, what is the effect of the --private-network option?

A.It isolates the container's network from the host
B.It forces the container to use a bridge
C.It disables network encryption
D.It restricts access to localhost
E.It prevents the container from starting
AnswerA

--private-network gives the container its own isolated network namespace, separate from the host's interfaces and routing table. This satisfies the requirement to isolate container traffic, preventing direct host network access unless a virtual Ethernet link is explicitly configured.

Why this answer

The --private-network option in systemd-nspawn creates a new, isolated network namespace for the container. This means the container gets its own loopback interface and no external network interfaces, completely separating its network stack from the host's. As a result, the container cannot communicate with the host or external networks unless additional virtual interfaces are configured.

Exam trap

The trap here is confusing network isolation with network configuration; candidates might think --private-network sets up a bridge or restricts localhost access, but it simply creates an isolated network namespace.

How to eliminate wrong answers

Option B is wrong because --private-network does not force the use of a bridge; bridging requires explicit configuration such as --network-bridge=, and the option itself only isolates the network namespace. Option C is wrong because network encryption is not a feature of systemd-nspawn's networking options; the option has nothing to do with encryption. Option D is wrong because restricting access to localhost is not the purpose; the container gets its own loopback, but the option does not restrict host localhost access specifically.

Option E is wrong because the option does not prevent the container from starting; it simply configures an isolated network namespace.

8
MCQmedium

A Docker container running a web server is unable to serve traffic on port 8080. You verify the Dockerfile exposes port 80. What is the correct way to map this for external access?

A.docker run -p 80:8080
B.docker run -p 8080:80
C.docker run --net host
D.docker run --expose 8080
E.docker run -P 8080
AnswerB

The -p 8080:80 flag publishes host port 8080 to container port 80, where the web server actually listens per the Dockerfile. EXPOSE alone only documents the port; explicit publishing is required for external access, satisfying the stem's mapping requirement.

Why this answer

The -p flag syntax is HOST_PORT:CONTAINER_PORT. Since the web server inside the container listens on port 80 (per the Dockerfile EXPOSE), and you want it reachable on host port 8080, the correct mapping is -p 8080:80 — host 8080 forwards to container 80. Docker's userland proxy or iptables DNAT rules then translate incoming traffic on the host's 8080 to the container's 80.

Exam trap

305-300 often tests whether candidates reverse the -p HOST:CONTAINER order or confuse EXPOSE (metadata only) with -p (actual publishing), leading them to pick -p 80:8080 or --expose.

How to eliminate wrong answers

Option A is wrong because -p 80:8080 maps host port 80 to container port 8080, but the container's web server listens on 80, so traffic would hit a closed port inside the container. Option C is wrong because --net host removes network isolation entirely, making the container share the host's network namespace — the server would bind directly to host port 80, not 8080, and this bypasses port mapping rather than solving it. Option D is wrong because --expose only documents a port in metadata; it does not publish it to the host, so external access is still impossible.

Option E is wrong because -P (capital) publishes all EXPOSEd ports to random host ports and does not accept a port argument like '8080'.

9
MCQmedium

You are running a Docker container and need to map port 8080 on the host to port 80 in the container. Which command argument should you use?

A.-p 80:8080
B.-p 8080:80
C.--port 8080:80
D.--map 8080:80
AnswerB

Docker's -p flag takes host-port:container-port order, so -p 8080:80 publishes host port 8080 and forwards it to port 80 inside the container. Reversing the pair would map the ports the wrong way round, failing the stem's stated mapping.

Why this answer

The -p flag (short for --publish) maps a host port to a container port using the format -p HOST_PORT:CONTAINER_PORT. Since the requirement is to expose container port 80 on host port 8080, the correct syntax is -p 8080:80. Docker's port publishing always places the host port on the left of the colon and the container port on the right.

Exam trap

The trap here is the ordering of host and container ports — candidates frequently reverse them under time pressure, forgetting that the host port always comes first in the -p HOST:CONTAINER syntax.

How to eliminate wrong answers

Option A is wrong because -p 80:8080 reverses the mapping, publishing container port 8080 on host port 80, which is the opposite of what was requested. Option C is wrong because --port is not a valid Docker CLI flag; the long form is --publish, not --port. Option D is wrong because --map is not a Docker CLI flag at all — Docker uses -p/--publish for port mapping, not --map.

10
MCQmedium

Which Dockerfile instruction is used to copy a file from the host file system into the image?

A.RUN
B.ADD
C.PUSH
D.COPY
E.IMPORT
AnswerD

COPY transfers files or directories from the build context on the host into the image filesystem at the specified destination. Unlike ADD, it performs no URL fetching or archive extraction, making it the precise instruction for the stem's host-to-image copy requirement.

Why this answer

The COPY instruction copies files or directories from the build context (host) into the image filesystem. It is the preferred instruction for straightforward file copying because it does not perform any automatic extraction or remote URL fetching. COPY is explicit and predictable.

Exam trap

The trap is choosing ADD over COPY because ADD sounds more capable, but the exam expects COPY as the explicit, predictable instruction for copying files from the host into the image.

How to eliminate wrong answers

Option A (RUN) is wrong because RUN executes commands during build (e.g., apt-get install) and does not copy files from the host. Option B (ADD) is wrong because while ADD can copy files, it also auto-extracts local tar archives and can fetch remote URLs, making it less predictable; the question asks for the instruction used to copy a file, and COPY is the canonical answer. Option C (PUSH) is wrong because it is not a Dockerfile instruction; docker push uploads images to a registry.

Option E (IMPORT) is wrong because it is not a Dockerfile instruction; docker import creates an image from a tarball.

11
Multi-Selectmedium

Which THREE instructions in a Dockerfile can modify the image's filesystem?

Select 3 answers
A.ADD
B.ENV
C.EXPOSE
D.RUN
E.COPY
AnswersA, D, E

ADD copies files from a build context or remote URL into the image filesystem, creating a new layer that persists in the resulting image. This directly modifies image content, satisfying the question's requirement for instructions that change the filesystem, unlike metadata-only directives such as CMD or ENTRYPOINT.

Why this answer

ADD is correct because it copies files, directories, or remote URLs from the build context or a URL into the image filesystem, creating or modifying files in the resulting layer. RUN is correct because it executes a command in a new layer on top of the current image and commits the results, so commands like apt-get install or mkdir directly modify the image's filesystem. COPY is correct because it copies files or directories from the build context into the image filesystem, adding them as a new layer.

ENV is not correct because it only sets environment variables in the image metadata and does not alter any files. EXPOSE is not correct because it only documents the intended network port in image metadata and does not change the filesystem.

Exam trap

The trap is assuming metadata instructions like ENV or EXPOSE modify the filesystem — candidates must distinguish between instructions that create image layers (ADD, COPY, RUN) and those that only set metadata.

12
MCQmedium

You are using systemd-nspawn to run a container and need to allow it to use the host's network stack directly, without any network namespace isolation. Which option should you pass to systemd-nspawn?

A.Do not specify any network-related option.
B.`--private-network`
C.`--network-namespace=host`
D.`--network-interface=host0`
AnswerA

By default, systemd-nspawn does not create a separate network namespace, so the container shares the host's network stack. If you omit all network options such as `--private-network` or `--network-interface`, the container uses the host's interfaces and routing directly. This is the intended way to achieve host network sharing with systemd-nspawn.

Why this answer

systemd-nspawn creates a new network namespace only when a network-related option is given. Without any such option, the container inherits the host's network namespace and thus shares its network stack. Options like `--private-network` or `--network-interface` would introduce isolation or a dedicated interface, which is not what the scenario requires.

Exam trap

The trap here is assuming that a special flag is needed to share the host network namespace, when in fact it is the default behavior.

13
MCQmedium

You are configuring LXC and want to set a CPU limit for a container. Which cgroup parameter is used to specify the quota of CPU time in microseconds?

A.lxc.cgroup.cpu.limit
B.lxc.cgroup.cpu.cfs_quota_us
C.lxc.cgroup.cpu.shares
D.lxc.cgroup.cpu.period_us
AnswerB

`lxc.cgroup.cpu.cfs_quota_us` sets the CFS bandwidth quota in microseconds per period, directly satisfying the stem's requirement for a CPU-time quota. Unlike `cpu.shares`, which only weights relative contention, this parameter enforces an absolute ceiling on runtime, so the container cannot exceed its allotted CPU time.

Why this answer

The cgroup CPU controller exposes the CFS (Completely Fair Scheduler) bandwidth control parameters cpu.cfs_quota_us and cpu.cfs_period_us. In LXC, these are set via the lxc.cgroup.cpu.cfs_quota_us key, which specifies the maximum CPU time (in microseconds) the container's tasks may consume within each period defined by cpu.cfs_period_us. Setting cfs_quota_us to 50000 with the default period of 100000 us effectively caps the container at 50% of one CPU core.

Exam trap

The trap here is confusing cpu.shares (relative weight, default 1024) with cpu.cfs_quota_us (absolute microsecond quota) — candidates who only remember 'shares controls CPU' pick option C.

How to eliminate wrong answers

Option A is wrong because lxc.cgroup.cpu.limit is not a real cgroup or LXC parameter — there is no 'cpu.limit' file in the cgroup v1 CPU controller, so this key would be silently ignored or cause an error. Option C is wrong because lxc.cgroup.cpu.shares sets a relative weight (default 1024) used by the CFS scheduler for proportional sharing when the CPU is contended, not an absolute quota of CPU time. Option D is wrong because lxc.cgroup.cpu.period_us defines the length of the scheduling period (default 100000 us) over which the quota is enforced, not the quota itself.

14
Multi-Selecthard

Which THREE networking modes are natively supported by Docker?

Select 3 answers
A.bridge
B.gateway
C.tunnel
D.none
E.host
AnswersA, D, E

The bridge mode is Docker's default, creating a private internal network on the host and connecting containers to it through a virtual bridge interface. It is natively supported, making it one of the three networking modes the question requires.

Why this answer

Docker natively supports the bridge network driver (A), which creates a private internal network on the host and is the default mode for containers, allowing them to communicate via the docker0 virtual bridge. Docker also natively supports the none mode (D), which gives a container no network stack except a loopback interface, isolating it from all networking. The host mode (E) is natively supported as well, removing network isolation so the container shares the host's network namespace and IP stack directly.

The gateway (B) and tunnel (C) options are not Docker network drivers; gateway is a role or address concept rather than a mode, and tunnel describes overlay/VPN-style connectivity (e.g., Docker overlay or third-party plugins) rather than a native standalone Docker networking mode.

Exam trap

The trap is that 'gateway' and 'tunnel' sound like plausible network modes because they describe real networking concepts, but Docker's built-in driver list is specifically bridge, host, none, overlay, and macvlan — candidates who reason from general networking knowledge rather than Docker documentation pick the wrong options.

15
MCQeasy

You are using systemd-nspawn to run a container and want to ensure that the container's processes are isolated from the host's process tree. Which option should you use?

A.--private-users
B.--boot
C.Process isolation is enabled by default with PID namespaces; no additional option is needed.
D.--private-network
AnswerC

systemd-nspawn by default creates a PID namespace for the container, which isolates its processes from the host's process tree. Processes inside the container only see other processes in the same container, not those on the host. This is a fundamental isolation feature and does not require an extra flag. While other options like --private-users add user isolation, PID namespace isolation is always active unless explicitly disabled with --private-pid or similar, which is not the case here.

Why this answer

systemd-nspawn automatically sets up a PID namespace for each container, ensuring that processes inside the container are isolated from the host's process tree. This means container processes cannot see or interact with host processes, and vice versa. No additional option is needed to achieve this basic level of process isolation.

Other options like --private-users add user namespace isolation, but process isolation is a default behavior. Therefore, the correct answer is that no extra option is required.

Exam trap

The trap here is assuming that a specific flag is needed for process isolation, when in fact systemd-nspawn enables PID namespaces by default.

16
Multi-Selecthard

Which THREE features are provided by Linux Namespaces in the context of containers?

Select 3 answers
A.CPU scheduling
B.Disk quotas
C.PID isolation
D.Network isolation
E.Mount isolation
AnswersC, D, E

PID namespaces give each container its own process ID numbering, so processes inside see themselves starting at PID 1 and cannot observe or signal host processes. This delivers the process isolation the question asks for, preventing cross-container visibility of the host process tree.

Why this answer

Linux namespaces provide PID isolation (C), giving each container its own process ID tree so processes inside see their own PID 1 and cannot see host processes. Network isolation (D) is provided by the network namespace, which gives a container its own network interfaces, routing tables, and ports. Mount isolation (E) is provided by the mount namespace, allowing each container its own filesystem mount points independent of the host.

CPU scheduling (A) is handled by cgroups (cpu/cpuacct controllers), not namespaces, and disk quotas (B) are managed via filesystem quotas or cgroup blkio limits, not namespaces.

Exam trap

The trap is confusing namespaces (isolation) with cgroups (resource limiting), leading candidates to select CPU scheduling or disk quotas.

17
MCQeasy

What does the 'docker rm' command do?

A.Renames a container
B.Stops a container
C.Removes an image
D.Removes a container
AnswerD

'docker rm' deletes a stopped container from the local Docker host, removing its writable layer and metadata. It does not touch images, volumes, or running containers unless forced with -f, distinguishing it from 'docker rmi', which removes images.

Why this answer

docker rm removes one or more containers from the host, deleting their writable layer and metadata. It does not touch images, does not stop running containers unless -f is used, and does not rename anything. This is the counterpart to docker rmi, which removes images.

Exam trap

The trap is confusing docker rm (remove container) with docker rmi (remove image) — the similar names cause candidates to pick 'Removes an image' incorrectly.

How to eliminate wrong answers

Option A (Renames a container) is wrong because renaming is done with docker rename, not docker rm. Option B (Stops a container) is wrong because stopping is done with docker stop (or docker kill); docker rm only removes containers and will refuse to remove a running one without -f. Option C (Removes an image) is wrong because image removal uses docker rmi (or docker image rm); docker rm operates on containers, not images.

18
MCQmedium

A Docker container is failing to connect to an external database despite the host being able to ping it. You suspect a bridge networking issue. Which command allows you to inspect the current NAT rules created by Docker?

A.docker network inspect bridge
B.iptables -t nat -L -n
C.ip link show docker0
D.sysctl -a | grep net.bridge
AnswerB

Docker adds rules to the NAT table for port forwarding and masquerading.

Why this answer

The correct command is `iptables -t nat -L -n` because Docker uses iptables NAT rules to perform outbound masquerading for containers on bridge networks. When a container sends traffic to an external database, the packet is SNAT'd to the host's IP via rules in the nat table's POSTROUTING chain. Inspecting this table reveals whether Docker's MASQUERADE rule is present and correctly configured, which is essential for diagnosing connectivity failures.

Exam trap

The trap here is confusing network inspection commands (like `docker network inspect`) with packet-level NAT rule inspection; candidates often assume Docker's network inspect shows all networking details, but it does not reveal iptables NAT rules.

How to eliminate wrong answers

Option A is wrong because `docker network inspect bridge` only shows the bridge network's configuration (subnet, gateway, connected containers) but does not display the underlying iptables NAT rules that handle address translation. Option C is wrong because `ip link show docker0` only verifies the existence and state of the docker0 bridge interface, not the NAT rules that govern outbound traffic. Option D is wrong because `sysctl -a | grep net.bridge` lists kernel parameters related to bridge behavior (e.g., bridge-nf-call-iptables) but does not show the actual NAT rules created by Docker.

19
MCQmedium

Which file is primarily responsible for defining the configuration and environment variables for an OpenVZ container?

A./etc/openvz/config
B./var/lib/vz/config
C./etc/vz/container.conf
D./etc/vz/vz.conf
E./etc/vz/conf/CTID.conf
AnswerE

/etc/vz/conf/CTID.conf holds each OpenVZ container's configuration, including environment variables and resource limits, with CTID replaced by the container's numeric ID. This satisfies the stem's requirement for the file defining configuration and environment variables, since OpenVZ reads per-container settings from this path rather than a global file.

Why this answer

OpenVZ stores per-container configuration files in /etc/vz/conf/ using the container ID (CTID) as the filename, e.g., /etc/vz/conf/101.conf. This file defines resource limits, network settings, and environment variables for that specific container. The global OpenVZ configuration is in /etc/vz/vz.conf, but per-container settings live in the CTID.conf file.

Exam trap

The trap is confusing the global OpenVZ configuration file (/etc/vz/vz.conf) with the per-container configuration file (/etc/vz/conf/CTID.conf), or selecting plausible but nonexistent paths like /etc/openvz/config.

How to eliminate wrong answers

Option A is wrong because /etc/openvz/config is not a standard OpenVZ path; OpenVZ uses /etc/vz/. Option B is wrong because /var/lib/vz/config is not the per-container config location; /var/lib/vz is used by Proxmox for storage, not OpenVZ container configs. Option C is wrong because /etc/vz/container.conf is not a real file; the global config is vz.conf.

Option D is wrong because /etc/vz/vz.conf is the global OpenVZ configuration file, not the per-container one.

20
MCQhard

You are using systemd-nspawn. How do you create an image of a container to be used as a template?

A.tar -cvf
B.docker export
C.lxc-copy
D.machinectl export-tar
AnswerD

Using `machinectl export-tar` streams a running or stopped container's entire filesystem into a tar archive, which can later be imported as a template. This satisfies the stem's requirement to create a reusable image from a systemd-nspawn container, since nspawn containers are managed as machines via machinectl rather than Docker-style commits.

Why this answer

machinectl export-tar is the systemd-nspawn command that exports a running or stopped container's filesystem as a tar archive, which can then be imported as a template image. It is part of the systemd-machined toolset and is the native way to snapshot an nspawn container for reuse.

Exam trap

The trap is mixing up container tooling ecosystems — candidates pick docker export or lxc-copy because they recognize 'export' or 'copy', forgetting that systemd-nspawn uses machinectl exclusively.

How to eliminate wrong answers

Option A is wrong because tar -cvf only creates a generic archive of files — it does not understand nspawn container metadata or produce a machinectl-importable image. Option B is wrong because docker export is a Docker-specific command and has no relationship to systemd-nspawn containers. Option C is wrong because lxc-copy is an LXC/LXD tool, not part of the systemd-nspawn ecosystem.

21
MCQmedium

What is the primary function of a Docker Registry?

A.To store and distribute images
B.To build images
C.To run containers
D.To manage networking
AnswerA

A registry acts as the central repository that stores versioned container images and serves them to hosts on request, satisfying the need to persist and distribute artefacts. It is not a build tool or runtime; its function is storage plus retrieval over the network, enabling consistent image pulls across environments.

Why this answer

A Docker Registry is a stateless, server-side application that stores and distributes Docker images, acting as the central repository for pushing and pulling image layers. Tools like `docker push` and `docker pull` communicate with the registry's HTTP API (typically on port 5000 or 443) to upload or retrieve images. Docker Hub, Amazon ECR, and Harbor are all examples of registries.

Exam trap

The trap here is confusing the registry (stores/distributes images) with the Docker daemon or engine (builds and runs containers), since both are 'Docker' components and candidates often conflate their roles.

How to eliminate wrong answers

Option B is wrong because building images is the job of the Docker client/daemon via `docker build` and a Dockerfile, not the registry. Option C is wrong because running containers is performed by the Docker Engine (containerd/runc) on a host, not by the registry. Option D is wrong because networking (bridge, overlay, host drivers) is managed by the Docker daemon and CNI plugins, not by a registry.

22
Multi-Selecthard

You are configuring a rootless Podman container that must persist data across container restarts and also needs to communicate with other containers on the same host using a user-defined network. Which two actions must you perform to achieve these goals? (Choose two.)

Select 2 answers
A.Use a bind mount to a host directory and set the --userns=host flag to avoid permission issues.
B.Add the --ipc=host flag to allow containers to share memory and communicate.
C.Run the container with the --privileged flag to allow volume mounting and network access.
D.Create a user-defined network with podman network create and attach the container to it.
E.Create a named volume with podman volume create and mount it into the container.
AnswersD, E

User-defined networks in Podman allow containers to communicate with each other by name via an embedded DNS server. Creating a network with podman network create and then running the container with --network <name> enables inter-container communication. This is necessary because the default network may not provide name resolution or isolation. It fulfills the requirement for communication between containers on the same host.

Why this answer

To persist data across restarts in rootless Podman, a named volume created with podman volume create and mounted into the container is the correct approach. For containers to communicate by name on the same host, a user-defined network created with podman network create and attached to the container is required. The other options either introduce unnecessary privileges or do not address both requirements.

Exam trap

The trap here is thinking that running a container with --privileged or sharing the host IPC namespace is necessary for volume persistence and inter-container networking, when these features work without such broad privileges.

23
MCQhard

You are troubleshooting a Docker container that fails to start with the error message: 'Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error mounting /proc: no such file or directory'. The host is running a recent Linux kernel and Docker is using the default runtime. What is the most likely cause?

A.The Docker daemon is not running with the correct seccomp profile.
B.The container's root filesystem is missing the /proc directory.
C.The host's /proc filesystem is not mounted or is inaccessible.
D.The container image is corrupted and needs to be pulled again.
AnswerB

During container initialization, runc attempts to mount a new proc filesystem at /proc inside the container's root filesystem. If the /proc directory does not exist in the container image, the mount call fails with 'no such file or directory'. This is a common issue when building minimal images from scratch without creating the standard directories. The solution is to ensure the image includes an empty /proc directory.

Why this answer

The error occurs because runc tries to mount a new proc filesystem at /proc inside the container, but the target directory does not exist in the container's root filesystem. Minimal images built from scratch often lack standard directories like /proc, /sys, and /dev. Creating these directories in the Dockerfile resolves the issue.

The other options do not match the specific error message about a missing file or directory during mount.

Exam trap

The trap here is focusing on the host or daemon configuration when the error actually points to a missing directory inside the container image itself.

24
Multi-Selectmedium

You are configuring an LXC container and need to limit its CPU and memory usage. Which TWO of the following configuration options in the container's config file are valid for this purpose? (Choose two.)

Select 2 answers
A.lxc.cgroup2.cpu.max = 50000 100000
B.lxc.cgroup2.cpuset.cpus = 0-1
C.lxc.cgroup2.memory.max = 512M
D.lxc.memory.limit = 1G
E.lxc.cpu.limit = 2
AnswersA, C

This option sets a CPU bandwidth limit using cgroup v2. The values represent quota and period in microseconds, so 50000 100000 means the container can use 50% of one CPU core. It is a valid and current way to restrict CPU usage in LXC when using cgroup v2, which is the default on modern systems.

Why this answer

LXC uses cgroup v2 settings to enforce resource limits. The options lxc.cgroup2.cpu.max and lxc.cgroup2.memory.max are valid and directly limit CPU bandwidth and memory usage, respectively. The other options either use non-existent configuration keys or, in the case of cpuset.cpus, control CPU affinity rather than usage limits.

Thus, only the cgroup2-based limits achieve the goal.

Exam trap

The trap here is assuming that any configuration key containing 'cpu' or 'memory' will work, when in fact LXC requires specific cgroup2-prefixed keys for resource limiting.

25
MCQmedium

When using 'docker-compose', which file format is used to define the services?

A.YAML
B.INI
C.XML
D.JSON
AnswerA

Compose's declarative service definitions rely on YAML's indentation-based mapping, which expresses nested services, images and volumes without the verbosity of JSON or XML. The stem asks which format defines services, and Compose reads docker-compose.yml as YAML by default.

Why this answer

Docker Compose uses YAML (Yet Another Markup Language / YAML Ain't Markup Language) files, conventionally named docker-compose.yml or compose.yaml, to define services, networks, volumes, and build contexts. YAML's indentation-based structure maps cleanly to Compose's nested service definitions. INI, XML, and JSON are not supported by Compose for its primary configuration file.

Exam trap

The trap is that YAML is technically a JSON superset, so candidates who know JSON is valid YAML may pick JSON — but the exam asks for Compose's defined file format, which is YAML.

How to eliminate wrong answers

Option B (INI) is wrong because INI's flat section/key format cannot express the nested lists and maps Compose requires (e.g., multiple ports, environment arrays, depends_on). Option C (XML) is wrong because Compose has never used XML; XML's verbosity and lack of native list semantics make it unsuitable for the Compose schema. Option D (JSON) is wrong because although YAML is a superset of JSON and some tools accept JSON, Docker Compose's documented and canonical format is YAML — JSON is not the file format used.

26
MCQmedium

When using Docker volumes, which type of mount should you use if you want the data to persist on the host filesystem at a specific, user-defined path?

A.Named volume
B.Anonymous volume
C.Bind mount
D.Tmpfs mount
AnswerC

A bind mount maps a specific host directory path, chosen by the user, into the container, so data written there persists on the host filesystem at that exact location. Named volumes persist too, but Docker manages their path rather than the user defining it.

Why this answer

A bind mount maps a specific host directory or file path directly into the container, giving the user full control over the exact host location where data persists. This is the correct choice when the requirement is a user-defined, specific host path, because named and anonymous volumes are managed by Docker in its own storage area (/var/lib/docker/volumes) and do not let you choose an arbitrary host path. Bind mounts are the only Docker volume type that satisfies the 'specific, user-defined path' requirement.

Exam trap

The trap is assuming 'persistent' automatically means 'named volume' — candidates overlook that the question specifies a user-defined host path, which only bind mounts provide, since named volumes use Docker-managed paths.

How to eliminate wrong answers

Option A is wrong because named volumes are stored in Docker's managed volume directory and referenced by name; while persistent, the host path is chosen by Docker, not the user. Option B is wrong because anonymous volumes are also Docker-managed and get random hashed names, offering no control over host location and being harder to reference. Option D is wrong because tmpfs mounts store data in memory only and are lost on container stop, so they cannot provide host filesystem persistence at all.

27
MCQhard

You are troubleshooting a container networking issue. You notice that traffic from the container is not being SNATed. What should you check in the iptables rules?

A.nat table, PREROUTING chain
B.nat table, POSTROUTING chain
C.filter table, FORWARD chain
D.mangle table, OUTPUT chain
AnswerB

Source NAT for outbound container traffic is performed in the nat table's POSTROUTING chain, where MASQUERADE or SNAT rules rewrite the source address after routing. Inspecting this chain reveals whether the SNAT rule is present, correctly matched, or bypassed by an earlier rule.

Why this answer

SNAT (Source NAT) is performed in the nat table's POSTROUTING chain, which is traversed after the routing decision and just before the packet leaves the interface. If container traffic is not being SNATed, the POSTROUTING chain in the nat table is where the MASQUERADE or SNAT rule should exist. Checking this chain will reveal whether the rule is missing, misordered, or not matching the container's source subnet.

Exam trap

The trap is confusing DNAT (PREROUTING) with SNAT (POSTROUTING); candidates often pick PREROUTING because it is the first nat chain they think of.

How to eliminate wrong answers

Option A is wrong because the nat table's PREROUTING chain handles DNAT (destination NAT), such as port forwarding to containers, not SNAT. Option C is wrong because the filter table's FORWARD chain controls whether packets are allowed to be routed between interfaces, not whether their source address is translated. Option D is wrong because the mangle table's OUTPUT chain is used for packet header alteration (e.g., TOS, TTL) for locally generated packets, not for SNAT of forwarded container traffic.

28
MCQeasy

Which command is used to remove an unused Docker image?

A.docker rm
B.docker image delete
C.docker prune image
D.docker rmi
AnswerD

docker rmi removes images from the local image store, deleting tagged references and, with -f, dependent layers. It is the dedicated image-removal command, directly satisfying the stem's requirement to delete an unused image rather than containers or volumes.

Why this answer

The docker rmi command removes one or more Docker images from the local image store. 'rmi' stands for 'remove image' and accepts image names or IDs. This is the direct counterpart to docker rm, which removes containers.

Exam trap

The trap is confusing docker rm (containers) with docker rmi (images), and inventing plausible but non-existent subcommands like docker image delete or docker prune image.

How to eliminate wrong answers

Option A (docker rm) is wrong because it removes containers, not images. Option B (docker image delete) is wrong because 'delete' is not a valid Docker CLI subcommand; the correct form is docker image rm or docker rmi. Option C (docker prune image) is wrong because the correct syntax is docker image prune (or docker system prune), which removes dangling images, not a specific unused image by name.

29
Multi-Selectmedium

Which TWO of the following are valid container orchestration platforms?

Select 2 answers
A.Nginx
B.Kubernetes
C.Docker Desktop
D.Nomad
E.GitLab
AnswersB, D

Kubernetes satisfies the orchestration requirement by automating container deployment, scaling and management across clusters. It provides declarative configuration, self-healing, service discovery and load balancing, which are the defining capabilities the question demands. Unlike standalone runtimes such as Docker Engine, Kubernetes coordinates workloads across multiple hosts, making it a valid orchestration platform.

Why this answer

Kubernetes (B) is a valid container orchestration platform because it schedules and manages containers across a cluster of nodes, handling deployment, scaling, service discovery, and self-healing via components like the kube-apiserver, kubelet, and etcd. Nomad (D) is also a valid orchestration platform, as HashiCorp Nomad schedules and runs containerized and non-containerized workloads across a cluster using job specifications and drivers such as Docker. Nginx (A) is a web server and reverse proxy, not an orchestrator, though it can act as an ingress/load balancer in front of orchestrated workloads.

Docker Desktop (C) is a local development environment for building and running containers on a single machine, not a cluster orchestration platform. GitLab (E) is a DevOps/CI-CD platform and Git repository manager, not a container orchestrator, even though it can integrate with Kubernetes.

Exam trap

The trap here is confusing container-related tools (Docker Desktop, Nginx, GitLab) with true orchestration platforms that schedule and manage containers across multiple nodes.

30
Multi-Selectmedium

Which TWO commands are used to manage images in Docker?

Select 2 answers
A.docker tag
B.docker run
C.docker create
D.docker attach
E.docker build
AnswersA, E

docker tag assigns an additional repository name and tag to an existing local image, creating a new reference without rebuilding layers. This is an image-management operation, satisfying the stem's requirement for commands that manage images rather than containers or networks.

Why this answer

docker tag (A) is correct because it manages images by creating a new reference/tag pointing to an existing image (docker tag SOURCE_IMAGE[:TAG] TARGET_IMAGE[:TAG]), which is an image-level operation. docker build (E) is correct because it manages images by constructing a new image from a Dockerfile and build context, producing an image stored in the local image cache. The other options operate on containers rather than images: docker run (B) creates and starts a container from an image, docker create (C) creates a container without starting it, and docker attach (D) attaches the local standard input/output/error streams to a running container's process.

Exam trap

305-300 often tests the boundary between image-level and container-level commands, so candidates pick docker run or docker create because they think of them as the most common Docker commands rather than checking whether they act on images.

31
Multi-Selecthard

Which THREE storage drivers are supported by Docker?

Select 3 answers
A.devicemapper
B.xfs
C.aufs
D.ext4
E.overlay2
AnswersA, C, E

devicemapper is a Docker storage driver using thin provisioning on block devices via the kernel's device-mapper framework, controlling layers through snapshots. It satisfies the stem by being one of the drivers Docker documents and supports for managing image and container layers.

Why this answer

Docker supports the devicemapper storage driver (A), which uses the Device Mapper kernel framework and thin provisioning to manage image and container layers on block devices. It also supports aufs (C), the original copy-on-write union filesystem driver used on older Ubuntu/Debian kernels. The overlay2 driver (E) is the modern, preferred Docker storage driver, using the OverlayFS union filesystem with multiple lower layers for better performance and inode efficiency.

Options B (xfs) and D (ext4) are not storage drivers but rather filesystem types; they can serve as the backing filesystem for drivers like overlay2 or devicemapper, but Docker does not use them as storage drivers themselves.

Exam trap

305-300 often tests the confusion between filesystems (ext4, XFS, btrfs) and Docker storage drivers (overlay2, devicemapper, aufs) — candidates must recognize that filesystems are the substrate, not the driver.

32
MCQeasy

What is the main advantage of using a container over a virtual machine?

A.Ability to run different kernels
B.Stronger security isolation
C.No network configuration
D.Lighter weight and faster startup
AnswerD

Containers share the host kernel and isolate processes via namespaces and cgroups, avoiding the full guest operating system a virtual machine must boot. This architectural difference yields smaller images and startup in seconds rather than the minutes a hypervisor-based VM typically needs.

Why this answer

Containers share the host OS kernel and only package the application and its dependencies, so they avoid the overhead of booting a full guest OS. This makes them significantly lighter in resource usage and faster to start (often milliseconds to seconds) compared to virtual machines, which must boot an entire OS per instance.

Exam trap

The trap is assuming containers provide stronger security isolation than VMs — candidates conflate 'lightweight' with 'more secure', when in fact the shared kernel makes containers less isolated, and the correct advantage is weight and startup speed.

How to eliminate wrong answers

Option A is wrong because containers share the host kernel and cannot run a different kernel — that is a capability of virtual machines with their own guest kernels. Option B is wrong because VMs provide stronger isolation via hardware virtualization and separate kernels, while containers share the kernel and have a weaker isolation boundary. Option C is wrong because containers absolutely require network configuration (bridge, overlay, macvlan, host modes) — they do not eliminate networking.

33
MCQmedium

You need to inspect the metadata of a specific Docker image without pulling it from a remote registry. Which command should you use?

A.docker pull --metadata
B.docker image history
C.docker manifest inspect
D.docker image inspect
AnswerC

docker manifest inspect queries the registry API directly, returning the image's manifest, layers, platform variants and digests without downloading layer blobs to the local daemon. That satisfies the stem's constraint of inspecting metadata without pulling the image.

Why this answer

'docker manifest inspect' queries the registry's manifest API directly and returns metadata such as platform variants, digests, and layer information without downloading the image layers. It is the correct tool for inspecting a remote image's metadata without pulling it.

Exam trap

305-300 often tests the confusion between local image inspection commands ('docker image inspect', 'docker image history') and remote registry inspection ('docker manifest inspect'), catching candidates who forget that local commands require a prior pull.

How to eliminate wrong answers

Option A is wrong because 'docker pull --metadata' is not a valid Docker CLI flag — 'docker pull' downloads the image and has no metadata-only mode. Option B is wrong because 'docker image history' shows the layer history of an image already present in the local daemon, requiring a prior pull. Option D is wrong because 'docker image inspect' inspects a local image in the daemon, not a remote registry image, so it also requires the image to be pulled first.

34
MCQmedium

You are debugging a Docker image buildup that fails at the 'RUN' instruction due to missing network access during the build. What command option should be checked if the build environment uses a proxy?

A.--proxy
B.--build-arg
C.--privileged
D.--network=host
E.--env-file
AnswerB

Docker passes proxy settings into the build through --build-arg, which injects values such as HTTP_PROXY as environment variables available to RUN instructions. Without it, the build container cannot reach external repositories, so the RUN step fails despite valid host network access.

Why this answer

Docker's build-time proxy configuration is passed via --build-arg with the predefined HTTP_PROXY, HTTPS_PROXY, and NO_PROXY arguments, which Docker automatically recognizes and injects into the build environment. The --proxy flag does not exist in docker build, so --build-arg is the correct mechanism for supplying proxy settings when RUN instructions need network access.

Exam trap

The trap is assuming Docker has a dedicated --proxy flag analogous to other tools — candidates who have not memorized Docker's build-arg conventions pick it, but Docker deliberately reuses build arguments for proxy configuration.

How to eliminate wrong answers

Option A is wrong because --proxy is not a valid docker build option — Docker uses build arguments for proxy injection, not a dedicated proxy flag. Option C is wrong because --privileged grants the container elevated kernel capabilities and is unrelated to proxy or network configuration. Option D is wrong because --network=host changes the container's network namespace to share the host's, which does not supply proxy environment variables and is not the standard fix for proxy-restricted builds.

Option E is wrong because --env-file sets runtime environment variables for docker run, not build-time variables for docker build.

35
MCQmedium

You are using BSD Jails and need to start a jail. Which utility is the standard management tool for jail administration?

A.jexec
B.jail
C.jails-admin
D.jail-manage
E.jls
AnswerB

The jail utility is FreeBSD's standard administrative command for creating, starting, stopping and listing jails. Running 'jail' with a configuration or parameters starts the jail and executes its command, directly fulfilling the requirement to start a jail.

Why this answer

The jail utility is the standard FreeBSD command for creating, starting, and managing jails. Running jail with parameters such as path, hostname, and command starts a new jail. It is the foundational management tool, complemented by jexec for entering a running jail and jls for listing jails.

Exam trap

The trap is confusing jexec (enter a jail) and jls (list jails) with the jail command itself, or selecting fabricated utilities like jails-admin or jail-manage.

How to eliminate wrong answers

Option A (jexec) is wrong because it is used to execute a command inside an already-running jail, not to start one. Option C (jails-admin) is wrong because no such standard utility exists in FreeBSD. Option D (jail-manage) is wrong because it is not a real FreeBSD command.

Option E (jls) is wrong because it lists active jails and their parameters, but does not start them.

36
Multi-Selecthard

Which THREE items are typically included in an OpenVZ configuration file?

Select 3 answers
A.BIOS settings
B.User Beancounters (resource limits)
C.OS template reference
D.Networking parameters
E.Kernel source code
AnswersB, C, D

User Beancounters are per-container resource limits enforced by the OpenVZ kernel, controlling CPU, memory and disk quotas. They appear in the container's configuration file alongside other parameters, satisfying the requirement for a typical OpenVZ configuration item.

Why this answer

In an OpenVZ container configuration file (typically /etc/vz/conf/<CTID>.conf), User Beancounters (option B) are included as resource limits such as kmemsize, privvmpages, and numproc, which control how much memory, processes, and other resources the container may consume. The OS template reference (option C) is also included, usually via the OSTEMPLATE parameter, which records which OS template (e.g., centos-7-x86_64) was used to create the container and is needed for operations like reinstalling or rebuilding it. Networking parameters (option D) are included as well, with entries such as IP_ADDRESS, HOSTNAME, and NETIF to define the container's IP addressing and virtual network interface.

BIOS settings (option A) are not part of an OpenVZ configuration file because OpenVZ containers are OS-level virtualizations that share the host kernel and do not have their own BIOS or firmware. Kernel source code (option E) is likewise not included, since containers use the host's kernel and the configuration file only stores container-specific runtime and resource parameters, not kernel source.

Exam trap

The trap is including host-level or kernel-level items (BIOS, kernel source) as container configuration components — candidates must remember that OpenVZ containers are isolated userspace environments sharing the host kernel.

37
MCQhard

You are troubleshooting a Docker container that fails to start with the error 'no space left on device' even though `df -h` shows ample free space on the host's root filesystem. The Docker data root is on a separate partition. Which command should you use to check the actual disk usage of Docker's data root?

A.`docker system df -v`
B.`docker events`
C.`docker stats`
D.`docker info`
AnswerA

`docker system df -v` shows detailed disk usage of images, containers, volumes, and build cache, including which items consume space. Since the Docker data root is on a separate partition, `df -h` on the host root may not reflect it. This command reveals the actual consumption within Docker's storage area, helping identify the cause of the 'no space left' error.

Why this answer

`docker system df -v` reports detailed disk usage for images, containers, volumes, and build cache. When the Docker data root resides on a separate partition, the host's `df` may show free space elsewhere. This command exposes the actual consumption within Docker's storage, allowing you to identify whether images, volumes, or cache are filling the partition.

Exam trap

The trap here is relying on host-level `df` output and overlooking that Docker's data root may be on a different filesystem with its own capacity limits.

38
MCQhard

An administrator needs to run a container that requires access to a specific block device on the host, such as /dev/sdb, for direct I/O operations. Which Docker run option should be used to grant the container access to this device?

A.--privileged
B.--device /dev/sdb
C.-v /dev/sdb:/dev/sdb
D.--cap-add SYS_RAWIO
AnswerB

The --device flag allows passing a host device into the container, making it accessible as /dev/sdb inside the container. This grants direct access to the block device, enabling I/O operations. It is the correct way to expose specific devices without using privileged mode. Other options do not provide device access.

Why this answer

The --device option is designed to expose a specific host device to a container while properly configuring device cgroup permissions. It allows the container to perform I/O on that device. Other options like --privileged grant broad access, volume mounts do not set permissions, and capabilities alone do not bypass device cgroup restrictions.

Exam trap

The trap here is thinking that mounting a device node as a volume or adding a capability is sufficient for device access, ignoring the need for device cgroup configuration.

39
MCQhard

In a Docker swarm, which mode of service publishing allows incoming traffic to be load-balanced across all healthy container replicas?

A.macvlan
B.ingress
C.overlay
D.host
AnswerB

Ingress mode publishes a service on the swarm's routing mesh, so every node accepts traffic on the published port and forwards it to healthy replicas regardless of placement. This provides the load-balancing across all healthy container replicas that the scenario requires.

Why this answer

In Docker Swarm, the ingress mode publishes a service on the routing mesh, so the port is exposed on every swarm node and incoming traffic is load-balanced across all healthy replicas of the service. This is the default publishing mode and is what enables any node to accept traffic for a service regardless of where its tasks run.

Exam trap

The trap is confusing the overlay network driver (which carries container-to-container traffic) with the ingress publishing mode (which load-balances external traffic) — candidates pick overlay thinking it handles load balancing, when it only provides the network fabric.

How to eliminate wrong answers

Option A is wrong because macvlan is a network driver that gives containers their own MAC addresses on the physical network, not a swarm service publishing mode for load balancing. Option C is wrong because overlay is the network driver that enables cross-host container communication in a swarm, not the publishing mode that load-balances ingress traffic. Option D is wrong because host mode publishes the port directly on the node running the task, bypassing the routing mesh and preventing swarm-wide load balancing.

40
MCQeasy

Which command lists all Docker images currently on the host?

A.docker ps
B.docker show
C.docker images
D.docker list
AnswerC

The docker images command queries the local image cache and returns every stored image with repository, tag, image ID, creation time and size. It requires no running container and reads directly from the host's Docker daemon, satisfying the stem's request to list images on the host.

Why this answer

'docker images' queries the local image store and lists all images present on the host, showing repository, tag, image ID, creation time, and size. It is the canonical command for inspecting locally cached images before running or removing them.

Exam trap

The trap is mixing up the container-listing command ('docker ps') with the image-listing command ('docker images') — both are common, and candidates under time pressure may pick 'ps' because it is the first Docker command they memorized.

How to eliminate wrong answers

Option A is wrong because 'docker ps' lists running containers (and with -a, all containers), not images — it queries the container runtime state, not the image store. Option B is wrong because 'docker show' is not a valid Docker subcommand; there is no such verb in the Docker CLI. Option D is wrong because 'docker list' is also not a valid subcommand — the correct verbs are 'images' for images and 'ps' for containers.

41
MCQhard

When cleaning up Docker resources, which command will remove all stopped containers, unused networks, and dangling images in one step?

A.docker container prune
B.docker volume prune
C.docker image prune -a
D.docker cleanup
E.docker system prune
AnswerE

docker system prune removes stopped containers, unused networks and dangling images in a single invocation, matching the requirement to clean these resources in one step. Adding -a extends it to all unused images, but the base command already covers the three specified categories.

Why this answer

docker system prune removes all stopped containers, unused networks, dangling images, and (with -a) unused images in a single command. It is the one-step cleanup command that consolidates what would otherwise require separate container prune, network prune, and image prune invocations.

Exam trap

The trap is that candidates may pick a narrower prune command (container, image, or volume) when the question explicitly asks for a single command that handles containers, networks, and images together — only docker system prune does all three.

How to eliminate wrong answers

Option A is wrong because docker container prune removes only stopped containers, leaving networks and images untouched. Option B is wrong because docker volume prune removes only unused volumes, not containers or images. Option C is wrong because docker image prune -a removes unused images only, not containers or networks.

Option D is wrong because 'docker cleanup' is not a valid Docker subcommand.

42
MCQeasy

Which Docker command is used to display the resource usage (CPU, memory) of running containers?

A.docker stats
B.docker top
C.docker usage
D.docker info
AnswerA

docker stats streams live CPU, memory, network and block I/O metrics for each running container, refreshed continuously. This directly satisfies the requirement to display resource usage of running containers, unlike docker ps, which only lists containers without consumption figures.

Why this answer

`docker stats` is the dedicated Docker CLI subcommand that streams live resource-usage metrics for running containers, including CPU percentage, memory usage/limit, memory percentage, network I/O, block I/O, and PIDs. It reads these values from the cgroup statistics exposed by the container runtime, so it reflects actual kernel-level accounting rather than estimates. By default it shows all running containers and refreshes continuously until you press Ctrl+C.

Exam trap

The trap here is confusing `docker top` (process listing) with `docker stats` (resource metrics), since both sound like they show 'what's running' — candidates must remember that only `stats` reports CPU and memory.

How to eliminate wrong answers

Option B is wrong because `docker top` only displays the running processes inside a container (equivalent to a `ps` listing for that container's PID namespace) and reports no CPU or memory metrics. Option C is wrong because `docker usage` is not a valid Docker subcommand — Docker has no such command, so it returns an 'unknown command' error. Option D is wrong because `docker info` prints daemon-wide configuration and host information (kernel version, storage driver, number of containers/images, cgroup driver), not per-container resource consumption.

43
Multi-Selecthard

Which THREE configuration items can be managed by LXC cgroups?

Select 3 answers
A.CPU shares
B.User permissions
C.Device access
D.Memory limits
E.DNS settings
AnswersA, C, D

CPU shares are a cgroup CPU-scheduling control, letting LXC allocate relative processor time between containers. This satisfies the stem's requirement for a manageable cgroup item, since shares directly tune CPU distribution rather than merely reporting usage or configuring storage and networking.

Why this answer

LXC uses Linux control groups (cgroups) to isolate and limit container resource consumption, and CPU shares (A) are managed via the cpu cgroup subsystem (e.g., cpu.shares) to control relative CPU scheduling weight. Device access (C) is enforced through the devices cgroup subsystem, which uses an allow/deny list (devices.allow/devices.deny) to control which block and character devices a container may access. Memory limits (D) are handled by the memory cgroup subsystem (e.g., memory.limit_in_bytes) to cap RAM usage and trigger OOM behavior.

User permissions (B) are not a cgroup function; they are governed by Linux user/group IDs, UID/GID mapping in the LXC config, and file permissions. DNS settings (E) are configured through files such as /etc/resolv.conf or LXC network configuration, not through cgroups.

Exam trap

305-300 often tests whether candidates conflate cgroup-managed resources (CPU, memory, devices, blkio, pids) with adjacent container settings like user namespaces and DNS, which are configured through entirely different LXC mechanisms.

44
MCQhard

You are building a Docker image and want to ensure that a build-time variable is available only during the build, not persisted in the final image's environment. Which instruction should you use?

A.ENV
B.LABEL
C.EXPOSE
D.ARG
AnswerD

`ARG` defines a build-time variable that can be passed with `--build-arg` and is available only during the build stage. It is not persisted in the image's environment or history in a way that exposes the value to running containers. This matches the requirement of a variable that is used during build but not retained in the final image.

Why this answer

`ARG` is designed for values that are needed only while building the image. It can be supplied with `--build-arg` and is not stored in the final image's environment. `ENV` would persist the value, while `LABEL` and `EXPOSE` serve unrelated metadata and port documentation purposes. Only the build-argument instruction meets the requirement of a transient build-time variable.

Exam trap

The trap here is confusing build-time arguments with runtime environment variables, assuming that any variable set in a Dockerfile is automatically removed after the build.

45
Multi-Selecthard

You are optimizing a Dockerfile to reduce image size. Which THREE of the following practices are recommended?

Select 3 answers
A.Use the FROM latest tag for all base images
B.Always install recommended packages for security
C.Remove /var/lib/apt/lists/* after installing packages
D.Use multi-stage builds to discard build-time dependencies
E.Use a single RUN command to chain multiple commands with &&
AnswersC, D, E

APT leaves package index caches under /var/lib/apt/lists/* after installation; deleting them in the same layer prevents that metadata persisting into the final image. This directly satisfies the image-size reduction constraint, since those cached lists are otherwise retained in the layer.

Why this answer

Option C is correct because after running apt-get install, the package lists stored in /var/lib/apt/lists/* are no longer needed at runtime, and deleting them in the same RUN layer prevents them from being baked into the image and bloating its size. Option D is correct because multi-stage builds let you compile or build in an intermediate stage and copy only the resulting artifacts into a minimal final stage, so compilers, SDKs, and other build-time dependencies never end up in the shipped image. Option E is correct because chaining commands with && in a single RUN creates one layer; if you split them across multiple RUN instructions, intermediate files created and later deleted still persist in earlier layers and inflate the image.

Option A is not recommended because the latest tag is mutable and non-deterministic, leading to unpredictable builds and larger or incompatible base images rather than a size optimization. Option B is not recommended because installing recommended packages pulls in extra dependencies you may not need, increasing image size and attack surface; --no-install-recommends is the preferred approach.

Exam trap

305-300 often tests the misconception that deleting files in a later Dockerfile instruction reduces image size — candidates forget that each RUN creates a separate layer, so cleanup must happen in the same layer as the install.

46
MCQeasy

A developer wants to run a short-lived container that executes a command and then removes itself automatically after exit. Which `docker run` flag should be used?

A.`--rm`
B.`--detach`
C.`--interactive`
D.`--tty`
AnswerA

The `--rm` flag tells Docker to automatically remove the container's filesystem when it exits. This is ideal for short-lived tasks where the container does not need to persist. It prevents accumulation of stopped containers and matches the requirement of self-removal after the command completes.

Why this answer

`--rm` is specifically designed to remove the container automatically when it exits. It is commonly used for one-off commands and CI jobs. The other flags control background execution, STDIN, or TTY allocation, none of which affect post-exit cleanup.

Only `--rm` ensures the container does not linger after its task finishes.

Exam trap

The trap here is mixing up flags that control terminal attachment with flags that control container lifecycle, assuming that any run flag might cause cleanup.

47
MCQmedium

In the context of container orchestration, what is the role of a 'sidecar' container?

A.To provide auxiliary services like logging or monitoring for the main container
B.To act as a load balancer for the cluster
C.To store persistent data for the primary container
D.To run in a separate network namespace
E.To replace the main container when it crashes
AnswerA

A sidecar runs alongside the main container in the same pod, sharing its network namespace and lifecycle, to handle auxiliary concerns such as log shipping, metrics collection or proxying. This offloads cross-cutting functions without altering the primary application image.

Why this answer

A sidecar container runs alongside the main application container in the same pod, providing auxiliary functionality such as log shipping, metrics collection, proxying, or configuration sync. It shares the pod's network namespace and lifecycle, augmenting rather than replacing the primary container. This is the canonical definition in Kubernetes and general container orchestration.

Exam trap

The trap is overgeneralizing the sidecar role to include load balancing or persistence — candidates pick answers that describe other Kubernetes primitives (Services, Volumes) rather than the sidecar's auxiliary-service purpose.

How to eliminate wrong answers

Option B is wrong because load balancing in a cluster is handled by Services, Ingress controllers, or dedicated proxies — not by a sidecar's defining role, though a sidecar proxy (like Envoy in a service mesh) can participate in load balancing as an auxiliary function. Option C is wrong because persistent data is provided by volumes or PersistentVolumes, not by sidecar containers. Option D is wrong because sidecars share the pod's network namespace by design, not run in a separate one.

Option E is wrong because sidecars do not replace the main container on crash — that is the role of restart policies or ReplicaSets.

48
MCQhard

You are debugging a Docker network issue where containers on different hosts cannot communicate. Which network driver is specifically designed to support multi-host overlay networking?

A.bridge
B.macvlan
C.ipvlan
D.host
E.overlay
AnswerE

The overlay driver encapsulates container traffic in VXLAN, extending a single logical network across multiple Docker hosts. This satisfies the stem's multi-host constraint, which bridge and host drivers cannot meet since they are confined to one host.

Why this answer

Option E is correct because the 'overlay' driver is specifically designed for multi-host networking in Docker Swarm, using VXLAN tunnels to encapsulate container traffic across hosts. It creates a distributed network that spans multiple Docker daemons, enabling containers on different hosts to communicate as if on the same Layer 2 network.

Exam trap

The trap is confusing overlay with macvlan or ipvlan — candidates may think any advanced driver supports multi-host, but only overlay is purpose-built for cross-host container communication.

How to eliminate wrong answers

Option A is wrong because the 'bridge' driver is limited to a single host — it creates a private internal network on one Docker daemon and cannot span multiple hosts without additional routing. Option B is wrong because 'macvlan' assigns MAC addresses to containers, making them appear as physical devices on the network, but it is typically scoped to a single host or requires complex underlay configuration. Option C is wrong because 'ipvlan' is similar to macvlan but uses IP-based multiplexing; it is not designed for multi-host overlay networking.

Option D is wrong because the 'host' driver removes network isolation entirely, placing the container on the host's network stack — it does not provide multi-host connectivity.

49
MCQeasy

Which command-line tool is primarily used to inspect the metadata and configuration of a running Docker container?

A.docker ps
B.docker stats
C.docker info
D.docker inspect
E.docker describe
AnswerD

docker inspect returns the container's full JSON metadata: configuration, network settings, mounts, environment variables and state. It reads the daemon's stored object rather than live process output, matching the stem's requirement to examine metadata and configuration of a running container.

Why this answer

docker inspect returns detailed JSON metadata about a container, including its configuration, network settings, mounts, and state. It is the primary tool for examining the low-level details of a running or stopped container.

Exam trap

The trap is confusing docker inspect with docker ps or docker info — candidates may think 'inspect' is for listing, but it's for deep metadata retrieval, and 'describe' is a Kubernetes term, not Docker.

How to eliminate wrong answers

Option A (docker ps) is wrong because it only lists running containers with basic information like ID, image, and status — it does not show configuration metadata. Option B (docker stats) is wrong because it displays live resource usage statistics (CPU, memory, network I/O) rather than configuration details. Option C (docker info) is wrong because it shows system-wide Docker daemon information, not details about a specific container.

Option E (docker describe) is wrong because there is no such Docker command — 'describe' is a kubectl command in Kubernetes, not Docker.

50
Multi-Selectmedium

Which THREE of the following are components of the Docker architecture?

Select 3 answers
A.Docker Daemon
B.Docker Kernel
C.Docker Client
D.Docker GUI
E.Docker Registry
AnswersA, C, E

The Docker daemon (dockerd) is the persistent background process that builds images, runs containers and manages Docker objects via the Docker API. It is a core architectural component, so it belongs in the correct three-part selection.

Why this answer

Docker Daemon (A) is correct because dockerd is the persistent background service that listens for Docker API requests and manages Docker objects such as images, containers, networks, and volumes. Docker Client (C) is correct because the docker CLI is the primary user interface that sends commands to the daemon via the Docker REST API over a socket or network. Docker Registry (E) is correct because it is the storage and distribution system for Docker images, with Docker Hub as the default public registry from which images are pulled and to which they are pushed.

Docker Kernel (B) is not a Docker component; Docker relies on the host OS kernel's features (namespaces, cgroups) but does not ship its own kernel. Docker GUI (D) is not a core architectural component; graphical tools like Docker Desktop or Portainer are optional third-party or wrapper interfaces, not part of the Docker architecture itself.

Exam trap

The trap is that distractors like 'Docker Kernel' or 'Docker GUI' sound plausible because Docker does use the kernel and GUIs exist — but neither is a defined architectural component of Docker itself.

51
MCQmedium

Which command allows you to enter an existing running container and execute a new command inside it?

A.docker exec
B.docker commit
C.docker attach
D.docker run
AnswerA

docker exec runs a new command inside a container that is already running, which is exactly the requirement. It differs from docker run, which starts a fresh container, and from docker attach, which merely connects to the existing main process.

Why this answer

The `docker exec` command runs a new process inside an already-running container, which is exactly what is needed to enter a container and execute a command such as a shell. For example, `docker exec -it <container> /bin/bash` opens an interactive shell inside the running container without stopping or restarting it. This is the standard, non-disruptive way to access a running container.

Exam trap

The trap is confusing `docker exec` with `docker attach` — candidates may think attach lets them run commands, but attach only connects to PID 1's stdio and can disrupt the container, whereas exec spawns a new process.

How to eliminate wrong answers

Option B is wrong because `docker commit` creates a new image from a container's current state — it does not execute commands or provide interactive access. Option C is wrong because `docker attach` connects to the container's main process (PID 1) stdio, which can be disruptive and does not start a new command; detaching can also accidentally stop the container. Option D is wrong because `docker run` creates and starts a brand-new container from an image, rather than entering an existing running one.

52
MCQhard

You are building a Docker image and need to ensure that the container process runs as a non-root user with UID 1000 and that this user exists in the image. Which pair of Dockerfile instructions achieves this correctly?

A.`USER appuser` followed by `RUN useradd -u 1000 appuser`
B.`USER 1000` followed by `RUN useradd -u 1000 appuser`
C.`RUN useradd -u 1000 -m appuser` followed by `USER appuser`
D.`RUN useradd -u 1000 appuser` followed by `USER 1000`
AnswerC

`useradd -u 1000 -m appuser` creates the user with the specified UID and a home directory during the build, while running as root. The subsequent `USER appuser` instruction sets the runtime user for the rest of the build and the container. This order ensures the user exists before it is referenced, which is the correct and reliable pattern.

Why this answer

The user must exist before it can be selected. Creating it with `useradd` while the build still runs as root, then switching with `USER appuser`, ensures the account is present in /etc/passwd and that the container process runs with the intended non-root identity. Reversing the order or using a numeric UID without creating the account leads to failures or reduced clarity.

Exam trap

The trap here is assuming that `USER` creates the account or that the order of `USER` and `useradd` does not matter.

53
Multi-Selectmedium

Which TWO types of namespaces are commonly used to achieve container isolation in Linux?

Select 2 answers
A.GPU
B.Network
C.CPU
D.PID
E.Kernel
AnswersB, D

Network namespaces give each container its own isolated set of interfaces, routing tables, firewall rules and ports, so processes cannot see or interfere with the host's or other containers' networking. This satisfies the isolation requirement by virtualising the network stack per container.

Why this answer

Network namespaces (B) are correct because they give each container its own isolated network stack — separate interfaces, IP addresses, routing tables, and firewall rules — which is a core mechanism used by tools like Docker and Kubernetes for container isolation. PID namespaces (D) are also correct because they isolate the process ID number space, so processes inside a container only see their own PID tree (starting at PID 1) and cannot see or signal host processes. The other options do not belong: GPU (A) and CPU (C) are hardware resources managed via cgroups and device access, not namespace types, and Kernel (E) is not a Linux namespace — the kernel itself is shared, with namespaces isolating specific global resources like mount, UTS, IPC, user, network, and PID.

Exam trap

The trap is conflating namespaces with cgroups — candidates often pick CPU because they associate it with container resource control, but CPU limits are cgroup functionality, not namespace isolation.

54
MCQhard

You are building a multi-stage Dockerfile and want to copy a binary from the 'builder' stage to the final stage. Which syntax is correct?

A.ADD --from=builder /bin/app /bin/app
B.COPY --from=builder /bin/app /bin/app
C.COPY builder:/bin/app /bin/app
D.COPY --stage=builder /bin/app /bin/app
AnswerB

COPY --from=builder references the earlier build stage by name, pulling only the compiled binary into the final image without dragging along the builder's toolchain or layers. This satisfies the stem's multi-stage requirement, keeping the runtime image minimal while the build dependencies stay confined to the discarded stage.

Why this answer

Docker's multi-stage build feature allows COPY --from=<stage> to pull artifacts from a previously built stage (or an external image) into the current stage. The syntax COPY --from=builder /bin/app /bin/app copies the binary /bin/app from the stage named 'builder' into the final image at /bin/app, keeping the final image small by excluding the builder's toolchain and dependencies.

Exam trap

The trap is the near-miss flag names — candidates who half-remember the syntax pick ADD --from or COPY --stage, but only COPY supports --from and the flag is spelled --from, not --stage.

How to eliminate wrong answers

Option A is wrong because ADD does not support the --from flag — only COPY does; ADD is for local files, tarballs, and URLs, and using --from with ADD is invalid syntax. Option C is wrong because 'builder:/bin/app' is not valid Dockerfile syntax; the stage reference must be expressed with the --from flag, not as a path prefix. Option D is wrong because the flag is --from, not --stage; --stage is not a recognized Dockerfile instruction flag and would cause a build error.

55
MCQmedium

You are migrating a legacy application to an LXC container and need to ensure the container has access to the host's /dev/sda block device. Which configuration key must be added to the container's configuration file?

A.lxc.mount.device = /dev/sda
B.lxc.cap.sys_admin = 1
C.lxc.cgroup.devices.allow = b 8:0 rwm
D.lxc.dev.access = /dev/sda
AnswerC

The cgroup devices controller filters access by major:minor numbers, so 'b 8:0 rwm' permits block device 8:0 (/dev/sda) with read, write and mknod rights. Without this allow rule, the container's device cgroup denies access, satisfying the requirement to expose the host block device.

Why this answer

LXC controls device access through the cgroup devices controller, and the config key lxc.cgroup.devices.allow uses the syntax 'TYPE MAJOR:MINOR PERMISSIONS'. For /dev/sda, the type is 'b' (block), major 8, minor 0, and permissions 'rwm' (read, write, mknod). This whitelists the block device so the container can access it, and it must be paired with a bind mount (lxc.mount.entry) to actually expose the device node inside the container.

Exam trap

305-300 often tests whether candidates pick a plausible-sounding but nonexistent config key (lxc.mount.device, lxc.dev.access) or over-grant privileges with CAP_SYS_ADMIN instead of using the correct cgroup devices.allow syntax.

How to eliminate wrong answers

Option A is wrong because lxc.mount.device is not a valid LXC configuration key — LXC uses lxc.mount.entry for bind mounts, and device access is controlled by cgroup rules, not a mount directive. Option B is wrong because lxc.cap.sys_admin = 1 grants the container the CAP_SYS_ADMIN capability, which is a broad privilege escalation and does not by itself allow access to a specific block device — device whitelisting is the correct mechanism. Option D is wrong because lxc.dev.access is not a real LXC config key; it is a fabricated name that sounds plausible but has no effect.

56
MCQeasy

Which command-line option is used to run a Docker container in the background (detached mode)?

A.-i
B.--bg
C.-d
D.-b
E.-t
AnswerC

The -d flag detaches the container, running it in the background and returning the container ID to the shell. This satisfies the detached-mode requirement, unlike -it which attaches an interactive TTY to the foreground process.

Why this answer

The -d (or --detach) flag runs a Docker container in the background, returning the container ID and freeing the terminal. This is the standard way to start long-running services like web servers without blocking the shell. Combined with -p for port mapping and --name for identification, it is the canonical detached-mode invocation.

Exam trap

The trap is that -i and -t are commonly used together for interactive containers, so candidates may confuse them with detachment; the exam expects recognition that only -d (--detach) backgrounds the container.

How to eliminate wrong answers

Option A is wrong because -i keeps STDIN open for interactive input; it does not detach the container. Option B is wrong because --bg is not a Docker flag; the correct long form is --detach. Option D is wrong because -b is not a valid Docker run flag for background mode (it was historically used for bridge networking in some contexts, but not detachment).

Option E is wrong because -t allocates a pseudo-TTY; it is often paired with -i for interactive sessions but does not detach.

57
MCQmedium

You are managing an LXC container and need to create a snapshot of the container's root file system. Which command achieves this?

A.lxc-snapshot -n container_name
B.lxc-checkpoint -n container_name
C.lxc-copy -s container_name
D.lxc-backup
E.lxc-clone --snapshot
AnswerA

`lxc-snapshot -n container_name` invokes the LXC snapshot utility against the named container, capturing the root file system state through the container's backing storage. It satisfies the stem's requirement to snapshot an LXC container's root file system directly, without manual copy or export steps.

Why this answer

The `lxc-snapshot -n <container_name>` command creates a snapshot of an LXC container's root filesystem. It is the standard LXC utility for snapshotting containers, allowing you to capture the current state of the container's filesystem for backup or rollback purposes.

Exam trap

The trap is confusing filesystem snapshots (`lxc-snapshot`) with checkpoint/restore (`lxc-checkpoint`) or cloning (`lxc-copy`/`lxc-clone`) — candidates must distinguish between capturing filesystem state versus process state versus creating a new container.

How to eliminate wrong answers

Option B is wrong because `lxc-checkpoint` is used for checkpoint/restore of a running container's state (processes, memory, etc.) via CRIU, not for creating a filesystem snapshot. Option C is wrong because `lxc-copy -s` is not the correct syntax for snapshotting — `lxc-copy` is used to copy or clone containers, and while it has snapshot-related options, the dedicated snapshot command is `lxc-snapshot`. Option D is wrong because `lxc-backup` is not a valid LXC command — there is no such utility.

Option E is wrong because `lxc-clone --snapshot` is not the correct command — `lxc-clone` is an older/deprecated tool for cloning containers, and the snapshot-specific command is `lxc-snapshot`.

58
MCQhard

In an OpenVZ environment, you need to limit the number of processes a container can create. Which parameter in the container configuration file should be modified?

A.PHYSPAGES
B.NUMPROC
C.KMEMSIZE
D.PRIVVMPAGES
AnswerB

NUMPROC directly caps the process count within an OpenVZ container, satisfying the requirement to limit process creation. Set in the container configuration file, it enforces this per-container barrier independently of host-wide limits, unlike CPU or memory parameters that govern different resources entirely.

Why this answer

In OpenVZ, the NUMPROC parameter in the container's configuration file (e.g., /etc/vz/conf/CTID.conf) directly controls the maximum number of processes and threads that can exist within that container. It acts as a hard limit on the total process count, preventing a single container from exhausting the host's process table. This is the correct parameter to modify when you need to restrict process creation for a specific container.

Exam trap

The trap here is confusing memory-related parameters (PHYSPAGES, KMEMSIZE, PRIVVMPAGES) with process-count limits, as candidates may assume any resource parameter affects process creation.

How to eliminate wrong answers

Option A is wrong because PHYSPAGES limits the amount of physical memory (in pages) a container can allocate, not the number of processes. Option C is wrong because KMEMSIZE controls the size of kernel memory that can be allocated to a container, which is unrelated to process count. Option D is wrong because PRIVVMPAGES limits the number of private virtual memory pages a container can use, which governs memory usage, not process creation.

59
MCQhard

In systemd-nspawn, how do you specify a different root directory for the container?

A.--path
B.--root
C.-D
D.-r
AnswerC

The `-D` flag sets the container's root directory, satisfying the requirement to specify a different root filesystem. It accepts a path to a directory tree or image, which systemd-nspawn then uses as the container's root, rather than defaulting to a machine-name-derived location under `/var/lib/machines`.

Why this answer

The -D flag (long form --directory) in systemd-nspawn specifies the root directory for the container. This is the documented option for pointing nspawn at a directory tree that should be used as the container's filesystem root. For example, 'systemd-nspawn -D /var/lib/machines/mycontainer' boots the container using that path as its root.

Exam trap

The trap here is confusing systemd-nspawn's -D/--directory with similarly named flags from other container tools (podman --root, chroot's positional root, or Docker's --workdir), causing candidates to pick a plausible-sounding but nonexistent nspawn option.

How to eliminate wrong answers

Option A is wrong because --path is not a valid systemd-nspawn option; nspawn uses --directory/-D for the root filesystem location. Option B is wrong because --root is not a systemd-nspawn flag — that naming convention belongs to tools like chroot or podman, not nspawn. Option D is wrong because -r is not the root-directory switch in nspawn; in some tools -r means read-only or recursive, and nspawn reserves -D for the directory.

60
MCQeasy

What is the primary difference between a container image and a container instance?

A.Images are stored in RAM, instances are on disk
B.The image is the template; the instance is the running process
C.Instances cannot be stopped
D.The instance is the template; the image is the running process
E.They are the same thing
AnswerB

An image is an immutable, layered filesystem template stored locally or in a registry; a container instance is that image instantiated as a running process with a writable layer. This template-versus-process distinction directly answers the stem's request for the primary difference.

Why this answer

A container image is an immutable, layered filesystem template (built from a Dockerfile) that packages the application and its dependencies. A container instance is a running (or stopped) instantiation of that image with its own writable layer, process namespace, and runtime state. The image is the blueprint; the instance is the executing process.

Exam trap

The trap is the classic template-vs-instance confusion — candidates sometimes pick the reversed option (D) or assume images live in RAM, missing that images are on-disk immutable layers and instances are the running processes.

How to eliminate wrong answers

Option A is wrong because images are stored on disk (in a registry or local image store), not in RAM; running instances consume RAM. Option C is wrong because container instances can absolutely be stopped (docker stop, pod termination) — they are not immortal. Option D is wrong because it reverses the relationship: the image is the template, not the instance.

Option E is wrong because image and instance are distinct concepts in the container lifecycle, analogous to class vs. object.

61
MCQeasy

What is the primary function of the ENTRYPOINT instruction in a Dockerfile?

A.Setting environment variables
B.Defining volume mount points
C.Configuring the executable that runs when the container starts
D.Specifying metadata
E.Installing software packages
AnswerC

ENTRYPOINT sets the executable that runs when the container starts, satisfying the stem's requirement. Unlike CMD, which supplies default arguments that a docker run command can override, ENTRYPOINT fixes the process itself, with CMD values passed to it as parameters.

Why this answer

ENTRYPOINT defines the executable that runs when the container starts, making the container behave like a self-contained command. Unlike CMD, which provides default arguments that can be overridden at 'docker run', ENTRYPOINT is not replaced by command-line arguments — those arguments are appended to it. This is why ENTRYPOINT is used to configure a container as an executable.

Exam trap

The trap is conflating ENTRYPOINT with CMD — candidates often pick the answer describing default commands or environment setup, forgetting that ENTRYPOINT is the non-overridable executable definition while CMD supplies overridable defaults.

How to eliminate wrong answers

Option A is wrong because environment variables are set with ENV, not ENTRYPOINT. Option B is wrong because volume mount points are declared with VOLUME. Option D is wrong because metadata such as author and description is set with LABEL (or the deprecated MAINTAINER).

Option E is wrong because package installation happens via RUN during build, not via ENTRYPOINT at runtime.

62
MCQeasy

How do you view the logs of a running container?

A.docker logs [container]
B.docker show-logs
C.cat /var/lib/docker/logs
D.docker log
AnswerA

`docker logs [container]` retrieves stdout and stderr captured by the container's configured logging driver, streaming them to your terminal without entering the container. This satisfies the scenario's requirement to view a running container's logs directly, since Docker retains that output for the container's lifetime.

Why this answer

The correct command to view the logs of a running container is `docker logs [container]`. This command retrieves the standard output (stdout) and standard error (stderr) from the container's main process, which Docker captures and stores using a logging driver (default is json-file). It works for both running and stopped containers, and options like `-f` (follow) and `--tail` allow real-time monitoring or limiting output.

Exam trap

The trap here is confusing the correct plural command `docker logs` with the singular `docker log`, or assuming logs are stored in a central directory like `/var/lib/docker/logs`, when they are actually per-container and accessed via the Docker CLI.

How to eliminate wrong answers

Option B is wrong because `docker show-logs` is not a valid Docker command; there is no such subcommand. Option C is wrong because Docker does not store container logs in a single file at `/var/lib/docker/logs`; instead, logs are stored per container under `/var/lib/docker/containers/<container-id>/<container-id>-json.log` when using the default json-file driver, and directly reading them is not the standard method. Option D is wrong because `docker log` is not a valid command; the correct subcommand is `logs` (plural).

63
MCQmedium

Which instruction in a Dockerfile is best suited for installing packages to minimize image size?

A.COPY apt-cache /
B.CMD apt-get install package
C.RUN apt-get update && apt-get install -y package
D.RUN apt-get update && apt-get install -y package && rm -rf /var/lib/apt/lists/*
AnswerD

Combining update, install and cache removal in a single RUN layer prevents apt metadata persisting in the final image, directly satisfying the minimise-image-size constraint. Separate instructions would each commit a layer, retaining the lists irreversibly. The `rm -rf` executes before the layer is committed, so nothing is left behind.

Why this answer

The RUN instruction with apt-get update, install, and cleanup in a single layer is best because it prevents the apt package lists from being stored in the final image. By combining update, install, and rm -rf /var/lib/apt/lists/* in one RUN, Docker creates a single layer where the lists are downloaded, used, and then deleted before the layer is committed. This minimizes image size because the intermediate files never persist in any layer.

Other options either don't install packages (COPY, CMD) or leave cached lists in the image (RUN without cleanup).

Exam trap

305-300 often tests the misconception that any RUN with apt-get install is sufficient, but the trap is forgetting that cleanup must happen in the same RUN instruction to avoid leaving cached package lists in the image layer.

How to eliminate wrong answers

Option A is wrong because COPY apt-cache / does not install any packages; it merely copies a file or directory named 'apt-cache' into the root, which is not a valid package installation method and would likely fail or add unnecessary files. Option B is wrong because CMD sets the default command for the container at runtime, not during build; it does not execute apt-get install during image build, so packages are not installed into the image. Option C is wrong because while it installs packages, it leaves the apt package lists in /var/lib/apt/lists/, which adds unnecessary size to the image; without cleanup, those lists persist in the layer.

64
Multi-Selectmedium

Which TWO commands are valid for inspecting container network settings?

Select 2 answers
A.docker inspect
B.docker show net
C.docker net status
D.docker list network
E.docker network inspect
AnswersA, E

Docker inspect returns the container's full configuration as JSON, including the NetworkSettings object with IP address, gateway, MAC address, port bindings and connected networks. That directly satisfies the stem's requirement to inspect container network settings, unlike commands that only list or alter them.

Why this answer

Option A, `docker inspect`, is correct because it returns the full JSON configuration of a container, including its NetworkSettings section with IP address, gateway, MAC address, and attached networks. Option E, `docker network inspect`, is correct because it inspects a Docker network object and shows connected containers, subnet, gateway, and driver details. Options B, C, and D are not valid Docker CLI commands, so they cannot be used to inspect container network settings.

Exam trap

The trap is accepting plausible-sounding but non-existent Docker subcommands like 'docker show net' or 'docker net status' — candidates must know the exact CLI verbs (inspect, network inspect, network ls).

65
MCQmedium

What is the purpose of the 'rkt' (Rocket) container runtime?

A.To replace the kernel
B.To run pods in a secure, pluggable manner
C.To manage cloud infrastructure
D.To provide a GUI for Docker
AnswerB

Rocket runs application containers grouped as pods, using a pluggable execution stage and signature-verified images to isolate workloads securely. This pod-centric, pluggable design satisfies the scenario's requirement for running pods in a secure, pluggable manner, distinguishing it from single-container runtimes.

Why this answer

The 'rkt' (Rocket) container runtime was developed by CoreOS as an alternative to Docker, designed to run application containers (often grouped into pods) with a strong focus on security, composability, and adherence to open standards. It implements a pluggable execution model where different isolation mechanisms (e.g., KVM, cgroups) can be used, and it supports pod-level networking and image formats like ACI (App Container Image). Its primary purpose is to securely and portably run containerized workloads, especially pods, in a pluggable manner.

Exam trap

The trap here is confusing a container runtime with an orchestrator or a kernel component; candidates might think 'rkt' manages infrastructure or replaces the kernel, but it is strictly a runtime for executing containers/pods securely.

How to eliminate wrong answers

Option A is wrong because a container runtime does not replace the kernel; it relies on kernel features like namespaces and cgroups for isolation, and rkt specifically can optionally use a hypervisor but never substitutes the OS kernel. Option C is wrong because managing cloud infrastructure is the domain of orchestration and infrastructure-as-code tools (e.g., Kubernetes, Terraform), not a container runtime like rkt. Option D is wrong because rkt is a command-line runtime with no graphical user interface; GUI tools for Docker are separate projects like Portainer or Docker Desktop.

66
MCQmedium

You are using Docker and need to inspect the metadata of a running container, including its IP address, environment variables, and mounted volumes. Which command provides all this information in a single JSON output?

A.docker logs <container>
B.docker inspect <container>
C.docker ps --format json
D.docker stats <container>
AnswerB

docker inspect returns detailed JSON metadata about a container, including its network settings (IP address), environment variables, mounts, and much more. It is the primary tool for retrieving low-level configuration and runtime information. The output can be filtered with --format to extract specific fields. This command satisfies all the requirements in the scenario with a single invocation.

Why this answer

The docker inspect command outputs comprehensive JSON metadata for a container, including network settings, environment variables, and mounts. Other commands like docker ps, docker stats, and docker logs serve different purposes such as listing, monitoring, or retrieving logs. Only docker inspect provides the full configuration details required in this scenario.

Exam trap

The trap here is confusing container listing or monitoring commands with inspection commands, and assuming that docker ps or docker stats can provide detailed configuration metadata like IP address and mounts.

67
MCQeasy

Which command shows the history of layers in a Docker image?

A.docker history
B.docker log
C.docker layers
D.docker image info
AnswerA

`docker history` reads an image's manifest and prints each layer with its ID, size and originating instruction, directly satisfying the requirement to show layer history. Unlike `docker inspect`, which returns JSON metadata about the whole image, it enumerates the individual build steps, making it the precise command for this scenario.

Why this answer

The `docker history` command displays the complete layer history of a Docker image, showing each intermediate layer created by the Dockerfile instructions, along with the layer ID, creation time, size, and the command that created it. This is the standard way to inspect how an image was built and identify which layers consume the most space.

Exam trap

The trap here is confusing container runtime commands (`docker logs`) with image inspection commands, or assuming a `docker layers` subcommand exists when it does not — candidates must know the exact Docker CLI surface.

How to eliminate wrong answers

Option B is wrong because `docker log` (or more accurately `docker logs`) displays the stdout/stderr output of a running or stopped container, not image layer information. Option C is wrong because `docker layers` is not a valid Docker CLI command — no such subcommand exists. Option D is wrong because `docker image info` is not a valid Docker CLI command; image metadata is retrieved via `docker inspect` or `docker image inspect`.

68
MCQhard

You are running a Docker container that needs to persist data in a directory that is backed by a storage area on the host. The host uses the overlay2 storage driver. You want the container to write data that survives container removal and is accessible directly on the host filesystem. Which approach should you use?

A.Commit the container to a new image after writing data, and run a new container from that image.
B.Create a named volume with docker volume create and mount it into the container.
C.Use a bind mount to map a host directory into the container.
D.Use a tmpfs mount to store the data in memory.
AnswerC

A bind mount maps an existing directory on the host directly into the container. Data written by the container appears immediately in that host directory, and it persists independently of the container lifecycle. This satisfies both requirements: data survives container removal and is directly accessible on the host filesystem without needing Docker-specific tools to locate it.

Why this answer

Bind mounts directly associate a host directory with a container path, so files written by the container are stored on the host and persist after the container is removed. They also allow direct access to the data from the host without Docker-specific commands. Named volumes persist but are managed by Docker, while tmpfs is memory-only and commits are for image creation, not runtime data persistence.

Exam trap

The trap here is confusing Docker-managed named volumes with bind mounts; both persist data, but only bind mounts give direct host filesystem access at a user-specified path.

69
MCQhard

You are using Docker and want to create a volume that is shared between multiple containers and persists even if the containers are deleted. What is the best approach?

A.Anonymous volume
B.Tmpfs
C.Bind mount
D.Named volume
AnswerD

Named volumes are stored outside the container's writable layer, under Docker's managed volume directory, so data survives container deletion and can be mounted by several containers simultaneously via the same volume name — satisfying both the sharing and persistence constraints in the stem.

Why this answer

A named volume is created and managed by Docker with a user-specified name, stored under /var/lib/docker/volumes, and persists independently of container lifecycle. It can be mounted into multiple containers simultaneously, making it the best choice for shared, persistent data. Named volumes are the recommended approach for production data persistence.

Exam trap

The trap is assuming bind mounts are the best for persistence, when the question emphasizes sharing between multiple containers and persistence after deletion — the defining strengths of named volumes.

How to eliminate wrong answers

Option A (anonymous volume) is wrong because it is created without a name, making it hard to reference or reuse across containers, and it is easily orphaned. Option B (tmpfs) is wrong because tmpfs mounts are stored in memory and are lost when the container stops — they do not persist. Option C (bind mount) is wrong because it mounts a host directory path directly; while it persists, it couples the container to host filesystem layout and is less portable than a named volume for shared multi-container use.

70
MCQeasy

A developer is building a container image and wants to reduce its final size by ensuring that no package manager cache files remain in the image layers. Which Dockerfile instruction should be used to remove these temporary files during the build?

A.ADD rm -rf /var/cache/apt/*
B.ENTRYPOINT rm -rf /var/cache/apt/*
C.CMD rm -rf /var/cache/apt/*
D.RUN rm -rf /var/cache/apt/*
AnswerD

Using RUN to delete cache files in the same layer where they were created ensures the files are not persisted in the final image. If the deletion occurs in a separate RUN instruction, the cache files remain in the earlier layer and still contribute to the image size. Combining installation and cleanup in a single RUN instruction is the recommended practice.

Why this answer

To reduce image size by removing temporary files, the deletion must occur in the same layer where the files were created. The RUN instruction executes commands during the build, so using RUN to remove cache files in the same layer ensures they are not committed to the final image. Other instructions like CMD, ENTRYPOINT, or ADD do not execute during build and cannot remove files.

Exam trap

The trap here is confusing build-time instructions with runtime instructions, assuming that any instruction can modify the image layers.

71
MCQeasy

You are using Docker and need to view the layers that make up an image to understand its build history. Which command should you use?

A.docker history <image>
B.docker inspect <image>
C.docker layers <image>
D.docker diff <image>
AnswerA

docker history displays the intermediate layers of an image along with the commands that created them, their sizes, and creation timestamps. It provides a concise view of the image's build history, which is exactly what is needed to understand how the image was constructed. This command is specifically designed for this purpose and is the correct choice.

Why this answer

The docker history command lists the layers of an image along with the commands that created them, making it the right tool to understand build history. docker inspect provides metadata but not a layer-by-layer history, docker layers does not exist, and docker diff is for container filesystem changes. Therefore, docker history is the correct answer.

Exam trap

The trap here is assuming that docker inspect or a non-existent docker layers command can show image layer history, when only docker history provides that specific view.

72
MCQmedium

What is the role of the 'Dockerfile' in the container build process?

A.To define network topology
B.To list running containers
C.To store container data
D.To provide build instructions
AnswerD

The Dockerfile supplies the declarative build instructions — base image, RUN commands, COPY directives and ENTRYPOINT — that docker build executes layer by layer. It defines the image contents, satisfying the requirement to specify how the container image is constructed.

Why this answer

A Dockerfile is a text file containing a series of instructions (FROM, RUN, COPY, CMD, etc.) that Docker uses to build a container image. It defines the base image, dependencies, environment, and startup command, effectively providing the build recipe. The 'docker build' command reads the Dockerfile and executes each instruction in order to produce a layered image.

Exam trap

The trap is assuming the Dockerfile does more than define build instructions — candidates may confuse it with runtime configuration files like docker-compose.yml or network/volume definitions.

How to eliminate wrong answers

Option A is wrong because network topology in Docker is defined by network drivers and 'docker network' commands, not by the Dockerfile. Option B is wrong because listing running containers is done with 'docker ps', not via a Dockerfile. Option C is wrong because container data is stored in volumes or bind mounts, which are configured at runtime, not in the Dockerfile (though VOLUME can declare a mount point, it does not store data itself).

73
Multi-Selectmedium

Which TWO of the following are valid storage drivers used by Docker to manage image layers?

Select 2 answers
A.overlay2
B.ext4
C.vfs-driver
D.zfs-layer
E.aufs
AnswersA, E

overlay2 is a valid Docker storage driver that stacks image layers using the OverlayFS union filesystem, supporting copy-on-write between lower and upper directories. It is the default and recommended driver on modern Linux hosts, making it a legitimate answer for managing image layers.

Why this answer

overlay2 (A) is a valid Docker storage driver that uses the OverlayFS union filesystem to stack image layers and is the default driver on most modern Linux distributions. aufs (E) is also a valid Docker storage driver, historically used on Ubuntu/Debian, that implements a union mount to manage image layers. ext4 (B) is a filesystem, not a Docker storage driver, so it cannot manage image layers. vfs-driver (C) is not a real driver name; the actual driver is 'vfs', and it is a simple non-union driver, but the option as written is incorrect. zfs-layer (D) is not a valid driver name; the actual Docker driver is 'zfs', so this option is incorrect.

Exam trap

The trap here is that candidates confuse filesystems (ext4, XFS) with Docker storage drivers, or accept plausible-sounding but fabricated names like 'vfs-driver' and 'zfs-layer' instead of the exact driver identifiers 'vfs' and 'zfs'.

74
MCQmedium

You are running a Podman container as a non-root user with rootless mode. The container needs to bind to TCP port 80 inside the container's network namespace so a legacy application can listen for HTTP traffic. Which capability must be added to the container to allow binding to this privileged port without running the container as root?

A.CAP_NET_ADMIN
B.CAP_DAC_OVERRIDE
C.CAP_NET_BIND_SERVICE
D.CAP_SYS_ADMIN
AnswerC

CAP_NET_BIND_SERVICE allows a non-root process to bind to ports below 1024, including port 80. In rootless Podman, the container process runs as an unprivileged user on the host, so without this capability the bind to port 80 fails with a permission denied error. Adding this capability via --cap-add=NET_BIND_SERVICE grants exactly the needed privilege while keeping the rest of the container unprivileged.

Why this answer

Binding to ports below 1024 requires the CAP_NET_BIND_SERVICE capability when the process does not have root privileges. In rootless Podman, the container process is mapped to an unprivileged user, so the kernel denies the bind on port 80 unless this capability is explicitly added. The other capabilities listed address unrelated privilege areas and would not resolve the bind failure.

Exam trap

The trap here is assuming that any network-related capability, such as CAP_NET_ADMIN, will allow binding to a privileged port, when only CAP_NET_BIND_SERVICE grants that specific permission.

75
MCQhard

You are troubleshooting a Docker container that cannot reach the internet despite the host having connectivity. The container uses the default bridge network. Which iptables chain is most likely causing the block?

A.PREROUTING
B.POSTROUTING
C.FORWARD
D.OUTPUT
AnswerC

Docker's default bridge network routes container traffic through the host's FORWARD chain, since packets are forwarded between the bridge and the external interface. A restrictive FORWARD policy (DROP) blocks that path even though the host itself has connectivity, making FORWARD the chain responsible for the container's failed internet access.

Why this answer

Docker's default bridge network relies on the host's FORWARD chain to route packets between the docker0 bridge and the external interface. If the FORWARD chain's default policy is DROP (common on hardened hosts or when firewalld/ufw is misconfigured), container traffic is silently dropped even though the host itself has internet access. Docker normally inserts its own DOCKER-USER and DOCKER-FORWARD rules to permit this, but a conflicting firewall rule or a policy change can override them.

Exam trap

The trap is that candidates assume the problem is NAT (POSTROUTING) because they conflate 'no internet' with 'no masquerading', when the more common cause is the FORWARD chain policy blocking routed container traffic.

How to eliminate wrong answers

Option A is wrong because PREROUTING handles DNAT for published ports (incoming traffic to containers), not outbound container-to-internet traffic. Option B is wrong because POSTROUTING handles SNAT/masquerading of outbound packets — if masquerading were broken, the symptom would be different (packets leaving with the container's private IP), and Docker sets this up automatically. Option D is wrong because OUTPUT only applies to locally generated host traffic, not to packets being forwarded from the docker0 bridge.

Page 1 of 2 · 84 questions totalNext →

Ready to test yourself?

Try a timed practice session using only Container Virtualization questions.