Knowledgebase

Find frequently asked questions and setup guides by searching or by browsing the categories.

The Short Answer

Docker is a tool that packs an application together with everything it needs to run (libraries, runtime, configuration) into an image, and runs that image as a container: an isolated group of processes that shares the host's Linux kernel. The same image runs the same way on a laptop, a test server, and a production server, which removes most "it works on my machine" problems.

docker run -d --name web -p 8080:80 nginx

This one command downloads the official Nginx image if it is not on the server yet, starts a container from it in the background, and makes it reachable on port 8080 of the server. The options are explained in docker run.

Image and Container

An image is a read-only template: a file system in layers, plus a note of which command to start. A container is a running instance of an image with a thin writable layer on top. You can start many containers from one image, and removing a container does not touch the image. The idea of a container in general is covered in what is a container.

The Main Parts

PartWhat it is
Docker EngineThe background service
dockerThe command you type
DockerfileThe recipe for an image
RegistryA store of images
ComposeSeveral containers, one file

A Dockerfile lists the steps that build an image from a base image; see Dockerfile. A registry holds images that you pull and push; Docker Hub is the default one, and you can run a private registry. Compose describes an application of several containers, with its networks and volumes, in a compose.yaml file; see how to install Docker Compose and docker compose up -d.

Data, Ports, and Networks

  • Volumes: a container's writable layer is lost when the container is removed. Databases and uploads belong in a volume, which lives on outside the container; see Docker volumes.
  • Ports: a container has its own network stack. -p 8080:80 maps a port of the host to a port in the container; see Docker port mapping.
  • Networks: containers on the same user-defined network reach each other by name; see Docker networks.

What It Is Good for on One Server

  • Several applications side by side, each with its own version of PHP, Node.js, or Python, without conflicts.
  • Clean installs and removals: deleting a container leaves no packages behind on the host.
  • Repeatable setups: a compose.yaml file in a Git repository rebuilds the whole stack on a new server.
  • Updates and rollbacks: pull a new image tag and recreate the container; keep the old tag to go back.

What Docker Is Not

Not a virtual machine. A container has no kernel of its own. It starts in moments, but it can only run Linux software on the host's Linux kernel. A VM boots its own kernel; see what is a virtual machine.

Not a security boundary on its own. Containers share the host kernel, and a container started with extra privileges, or with the Docker socket mounted inside it, can control the host. Membership in the docker group grants root-level privileges on the host; see Docker without sudo. Keep images updated and run applications as a non-root user inside the container.

Docker Engine and Docker Desktop

On a server you install Docker Engine: the service and the command-line tools, with no graphical interface. Docker Desktop is a separate application for developer workstations that bundles the engine with a graphical interface and runs it inside a small Linux VM. For a server, follow how to install Docker on Ubuntu or how to install Docker on Debian.

Docker and Podman

Podman runs the same images with nearly the same commands, but without a central background service, and it is built to run containers as an ordinary user (rootless). On AlmaLinux and Rocky Linux it comes from the distribution's own repositories, which do not ship Docker. The comparison is in Podman vs Docker, and the everyday commands are collected in the Docker commands cheat sheet.

Was this answer helpful?
Loading...