Q. What is the purpose of the 'docker inspect' command?

  • (A) To view logs of a container
  • (B) To display detailed information about a Docker object
  • (C) To list running containers
  • (D) To build a Docker image
πŸ’¬ Discuss
βœ… Correct Answer: (B) To display detailed information about a Docker object
Explanation: The 'docker inspect' command provides detailed information about Docker objects such as containers, images, volumes, and networks.

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

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

Q. What is the purpose of the 'docker exec' command?

  • (A) To execute a command in a running container
  • (B) To start a new container
  • (C) To build a Docker image
  • (D) To stop a running container
πŸ’¬ Discuss
βœ… Correct Answer: (A) To execute a command in a running container
Explanation: The 'docker exec' command is used to run a command inside a running container. For example, 'docker exec -it <container_id> bash'.

Q. What is the purpose of the 'docker commit' command?

  • (A) To save changes made to a container as a new image
  • (B) To push an image to Docker Hub
  • (C) To create a new container
  • (D) To delete a Docker image
πŸ’¬ Discuss
βœ… Correct Answer: (A) To save changes made to a container as a new image
Explanation: The 'docker commit' command is used to create a new image from a container's changes. For example, 'docker commit <container_id> new_image_name'.

Q. Which Docker command is used to build a Docker image from a Dockerfile?

  • (A) docker create
  • (B) docker build
  • (C) docker run
  • (D) docker generate
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker build
Explanation: 'docker build' is used to create a Docker image from a Dockerfile.

Q. What is a Docker 'service' in the context of Docker Swarm?

  • (A) A single container running on the Swarm cluster
  • (B) A group of containers managed by Docker Swarm
  • (C) A networking resource for containers
  • (D) A task for orchestrating containers
πŸ’¬ Discuss
βœ… Correct Answer: (B) A group of containers managed by Docker Swarm
Explanation: A Docker 'service' in Docker Swarm is a set of containers deployed and managed together, often across multiple nodes.

Q. Which of the following is a valid Docker command to view the logs of a container?

  • (A) docker logs container_name
  • (B) docker view container_logs
  • (C) docker status container_name
  • (D) docker exec container_name logs
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker logs container_name
Explanation: 'docker logs container_name' is used to view the logs of a running or stopped container.

Q. What is Docker Hub?

  • (A) A tool for building Docker images
  • (B) A public repository for Docker images
  • (C) A network service for containers
  • (D) A tool for orchestrating Docker containers
πŸ’¬ Discuss
βœ… Correct Answer: (B) A public repository for Docker images
Explanation: Docker Hub is a public registry where Docker images can be stored and shared.

Q. What does the 'docker-compose up' command do?

  • (A) Starts the services defined in a docker-compose.yml file
  • (B) Stops the services in a docker-compose.yml file
  • (C) Builds the Docker image from the Dockerfile
  • (D) Uploads a Docker image to Docker Hub
πŸ’¬ Discuss
βœ… Correct Answer: (A) Starts the services defined in a docker-compose.yml file
Explanation: 'docker-compose up' starts the services defined in a 'docker-compose.yml' file.

Q. What is the purpose of Docker's multi-stage builds?

  • (A) To build images with multiple base images to reduce the image size
  • (B) To add multiple layers to a Docker image
  • (C) To automate the deployment of containers
  • (D) To run containers on multiple machines
πŸ’¬ Discuss
βœ… Correct Answer: (A) To build images with multiple base images to reduce the image size
Explanation: Multi-stage builds allow you to use multiple FROM statements in the Dockerfile to reduce image size by removing unnecessary dependencies.