Core Concepts · Quick recall Q&A

1 min read
Foundational2 min read
Rapid overview

Quick recall Q&A

1. Explain Docker image layers

  • Each Dockerfile instruction creates a layer
  • Layers are cached and reused
  • Changes in early layers invalidate subsequent layer cache
  • Use multi-stage builds to reduce final image size

2. What's the difference between CMD and ENTRYPOINT?

  • ENTRYPOINT: Defines the executable (harder to override)
  • CMD: Provides default arguments (easily overridden)
  • Combined: ENTRYPOINT ["executable"] + CMD ["arg1", "arg2"]

3. How do you optimize Docker image size?

  1. Use minimal base images (alpine, distroless)
  2. Multi-stage builds
  3. Combine RUN commands
  4. Remove unnecessary files in same layer
  5. Use .dockerignore
  6. Don't install dev dependencies

4. Explain Docker networking modes

  • Bridge: Default isolated network, containers communicate via container names
  • Host: Container uses host's network, no isolation
  • None: No network access
  • Overlay: Cross-host networking for orchestration

See also