DCA Quality Assurance & Improvement 4 — Questions and Answers
Question 1: Which Docker Swarm feature automatically replaces a failed service task on a healthy node?
- Service constraints
- Task rescheduling via the reconciliation loop (Correct answer)
- Manual 'docker service scale' intervention
- Node drain followed by manual restart
Correct answer: Task rescheduling via the reconciliation loop
Swarm's manager continuously reconciles desired vs actual state and schedules new tasks to replace failed ones on healthy nodes automatically.
Question 2: A team wants to prevent 'latest' tags from being deployed to production Swarm services. Which approach enforces this policy?
- Use Docker Content Trust and only sign versioned tags
- Set DOCKER_TAG=latest in the daemon config
- Use image pinning in stack files with explicit digest references (Correct answer)
- Configure Swarm with --no-latest flag
Correct answer: Use image pinning in stack files with explicit digest references
Referencing images by digest in stack compose files ensures exactly the tested image is deployed, preventing accidental 'latest' mutations.
Question 3: What does the 'docker system prune -a' command remove, and what QA risk does it carry?
- Only stopped containers; low risk
- All unused images including those not linked to a container, risking removal of cached base images needed for CI builds (Correct answer)
- Only dangling images; no risk to tagged images
- All containers regardless of state; may delete running services
Correct answer: All unused images including those not linked to a container, risking removal of cached base images needed for CI builds
'-a' extends the prune to all unused images (not just dangling ones), which can delete base images cached for faster CI builds if no container references them.
Question 4: Which Docker logging driver is most appropriate for a production environment that requires centralized log aggregation with structured JSON output?
- json-file
- local
- syslog
- fluentd (Correct answer)
Correct answer: fluentd
The fluentd driver forwards logs to a Fluentd aggregator in real time, enabling structured, centralized log collection suitable for production observability.
Question 5: In a CI pipeline, 'docker build' exits with code 1. Which step should be taken first to diagnose the failure?
- Re-run with '--no-cache' to rule out stale layers
- Check the build log output for the specific RUN instruction that failed (Correct answer)
- Delete all local images and rebuild from scratch
- Switch to a different base image
Correct answer: Check the build log output for the specific RUN instruction that failed
The build log identifies the exact failing RUN step and its stderr, providing the most direct path to diagnosing the failure cause.
Question 6: What is the function of 'docker service rollback' compared to 'docker service update --rollback'?
- They are identical commands with different syntax
- 'docker service rollback' reverts to the previous service spec; '--rollback' is used to configure rollback parameters (Correct answer)
- Only 'docker service update --rollback' can revert image changes
- 'docker service rollback' deletes the service and redeploys from a snapshot
Correct answer: 'docker service rollback' reverts to the previous service spec; '--rollback' is used to configure rollback parameters
'docker service rollback' is a dedicated command that immediately reverts the service to its previous configuration, while '--rollback' in update sets rollback policy parameters.
Question 7: Which Dockerfile instruction, when used incorrectly, most commonly leads to unnecessarily large image sizes that fail image size quality gates?
- FROM
- COPY
- RUN (installing packages without cleaning up cache in the same layer) (Correct answer)
- EXPOSE
Correct answer: RUN (installing packages without cleaning up cache in the same layer)
Each RUN creates a new layer; installing packages and cleaning up in separate RUN instructions leaves the package cache committed in an intermediate layer, bloating the image.
Which Docker Swarm feature automatically replaces a failed service task on a healthy node?