Q. Which of the following is a valid syntax to create a secret from a file?

  • (A) docker secret create my_secret < file.txt
  • (B) docker secret create file.txt my_secret
  • (C) docker secret add my_secret file.txt
  • (D) docker secret --add my_secret file.txt
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker secret create my_secret < file.txt
Explanation: The `<` operator is used to provide the contents of the file as input when creating a secret.

Q. In which directory are secrets mounted inside a running container?

  • (A) /secrets
  • (B) /docker/secrets
  • (C) /etc/secrets
  • (D) /run/secrets
πŸ’¬ Discuss
βœ… Correct Answer: (D) /run/secrets
Explanation: Secrets are accessible to containers as files under the `/run/secrets` directory.

Q. Can a secret be used in a standalone Docker container?

  • (A) Yes, always
  • (B) Only on Linux hosts
  • (C) No, secrets are only supported in Docker Swarm mode
  • (D) Only if the container has root access
πŸ’¬ Discuss
βœ… Correct Answer: (C) No, secrets are only supported in Docker Swarm mode
Explanation: Secrets management is available only when Docker is operating in Swarm mode.

Q. What is the default file permission for Docker secrets inside containers?

  • (A) 0777
  • (B) 0644
  • (C) 0600
  • (D) 0400
πŸ’¬ Discuss
βœ… Correct Answer: (D) 0400
Explanation: By default, secrets are mounted with 0400 permission to restrict access.

Q. Which of the following best describes a Docker secret?

  • (A) Encrypted environment variable
  • (B) Encrypted file mounted inside a container
  • (C) Image label containing credentials
  • (D) Temporary Docker volume
πŸ’¬ Discuss
βœ… Correct Answer: (B) Encrypted file mounted inside a container
Explanation: Docker secrets are encrypted and mounted as files in containers.

Q. Can you update the contents of a Docker secret directly?

  • (A) Yes, using docker secret update
  • (B) Yes, using docker secret edit
  • (C) No, you must delete and recreate it
  • (D) Yes, by editing the secret file in the container
πŸ’¬ Discuss
βœ… Correct Answer: (C) No, you must delete and recreate it
Explanation: Docker secrets are immutable. You must delete and recreate them to change their contents.

Q. What command lists all Docker secrets in a Swarm?

  • (A) docker secrets ls
  • (B) docker secret list
  • (C) docker secret ls
  • (D) docker secrets show
πŸ’¬ Discuss
βœ… Correct Answer: (C) docker secret ls
Explanation: `docker secret ls` lists all secrets available in the Docker Swarm.

Q. What happens when a secret is deleted using Docker CLI?

  • (A) It remains in use until manually removed from containers
  • (B) It is removed from all services using it
  • (C) It is automatically re-created on next restart
  • (D) It remains encrypted in Docker cache
πŸ’¬ Discuss
βœ… Correct Answer: (B) It is removed from all services using it
Explanation: Once deleted, the secret is removed from the Swarm and no longer available to services.

Q. Which of these best practices is recommended when working with secrets?

  • (A) Pass secrets as environment variables
  • (B) Mount secrets as volumes
  • (C) Access secrets via mounted files only
  • (D) Store secrets in image ENV instructions
πŸ’¬ Discuss
βœ… Correct Answer: (C) Access secrets via mounted files only
Explanation: The most secure practice is to use mounted files for accessing secrets.

Q. How are secrets encrypted in Docker?

  • (A) With TLS encryption at rest
  • (B) With symmetric encryption using AES
  • (C) With public-key encryption
  • (D) Using base64 encoding
πŸ’¬ Discuss
βœ… Correct Answer: (A) With TLS encryption at rest
Explanation: Docker uses TLS to encrypt secrets in transit and encrypts them at rest on disk in manager nodes.