Q. Which of the following Docker commands is used to view the history of an image?

  • (A) docker history image_name
  • (B) docker image history image_name
  • (C) docker inspect image_name
  • (D) docker logs image_name
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker history image_name
Explanation: 'docker history image_name' is used to view the history of an image.

Q. Which of the following is NOT a valid Docker command?

  • (A) docker list
  • (B) docker ps
  • (C) docker images
  • (D) docker rmi
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker list
Explanation: 'docker list' is not a valid Docker command. The correct command is 'docker ps' to list containers.

Q. Which of the following is the purpose of the 'docker-compose logs' command?

  • (A) Displays logs of a specific container
  • (B) Shows the logs of all services defined in a Docker Compose file
  • (C) Starts a service in a detached mode
  • (D) Stops a service in a Docker Compose application
πŸ’¬ Discuss
βœ… Correct Answer: (B) Shows the logs of all services defined in a Docker Compose file
Explanation: 'docker-compose logs' is used to show the logs of all services defined in the Docker Compose file.

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

  • (A) To add metadata to a Docker image
  • (B) To create a new container
  • (C) To rename a Docker image
  • (D) To assign a version or tag to a Docker image
πŸ’¬ Discuss
βœ… Correct Answer: (D) To assign a version or tag to a Docker image
Explanation: The 'docker tag' command is used to assign a version or tag to a Docker image. For example, 'docker tag my_image:latest my_image:v1.0'.

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

  • (A) docker upload
  • (B) docker push
  • (C) docker publish
  • (D) docker send
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker push
Explanation: The 'docker push' command is used to upload a Docker image to a registry like Docker Hub. For example, 'docker push my_image:latest'.

Q. What is the purpose of the 'docker system prune' command?

  • (A) To remove all Docker images
  • (B) To clean up unused Docker objects (images, containers, networks, etc.)
  • (C) To stop all running containers
  • (D) To delete all Docker volumes
πŸ’¬ Discuss
βœ… Correct Answer: (B) To clean up unused Docker objects (images, containers, networks, etc.)
Explanation: The 'docker system prune' command removes all unused Docker objects, including images, containers, networks, and build cache.

Q. What is the purpose of the 'docker-compose up' command?

  • (A) To build Docker images
  • (B) To start containers defined in a docker-compose.yml file
  • (C) To stop all running containers
  • (D) To push images to Docker Hub
πŸ’¬ Discuss
βœ… Correct Answer: (B) To start containers defined in a docker-compose.yml file
Explanation: The 'docker-compose up' command starts and runs the containers defined in the 'docker-compose.yml' file.

Q. Which command is used to list all Docker networks?

  • (A) docker network ls
  • (B) docker list networks
  • (C) docker net ls
  • (D) docker inspect networks
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker network ls
Explanation: The 'docker network ls' command lists all Docker networks on the host.

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

  • (A) To view resource usage statistics of running containers
  • (B) To list all Docker images
  • (C) To inspect Docker volumes
  • (D) To monitor Docker Hub activity
πŸ’¬ Discuss
βœ… Correct Answer: (A) To view resource usage statistics of running containers
Explanation: The 'docker stats' command provides real-time resource usage statistics (CPU, memory, etc.) for running containers.

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

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