

















































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


















































































Question 1.Which Docker command initializes a new Swarm manager on the local host? A) docker swarm start B) docker swarm init C) docker init swarm D) docker manager create Answer: B Explanation: docker swarm init creates a new Swarm and makes the current node a manager. Question 2.What is the default number of manager nodes required to achieve a quorum in a Swarm using the Raft consensus algorithm? A) 1 B) 2 C) 3 D) 5 Answer: C Explanation: Raft requires a majority of managers; with 3 managers, 2 constitute a quorum. Question 3.Which placement constraint ensures a service runs only on nodes labeled “region=us-east”? A) node.role == manager B) node.labels.region == us-east C) node.id == us-east D) node.labels == region:us-east Answer: B Explanation: node.labels.region == us-east matches nodes having that label.
Question 4.In a Swarm service, what does the --mode global flag achieve? A) Deploys a single replica across the cluster B) Deploys one task on every active node C) Deploys tasks only on manager nodes D) Deploys tasks only on worker nodes Answer: B Explanation: Global mode schedules exactly one task on each node that meets placement constraints. Question 5.What happens when you run docker service update --rollback? A) The service is removed and recreated from the original image B) The service’s tasks are stopped and the previous version is redeployed C) The service’s scaling is set back to 1 replica D) The service’s environment variables are cleared Answer: B Explanation: --rollback reverts a service to the previous successful configuration and image. Question 6.Which Docker Compose version key is required to deploy a stack with docker stack deploy? A) version: "2" B) version: "3" C) version: "1" D) version: "4" Answer: B Explanation: Docker Stack deploy supports Compose file format version 3 (or later) for Swarm mode.
Question 10.Which Dockerfile instruction is executed last during the image build process? A) FROM B) RUN C) CMD D) ENTRYPOINT Answer: C Explanation: CMD is metadata, not a build step; it is recorded after all other instructions are processed. Question 11.What does the docker image prune - a command do? A) Removes all stopped containers B) Deletes all dangling images only C) Deletes all unused images, including those with tags D) Removes all images regardless of usage Answer: C Explanation: -a tells Docker to remove any images not referenced by a container, even if they have tags. Question 12.How can you verify the integrity of a signed image when Docker Content Trust is enabled? A) docker trust inspect --pretty B) docker image verify C) docker pull (will fail if signature invalid) D) docker trust view Answer: C
Explanation: With DCT enabled, Docker will only pull images that have a valid signature; a bad signature aborts the pull. Question 13.What is the purpose of the EXPOSE instruction in a Dockerfile? A) Opens firewall ports on the host automatically B) Documents which ports the container listens on for external mapping C) Maps container ports to random host ports at runtime D) Enables network traffic encryption for the specified ports Answer: B Explanation: EXPOSE is metadata that informs users and tools about the intended listening ports. Question 14.Which storage driver provides the best performance on modern Linux kernels (≥ 4.0) and is the default for most distributions? A) aufs B) devicemapper C) overlay D) btrfs Answer: C Explanation: overlay2 is the recommended driver for kernels 4.0+ due to its simplicity and performance. Question 15.What does the --log-driver=syslog option configure for a container? A) Sends container logs to the Docker daemon’s JSON file B) Stores logs in a local syslog file on the host C) Streams logs to a remote syslog server
B) Universal Control Plane (UCP) C) Docker Trusted Registry (DTR) D) Docker Engine Answer: B Explanation: UCP implements RBAC, allowing administrators to define roles and permissions. Question 19.Which network driver allows containers to obtain an IP address from the host’s physical network interface? A) bridge B) overlay C) macvlan D) none Answer: C Explanation: macvlan assigns containers MAC addresses on the host’s network, making them appear as separate physical devices. Question 20.What does the docker network create - d overlay mynet command accomplish? A) Creates a bridge network named mynet B) Creates an overlay network for multi‑host communication in Swarm mode C) Creates a host network that shares the host’s network stack D) Creates a macvlan network attached to the default interface Answer: B Explanation: The -d overlay flag creates an overlay network usable across Swarm nodes. Question 21.How does Docker implement inter‑container communication on a user‑defined bridge network?
A) Through direct host‑level socket binding B) By assigning each container a unique MAC address on the host’s NIC C) Via an internal virtual Ethernet (veth) pair and a Linux bridge D) By using NAT rules in iptables only Answer: C Explanation: Docker creates a veth pair for each container and connects the host end to a Linux bridge, enabling L2 communication. Question 22.What is the purpose of the --publish 8080:80 flag when running a container? A) Exposes port 8080 inside the container and maps it to host port 80 B) Maps host port 8080 to container port 80, making the service reachable externally C) Publishes the container’s port 80 to all Swarm nodes automatically D) Enables load balancing across all containers listening on port 80 Answer: B Explanation: --publish hostPort:containerPort forwards traffic from the host’s 8080 to the container’s 80. Question 23.Which of the following statements about Docker secrets is true? A) Secrets are stored in plain text on the host file system B) Secrets can be updated at runtime without recreating the service C) Secrets are mounted as temporary files inside the container at /run/secrets D) Secrets are automatically encrypted when transmitted over the network but not at rest Answer: C Explanation: Docker injects secret values as files under /run/secrets with strict permissions. Question 24.What does the docker config create command allow you to store?
Question 27.What is the default replication factor for a service created without specifying -- replicas? A) 0 B) 1 C) 2 D) 3 Answer: B Explanation: If not specified, Swarm creates a single replica of the service. Question 28.How can you lock a Swarm to prevent new nodes from joining? A) docker swarm lock B) docker swarm update --lock true C) docker swarm pause D) docker swarm leave --force Answer: A Explanation: docker swarm lock prompts for a passphrase and prevents new join operations until unlocked. Question 29.What does the docker system df command display? A) Disk usage statistics for images, containers, and volumes B) CPU and memory usage of running containers C) Network bandwidth consumption per container D) Detailed logs of Docker daemon activities Answer: A Explanation: docker system df summarizes disk space used by Docker objects.
Question 30.Which of the following Dockerfile instructions creates a new layer? A) FROM B) LABEL C) ENV D) WORKDIR Answer: C Explanation: ENV creates a new layer because it modifies the image metadata; LABEL does not create a new layer, while FROM starts a new image. Question 31.What is the result of specifying HEALTHCHECK CMD curl - f http://localhost/ || exit 1 in a Dockerfile? A) Docker will restart the container automatically if the health check fails B) Docker will mark the container as unhealthy but take no further action C) Docker will prevent the container from starting if the health check fails once D) Docker will remove the container from the host immediately Answer: B Explanation: The health check status is reported; Docker does not automatically restart or remove the container. Question 32.In which scenario would you prefer the host network driver over bridge? A) When you need container isolation from the host’s network stack B) When you require maximum network performance with no NAT overhead C) When you want automatic service discovery via DNS D) When you need to assign static IPs from a custom subnet Answer: B
Explanation: json-file writes container logs to JSON-formatted files on the host. Question 36.Which command can be used to rotate the manager TLS certificates in a Swarm? A) docker swarm rotate-certs B) docker swarm update --cert-expiry 90d C) docker swarm ca --rotate D) docker node rotate-certs Answer: C Explanation: docker swarm ca --rotate regenerates the Swarm’s CA and issues new node certificates. Question 37.What does the --detach (-d) flag do when creating a Docker service? A) Runs the service in the foreground, showing logs B) Runs the service in detached mode, returning control to the CLI immediately C) Detaches the service from the Swarm network D) Prevents the service from being replicated Answer: B Explanation: -d starts the service and returns the prompt without streaming logs. Question 38.Which of the following best describes a Docker “stack”? A) A collection of Docker images stored in a registry B) A set of services defined in a Compose file and deployed to a Swarm C) A group of containers that share a common volume D) A single container with multiple processes running inside Answer: B
Explanation: A stack is a group of inter‑related services described by a Compose file and deployed with docker stack deploy. Question 39.What is the purpose of the --mount type=tmpfs option when running a container? A) Persists data on the host filesystem after container exit B) Creates an in‑memory filesystem inside the container, which is cleared on stop C) Mounts a host directory as read‑only inside the container D) Shares a Docker volume between multiple containers Answer: B Explanation: tmpfs mounts a temporary filesystem that lives only in memory and is removed when the container stops. Question 40.How can you limit a container to 256 MiB of memory? A) docker run --memory 256M … B) docker run --memory-limit 256MiB … C) docker run --mem 256MiB … D) docker run - m 256MiB … Answer: A Explanation: --memory (or -m) accepts size values like 256M to set the memory limit. Question 41.What does the docker info command display regarding Swarm mode? A) The number of running services only B) Whether Swarm is active and the node’s role (manager/worker) C) Detailed logs of all Swarm events D) The list of all images in the local registry Answer: B
D) By employing SELinux policies only Answer: B Explanation: cgroups provide the mechanism for limiting CPU, memory, block I/O, etc., per container. Question 45.What is the primary benefit of using a private Docker Trusted Registry (DTR)? A) Automatic scaling of containers across hosts B) Secure storage, signing, and scanning of images within an organization C) Real‑time log aggregation for all containers D) Built‑in orchestration of multi‑host services Answer: B Explanation: DTR offers private image storage, content trust signing, and vulnerability scanning. Question 46.Which of the following statements about Docker’s overlay2 driver is true? A) It requires a dedicated block device per container B) It supports copy‑on‑write semantics using multiple lower layers C) It cannot be used on a Docker Desktop for Mac environment D) It stores each layer as a separate Docker image file on the host Answer: B Explanation: overlay2 implements copy‑on‑write by stacking multiple read‑only layers with a writable top layer. Question 47.What does the docker swarm join-token worker --rotate command accomplish? A) Generates a new worker join token and invalidates the old one B) Restarts all worker nodes with a fresh token C) Rotates the Swarm’s CA certificate for workers only
D) Adds a new worker node to the Swarm automatically Answer: A Explanation: --rotate creates a new token, enhancing security by invalidating previous tokens. Question 48.How can you make a Docker service publish a port on every node in the Swarm (i.e., “mode=host” publishing)? A) docker service create --publish mode=host,protocol=tcp,target=80,published=8080 … B) docker service create --publish 8080:80/host … C) docker service create --mode global --publish 8080:80 … D) docker service create --publish mode=global,8080:80 … Answer: A Explanation: The mode=host option in the publish syntax binds the container port directly to each node’s host port. Question 49.What is the purpose of the docker node promote command? A) Converts a worker node into a manager node within the Swarm B) Increases the CPU quota of a node C) Moves a node from one Swarm cluster to another D) Upgrades the Docker Engine version on the node Answer: A Explanation: docker node promote changes the node’s role from worker to manager. Question 50.How does Docker’s “user‑namespace remapping” improve security? A) It encrypts all container file systems on disk B) It maps container root user (UID 0) to an unprivileged host UID, reducing privilege escalation risk
A) Docker will send SIGTERM to the container’s PID 1 when stopping the container B) Docker will ignore all signals except SIGTERM C) Docker will restart the container automatically after receiving SIGTERM D) Docker will convert all incoming signals to SIGTERM before delivering them Answer: A Explanation: STOPSIGNAL defines which signal Docker sends to the main process on docker stop. Question 54.Which of the following best describes a “service” in Docker Swarm? A) A single container instance running on a host B) A declarative definition that manages a set of identical tasks (containers) across the cluster C) A Docker image stored in a registry D) A network bridge that connects containers together Answer: B Explanation: A service defines the desired state (image, replicas, network, etc.) and Swarm ensures the tasks match that state. Question 55.How can you limit a Swarm service to run only on nodes that have the label ssd=true? A) docker service create --constraint node.labels.ssd == true … B) docker service create --placement-pref node.labels.ssd == true … C) docker service create --node-filter ssd=true … D) docker service create --label node.ssd=true … Answer: A Explanation: --constraint with node.labels.ssd == true restricts placement to matching nodes.
Question 56.What does the docker compose config command output? A) The merged and interpolated Compose file in canonical form B) A list of all running containers managed by Compose C) The logs of the last container started by Compose D) The current resource usage of the Compose project Answer: A Explanation: docker compose config renders the final Compose configuration after processing extensions and variables. Question 57.In a Dockerfile, which instruction is most appropriate for adding a tarball and automatically extracting it? A) COPY archive.tar.gz /app/ B) ADD archive.tar.gz /app/ C) RUN tar - xzf archive.tar.gz - C /app/ D) COPY --extract archive.tar.gz /app/ Answer: B Explanation: ADD will automatically extract local tar archives into the destination directory. Question 58.What is the default behavior of Docker when pulling an image that already exists locally but has a newer version in the registry? A) Docker always pulls the newer image regardless of local copy B) Docker checks the digest; if different, it pulls the newer image C) Docker prompts the user to confirm the pull D) Docker never pulls if an image with the same tag exists locally Answer: B Explanation: Docker compares image digests; if they differ, it downloads the newer image.