💾Thananjhayan
← Back to notes

Docker Basics & Core Concepts

July 12, 2025

The building blocks of Docker, and the short answers I'd give in a viva.

The mental model

  • Image — a blueprint / template, built from a Dockerfile. Read-only.
  • Container — a running instance of an image (a live copy of the blueprint).
  • Dockerfile — instructions to build one image (one per service).
  • docker-compose.yml — defines and runs multiple containers together (orchestration).
  • Docker Hub — a cloud registry to store and share images. Like GitHub, but for images.

Viva questions & short answers

  • Dockerfile vs docker-compose? A Dockerfile builds one image; Compose runs many containers together.
  • Image vs container? Image = template; container = running instance of it.
  • What does EXPOSE do? Documents the port the app listens on — it does not publish it. ports: (Compose) or -p (CLI) actually publishes it.
  • Why tag with a username? Docker Hub needs the username/repo format to know where to push the image.
  • What does docker push do? Uploads the local image to the Docker Hub registry.
  • Why depends_on? Starts one service before another (e.g. backend before frontend).
  • Why can't the browser reach http://backend:5000? Service names only resolve inside the Docker network. The browser must use http://localhost:5000.

See also: [[dockerfile-instructions]], [[docker-cli-commands]], [[docker-compose]], [[docker-hub-push-images]].

💬 Comments