nextRound
TechnologiesCoding ProblemsBookmarksLearning Paths
nextRound
TechnologiesCoding ProblemsBookmarksLearning Paths
nextRound

AI-powered interview preparation platform. Practice with curated questions, mock interviews, and personalized learning paths to crack your dream tech interview.

Quick Links

  • Technologies
  • Saved Questions
  • Pricing

Company

  • About Us
  • Contact Us

Legal

  • Privacy Policy
  • Terms of Use

© 2026 nextRound. All rights reserved.

TOPIC OVERVIEW

Docker/Dockerfile

The recipe that defines exactly how an image gets built, instruction by instruction.

10 QuestionsIntermediateHigh Priority ~11 min read

Instructions run in order, each generally producing a layer. RUN executes at build time and bakes its result into a layer, while CMD and ENTRYPOINT define what actually runs when a container starts, not during the build. The common point of confusion is overridability: CMD is easily overridden by arguments passed to docker run, while ENTRYPOINT generally isn't unless explicitly overridden with a flag — and the two are often combined, with ENTRYPOINT defining the fixed command and CMD supplying its default arguments.

COPY and ADD look interchangeable but aren't: ADD has extra built-in behavior (fetching from a remote URL, auto-extracting local tar archives) that makes it less predictable, which is exactly why COPY is generally preferred for straightforward file copying. .dockerignore keeps the build context small and cache-friendly by excluding files that shouldn't be sent to the build at all. And a subtle but important detail: deleting a file in a later RUN instruction doesn't shrink the image, since the earlier layer where that file was created already baked its size into the image history — cleanup has to happen in the same layer that created the file to actually matter.

What you'll walk away knowing

The difference between RUN (build-time) and CMD/ENTRYPOINT (container start-time), and how they're overridden
Why COPY is generally preferred over ADD despite ADD having more built-in features
What .dockerignore does for build context size and cache efficiency
Why deleting a file in a later RUN layer doesn't reduce the image size, and what to do instead
1What does the COPY instruction do in dockerfile?Intermediate2What does CMD do in dockerfile?Beginner3What does EXPOSE do in a Dockerfile?Intermediate4What is a Dockerfile?Intermediate5What does the ADD instruction do?Intermediate6What does the FROM instruction do in dockerfile?Beginner7What is .dockerignore and why is it important?Intermediate8What does the RUN instruction do in dockerfile?Intermediate9What does WORKDIR do in dockerfile?Intermediate10What does ENV do in dockerfile?Intermediate
All Topics
1
Basics
Engine
Using Docker
2
Images
Hub
Dockerfile
3
Container
Volumes and Storage
Compose
4
CI-CD
Security
Performance
Sharethis topic

Share via WhatsApp, X, Facebook, LinkedIn or copy link. Open Graph preview enabled.