Q. Which command is used to start a container in the background?

  • (A) docker start -d container_name
  • (B) docker run -d container_name
  • (C) docker start container_name
  • (D) docker exec -d container_name
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker run -d container_name
Explanation: 'docker run -d container_name' starts a container in detached mode (background).

Q. Which of the following commands is used to create a new Docker network?

  • (A) docker network create network_name
  • (B) docker network add network_name
  • (C) docker create network network_name
  • (D) docker network init network_name
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker network create network_name
Explanation: 'docker network create network_name' is used to create a new Docker network.

Q. Which of the following is NOT a type of Docker network driver?

  • (A) bridge
  • (B) host
  • (C) overlay
  • (D) cloud
πŸ’¬ Discuss
βœ… Correct Answer: (D) cloud
Explanation: There is no 'cloud' network driver in Docker. 'bridge', 'host', and 'overlay' are valid network drivers.

Q. Which of the following command removes all unused images, containers, and networks?

  • (A) docker prune all
  • (B) docker system prune
  • (C) docker cleanup
  • (D) docker delete unused
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker system prune
Explanation: 'docker system prune' removes all unused images, containers, networks, and optionally volumes.

Q. What is the purpose of the 'docker-compose.yml' file?

  • (A) To define a set of Docker containers and services for an application
  • (B) To define a Docker network
  • (C) To configure Docker host settings
  • (D) To store Docker logs
πŸ’¬ Discuss
βœ… Correct Answer: (A) To define a set of Docker containers and services for an application
Explanation: 'docker-compose.yml' defines the configuration for a multi-container Docker application, including services, networks, and volumes.

Q. Which of the following Docker commands is used to build an image from a Dockerfile?

  • (A) docker create image
  • (B) docker build -t image_name .
  • (C) docker make image image_name
  • (D) docker image build -t image_name .
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker build -t image_name .
Explanation: 'docker build -t image_name .' is the command to build an image from a Dockerfile in the current directory.

Q. Which of the following is a command to list all running containers in Docker?

  • (A) docker list running
  • (B) docker ps
  • (C) docker containers list
  • (D) docker status
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker ps
Explanation: 'docker ps' lists all the running containers.

Q. Which of the following is used to allocate a specific amount of CPU to a Docker container?

  • (A) --cpu-shares
  • (B) --memory
  • (C) --cpu-limit
  • (D) --cpus
πŸ’¬ Discuss
βœ… Correct Answer: (A) --cpu-shares
Explanation: '--cpu-shares' is used to set CPU shares for a container in Docker.

Q. Which of the following is the correct way to expose a Docker container’s port to the host?

  • (A) docker run -p 8080:80 container_name
  • (B) docker run --port 8080:80 container_name
  • (C) docker expose -p 8080:80 container_name
  • (D) docker bind 8080:80 container_name
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker run -p 8080:80 container_name
Explanation: 'docker run -p 8080:80 container_name' is the correct command to expose a port from the container to the host.

Q. Which of the following is true about Docker containers?

  • (A) Containers are lightweight and run directly on the host OS without the need for a guest OS
  • (B) Containers require a virtual machine to run
  • (C) Containers are virtual machines
  • (D) Containers are slower than virtual machines
πŸ’¬ Discuss
βœ… Correct Answer: (A) Containers are lightweight and run directly on the host OS without the need for a guest OS
Explanation: Docker containers are lightweight and run directly on the host OS, sharing its kernel.