docker pull
- Docker & Kubernetes course
- Beginner
- Lesson 39/82
- 4 min
Learn to pull images from a registry with docker pull.
docker pull
docker pull downloads an image from the registry. The image arrives in layers; layers already present locally aren't downloaded again (Already exists):
$ docker pull python:3.12-slim
3.12-slim: Pulling from library/python
a2318d6c47ec: Already exists
7f9a2c0b1d3e: Pull complete
Digest: sha256:9c4f…
Status: Downloaded newer image for python:3.12-slimdocker run pulls automatically if the image is missing; but it doesn't update an image that exists.
Platform and digest
Images are published for several processor architectures (amd64, arm64). Docker picks the one matching your machine; another architecture can be requested with --platform. Pulling by digest guarantees exactly the same content:
docker pull --platform linux/arm64 nginx:alpine
docker pull nginx@sha256:2d19…
docker run --pull always nginx:alpine # check for the latest every timePractice Run with the current image
Write two commands: pull the python:3.12-slim image; then start a container named web in the background, checking the registry for the current nginx:alpine image every time.
Starter code
# buraya yazSample solution
docker pull python:3.12-slim
docker run -d --pull always --name web nginx:alpineExpected output
Status: Downloaded newer image for python:3.12-slim alpine: Pulling from library/nginx Status: Image is up to date for nginx:alpine 9d8c7b6a5f4e
Questions and answers
Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.
1 With an old nginx:alpine locally, what does docker run nginx:alpine do?
- It uses the old local image Correct answer
- It always downloads the newest
- It errors
- It merges the two
Explanation: To update, docker pull or docker run --pull always is used.
2 Pull an image for the ARM architecture.
docker pull ____ linux/arm64 nginx:alpine
docker pull --platform linux/arm64 nginx:alpine
Explanation: --platform takes os/architecture.
3 Match.
| Term | Meaning |
|---|---|
Already exists |
Layer exists locally |
Pull complete |
Layer downloaded |
--platform |
Architecture choice |
@sha256: |
Immutable content |