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

  • (A) To download an image from a Docker registry
  • (B) To create a new image from a Dockerfile
  • (C) To push an image to a Docker registry
  • (D) To remove an image from the local machine
πŸ’¬ Discuss
βœ… Correct Answer: (A) To download an image from a Docker registry
Explanation: 'docker pull' is used to download an image from a registry like Docker Hub.

Q. Which Docker command would you use to enter an interactive shell inside a running container?

  • (A) docker exec -it
  • (B) docker run -it
  • (C) docker enter -it
  • (D) docker start -i
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker exec -it
Explanation: 'docker exec -it' is used to run an interactive shell inside a running container.

Q. What is Docker Swarm?

  • (A) A system for managing and orchestrating multi-container applications
  • (B) A networking tool for containers
  • (C) A Docker container image
  • (D) A tool for building Docker images
πŸ’¬ Discuss
βœ… Correct Answer: (A) A system for managing and orchestrating multi-container applications
Explanation: Docker Swarm is a native clustering and orchestration tool for Docker, allowing for the management of multi-container applications across multiple Docker hosts.

Q. How do you forcefully remove a running container?

  • (A) docker rm -f
  • (B) docker stop -f
  • (C) docker remove -f
  • (D) docker kill
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker rm -f
Explanation: 'docker rm -f' forces the removal of a running container.

Q. What is the purpose of the 'EXPOSE' instruction in a Dockerfile?

  • (A) To publish a container's port to the host
  • (B) To specify which ports the container will listen on
  • (C) To open a firewall port
  • (D) To map a container port to a host port
πŸ’¬ Discuss
βœ… Correct Answer: (B) To specify which ports the container will listen on
Explanation: The 'EXPOSE' instruction in a Dockerfile informs Docker that the container listens on the specified network ports at runtime. It does not publish the port to the host.

Q. Which command is used to view logs of a Docker container?

  • (A) docker logs
  • (B) docker view
  • (C) docker history
  • (D) docker inspect
πŸ’¬ Discuss
βœ… Correct Answer: (A) docker logs
Explanation: The 'docker logs' command is used to fetch the logs of a container. Use 'docker logs <container_id>' to view the logs.

Q. What is the purpose of Docker volumes?

  • (A) To store Docker images
  • (B) To persist data generated by Docker containers
  • (C) To manage Docker networks
  • (D) To monitor Docker containers
πŸ’¬ Discuss
βœ… Correct Answer: (B) To persist data generated by Docker containers
Explanation: Docker volumes are used to persist data generated by and used by Docker containers, even after the container is deleted.

Q. Which command is used to stop a running Docker container?

  • (A) docker halt
  • (B) docker stop
  • (C) docker kill
  • (D) docker pause
πŸ’¬ Discuss
βœ… Correct Answer: (B) docker stop
Explanation: The 'docker stop' command gracefully stops a running container by sending a SIGTERM signal. Use 'docker stop <container_id>'.

Q. What is the purpose of the 'ENTRYPOINT' instruction in a Dockerfile?

  • (A) To define the default command for the container
  • (B) To specify environment variables
  • (C) To set the working directory
  • (D) To expose network ports
πŸ’¬ Discuss
βœ… Correct Answer: (A) To define the default command for the container
Explanation: The 'ENTRYPOINT' instruction in a Dockerfile defines the default command that will be executed when the container starts.

Q. Which command is used to remove all stopped containers?

  • (A) docker rm -f
  • (B) docker prune
  • (C) docker clean
  • (D) docker rm $(docker ps -a -q)
πŸ’¬ Discuss
βœ… Correct Answer: (D) docker rm $(docker ps -a -q)
Explanation: The command 'docker rm $(docker ps -a -q)' removes all stopped containers by listing all container IDs and passing them to 'docker rm'.