Docker
In short
Docker is an open-source platform for packaging an application and everything it needs into a container that runs the same way on any machine.
What is Docker?
Docker is a tool for building, sharing, and running containers. It packages an application together with its runtime, libraries, and configuration into a single unit, so it behaves the same on a developer's laptop, a test server, and in production. This solves the classic 'it works on my machine' problem.
You describe how to build your app in a text file called a Dockerfile. Running docker build turns it into an image, a read-only template stored in layers, and running docker run starts a container, which is a live, isolated instance of that image. Images are shared through registries such as Docker Hub, and Docker Compose lets you define and start multi-container setups, like an app plus its database, with one command.
Shipping containers inspired the idea: before standardized containers, every kind of cargo needed special handling, but a standard box fits on any ship, train, or truck. Docker images work the same way and run on any machine with a compatible container runtime.
Docker is often confused with containers themselves or with Kubernetes. Containers are the underlying technology, which Docker made popular and easy to use, and images built with Docker follow the open OCI standard, so they also run on other runtimes such as containerd and Podman. Kubernetes is a separate system that runs and manages many containers across a cluster of machines.
At a glance
Key takeaways
- Docker packages an application and its dependencies into a container image.
- A
Dockerfiledefines how the image is built. - An image is the template; a container is a running instance of it.
- Docker Compose runs multi-container applications on one machine.
- Docker images follow the OCI standard and work with other container runtimes too.
Example
# Start from an official Node.js base image
FROM node:24-alpine
# Set the working directory inside the container
WORKDIR /app
# Install dependencies first to take advantage of layer caching
COPY package*.json ./
RUN npm ci --omit=dev
# Copy the rest of the source code and define the start command
COPY . .
EXPOSE 3000
CMD ["node", "server.js"]Readers ask
What is the difference between Docker and a virtual machine?
A virtual machine emulates a full computer with its own operating system, while a Docker container shares the host's kernel and isolates only the application and its dependencies. As a result, containers are much smaller and start in seconds or less, while virtual machines provide stronger isolation.
What is the difference between a Docker image and a container?
An image is a read-only template that contains the application and its dependencies. A container is a running instance created from that image, and you can start many containers from the same image.
What is the difference between Docker and Kubernetes?
Docker builds and runs containers, usually on a single machine. Kubernetes orchestrates many containers across a cluster of machines, handling scheduling, scaling, and recovery from failures.
Often compared
See also
- ContainerDevOps & Cloud, p. 12A container is a lightweight, isolated package that bundles an application with its dependencies and runs it on the host's shared operating system kernel.
- KubernetesDevOps & Cloud, p. 32Kubernetes is an open-source system that automates deploying, scaling, and managing containerized applications across a cluster of machines.
- Virtual MachineDevOps & Cloud, p. 53A virtual machine is a software-based computer that runs its own operating system on shared physical hardware, isolated from other machines on the same host.
- DevOpsDevOps & Cloud, p. 14DevOps is a set of practices and a culture that brings software development and IT operations together to deliver software faster and more reliably.
- CI/CDDevOps & Cloud, p. 9CI/CD is a set of automated practices that build, test, and release code changes frequently, so software can be delivered to users quickly and safely.
- MicroservicesSoftware Architecture, p. 27Microservices are an architectural style where an application is split into small, independently deployable services that communicate over a network.
- Docker ComposeDevOps & Cloud, p. 18Docker Compose is a tool for defining and running multi-container applications, such as a web server plus a database, from one YAML file with one command.
Sources
Spotted a mistake or something missing on this page?Suggest an edit