docker pull
is a command you can use to pull an image from a remote registry. Registry like Docker Hub has most of the base images you use to create an image. So, when you use pre-built images then you can use pull
command without needing to define and configure your own.
$ docker pull [OPTIONS] NAME[:TAG|@DIGEST]
Here,
Options:
--all-tags
, -a
→ Download all tagged images in the repository--disable-content-trust
→ Skip image verification--platform
→ Set platform if the server is multi-platform--quiet
, -q
→ Suppress verbose output$ docker pull hello-world
latest: Pulling from library/hello-world
2db29710123e: Pull complete
Digest: sha256:13e367d31ae85359f42d637adf6da428f76d75dc9afeb3c21faea0d976f5c651
Status: Downloaded newer image for hello-world:latest
docker.io/library/hello-world:latest
Note: If no tag is provided, Docker Engine uses the :latest
tag as a default tag.
Or, you can use tags to download specific tagged image:
$ docker pull hello-world:linux
linux: Pulling from library/hello-world
Digest: sha256:7693efac53eb85ff1afb03f7f2560015c57ac2175707f1f141f31161634c9dba
Status: Downloaded newer image for hello-world:linux
docker.io/library/hello-world:linux
Sometimes, you don’t want images to be updated to newer versions but preferred to be fixed. Then, docker has a feature that you can pull an image by its digest. You can define the exact version of an image. By doing so, you will be always using the same image version.
$ docker pull ubuntu:20.04
20.04: Pulling from library/ubuntu
Digest: sha256:2560015c57ac217693efac53eb85ff107f1f141f31161634c9dbaafb03f7f757
Status: Downloaded newer image for ubuntu:20.04
docker.io/library/ubuntu:20.04
Here, sha256:2560015c57ac217693efac53eb85ff107f1f141f31161634c9dbaafb03f7f757
is a digest of the image.
Now, you can pull an image using the digest printed above:
$ docker pull ubuntu@sha256:2560015c57ac217693efac53eb85ff107f1f141f31161634c9dbaafb03f7f757
ubuntu@sha256:2560015c57ac217693efac53eb85ff107f1f141f31161634c9dbaafb03f7f757: Pulling from library/ubuntu
Digest: sha256:2560015c57ac217693efac53eb85ff107f1f141f31161634c9dbaafb03f7f757
Status: Downloaded newer image for ubuntu@sha256:2560015c57ac217693efac53eb85ff107f1f141f31161634c9dbaafb03f7f757
docker.io/library/ubuntu@sha256:2560015c57ac217693efac53eb85ff107f1f141f31161634c9dbaafb03f7f757
Also, the digest can be used in Dockerfile
with FROM
instruction:
FROM ubuntu@sha256:2560015c57ac217693efac53eb85ff107f1f141f31161634c9dbaafb03f7f757
ARG VAR1=value1
...
If you have a different registry or your own local repository, then you can pull images from them also
$ docker pull localregistry.local:8000/dev/dev-image
Here, all the credentials are managed by docker login
. Know more about docker login.
$ docker pull --all-tags ubuntu
It will pull multiple images of a repository with different versions.
$ docker images ubuntu
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 693efac53ebd 2 days ago 77.8MB
ubuntu 22.04 d2e4e1f51132 2 days ago 77.8MB
ubuntu jammy d2e4e1f51132 2 days ago 77.8MB
ubuntu rolling d2e4e1f51132 2 days ago 77.8MB
ubuntu kinetic d2e4e1f51132 2 days ago 77.8MB
You can cancel by pressing ctrl + c
while it’s running in a terminal.