Dockerfile MCQs with answers
67 questions tagged Dockerfile, each with the correct answer and an explanation. Page 2 of 4.
- Which instruction is used to run scripts after a container starts?
- Which Dockerfile instruction is used to add metadata to an image?
- How can you specify environment variables in a Dockerfile?
- What does the `EXPOSE` instruction do in a Dockerfile?
- Which instruction sets the working directory inside a Docker container?
- What is the function of the `CMD` instruction?
- Which Dockerfile instruction copies files from the host system to the container?
- What is the purpose of the `FROM` instruction in a Dockerfile?
- What happens if both `CMD` and `ENTRYPOINT` are defined?
- How do you override a CMD at runtime?
- Which instruction should be used to clean up cache during image build?
- Which instruction can be used to copy files with permission changes?
- What is the default shell in Dockerfile on Linux containers?
- How can you reduce image size while writing Dockerfiles?
- Which Dockerfile instruction defines the user to run subsequent commands?
- What’s the difference between `ADD` and `COPY`?
- Which instruction is best for downloading dependencies during image build?
- What does `VOLUME` do in Dockerfile?
- What is the result of using multiple `FROM` instructions?
- Which instruction allows combining multiple commands into one layer?