Why Docker?

Docker revolutionized the way we build, ship, and run applications. Instead of saying “it works on my machine,” Docker ensures it works everywhere.

1. What is a Container?

A container is a lightweight, standalone, executable package of software that includes everything needed to run an application.

Docker Architecture Diagram

2. Images vs. Containers

An Image is a template (like a class), while a Container is a running instance of that image (like an object).

Key Commands:

  • docker build - Create an image from a Dockerfile.
  • docker run - Start a container.
  • docker ps - List running containers.

3. The Dockerfile

Your journey usually starts with a simple Dockerfile:

FROM node:18
WORKDIR /app
COPY . .
RUN npm install
CMD ["node", "index.js"]

Summary

Docker is the standard for modern development. In the next part, we will dive into Docker Compose!