Docker image vs container vs registry, and how tags work
An image is a read-only template, a container is a running instance of an image, and a registry is a server that stores and shares images.
- Updated Nov 27, 2026
- Markdown
Tell images, containers and registries apart and push a tagged image to a registry.
- Docker installed
- A registry account such as Docker Hub (for the push step)
Image, registry, container and volume
- Pulling downloads an image from a registry to your server.
- Running starts a container, a live copy made from the image.
- The container writes its important data to a volume.
- Removing the container throws away its own changes, but the image and the volume stay.
- A new container starts from the same image.
- The volume is attached again, so the data is still there.
Static diagram
- RegistrypullImage
- ImagerunContainer
- Containerwrite dataVolume
- ContainerremoveImage
- Imagerun againContainer
- Volumedata is backContainer
A Docker image is a read-only template, a container is a running (or stopped) copy made from it, and a registry is a server that stores images so you can pull them elsewhere. An image tag such as postgres:16 is only a movable label for one version of an image.
How it works#
An image is a stack of read-only layers plus metadata (default command, ports, environment). A container is an image plus a thin writable layer and a running process. Many containers share the same image layers on disk, which is why starting a second container from the same image is cheap.
A registry stores images and serves them over HTTPS. Docker Hub is the default. An image reference has up to four parts: registry.example.com/team/app:1.0. Leave out the registry and Docker assumes Docker Hub. Leave out the tag and Docker assumes latest.
A tag is a label that points at an image. The owner can move it: postgres:16 today may be a newer build than last month, which is how patch updates arrive. The unchangeable identity of an image is its digest, a SHA-256 hash of its content, written image@sha256:.... docker pull downloads only layers you do not already have, and docker push uploads only layers the registry lacks.
A worked example, start to finish#
Follow one image from a registry to a running container.
docker pull nginx:1.27
docker run -d --name a nginx:1.27
docker run -d --name b nginx:1.27
docker ps
docker imagesdocker pull downloads the layers once. Containers a and b both start from the same image and share its layers on disk, each with its own thin writable layer. docker ps lists two containers, docker images lists one image. Remove them with docker rm -f a b. The image remains until you run docker rmi nginx:1.27.
To pin an image exactly, find its digest with docker images --digests and pull by it: docker pull nginx@sha256:DIGEST, where DIGEST is the value shown.
Step 1: Pull an image#
docker pull nginx:1.27
docker imagesWhat you should see: lines for each layer pulled, then a Digest line and a status saying the image is downloaded. docker images lists nginx with tag 1.27, an image ID and a size.
Step 2: Run a container from it#
docker run -d --name web -p 127.0.0.1:8080:80 nginx:1.27Using -p 8080:80 instead would expose the port on all interfaces, so binding to 127.0.0.1 keeps it private (see Publish container ports safely).
What you should see: a container ID, and docker ps lists web using image nginx:1.27.
Step 3: Tag and log in#
To push to your own account, the image name must start with your registry username:
docker tag nginx:1.27 yourname/my-nginx:1.0
docker logindocker tag does not copy anything. It adds a second name to the same image. docker login asks for your username and a password or access token. Prefer an access token that you can revoke.
What you should see: docker images shows both names with the same image ID. Login prints “Login Succeeded”.
Step 4: Push#
docker push yourname/my-nginx:1.0What you should see: a line per layer, mostly “Mounted from” or “Layer already exists” since the layers came from nginx, then a digest and size.
Anyone with access can now run docker pull yourname/my-nginx:1.0. Private registries work the same way, with the registry host in front of the name, for example registry.example.com/team/app:1.0, and docker login registry.example.com.
Check it worked#
docker images lists nginx:1.27 and yourname/my-nginx:1.0 with the same image ID. After the push, the repository and the 1.0 tag appear on the registry website. To see the digest of a local image, run docker images --digests, or docker inspect --format '{{index .RepoDigests 0}}' nginx:1.27 for a pulled one.
Edge cases and gotchas#
latestis not “newest”. It is the default tag name, and publishers may never update it. Pin a version tag in Compose files and deploy scripts.- Tags move, digests do not. If a rebuild must be byte-identical, pin
image@sha256:.... The trade-off is that you must update the digest yourself to get security fixes. - Pull rate limits exist. Anonymous pulls from Docker Hub are limited, and many servers behind one address share the allowance. Log in, or mirror important images in your own registry.
- Architecture matters. Many images are multi-platform, and Docker picks the one matching your CPU. If none matches you get an error like “no matching manifest for linux/arm64/v8”. Build or pull for the right platform.
- Credentials are stored on disk.
docker loginwrites to~/.docker/config.json, which anyone with access to your account can read. Use scoped tokens, and log out (docker logout) on shared machines. - Removing a container does not free its image.
docker rmi nginx:1.27fails with an error that the image is being used by a container until you remove that container. - Untagged
<none>images appear after rebuilds. They are old layers whose tag moved to a new build. They are safe to clean withdocker image prune(see Free disk space with docker prune).
Troubleshooting#
| Symptom | Likely cause | Fix |
|---|---|---|
denied: requested access to the resource is denied on push | Not logged in, or the name does not start with your username | docker login, then re-tag as yourname/repo:tag |
pull access denied for X, repository does not exist or may require 'docker login' | Typo, private repo, or not logged in | Check the name, log in |
manifest unknown | That tag does not exist in the repository | List tags on the registry website and fix the tag |
no matching manifest for linux/arm64/v8 (or amd64) | No image variant for your CPU | Use another tag or build for your platform |
unauthorized: incorrect username or password | Wrong credentials or an expired token | Create a new token and log in again |
x509: certificate signed by unknown authority | A private registry with an untrusted certificate | Install the CA certificate on the Docker host |
| Pull fails with a rate-limit message | Too many anonymous pulls | Log in, or use a mirror |
| Others cannot pull your pushed image | The repository is private, or the tag is wrong | Check the repository visibility and the exact name:tag |
docker pull keeps giving an old version | A local image with that tag already exists, or the tag was never updated upstream | Pull explicitly, or pin a newer tag |
Real-world scenario#
A deploy script runs docker pull myapp:latest and docker compose up -d. One Monday the app behaves differently, and nobody changed the server. Someone pushed a new build to latest on Friday, and the server pulled it during a restart.
You change the Compose file to a version tag, yourname/myapp:1.4, and build and push a new tag for every release. For the one service where an exact image matters, you pin the digest. Rolling back is now a one-line edit to the tag, which ties into Rollbacks. The same registry also serves the staging server, so both pull identical bytes.
Quick reference#
| Task | Command |
|---|---|
| Download an image | docker pull nginx:1.27 |
| List local images with digests | docker images --digests |
| Add a second name | docker tag SOURCE yourname/app:1.0 |
| Log in / out | docker login, docker logout |
| Upload | docker push yourname/app:1.0 |
| Remove a local image | docker rmi nginx:1.27 |
| Private registry reference | registry.example.com/team/app:1.0 |
Security and safety notes#
- Anything in an image can be read by anyone who can pull it. Never bake passwords, keys or
.envfiles into one (see Environment variables and secrets), and keep personal projects in private repositories.
Related lessons#
- Run your first container: start containers from images
- Write your first Dockerfile: build your own image to push
- Update a container to a new image: roll out a new tag
- Rollbacks: go back to a known good tag
Next#
Reclaim space safely with Free disk space with docker prune, safely.
Check what you learned
Frequently asked questions
Does deleting a container delete its image?
No. You can start many containers from one image, and removing a container leaves the image in place. Remove images separately with docker rmi.
What happens if I do not give a tag?
Docker uses the tag latest. It is just a name, not a promise of the newest version, so pin a specific tag for anything important.
Is a tag permanent?
No. A tag is a movable label, and the owner can point it at a new image at any time. For an exact, unchanging reference use the digest, written image@sha256:...
Where does docker login keep my credentials?
In ~/.docker/config.json, unless a credential helper stores them elsewhere. Use an access token instead of your account password, and keep that file private.
Sources
Keep going: guides and tutorials
- Deploy a Docker Compose App Self-Hosted: Web, Redis and Rollback Deploy a Docker Compose app on your own server with Levelrail: a web service and Redis, a bad release that does not take traffic, and a compose rollback.
- Docker Container Restarting in a Loop: 5 Causes, Fixed Five real reasons a Docker container keeps restarting, each reproduced with its exit code, the command that finds it and the fix. Then the same crash on Levelrail.
- Deploy an Express App to a VPS With Docker and Health Checks Deploy a Node.js Express API to your own server with no Dockerfile. Covers the port rule, a health route, secrets, deploy failure codes and rollback.