QuizzesWriting Production-Grade Dockerfiles — Concept Check
intermediate
docker

Writing Production-Grade Dockerfiles — Concept Check

Questions on Writing Production-Grade Dockerfiles. Production Dockerfiles use multi-stage builds, non-root users, .dockerignore, explicit version pinning, and health checks to produce small, secure, reproducible images.

8 minutes 8 questions Pass at 70%
Time Limit
8 minutes - timer starts when you begin
Change Answers Freely
Revisit and change any answer before submitting
Full Review After Submit
Correct answers and explanations shown for every question
Auto-submit on timeout
Quiz submits automatically when time runs out

Questions in this quiz

8 questions on Writing Production-Grade Dockerfiles — Concept Check. Work through them here, then start the quiz to answer them and see your score.

  1. 1.You have a Dockerfile without multi-stage builds, resulting in a 700 MB image. What can you do to reduce the image size?

    • ARemove the .dockerignore file
    • BRun the container as root to save space
    • CUse multi-stage builds to separate build and runtime stages
    • DUse node:latest as the base image
  2. 2.A developer notices that their Docker build context size is 480 MB. What is a likely cause?

    • AThe application uses too many npm packages
    • BThe .dockerignore file is missing or incomplete
    • CThe container runs as a non-root user
    • DThe base image is too large
  3. 3.You notice that your Docker container runs as root. Why is this a security risk?

    • AIt increases the build context size
    • BIt prevents using multi-stage builds
    • CIt can give attackers root access to the host if the app is compromised
    • DIt makes the image larger
  4. 4.In a multi-stage Dockerfile, what happens to the intermediate stages after the final image is built?

    • AThey are included in the final image
    • BThey are discarded, reducing the final image size
    • CThey are run as non-root users
    • DThey are cached for faster builds
  5. 5.Why is it important to pin exact versions of base images in a Dockerfile?

    • ATo allow running the container as a non-root user
    • BTo ensure reproducibility and avoid unexpected changes
    • CTo improve the performance of the container
    • DTo reduce the image size
  6. 6.A developer argues that using 'node:latest' in a Dockerfile is a good practice. What is a potential issue with this approach?

    • AIt can lead to unexpected changes and non-reproducible builds
    • BIt guarantees the latest security patches
    • CIt makes the build process faster
    • DIt reduces the image size
  7. 7.Why should sensitive files like .env not be included in the Docker image?

    • AThey can leak secrets and sensitive data
    • BThey slow down the build process
    • CThey increase the image size
    • DThey prevent the use of multi-stage builds
  8. 8.What is the purpose of a HEALTHCHECK in a Dockerfile?

    • ATo improve build speed
    • BTo monitor the container's health and restart if needed
    • CTo ensure the container runs as a non-root user
    • DTo reduce the image size