Q. Which Docker command is used to create a new Docker network?

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

Q. How can you scale a service in Docker Compose?

  • (A) Using the 'scale' option
  • (B) By modifying the service definition in the Compose file
  • (C) Using the 'docker-compose scale' command
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (D) All of the above
Explanation: Docker Compose provides multiple ways to scale services, including using the 'scale' option, modifying the Compose file, or using 'docker-compose scale'.

Q. What is the 'docker-compose down' command used for?

  • (A) To bring down a Docker container
  • (B) To stop and remove containers, networks, and volumes
  • (C) To view running services
  • (D) To build the Compose file
πŸ’¬ Discuss
βœ… Correct Answer: (B) To stop and remove containers, networks, and volumes
Explanation: 'docker-compose down' stops and removes all containers, networks, and volumes created by Docker Compose.

Q. Which of the following Docker commands is used to pull an image from a remote registry?

  • (A) docker push
  • (B) docker fetch
  • (C) docker pull
  • (D) docker get
πŸ’¬ Discuss
βœ… Correct Answer: (C) docker pull
Explanation: 'docker pull' is used to download an image from a remote registry like Docker Hub.

Q. What is the default command that Docker runs in a container if no command is specified?

  • (A) CMD
  • (B) ENTRYPOINT
  • (C) RUN
  • (D) BOTH CMD AND ENTRYPOINT
πŸ’¬ Discuss
βœ… Correct Answer: (A) CMD
Explanation: If no command is specified, Docker will use the default command specified in the Dockerfile as CMD.

Q. Which command is used to view Docker system-wide information?

  • (A) docker info
  • (B) docker details
  • (C) docker system info
  • (D) docker status
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker info
Explanation: 'docker info' provides system-wide information about Docker including number of containers, images, and the current Docker daemon settings.

Q. What is the main benefit of using Docker over virtual machines?

  • (A) Docker is faster and more lightweight
  • (B) Docker provides better isolation than virtual machines
  • (C) Docker is not dependent on hardware resources
  • (D) Docker can run on multiple operating systems without issue
πŸ’¬ Discuss
βœ… Correct Answer: (A) Docker is faster and more lightweight
Explanation: Docker containers are lightweight and faster than virtual machines because they share the host OS kernel rather than virtualizing hardware.

Q. Which command is used to push a Docker image to Docker Hub?

  • (A) docker push
  • (B) docker upload
  • (C) docker commit
  • (D) docker send
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker push
Explanation: 'docker push' is used to upload a local image to Docker Hub or another Docker registry.

Q. What does the 'docker exec' command do?

  • (A) Executes a command inside a running container
  • (B) Executes a new container
  • (C) Executes an image build
  • (D) Executes a Docker file
πŸ’¬ Discuss
βœ… Correct Answer: (A) Executes a command inside a running container
Explanation: 'docker exec' runs a command inside an already running container.

Q. What does the '--detach' or '-d' flag do when running 'docker run'?

  • (A) Runs the container in background mode
  • (B) Runs the container in interactive mode
  • (C) Assigns a random name to the container
  • (D) Forces the container to restart automatically
πŸ’¬ Discuss
βœ… Correct Answer: (A) Runs the container in background mode
Explanation: The '--detach' or '-d' flag runs the container in the background (detached mode).