Docker MCQ Banner

Docker Multiple Choice Questions (MCQs) and Answers

Master Docker with Practice MCQs. Explore our curated collection of Multiple Choice Questions. Ideal for placement and interview preparation, our questions range from basic to advanced, ensuring comprehensive coverage of Docker concepts. Begin your placement preparation journey now!

Q31

Q31 After installing Docker, you see a 'Permission Denied' error when running a Docker command. What should you do?

A

Reinstall Docker

B

Restart Docker

C

Add your user to the Docker group

D

Run Docker as root

Q32

Q32 Which Dockerfile instruction is used to specify the base image?

A

RUN

B

FROM

C

CMD

D

ENTRYPOINT

Q33

Q33 What is the default storage driver used by Docker on Linux?

A

aufs

B

overlay2

C

btrfs

D

zfs

Q34

Q34 What is the purpose of the ADD instruction in Dockerfile?

A

Copies files to the container

B

Runs commands inside the container

C

Exposes ports

D

Sets environment variables

Q35

Q35 What does the CMD instruction in Dockerfile specify?

A

The base image

B

Default command to run in the container

C

Environment variables

D

Networking configuration

Q36

Q36 What is a multi-stage build in Docker?

A

A single-stage Dockerfile

B

A way to create lightweight images

C

A process for creating containers

D

A debugging mechanism

Q37

Q37 What is the main difference between COPY and ADD in Dockerfile?

A

ADD is faster than COPY

B

COPY allows unpacking tar files

C

ADD can copy files from a URL

D

COPY exposes ports

Q38

Q38 How do you list all Docker images on your system?

A

docker ps

B

docker images

C

docker list

D

docker inspect

Q39

Q39 How do you remove an unused Docker image?

A

docker remove

B

docker rmi

C

docker clean

D

docker prune

Q40

Q40 How do you build a Docker image using a Dockerfile?

A

docker create -f Dockerfile

B

docker run -f Dockerfile

C

docker build -t .

D

docker image create Dockerfile

Q41

Q41 What should you check if a Docker image build fails?

A

Check the image version

B

Check the Dockerfile syntax

C

Check the container logs

D

Check the Docker network

Q42

Q42 An image build fails with the error 'no space left on device.' What should you do?

A

Restart Docker

B

Remove unused images and containers

C

Increase system storage

D

Rebuild the image

Q43

Q43 An image build fails due to missing dependencies. How can this be resolved?

A

Add dependencies in the Dockerfile

B

Restart the system

C

Rebuild the container

D

Remove the image

Q44

Q44 What is the role of namespaces in Docker containers?

A

To provide isolated file systems

B

To share resources across containers

C

To manage container logs

D

To configure container networks

Q45

Q45 What happens to the data in a container when it is stopped?

A

The data is saved to a local database

B

The data is lost unless persisted using volumes

C

The data is automatically backed up

D

The data is synchronized with the host

Q46

Q46 Which command is used to stop a running Docker container?

A

docker halt

B

docker stop

C

docker terminate

D

docker shutdown

Q47

Q47 How do you check the logs of a running container?

A

docker logs

B

docker view

C

docker inspect

D

docker console

Q48

Q48 Which flag is used with 'docker run' to allocate a pseudo-TTY to a container?

A

-d

B

-p

C

-t

D

-it

Q49

Q49 What is the primary difference between a bind mount and a volume?

A

Volumes are created automatically

B

Bind mounts are stored in Docker's default storage

C

Volumes are managed by Docker while bind mounts rely on the host file system

D

Bind mounts cannot persist data

Q50

Q50 How do you run a container interactively?

A

docker start -i

B

docker run -it

C

docker create -it

D

docker run -d

Q51

Q51 How do you restart a stopped container?

A

docker start

B

docker restart

C

docker run

D

docker reload

Q52

Q52 How do you execute a command inside a running container?

A

docker exec -it

B

docker run

C

docker attach

D

docker run --exec

Q53

Q53 What should you check if a container fails to start?

A

Check the container logs

B

Restart the Docker service

C

Remove the image

D

Check the host network settings

Q54

Q54 You cannot connect to a service running in a container. What might be the issue?

A

The container is not running

B

The host port is not mapped to the container port

C

The container image is corrupted

D

The Docker CLI is outdated

Q55

Q55 A container is consuming too much memory. How can this be managed?

A

Increase system memory

B

Stop the container

C

Set resource limits using --memory

D

Rebuild the container

Q56

Q56 What is a Docker volume?

A

A temporary file system

B

A command-line tool

C

A mechanism to persist data

D

A network configuration

Q57

Q57 What is the default location for Docker volumes on Linux?

A

/var/lib/docker/volumes

B

/docker/volumes

C

/var/volumes

D

/docker-data

Q58

Q58 What is the primary benefit of using named volumes over anonymous volumes?

A

Better performance

B

Easier management and reusability

C

Faster creation

D

Automatic backup

Q59

Q59 Which command lists all Docker volumes?

A

docker volume show

B

docker volume list

C

docker volume ls

D

docker volumes

Q60

Q60 What is the primary difference between bind mounts and named volumes?

A

Bind mounts are stored in Docker's default location

B

Named volumes are stored outside the container

C

Bind mounts map to specific host paths while volumes are managed by Docker

D

Named volumes are temporary

ad verticalad vertical
ad