docker pull
docker pull downloads a container image from a registry to your local Docker image store. It matters because every container starts from an image, and pulling is how Docker gets the read-only layers and metadata needed before a container can run. Understanding pulls helps you choose reliable tags, troubleshoot registry errors, and avoid surprises from moving image versions.
Overview: How docker pull Works
An image is not one giant file. It is a set of read-only filesystem layers plus a configuration object that records metadata such as the default command, environment variables, exposed ports, architecture, and root filesystem layer order. A registry, such as Docker Hub, GitHub Container Registry, Amazon ECR, or a private company registry, stores those objects and serves them over the registry API.
When you run docker pull nginx:1.27-alpine, the Docker CLI sends a request to the Docker daemon. The daemon resolves the image name, contacts the registry, asks what content the tag points to, and downloads only the missing blobs. If some layers are already present because another image shares them, Docker reuses the local copies. Layers are content-addressed, so Docker can verify downloaded data by digest instead of trusting a filename.
Image names have several optional parts. The short name nginx:1.27-alpine expands to Docker Hub’s official image namespace, effectively docker.io/library/nginx:1.27-alpine. A fully qualified image such as ghcr.io/example/api:1.0 names a specific registry host. The tag is the part after the colon. Tags are human-friendly labels, but they are not immutable by design. A registry owner can move a tag to new content. A digest, such as nginx@sha256:..., identifies exact image content.
Many popular images are multi-platform. A single tag can refer to a manifest list, also called an image index, containing separate Linux AMD64, Linux ARM64, and sometimes Windows variants. Docker chooses the platform that matches your daemon by default. On Docker Desktop for macOS and Windows, remember that Linux containers run inside a managed Linux VM, so the platform decision is made for that Linux environment, not for a native macOS container runtime.
Pulling an image does not create or start a container. It only stores image content locally. Later, docker run can create a container from that image by mounting the read-only layers together and adding a thin writable container layer. Removing a container does not remove the image; removing an image does not remove a container that still references it.
Syntax
The general command form is:
docker pull [OPTIONS] NAME[:TAG|@DIGEST]
| Part | Meaning |
|---|---|
NAME |
The image repository name, optionally including a registry host and namespace, such as nginx, redis, or ghcr.io/example/api. |
:TAG |
A label that points to image content, such as :1.27-alpine. If omitted, Docker uses :latest. |
@DIGEST |
A content identifier, commonly @sha256:..., used when you need exact reproducibility. |
--platform |
Request a specific platform variant, such as linux/amd64 or linux/arm64, when the image supports it. |
-q or --quiet |
Suppress most progress output and print only concise pull results. |
-a or --all-tags |
Pull all tagged images in a repository. This can download a large amount of data and is rarely needed for normal development. |
Use docker pull when you want to prefetch an image, verify registry access, update a local tag, or make a deployment host ready before starting containers. docker run also pulls automatically when the requested image is missing, but an explicit pull makes the image-fetch step visible.
Examples
Example 1: Pull a Specific Image Tag
docker pull nginx:1.27-alpine
Output:
1.27-alpine: Pulling from library/nginx
Digest: sha256:65645c7bb6a0661892a8b03b89d0743208a18dd2f3f17a54ef4b76fb8e2f2a10
Status: Downloaded newer image for nginx:1.27-alpine
docker.io/library/nginx:1.27-alpine
The exact digest may differ as image maintainers publish updates, but the shape is consistent. Docker resolved the short name to Docker Hub’s library/nginx repository, downloaded any missing layers, verified them, and stored the tag locally. This does not start Nginx. It only prepares the image for later use.
Example 2: See the Local Image After Pulling
docker image ls nginx:1.27-alpine
docker image inspect --format '{{.Id}} {{.Architecture}}/{{.Os}}' nginx:1.27-alpine
Output:
REPOSITORY TAG IMAGE ID CREATED SIZE
nginx 1.27-alpine a8758716bb6a 3 weeks ago 48.3MB
sha256:a8758716bb6afc9d0e798f3f23b85eab5dbbd188d481dd8f6a25c57ed9b10c1a amd64/linux
The first command lists the local image reference. The second reads Docker’s local image metadata and prints the image ID plus the selected architecture and operating system. Image IDs and sizes vary, especially across platforms. If you are on an Apple Silicon machine, for example, the architecture may be arm64 unless you explicitly requested another platform.
Example 3: Pull a Specific Platform Variant
docker pull --platform linux/amd64 redis:7.2-alpine
docker image inspect --format '{{.Architecture}}/{{.Os}}' redis:7.2-alpine
Output:
7.2-alpine: Pulling from library/redis
Digest: sha256:05a97a479bc73de66f087dc05b569010772880f778cc8671fa6b8aadee32e5c6
Status: Downloaded newer image for redis:7.2-alpine
docker.io/library/redis:7.2-alpine
amd64/linux
--platform is useful when building or testing for a deployment target that differs from your workstation. Pulling a non-native platform does not make it fast to run; Docker may need emulation. Use it deliberately, and prefer matching the target platform in CI or production.
Example 4: Pull by Digest for Exact Content
docker pull nginx@sha256:65645c7bb6a0661892a8b03b89d0743208a18dd2f3f17a54ef4b76fb8e2f2a10
Output:
docker.io/library/nginx@sha256:65645c7bb6a0661892a8b03b89d0743208a18dd2f3f17a54ef4b76fb8e2f2a10: Pulling from library/nginx
Status: Image is up to date for nginx@sha256:65645c7bb6a0661892a8b03b89d0743208a18dd2f3f17a54ef4b76fb8e2f2a10
A digest pull asks for exact content rather than whatever a tag currently points to. In real work, copy the digest from a trusted registry page, from docker image inspect, or from a tested CI pipeline. Digests are long, but they are the strongest way to make sure every machine pulls the same image content.
How It Works Step by Step
- The Docker CLI parses the image reference and sends a pull request to the daemon through the active Docker context.
- The daemon expands short names when needed. For example,
nginx:1.27-alpineuses the default Docker Hub registry and thelibrarynamespace. - If the registry requires authentication, Docker uses credentials stored by
docker loginand its configured credential helper. - The daemon asks the registry for a manifest. For a multi-platform tag, it may first receive an index and then select the manifest matching the requested or default platform.
- The manifest lists layer blob digests and an image configuration digest. Docker checks which of those blobs already exist locally.
- Docker downloads only missing blobs, verifies their digests, decompresses or stores them as required by the storage driver, and records the image metadata.
- The tag or digest reference is added to the local image store. No container writable layer is created because no container has been started.
- Later,
docker runcan use this image immediately, mount its read-only layers, add a writable container layer, and start the configured process.
If a Dockerfile includes FROM nginx:1.27-alpine, the build system also needs that base image locally or available from a registry. With modern BuildKit builds, Docker can fetch base image metadata and layers as part of the build. The underlying concept is still the same: manifests point to exact content, layers are verified by digest, and cached local content is reused.
Common Mistakes
Relying on an Implicit latest Tag
docker pull nginx
This command means docker pull nginx:latest. The latest tag is not a promise that the image is newest, safest, or compatible with your app. It is only a tag name, and it can move. Prefer a tested, specific tag:
docker pull nginx:1.27-alpine
Thinking docker pull Starts a Container
docker pull redis:7.2-alpine
docker ps
The second command will not show Redis running because pull only downloads the image. Start a container separately:
docker run -d --name redis-cache redis:7.2-alpine
Expecting EXPOSE to Publish a Pulled Image’s Port
docker pull nginx:1.27-alpine
docker run --rm nginx:1.27-alpine
The Nginx image contains metadata for port 80, but EXPOSE is documentation only. It does not bind a host port. Publish one when you create the container:
docker run --rm -p 8080:80 nginx:1.27-alpine
Pulling All Tags by Accident
docker pull --all-tags nginx
This can download many versions and consume disk space quickly. Pull one tested tag unless you have a specific mirror, audit, or offline-cache reason to pull every tag.
Using a Digest Without Tracking Updates
docker pull nginx@sha256:65645c7bb6a0661892a8b03b89d0743208a18dd2f3f17a54ef4b76fb8e2f2a10
Digest pinning is reproducible, but it also means you will not automatically receive patched image content. Use digests with a process for updating and retesting them, especially for base images in production.
Best Practices
- Use explicit tags such as
nginx:1.27-alpine,redis:7.2-alpine, oralpine:3.20instead of relying on an implicitlatest. - For production, consider pinning by digest after testing so deployments pull exact content.
- Pull images before a deployment window when startup time and registry availability matter.
- Use
docker loginfor private registries and let Docker’s credential helper store tokens instead of putting secrets in commands or Dockerfiles. - Use
--platformonly when you intentionally need a non-default platform variant. - Check local images with
docker image lsand inspect metadata withdocker image inspect. - Clean unused local images with image-pruning commands when disk space is a problem, but do that separately from pulling so cleanup is deliberate.
- Remember that pulling images and running containers are separate operations. A pull changes the local image store; a run creates a container.
Practice Exercises
- Pull
alpine:3.20, then inspect its architecture and operating system. Hint: usedocker image inspect --formatto print only the fields you need. - Pull
nginx:1.27-alpine, list it locally, then run it on host port8090. Expected end state: the pull prepares the image, and the later run publishes the web server. - Find a repo digest for a pulled image using
docker image inspect. Then explain to yourself why a digest is more reproducible than a tag but still needs an update process.
Summary
docker pulldownloads image manifests, configuration, and missing read-only layers from a registry.- Pulling an image does not create a container or start a process.
- Short image names default to Docker Hub, while fully qualified names specify another registry host.
- Tags are convenient labels and may move; digests identify exact content.
- Docker verifies layer content by digest and reuses layers already present locally.
- Multi-platform tags can point to several platform-specific manifests, and
--platformselects one intentionally. - Use specific tags or tested digests for repeatable work, and avoid accidental reliance on
latest.
