Docker Quiz - MCQ - Multiple Choice Questions

Docker is a platform that simplifies the development, deployment, and management of applications inside containers. This blog post aims to cover the essential concepts of Docker through a set of 30 multiple-choice questions. Each question includes an answer and an explanation to help you understand the fundamental aspects of Docker better.

1. What is Docker?

a) Programming Language
b) Text Editor
c) Containerization Platform
d) Web Server

2. Which command is used to create a new Docker image?

a) docker build
b) docker pull
c) docker run
d) docker commit

3. What does the Dockerfile contain?

a) Compiled source code
b) Docker images
c) Binary data
d) Instructions for building a Docker image

4. What is a Docker container?

a) A running instance of a Docker image
b) A lightweight virtual machine
c) A storage volume
d) A service running on Docker Swarm

5. What command is used to list all running Docker containers?

a) docker list
b) docker show
c) docker ps
d) docker display

6. Which command pulls an image from Docker Hub?

a) docker get
b) docker fetch
c) docker pull
d) docker download

7. How can you run a command inside an existing Docker container?

a) docker exec
b) docker attach
c) docker run
d) docker enter

8. Which command is used to remove a Docker image?

a) docker rmi
b) docker remove
c) docker del
d) docker erase

9. What is Docker Compose?

a) A scripting language for Docker
b) A continuous integration tool for Docker
c) A tool for defining and running multi-container Docker applications
d) A Docker CLI plugin

10. Which of the following is the default registry used by Docker?

a) Kubernetes Hub
b) Container Store
c) Docker Hub
d) Image Hub

11. What is the primary purpose of the Docker Engine?

a) To provide a graphical visualization of containers
b) To build and run containers
c) To manage databases inside containers
d) To interface with Kubernetes

12. Which of the following commands logs you into Docker Hub from the CLI?

a) docker login
b) docker auth
c) docker sign-in
d) docker connect

13. What does the -d flag do in the docker run command?

a) Deletes the container
b) Displays detailed information
c) Detaches the container (runs in the background)
d) Downloads the latest image

14. How do you specify a Dockerfile other than the default "Dockerfile" during the build process?

a) Use --filename option
b) Use --source option
c) Use --file option
d) Use --dockerfile option

15. In Docker, what is a bridge network?

a) A public network accessible from outside
b) A private network segment created for a specific container
c) A way to connect multiple containers to the internet
d) A network connecting containers to each other on the same host

16. How can you share storage volumes between containers?

a) Using --volumes-from
b) Using --share-storage
c) Using --link
d) Using --connect-volumes

17. Which of the following is not a valid storage driver for Docker?

a) aufs
b) btrfs
c) zfs
d) ntfs

18. What is the primary function of the .dockerignore file?

a) To list all images to be pulled from the Docker Hub
b) To specify commands to run inside a container
c) To prevent certain files and directories from being copied into an image
d) To provide metadata about a Docker image

19. Which Docker command shows the history and intermediate layers of an image?

a) docker inspect
b) docker details
c) docker history
d) docker layers

20. In a docker-compose.yml file, what is the function of the depends_on key?

a) Specifies the base images for services
b) Specifies the build context for services
c) Specifies the order in which services are started
d) Specifies the network links between services

21. What is the primary purpose of Docker Swarm?

a) Image version management
b) Multi-host container orchestration
c) Container storage optimization
d) Automated container build pipeline

22. What command initializes a node as a Docker Swarm manager?

a) docker swarm init
b) docker swarm start
c) docker swarm create
d) docker swarm manager

23. Which of the following is not a Docker network type?

a) bridge
b) host
c) overlay
d) transit

24. Which command is used to view the logs of a running Docker container?

a) docker logs CONTAINER_ID/NAME
b) docker show-logs CONTAINER_ID/NAME
c) docker view CONTAINER_ID/NAME
d) docker inspect CONTAINER_ID/NAME

25. What command creates a new volume in Docker?

a) docker volume create
b) docker create volume
c) docker volume new
d) docker new volume

26. How can you inspect the details of a Docker network?

a) docker network view NETWORK_NAME
b) docker network show NETWORK_NAME
c) docker network detail NETWORK_NAME
d) docker network inspect NETWORK_NAME

27. Which command stops a running Docker container?

a) docker kill CONTAINER_ID/NAME
b) docker pause CONTAINER_ID/NAME
c) docker halt CONTAINER_ID/NAME
d) docker stop CONTAINER_ID/NAME

28. How can you see all images available on your local machine?

a) docker show images
b) docker list images
c) docker images
d) docker img

29. How do you remove a Docker volume?

a) docker remove-volume VOLUME_NAME
b) docker rmvol VOLUME_NAME
c) docker volume rm VOLUME_NAME
d) docker delete VOLUME_NAME

30. Which command connects a container to a Docker network?

a) docker network connect NETWORK_NAME CONTAINER_NAME
b) docker connect NETWORK_NAME CONTAINER_NAME
c) docker attach NETWORK_NAME CONTAINER_NAME
d) docker link NETWORK_NAME CONTAINER_NAME

Comments

Spring Boot 3 Paid Course Published for Free
on my Java Guides YouTube Channel

Subscribe to my YouTube Channel (165K+ subscribers):
Java Guides Channel

Top 10 My Udemy Courses with Huge Discount:
Udemy Courses - Ramesh Fadatare