Docker MCQs – Docker Containers

21.) Which file system is used by Docker containers?

A) Ext4
B) Btrfs
C) UnionFS
D) NTFS

Answer: Option C

Explanation: Docker containers use UnionFS, a layered file system, for their storage.

22.) What is the default restart policy for a container?

A) Always
B) No
C) On-failure
D) Unless-stopped

Answer: Option B

Explanation: The default restart policy for a container is No, meaning it won’t restart automatically.

23.) What is the purpose of the docker exec command?

A) To create a new container
B) To restart a container
C) To remove a container
D) To run a command in a running container

Answer: Option D

Explanation: The docker exec command is used to run a command inside a running container.

24.) What is the default working directory inside a container?

A) /var
B) /root
C) / (root directory)
D) /home

Answer: Option C

Explanation: By default, the working directory inside a container is the root directory (/).

25.) How do you list all containers, including stopped ones?

A) docker ps
B) docker ps -a
C) docker containers
D) docker list –all

Answer: Option B

Explanation: The docker ps -a command lists all containers, including stopped ones.

26.) How do you rename a running container?

A) docker rename <old-name> <new-name>
B) docker rename <container-id>
C) docker name <container-id>
D) docker edit-name <container-id>

Answer: Option A

Explanation: The docker rename command renames a container from to .

27.) Which command shows the IP address of a running container?

A) docker ip
B) docker info
C) docker inspect
D) docker ps –ip

Answer: Option C

Explanation: The docker inspect command includes the container’s IP address in its detailed information.

28.) What is the default user inside a Docker container?

A) Admin
B) Root
C) Docker
D) System

Answer: Option B

Explanation: By default, the user inside a Docker container is root.

29.) How do you attach to a running container?

A) docker connect <container-id>
B) docker exec -it <container-id>
C) docker join <container-id>
D) docker attach <container-id>

Answer: Option D

Explanation: The docker attach command attaches your terminal to a running container.

30.) How do you copy files from a container to the host?

A) docker cp <container-id>:<src-path> <dest-path>
B) docker copy <container-id> <src-path>
D) docker export <src-path> <dest-path>
C) docker save <container-id>

Answer: Option A

Explanation: The docker cp command copies files from a container to the host or vice versa.

Leave a Reply

Your email address will not be published. Required fields are marked *