What is Docker?
Docker is a platform for building, running, and shipping applications in isolated environments called containers. Think of a container as a lightweight, portable package that includes everything your application needs to run.
The Problem Docker Solves
"It works on my machine" — this is one of the most common phrases in software development. Docker eliminates this problem by ensuring that your application runs the same way everywhere:
- On your laptop
- On your colleague's machine
- In CI/CD pipelines
- In production
Key Concepts
Images
A Docker image is a read-only template that contains instructions for creating a container. It includes the application code, runtime, libraries, and dependencies.
# Pull an image from Docker Hub
docker pull node:20-alpineContainers
A container is a running instance of an image. You can start, stop, and delete containers without affecting the underlying image.
# Run a container
docker run -d -p 3000:3000 my-app
# List running containers
docker psDockerfile
A Dockerfile is a text file with instructions for building an image:
FROM node:20-alpine
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]Docker Architecture
Docker uses a client-server architecture:
- Docker Client — The CLI tool you interact with
- Docker Daemon — The background service that manages containers
- Docker Registry — Where images are stored (Docker Hub is the default)
In the next part, we'll explore how containers differ from virtual machines and why that matters.