MugUp logoMugUp
HomeBrowseAboutBlog
LoginSign Up
MugUp

Plan your day, study, read, write and track your habits in one app.

Follow MugUp

Product

  • Features
  • Compare
  • Free Tools
  • Deck Library
  • MugUp for Discord

Community

  • Blog
  • Changelog
  • Feature Requests
  • Deck Requests

Company

  • Home
  • About
  • Contact

© 2026 MugUp. All rights reserved.

Terms of ServicePrivacy PolicyCookie Policy
  1. Browse decks
  2. Docker and Kubernetes
  3. Writing Dockerfiles and Building Images
Public deck

Docker and Kubernetes

How containers are built and run with Docker, and how Kubernetes schedules, connects and heals them. Written for engineers who deploy and debug containerised apps.

Engineering
AShared by Alex Chen
0PlaySign in to clone

You’re reading a free preview. Sign up to see every topic and question — and to play this deck as games.

See the whole deck

Writing Dockerfiles and Building Images

The Dockerfile instructions, how the build cache works, and how to build images that are small, fast to rebuild and do not run as root.

Play topicBack to deck

Content

41 total questions

MCQ: 10
Fill-in: 8
Flashcards: 12
Pair match: 11
Writing Dockerfiles and Building Images – Flashcards
Flashcards

Card #1

FROM

Card #2

RUN

Card #3

COPY

9 more questions in this game

Showing 3 of 12. Sign up free to see the rest.

Sign up freeLog in
Writing Dockerfiles and Building Images – MCQ
Multiple Choice Questions
  1. 1. In a Node.js Dockerfile, COPY . . comes before RUN npm ci, and every code change reinstalls all the dependencies. What fixes it?

    • Add RUN npm cache clean --force on the line after the install step
    • Copy package.json and the lockfile, run npm ci, then copy the rest
    • Switch the base image to a slim variant of the same Node.js version
    • Move the WORKDIR instruction so it comes after the npm ci step runs
  2. 2. A Dockerfile has RUN apt-get update on one line and RUN apt-get install -y curl on the next. Months later, a package you add to the install line fails to download. Why?

    • The cached update layer still holds an old package index
    • apt-get install only works when it is in the first RUN line
    • Each RUN line starts from an empty filesystem, so no index exists
    • The base image deletes the apt index between each pair of RUN lines
  3. 3. One RUN step downloads a 300 MB archive and the next RUN step deletes it. How much does this add to the image?

    • Nothing, because the later layer removes it from the image
    • About 150 MB, because deleted files are compressed in later layers
    • Nothing once docker image prune has run on the build machine
    • Still about 300 MB, because the earlier layer keeps the file
7 more questions in this game

Showing 3 of 10. Sign up free to see the rest.

Sign up freeLog in
Writing Dockerfiles and Building Images – Fill-in-the-blank
Fill in the Blank
  1. 1. To keep a secret out of every layer, BuildKit can mount it for a single step with RUN --mount=type=___.

    Answer:secret

    Hint: The mount type is named after what it carries

  2. 2. RUN --mount=type=___ keeps a package manager's download folder between builds without storing it in the image.

    Answer:cache

    Hint: Where downloads are kept for reuse

  3. 3. The flag COPY --___=app:app sets the owner of the copied files in the same step, so no separate layer is needed to change ownership.

    Answer:chown

    Hint: The Linux command that changes a file's owner

5 more questions in this game

Showing 3 of 8. Sign up free to see the rest.

Sign up freeLog in
Writing Dockerfiles and Building Images – Pair match
Pair Match
WORKDIR↔Sets the working directory for the instructions that follow
LABEL↔Adds key-value metadata to the image
HEALTHCHECK↔Command Docker runs to test whether the container is healthy
8 more questions in this game

Showing 3 of 11. Sign up free to see the rest.

Sign up freeLog in