Skip to main content
InterviewHubPRO
Section Overview
Q20

Question 20 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

40%
Docker & Containers (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

What is BuildKit and what advanced features does it provide?

senior LevelCode ExampleSystem Design

In Simple Words: BuildKit is the modern Docker build engine (enabled by default in modern Docker CLI or via DOCKER_BUILDKIT=1). It replaces the legacy serial build execution graph with an optimized Directed Acyclic Graph (DAG).

Key Features:

  1. Parallel Stage Execution: Independent stages in a multi-stage Dockerfile execute concurrently across multiple CPU cores.
  2. Cache Mounts (--mount=type=cache): Caches package manager directories across builds without saving them into the final image:
    dockerfile
    RUN --mount=type=cache,target=/root/.npm npm ci
    RUN --mount=type=cache,target=/root/.cache/pip pip install -r requirements.txt
    
  3. Secret Mounts (--mount=type=secret): Safely exposes API keys and SSH keys during build without layer leakage.
  4. SSH Forwarding (--mount=type=ssh): Clones private Git repositories using the host's existing SSH agent.