# 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.

URL: https://levelrail.com/learn/docker/image-container-registry-explained/
Updated: 2026-11-27

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](https://levelrail.com/learn/glossary/#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.

```bash
docker pull nginx:1.27
docker run -d --name a nginx:1.27
docker run -d --name b nginx:1.27
docker ps
docker images
```

`docker 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

```bash
docker pull nginx:1.27
docker images
```

What 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

```bash
docker run -d --name web -p 127.0.0.1:8080:80 nginx:1.27
```

Using `-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](https://levelrail.com/learn/docker/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:

```bash
docker tag nginx:1.27 yourname/my-nginx:1.0
docker login
```

`docker 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

```bash
docker push yourname/my-nginx:1.0
```

What 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

- **`latest` is 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 login` writes 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.27` fails 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 with `docker image prune` (see [Free disk space with docker prune](https://levelrail.com/learn/docker/free-disk-space-with-docker-prune-safely/))).

## 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](https://levelrail.com/learn/deploy-operate/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 `.env` files into one (see [Environment variables and secrets](https://levelrail.com/learn/deploy-operate/environment-variables-and-secrets/))), and keep personal projects in private repositories.

## Related lessons

- [Run your first container](https://levelrail.com/learn/docker/run-your-first-container/)): start containers from images
- [Write your first Dockerfile](https://levelrail.com/learn/docker/write-your-first-dockerfile/)): build your own image to push
- [Update a container to a new image](https://levelrail.com/learn/docker/update-a-container-to-a-new-image/)): roll out a new tag
- [Rollbacks](https://levelrail.com/learn/deploy-operate/rollbacks/)): go back to a known good tag

## Next

Reclaim space safely with [Free disk space with docker prune, safely](https://levelrail.com/learn/docker/free-disk-space-with-docker-prune-safely/)).

## 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

- [Docker docs, Dockerfile reference](https://docs.docker.com/reference/dockerfile/)
