## glossary
What is Docker?
Docker is a containerization platform that packages an application together with all of its dependencies — libraries, runtime, configuration — into an isolated, portable unit called a container. The goal is to kill the oldest sentence in software development: "it works on my machine".
The promise holds because the container carries its entire environment with it. The exact artifact you tested on your laptop is what runs in staging and in production, bit for bit.
A container is not a virtual machine
The confusion is common and the difference matters. A virtual machine emulates hardware and runs a full operating system with its own kernel — which costs gigabytes and minutes to boot. A container shares the host kernel and isolates only the process and file space, costing megabytes and milliseconds.
- VM — stronger isolation, high overhead, boots in minutes, gigabyte-sized images.
- Container — process-level isolation, low overhead, starts in seconds, megabyte-sized images.
Image, container and Dockerfile
The three concepts fit together like this: the Dockerfile is the recipe, the image is the finished, immutable cake, and the container is a slice being served — a running instance of that image. From a single image you can spin up as many containers as you want.
# stage 1 — compiles with all the tooling
FROM node:20 AS build
WORKDIR /app
COPY package*.json ./
RUN npm ci
COPY . .
RUN npm run build
# stage 2 — only what is needed to run
FROM node:20-alpine
WORKDIR /app
COPY --from=build /app/dist ./dist
COPY --from=build /app/node_modules ./node_modules
USER node
EXPOSE 3000
CMD ["node", "dist/server.js"]Everyday commands
docker build -t my-api:1.0 . # builds the image
docker run -p 3000:3000 my-api:1.0 # starts a container
docker ps # lists running containers
docker logs -f <id> # follows the logs
docker exec -it <id> sh # opens a shell inside the container
docker compose up -d # brings up the project stackPrecautions that save you headaches
Containers are ephemeral: everything written inside them disappears when they die. Data that needs to survive goes into volumes or external services. Also, never put secrets in the Dockerfile — they get baked into the image layers and are recoverable by anyone who pulls it. Use environment variables or a secrets manager. The full guide is in Docker in programming.
## faq
Frequently asked questions
What is the difference between Docker and Kubernetes?
Docker builds and runs containers on one machine. Kubernetes orchestrates containers across many machines, handling scaling, distribution, failure recovery and networking between them. They are complementary: Kubernetes usually runs containers built with Docker.
Does Docker work well on Windows and macOS?
It works, but with an extra layer: since containers depend on the Linux kernel, Docker Desktop runs a lightweight virtual machine underneath. That means disk performance below native Linux, which is noticeable in projects with many files.
Do I need Docker for small projects?
Not always. For a solo project with few dependencies, it adds complexity without a clear payoff. The value shows up when there are multiple services, several developers, or a need for strict parity between development and production.
## read next