21.) What does the EXPOSE instruction in a Dockerfile do?
A) Publishes a port to the host machine
B) Maps container ports to host ports
C) Opens all container ports
D) Specifies the ports the container listens on
22.) What is the difference between a Docker image and a container?
A) A container is a running instance of an image
B) An image is a running instance of a container
C) Containers and images are the same
D) Images store logs, while containers run processes
23.) How do you export a Docker image to a file?
A) docker save
B) docker export
C) docker push
D) docker tar
24.) What is an image ID in Docker?
A) A unique identifier for a container
B) A hash that uniquely identifies a Docker image
C) A tag assigned to an image
D) A unique identifier for Docker Hub
25.) Which command removes all unused Docker images?
A) docker rmi
B) docker prune
C) docker system prune
D) docker clean
26.) What happens if you use docker build without a tag?
A) The build will fail
B) Docker assigns a default tag of latest
C) The image is tagged with the username
D) The image is built without a tag
27.) Which command optimizes the size of a Docker image by removing intermediate layers?
A) docker prune
B) docker image clean
C) docker build –squash
D) docker optimize
28.) What happens if multiple CMD instructions are used in a Dockerfile?
A) All CMD instructions are executed sequentially.
B) The last CMD instruction overrides the previous ones.
C) Docker throws an error during the build process.
D) Only the first CMD instruction is executed.
Related