Search Tutorials


Docker MCQ Questions and Answers | JavaInUse

Docker MCQ Questions and Answers

Q. What is Docker?

A. A container management system
B. A virtual machine
C. A source code repository
D. A continuous integration tool

Q. What is the main advantage of using Docker?

A. Easy collaboration
B. Simplified deployment
C. Improved performance
D. All of the above

Q. What is a Docker image?

A. A template for creating containers
B. A running instance of a container
C. A snapshot of a container's file system
D. A set of instructions for building containers

Q. How do you create a Docker image?

A. Use the docker build command
B. Use the docker run command
C. Use the docker create command
D. Use the docker start command

Q. What is a Dockerfile?

A. A text file with instructions to build a Docker image
B. A configuration file for running Docker containers
C. A script file for automating Docker tasks
D. A manifest file for managing Docker images

Q. What is the difference between Docker and a virtual machine?

A. Docker is more lightweight and efficient
B. Docker provides a consistent environment across systems
C. Docker is easier to scale and manage
D. All of the above

Q. How do you run a Docker container?

A. Use the docker start command
B. Use the docker run command
C. Use the docker create command
D. Use the docker exec command

Q. How do you connect to a running Docker container?

A. Use the docker attach command
B. Use the docker exec command
C. Use the docker connect command
D. Use the docker shell command

Q. What is a Docker registry?

A. A repository for storing and distributing Docker images
B. A service for managing and deploying Docker containers
C. A platform for developing and testing Docker applications
D. A tool for monitoring and analyzing Docker containers

Q. How do you push a Docker image to a registry?

A. Use the docker push command
B. Use the docker upload command
C. Use the docker send command
D. Use the docker share command





Q. What is a Docker volume?

A. A directory on the host machine that is mounted into a container
B. A storage space allocated for a container's data
C. A network share accessible by multiple containers
D. A temporary file system used by containers

Q. How do you mount a volume in a Docker container?

A. Use the -v option with the docker run command
B. Use the docker volume create command
C. Use the docker mount command
D. Use the docker attach command

Q. What is a Docker network?

A. A virtual network that connects containers
B. A tool for managing container communication
C. A service for load balancing container traffic
D. A protocol for secure container communication

Q. How do you create a Docker network?

A. Use the docker network create command
B. Use the docker network start command
C. Use the docker network connect command
D. Use the docker network attach command

Q. How do you connect a container to a Docker network?

A. Use the --network option with the docker run command
B. Use the docker network connect command
C. Use the docker attach command
D. Use the docker exec command

Q. What is the purpose of the following Docker command?

docker run -d -p 8080:80 nginx
A.
It builds a new Docker image named nginx and runs it in the background, mapping port 8080 on the host to port 80 in the container.
B.
It pulls the latest nginx image from the Docker Hub and runs a container in detached mode, exposing port 80 from the container as port 8080 on the host.
C.
It starts a new container based on the nginx image, mapping port 80 from the host to port 8080 in the container, and runs it in the background.
D.
It creates a new Docker network named nginx and attaches the container to it, forwarding port 8080 from the host to port 80 in the container.

Q. Which of the following Dockerfile instructions is used to set environment variables in a Docker container?

A.
FROM
B.
RUN
C.
ENV
D.
EXPOSE

Q. What is the purpose of the .dockerignore file in a Docker project?

A.
It specifies a list of files and directories that should be included when building a Docker image, similar to a .gitignore file.
B.
It defines the base image to use for building the Docker image, similar to the FROM instruction in a Dockerfile.
C.
It specifies a list of files and directories that should be excluded when building a Docker image, improving build performance and reducing image size.
D.
It defines environment variables and default arguments for Docker commands, making it easier to manage and configure Docker builds and runs.

Q. Which of the following Docker commands is used to stop and remove all running containers?

A.
docker stop $(docker ps -a -q)
B.
docker rm -f $(docker ps -a -q)
C.
docker kill $(docker ps -a -q)
D.
docker rm -f $(docker ps -q)

Q. Which of the following Dockerfile instructions is used to set the working directory inside a Docker container?

A.
WORKDIR /app
B.
RUN cd /app
C.
ENV DIR /app
D.
EXPOSE /app