SteelReed

Search

Search posts, questions…

DevOps & CloudQuestion 9 / 35

Junior

How does a Docker image differ from a container, and how do registries, tags and push/pull work?

Short answer

An image is a read-only template made of layers; a container is one run of an image, with an extra temporary writable layer and a process. A registry (Docker Hub, GHCR, ECR, Harbor) stores and shares images, like GitHub for code.

docker builddocker pushdocker pulldocker rundocker runDockerfileRead-only imagemany layersRegistryImage on another hostContainer 1 + writable layerContainer 2 + writable layer

3 points to say:

  1. One image, many containers; editing files in a container only changes its writable layer, never the image.
  2. Image name = registry/repository:tag; tags can move, the digest sha256:... is what is immutable.
  3. Push/pull through a registry works like git push/git pull; removing a container (docker rm) does not touch the image (docker rmi).

Keep reading the deep dive

Create a free account to read the full explanation and follow-up questions, mark questions as studied and review them on a schedule.