DCA Technology & Digital Tools 5 — Questions and Answers
Question 1: Which `docker inspect` format filter extracts only the container's IP address from the default bridge network?
- --format '{{.NetworkSettings.IPAddress}}' (Correct answer)
- --format '{{.Network.IP}}'
- --format '{{.Config.IP}}'
- --format '{{.Bridge.IP}}'
Correct answer: --format '{{.NetworkSettings.IPAddress}}'
`{{.NetworkSettings.IPAddress}}` is the correct Go template path to extract the container IP from bridge network settings.
Question 2: What does the `HEALTHCHECK` instruction in a Dockerfile do?
- Runs a command to test container health at build time
- Defines a command Docker periodically runs to assess if the container is healthy (Correct answer)
- Checks host system health before starting the container
- Validates network connectivity on container start
Correct answer: Defines a command Docker periodically runs to assess if the container is healthy
`HEALTHCHECK` tells Docker how to test a container's health; a failing check marks the container as `unhealthy` in `docker ps`.
Question 3: In Docker Swarm, which placement constraint syntax pins service tasks to nodes labeled `env=production`?
- --constraint 'node.label.env == production'
- --constraint 'node.labels.env == production' (Correct answer)
- --constraint 'label.env=production'
- --pin 'node.env=production'
Correct answer: --constraint 'node.labels.env == production'
The correct syntax references `node.labels.<key>` in a constraint expression to target nodes by their custom labels.
Question 4: Which log driver sends Docker container logs directly to a syslog endpoint?
- json-file
- gelf
- syslog (Correct answer)
- journald
Correct answer: syslog
The `syslog` log driver forwards container logs to a syslog server using RFC 5424 format over UDP, TCP, or TLS.
Question 5: What is the role of the Notary service in Docker Trusted Registry?
- Scans images for vulnerabilities
- Manages TLS certificates for the registry API
- Provides cryptographic signing and verification of image content (Correct answer)
- Handles user authentication for DTR
Correct answer: Provides cryptographic signing and verification of image content
Notary implements The Update Framework (TUF) to sign image manifests, enabling Docker Content Trust verification.
Question 6: Which command shows the history of layers in a Docker image, including the size of each layer?
- docker inspect --layers
- docker image layers
- docker history (Correct answer)
- docker image diff
Correct answer: docker history
`docker history <image>` lists each layer, the command that created it, and its uncompressed size.
Question 7: When a Docker Swarm service is updated with `--update-parallelism 2`, what does this control?
- The number of manager nodes that coordinate the update
- The number of task replicas updated simultaneously during a rolling update (Correct answer)
- The maximum number of failed tasks before rollback
- The delay between health checks during an update
Correct answer: The number of task replicas updated simultaneously during a rolling update
`--update-parallelism` sets how many replicas Swarm updates at the same time during a rolling update, balancing speed and availability.
Which `docker inspect` format filter extracts only the container's IP address from the default bridge network?