Q. Can Docker secrets be used in non-Swarm containers?

  • (A) Yes, always
  • (B) No, secrets are only for Swarm services
  • (C) Yes, with environment variables
  • (D) Yes, through bind mounts
πŸ’¬ Discuss
βœ… Correct Answer: (B) No, secrets are only for Swarm services
Explanation: Docker secrets are only available to services running in Swarm mode.

Q. What is the default directory where secrets are mounted inside the container?

  • (A) /etc/docker/secrets/
  • (B) /var/lib/docker/secrets/
  • (C) /run/secrets/
  • (D) /docker/secrets/
πŸ’¬ Discuss
βœ… Correct Answer: (C) /run/secrets/
Explanation: Docker secrets are mounted at `/run/secrets/<secret_name>` inside the container.

Q. How do you remove a Docker secret?

  • (A) docker secret delete
  • (B) docker secret rm
  • (C) docker secret remove
  • (D) docker secret erase
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker secret rm
Explanation: Use `docker secret rm <secret_name>` to remove a Docker secret.

Q. Are Docker secrets encrypted at rest?

  • (A) Yes
  • (B) No
  • (C) Only on Linux systems
  • (D) Only if TLS is enabled
πŸ’¬ Discuss
βœ… Correct Answer: (A) Yes
Explanation: Secrets are encrypted at rest and in transit in Swarm mode.

Q. Can Docker secrets be updated in place?

  • (A) Yes, using docker secret update
  • (B) No, secrets must be deleted and recreated
  • (C) Only using Docker Compose
  • (D) Yes, using a Dockerfile
πŸ’¬ Discuss
βœ… Correct Answer: (B) No, secrets must be deleted and recreated
Explanation: Secrets are immutable; you must delete and recreate them to update.

Q. What happens to a secret after the container using it stops?

  • (A) It is removed from the Docker node
  • (B) It is stored permanently on disk
  • (C) It is still available for other services
  • (D) It becomes publicly visible
πŸ’¬ Discuss
βœ… Correct Answer: (C) It is still available for other services
Explanation: Secrets persist in Swarm until manually removed, and are not tied to the container lifecycle.

Q. In which directory can a container find its secrets in Docker Swarm?

  • (A) /data/secrets
  • (B) /run/secrets
  • (C) /tmp/secrets
  • (D) /etc/secrets
πŸ’¬ Discuss
βœ… Correct Answer: (B) /run/secrets
Explanation: Docker mounts secrets into containers at the `/run/secrets` path.

Q. Which of these can be stored as a Docker secret?

  • (A) Database connection strings
  • (B) TLS certificates
  • (C) API keys
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above
Explanation: Docker secrets can hold any sensitive information as text, such as API keys, TLS certs, and DB passwords.

Q. Which Docker Swarm role has access to manage secrets?

  • (A) Worker node
  • (B) All nodes
  • (C) Manager node
  • (D) Client-only node
πŸ’¬ Discuss
βœ… Correct Answer: (C) Manager node
Explanation: Only manager nodes can manage secrets in a Docker Swarm.

Q. Which of the following is a secure way to handle secrets in Docker?

  • (A) Storing in environment variables
  • (B) Including in Dockerfile
  • (C) Using Docker secrets
  • (D) Logging them to console
πŸ’¬ Discuss
βœ… Correct Answer: (C) Using Docker secrets
Explanation: The best practice is to use Docker secrets for secure handling of sensitive data.