Docker

Docker is a set of tools for building, sharing and running containers, including the Dockerfile format, Docker Engine, Docker Desktop, Docker Compose and the Docker Hub image registry.

Also known as: Docker Engine, Docker Desktop

Related terms in this glossary

How it works

Docker, released in 2013, made Linux containers practical for everyday developers. Its main pieces are:

  • Dockerfile: a text file of instructions that builds an image layer by layer, for example choose a base image, copy code, install dependencies, set the start command.
  • BuildKit: the build engine behind docker build, with caching, multi-stage builds and multi-platform images.
  • Docker Engine: the daemon that runs containers on a host, using containerd underneath.
  • Docker Compose: a YAML file that starts several related containers together, common for local development.
  • Docker Hub: a public registry for sharing images.

Docker images follow the Open Container Initiative (OCI) standards, so they run on other runtimes too. Kubernetes removed its built-in Docker Engine integration ("dockershim") in version 1.24 in 2022, and now talks to runtimes such as containerd or CRI-O directly. Images built with Docker still run on Kubernetes unchanged.

Why it matters

Docker is still the most common way developers build and test containers locally. A well-written Dockerfile has a large effect on image size, build speed and security: multi-stage builds keep compilers out of production images, and a non-root user limits damage if the app is compromised. Check Docker Desktop's license terms for larger companies. Gepton covers image and build work in Docker and containerization.

Docker in depth

Example: a production-grade Dockerfile, explained

Example: a hypothetical Go service. The Dockerfile has two stages. The build stage starts from an official Go image, copies the module files first and downloads dependencies, so that layer is cached until dependencies change, then copies the source and compiles a static binary. The final stage starts from a minimal base, copies only the binary, sets a numeric non-root user, exposes the port and sets the entry point. A .dockerignore file keeps the .git folder, local environment files and test data out of the build context. Built with BuildKit, the image is small, rebuilds quickly after code changes and carries no compiler or shell for an attacker to use.

Habits that make Docker builds fast and safe

  • Order layers by change frequency: dependencies before source code, so caches survive most commits.
  • Use cache mounts and remote caches: BuildKit can cache package manager directories and share build cache between CI runs.
  • Never put secrets in build arguments or layers: use BuildKit secret mounts for private registries or tokens needed during the build.
  • Pin base images: by version, and by digest for reproducible builds; rebuild regularly to pick up security fixes.
  • Build for the right platforms: docker buildx can produce images for both amd64 and arm64, useful when clusters use ARM instances.
  • Add metadata: OCI labels for source repository and commit make images traceable.

Docker Compose for local development

Compose describes an application and its dependencies, such as a database, cache and message broker, in one file, so a new developer can start the whole stack with one command. Good Compose setups mirror production versions of dependencies, use named volumes for data, load configuration from environment files that are not committed, and include health checks so services start in the right order. Compose is a development and testing tool for most teams; production usually runs on Kubernetes or a managed container service.

How to review a team's Docker usage

Look atHealthy sign
Image sizeProduction images contain no build tools or package caches
Build time in CISmall code changes rebuild quickly thanks to caching
UserContainers run as non-root
Scan resultsFew fixable critical findings, and base images refreshed regularly
Dockerfile consistencyShared templates per language rather than many hand-written variants

Common mistakes

  • Running apt-get update in one layer and install in another, which caches stale package lists.
  • Copying the entire repository before installing dependencies, which breaks caching.
  • Using latest tags in production manifests.
  • Mounting the Docker socket into containers, which effectively grants root on the host.
  • Assuming Docker Desktop licensing is the same for every company size without checking the current terms.

Docker builds containers that pipelines in CI/CD push to registries and that orchestrators run. Alternatives such as Podman and Buildah produce the same OCI images. We cover image design, build pipelines and migration to containers in Docker and containerization.

Questions about Docker

Something else? Send us your question and an engineer replies with next steps.

Do we still need Docker if we run Kubernetes?

Kubernetes no longer uses Docker Engine as its runtime, so clusters run containers through containerd or CRI-O. But developers still need a way to build images and run them locally, and Docker remains the most common tool for that, alongside alternatives such as Podman, Buildah and cloud build services. Images built with Docker are standard OCI images and run on Kubernetes unchanged. So Docker typically stays on developer machines and in CI, while the cluster uses a different runtime underneath.

How small should a container image be?

There is no fixed target, but smaller is usually better for security, pull time and storage. The practical goal is that the production image contains only what the application needs at runtime: no compilers, package managers, test files or caches. Multi-stage builds and minimal or distroless base images get most services there. Some languages and frameworks, such as those needing a full runtime or native libraries, will always produce larger images, and that is fine if every layer is intentional.

Articles that mention Docker

All articles

Jump to

↑↓ to move↵ to open