D
DevPrepSystematic Prep
DEVPREP CODEX · #06

Docker Interview Questions

150 curated questions graded from Foundations (Easy) to Practical Patterns (Medium) and Internals & Architecture (Hard).

TOTAL QUESTIONS

150

THEORY QUESTIONS

150

IMPLEMENTATION FOLIOS

0

FREE QUESTIONS

5 / Level

Easy Level·50 Questions Total

Foundations & Core Concepts

Open Full Easy List
Q1What is Docker? How does it differ from a Virtual Machine (VM)?
  • Docker: A containerization platform that packages apps and dependencies into lightweight, portable containers sharing the host OS kernel.
  • Virtual Machine: Runs a complete guest OS on virtualized hardware via a hypervisor.
  • Key Differences:
    • OS Kernel: Docker shares the host kernel; VMs have independent guest kernels.
    • Size: Containers are megabytes; VMs are gigabytes.
    • Startup: Containers boot in milliseconds; VMs take minutes.
    • Overhead: Containers have near-zero overhead; VMs suffer high CPU/RAM virtualization tax.
Q2Explain the differences between an Image and a Container.
  • Docker Image: An immutable, read-only template containing code, runtime, libraries, and config. Acts as the blueprint (class in OOP).
  • Docker Container: A runtime instance of an image. Represents an isolated process running on the host (object in OOP).
  • Writable Layer: A container adds a thin, temporary writable layer on top of the image's immutable layers to store modifications.
Q3What is the purpose of the FROM directive in a Dockerfile?
  • Base Image: Specifies the starting parent image (e.g., FROM alpine:3.18) for subsequent instructions.
  • Position: Must be the first non-comment instruction (unless defining build-time variables via ARG first).
  • Multi-stage: Can appear multiple times in a single Dockerfile to initiate new build stages.
Q4Explain the difference between RUN, CMD, and ENTRYPOINT.
  • RUN: Executes commands during the build phase to install packages and create new image layers.
  • CMD: Defines default runtime commands/arguments that can be easily overridden by appended arguments in docker run.
  • ENTRYPOINT: Configures a container to run as an executable. Appended arguments in docker run are added to the entrypoint rather than overriding it.
Q5How do COPY and ADD differ in a Dockerfile?
  • COPY: Safely copies local files or directories from the host context into the container filesystem. (Preferred for standard copies).
  • ADD: Has two additional features:
    • Can fetch files from remote URLs.
    • Automatically extracts compressed tar/gzip/zip files into the container destination.
45 More Easy Questions Locked

Unlock the complete Docker Easy question bank

Get instant access to all 50 questions, in-depth model answers, code sandboxes, and all 27+ technologies for a single one-time payment.

Unlock All — One-time payment · Lifetime access
DEDICATED LEVEL PAGES

Browse All Docker Questions by Difficulty

INTERNAL LINKING & DEPENDENCIES

Related Technologies to Docker

CAREER PATHWAYS

Docker is a key requirement for these engineering roles:

Docker Interview Questions — Easy, Medium & Hard | DevPrep | DevPrep