Q. Which of the following is a valid way to mount a volume inside a container?

  • (A) docker run -v /app:/data nginx
  • (B) docker run nginx:/data /app
  • (C) docker mount /data:/app nginx
  • (D) docker start -mount /app:/data nginx
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker run -v /app:/data nginx
Explanation: The `-v` or `--mount` flags are used to mount volumes.

Q. What happens when you remove a container using a volume?

  • (A) The volume is automatically deleted
  • (B) Only the container is deleted, volume persists
  • (C) Both are deleted
  • (D) Nothing happens
πŸ’¬ Discuss
βœ… Correct Answer: (B) Only the container is deleted, volume persists
Explanation: Volumes are not deleted when a container is removed unless specified using `--volumes`.

Q. Which flag is used to mount volumes using long syntax in `docker run`?

  • (A) --add
  • (B) --mount
  • (C) --use
  • (D) --volume
πŸ’¬ Discuss
βœ… Correct Answer: (B) --mount
Explanation: `--mount` provides a clearer and more flexible syntax for mounting volumes compared to `-v`.

Q. Which type of volume is managed by Docker and stored in the Docker directory?

  • (A) Host bind mount
  • (B) Named volume
  • (C) Anonymous volume
  • (D) Shared volume
πŸ’¬ Discuss
βœ… Correct Answer: (B) Named volume
Explanation: Named volumes are created and managed by Docker and stored in `/var/lib/docker/volumes/`.

Q. Which of the following is a difference between a bind mount and a named volume?

  • (A) Bind mounts are stored in memory
  • (B) Named volumes are more portable and safer to share
  • (C) Named volumes require root access
  • (D) Bind mounts are encrypted by default
πŸ’¬ Discuss
βœ… Correct Answer: (B) Named volumes are more portable and safer to share
Explanation: Named volumes are managed by Docker and are more suitable for sharing between containers.

Q. Which command removes all unused volumes?

  • (A) docker volume clear
  • (B) docker volume flush
  • (C) docker volume prune
  • (D) docker volume clean
πŸ’¬ Discuss
βœ… Correct Answer: (C) docker volume prune
Explanation: `docker volume prune` removes all unused volumes to free up space.

Q. What type of volume is created when no name is specified in `docker run -v /data`?

  • (A) Named volume
  • (B) Temporary volume
  • (C) Anonymous volume
  • (D) Manual volume
πŸ’¬ Discuss
βœ… Correct Answer: (C) Anonymous volume
Explanation: If no name is given, Docker creates an anonymous volume automatically.

Q. Which is the default network driver in Docker?

  • (A) host
  • (B) bridge
  • (C) overlay
  • (D) macvlan
πŸ’¬ Discuss
βœ… Correct Answer: (B) bridge
Explanation: Docker uses the 'bridge' driver as the default network driver for standalone containers.

Q. Which Docker network driver allows containers on the same host to communicate?

  • (A) overlay
  • (B) host
  • (C) bridge
  • (D) none
πŸ’¬ Discuss
βœ… Correct Answer: (C) bridge
Explanation: The 'bridge' network driver creates a private network that allows containers on the same host to communicate.

Q. What does the 'host' network driver do in Docker?

  • (A) Assigns a random port
  • (B) Isolates container from the host
  • (C) Removes networking capabilities
  • (D) Uses the host's network stack directly
πŸ’¬ Discuss
βœ… Correct Answer: (D) Uses the host's network stack directly
Explanation: With the 'host' driver, the container shares the host's network stack.