2015-06-21 16:41:38 -04:00
|
|
|
# pull
|
|
|
|
|
2023-01-06 13:04:05 -05:00
|
|
|
<!---MARKER_GEN_START-->
|
2022-03-29 18:11:09 -04:00
|
|
|
Download an image from a registry
|
2015-06-21 16:41:38 -04:00
|
|
|
|
2023-01-06 13:04:05 -05:00
|
|
|
### Aliases
|
|
|
|
|
|
|
|
`docker image pull`, `docker pull`
|
|
|
|
|
|
|
|
### Options
|
|
|
|
|
|
|
|
| Name | Type | Default | Description |
|
|
|
|
|:---------------------------------------------|:---------|:--------|:-------------------------------------------------|
|
|
|
|
| [`-a`](#all-tags), [`--all-tags`](#all-tags) | | | Download all tagged images in the repository |
|
|
|
|
| `--disable-content-trust` | | | Skip image verification |
|
|
|
|
| `--platform` | `string` | | Set platform if server is multi-platform capable |
|
|
|
|
| `-q`, `--quiet` | | | Suppress verbose output |
|
|
|
|
|
cli: use custom annotation for aliases
Cobra allows for aliases to be defined for a command, but only allows these
to be defined at the same level (for example, `docker image ls` as alias for
`docker image list`). Our CLI has some commands that are available both as a
top-level shorthand as well as `docker <object> <verb>` subcommands. For example,
`docker ps` is a shorthand for `docker container ps` / `docker container ls`.
This patch introduces a custom "aliases" annotation that can be used to print
all available aliases for a command. While this requires these aliases to be
defined manually, in practice the list of aliases rarely changes, so maintenance
should be minimal.
As a convention, we could consider the first command in this list to be the
canonical command, so that we can use this information to add redirects in
our documentation in future.
Before this patch:
docker images --help
Usage: docker images [OPTIONS] [REPOSITORY[:TAG]]
List images
Options:
-a, --all Show all images (default hides intermediate images)
...
With this patch:
docker images --help
Usage: docker images [OPTIONS] [REPOSITORY[:TAG]]
List images
Aliases:
docker image ls, docker image list, docker images
Options:
-a, --all Show all images (default hides intermediate images)
...
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2022-06-28 04:52:25 -04:00
|
|
|
|
2023-01-06 13:04:05 -05:00
|
|
|
<!---MARKER_GEN_END-->
|
2015-06-21 16:41:38 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
## Description
|
|
|
|
|
2015-06-21 16:41:38 -04:00
|
|
|
Most of your images will be created on top of a base image from the
|
|
|
|
[Docker Hub](https://hub.docker.com) registry.
|
|
|
|
|
|
|
|
[Docker Hub](https://hub.docker.com) contains many pre-built images that you
|
|
|
|
can `pull` and try without needing to define and configure your own.
|
|
|
|
|
|
|
|
To download a particular image, or set of images (i.e., a repository),
|
2016-03-04 09:58:07 -05:00
|
|
|
use `docker pull`.
|
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
### Proxy configuration
|
2016-05-16 23:26:35 -04:00
|
|
|
|
2016-05-07 21:36:10 -04:00
|
|
|
If you are behind an HTTP proxy server, for example in corporate settings,
|
2016-05-16 23:26:35 -04:00
|
|
|
before open a connect to registry, you may need to configure the Docker
|
2022-04-02 08:07:51 -04:00
|
|
|
daemon's proxy settings, refer to the [dockerd command-line reference](dockerd.md#proxy-configuration)
|
|
|
|
for details.
|
2016-05-16 23:26:35 -04:00
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
### Concurrent downloads
|
2016-11-22 16:24:37 -05:00
|
|
|
|
|
|
|
By default the Docker daemon will pull three layers of an image at a time.
|
|
|
|
If you are on a low bandwidth connection this may cause timeout issues and you may want to lower
|
|
|
|
this via the `--max-concurrent-downloads` daemon option. See the
|
|
|
|
[daemon documentation](dockerd.md) for more details.
|
|
|
|
|
2016-03-04 09:58:07 -05:00
|
|
|
## Examples
|
|
|
|
|
|
|
|
### Pull an image from Docker Hub
|
|
|
|
|
|
|
|
To download a particular image, or set of images (i.e., a repository), use
|
2022-06-06 09:02:58 -04:00
|
|
|
`docker image pull` (or the `docker pull` shorthand). If no tag is provided,
|
|
|
|
Docker Engine uses the `:latest` tag as a default. This example pulls the
|
|
|
|
`debian:latest` image:
|
2016-03-04 09:58:07 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2022-06-06 09:02:58 -04:00
|
|
|
$ docker image pull debian
|
2016-03-04 09:58:07 -05:00
|
|
|
|
|
|
|
Using default tag: latest
|
|
|
|
latest: Pulling from library/debian
|
2022-06-06 09:02:58 -04:00
|
|
|
e756f3fdd6a3: Pull complete
|
|
|
|
Digest: sha256:3f1d6c17773a45c97bd8f158d665c9709d7b29ed7917ac934086ad96f92e4510
|
2016-03-04 09:58:07 -05:00
|
|
|
Status: Downloaded newer image for debian:latest
|
2022-06-06 09:02:58 -04:00
|
|
|
docker.io/library/debian:latest
|
2016-03-04 09:58:07 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
Docker images can consist of multiple layers. In the example above, the image
|
2022-06-06 09:02:58 -04:00
|
|
|
consists of a single layer; `e756f3fdd6a3`.
|
2016-03-04 09:58:07 -05:00
|
|
|
|
2023-11-23 17:21:07 -05:00
|
|
|
Layers can be reused by images. For example, the `debian:bookworm` image shares
|
|
|
|
its layer with the `debian:latest`. Pulling the `debian:bookworm` image therefore
|
2022-06-06 09:02:58 -04:00
|
|
|
only pulls its metadata, but not its layers, because the layer is already present
|
|
|
|
locally:
|
2016-03-04 09:58:07 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2023-11-23 17:21:07 -05:00
|
|
|
$ docker image pull debian:bookworm
|
2016-03-04 09:58:07 -05:00
|
|
|
|
2023-11-23 17:21:07 -05:00
|
|
|
bookworm: Pulling from library/debian
|
2022-06-06 09:02:58 -04:00
|
|
|
Digest: sha256:3f1d6c17773a45c97bd8f158d665c9709d7b29ed7917ac934086ad96f92e4510
|
2023-11-23 17:21:07 -05:00
|
|
|
Status: Downloaded newer image for debian:bookworm
|
|
|
|
docker.io/library/debian:bookworm
|
2016-03-04 09:58:07 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
To see which images are present locally, use the [`docker images`](images.md)
|
|
|
|
command:
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2016-03-04 09:58:07 -05:00
|
|
|
$ docker images
|
|
|
|
|
2022-06-06 09:02:58 -04:00
|
|
|
REPOSITORY TAG IMAGE ID CREATED SIZE
|
2023-11-23 17:21:07 -05:00
|
|
|
debian bookworm 4eacea30377a 8 days ago 124MB
|
2022-06-06 09:02:58 -04:00
|
|
|
debian latest 4eacea30377a 8 days ago 124MB
|
2016-03-04 09:58:07 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
Docker uses a content-addressable image store, and the image ID is a SHA256
|
|
|
|
digest covering the image's configuration and layers. In the example above,
|
2023-11-23 17:21:07 -05:00
|
|
|
`debian:bookworm` and `debian:latest` have the same image ID because they are
|
2022-06-06 09:02:58 -04:00
|
|
|
the *same* image tagged with different names. Because they are the same image,
|
|
|
|
their layers are stored only once and do not consume extra disk space.
|
2016-03-04 09:58:07 -05:00
|
|
|
|
|
|
|
For more information about images, layers, and the content-addressable store,
|
2020-04-19 09:43:08 -04:00
|
|
|
refer to [understand images, containers, and storage drivers](https://docs.docker.com/storage/storagedriver/).
|
2016-03-04 09:58:07 -05:00
|
|
|
|
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
### Pull an image by digest (immutable identifier)
|
2016-03-04 09:58:07 -05:00
|
|
|
|
|
|
|
So far, you've pulled images by their name (and "tag"). Using names and tags is
|
|
|
|
a convenient way to work with images. When using tags, you can `docker pull` an
|
|
|
|
image again to make sure you have the most up-to-date version of that image.
|
2022-06-06 09:02:58 -04:00
|
|
|
For example, `docker pull ubuntu:22.04` pulls the latest version of the Ubuntu
|
|
|
|
22.04 image.
|
2016-03-04 09:58:07 -05:00
|
|
|
|
|
|
|
In some cases you don't want images to be updated to newer versions, but prefer
|
|
|
|
to use a fixed version of an image. Docker enables you to pull an image by its
|
|
|
|
*digest*. When pulling an image by digest, you specify *exactly* which version
|
|
|
|
of an image to pull. Doing so, allows you to "pin" an image to that version,
|
|
|
|
and guarantee that the image you're using is always the same.
|
|
|
|
|
|
|
|
To know the digest of an image, pull the image first. Let's pull the latest
|
2022-06-06 09:02:58 -04:00
|
|
|
`ubuntu:22.04` image from Docker Hub:
|
2016-03-04 09:58:07 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2022-06-06 09:02:58 -04:00
|
|
|
$ docker pull ubuntu:22.04
|
2016-03-04 09:58:07 -05:00
|
|
|
|
2022-06-06 09:02:58 -04:00
|
|
|
22.04: Pulling from library/ubuntu
|
|
|
|
125a6e411906: Pull complete
|
|
|
|
Digest: sha256:26c68657ccce2cb0a31b330cb0be2b5e108d467f641c62e13ab40cbec258c68d
|
|
|
|
Status: Downloaded newer image for ubuntu:22.04
|
|
|
|
docker.io/library/ubuntu:22.04
|
2016-03-04 09:58:07 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
Docker prints the digest of the image after the pull has finished. In the example
|
|
|
|
above, the digest of the image is:
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2022-06-06 09:02:58 -04:00
|
|
|
sha256:26c68657ccce2cb0a31b330cb0be2b5e108d467f641c62e13ab40cbec258c68d
|
2021-08-21 08:54:14 -04:00
|
|
|
```
|
2016-03-04 09:58:07 -05:00
|
|
|
|
|
|
|
Docker also prints the digest of an image when *pushing* to a registry. This
|
|
|
|
may be useful if you want to pin to a version of the image you just pushed.
|
|
|
|
|
2016-10-19 13:25:45 -04:00
|
|
|
A digest takes the place of the tag when pulling an image, for example, to
|
2016-03-04 09:58:07 -05:00
|
|
|
pull the above image by digest, run the following command:
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2022-06-06 09:02:58 -04:00
|
|
|
$ docker pull ubuntu@sha256:26c68657ccce2cb0a31b330cb0be2b5e108d467f641c62e13ab40cbec258c68d
|
2016-03-04 09:58:07 -05:00
|
|
|
|
2022-06-06 09:02:58 -04:00
|
|
|
docker.io/library/ubuntu@sha256:26c68657ccce2cb0a31b330cb0be2b5e108d467f641c62e13ab40cbec258c68d: Pulling from library/ubuntu
|
|
|
|
Digest: sha256:26c68657ccce2cb0a31b330cb0be2b5e108d467f641c62e13ab40cbec258c68d
|
|
|
|
Status: Image is up to date for ubuntu@sha256:26c68657ccce2cb0a31b330cb0be2b5e108d467f641c62e13ab40cbec258c68d
|
|
|
|
docker.io/library/ubuntu@sha256:26c68657ccce2cb0a31b330cb0be2b5e108d467f641c62e13ab40cbec258c68d
|
2016-03-04 09:58:07 -05:00
|
|
|
```
|
|
|
|
|
|
|
|
Digest can also be used in the `FROM` of a Dockerfile, for example:
|
|
|
|
|
2020-03-17 10:01:52 -04:00
|
|
|
```dockerfile
|
2022-06-06 09:02:58 -04:00
|
|
|
FROM ubuntu@sha256:26c68657ccce2cb0a31b330cb0be2b5e108d467f641c62e13ab40cbec258c68d
|
2021-05-04 12:45:10 -04:00
|
|
|
LABEL org.opencontainers.image.authors="some maintainer <maintainer@example.com>"
|
2016-03-04 09:58:07 -05:00
|
|
|
```
|
|
|
|
|
2020-04-19 11:08:37 -04:00
|
|
|
> **Note**
|
|
|
|
>
|
|
|
|
> Using this feature "pins" an image to a specific version in time.
|
2022-06-06 09:02:58 -04:00
|
|
|
> Docker does therefore not pull updated versions of an image, which may include
|
2016-03-04 09:58:07 -05:00
|
|
|
> security updates. If you want to pull an updated image, you need to change the
|
|
|
|
> digest accordingly.
|
|
|
|
|
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
### Pull from a different registry
|
2016-03-04 09:58:07 -05:00
|
|
|
|
2016-06-11 17:31:53 -04:00
|
|
|
By default, `docker pull` pulls images from [Docker Hub](https://hub.docker.com). It is also possible to
|
2016-03-04 09:58:07 -05:00
|
|
|
manually specify the path of a registry to pull from. For example, if you have
|
|
|
|
set up a local registry, you can specify its path to pull from it. A registry
|
|
|
|
path is similar to a URL, but does not contain a protocol specifier (`https://`).
|
|
|
|
|
|
|
|
The following command pulls the `testing/test-image` image from a local registry
|
|
|
|
listening on port 5000 (`myregistry.local:5000`):
|
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2022-06-06 09:02:58 -04:00
|
|
|
$ docker image pull myregistry.local:5000/testing/test-image
|
2016-03-04 09:58:07 -05:00
|
|
|
```
|
|
|
|
|
2016-03-28 20:10:11 -04:00
|
|
|
Registry credentials are managed by [docker login](login.md).
|
|
|
|
|
2016-03-04 09:58:07 -05:00
|
|
|
Docker uses the `https://` protocol to communicate with a registry, unless the
|
|
|
|
registry is allowed to be accessed over an insecure connection. Refer to the
|
2016-04-28 02:55:22 -04:00
|
|
|
[insecure registries](dockerd.md#insecure-registries) section for more information.
|
2016-03-04 09:58:07 -05:00
|
|
|
|
|
|
|
|
2023-01-06 13:28:29 -05:00
|
|
|
### <a name="all-tags"></a> Pull a repository with multiple images (-a, --all-tags)
|
2016-03-04 09:58:07 -05:00
|
|
|
|
|
|
|
By default, `docker pull` pulls a *single* image from the registry. A repository
|
|
|
|
can contain multiple images. To pull all images from a repository, provide the
|
|
|
|
`-a` (or `--all-tags`) option when using `docker pull`.
|
|
|
|
|
2022-06-06 09:02:58 -04:00
|
|
|
This command pulls all images from the `ubuntu` repository:
|
2016-03-04 09:58:07 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2022-06-06 09:02:58 -04:00
|
|
|
$ docker image pull --all-tags ubuntu
|
2016-03-04 09:58:07 -05:00
|
|
|
|
2022-06-06 09:02:58 -04:00
|
|
|
Pulling repository ubuntu
|
2016-03-04 09:58:07 -05:00
|
|
|
ad57ef8d78d7: Download complete
|
|
|
|
105182bb5e8b: Download complete
|
|
|
|
511136ea3c5a: Download complete
|
|
|
|
73bd853d2ea5: Download complete
|
|
|
|
....
|
|
|
|
|
2022-06-06 09:02:58 -04:00
|
|
|
Status: Downloaded newer image for ubuntu
|
2016-03-04 09:58:07 -05:00
|
|
|
```
|
|
|
|
|
2022-06-06 09:02:58 -04:00
|
|
|
After the pull has completed use the `docker image ls` command (or the `docker images`
|
|
|
|
shorthand) to see the images that were pulled. The example below shows all the
|
|
|
|
`ubuntu` images that are present locally:
|
2016-03-04 09:58:07 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2022-06-06 09:02:58 -04:00
|
|
|
$ docker image ls --filter reference=ubuntu
|
|
|
|
REPOSITORY TAG IMAGE ID CREATED SIZE
|
|
|
|
ubuntu 18.04 c6ad7e71ba7d 5 weeks ago 63.2MB
|
|
|
|
ubuntu bionic c6ad7e71ba7d 5 weeks ago 63.2MB
|
|
|
|
ubuntu 22.04 5ccefbfc0416 2 months ago 78MB
|
|
|
|
ubuntu focal ff0fea8310f3 2 months ago 72.8MB
|
|
|
|
ubuntu latest ff0fea8310f3 2 months ago 72.8MB
|
|
|
|
ubuntu jammy 41ba606c8ab9 3 months ago 79MB
|
|
|
|
ubuntu 20.04 ba6acccedd29 7 months ago 72.8MB
|
2016-03-04 09:58:07 -05:00
|
|
|
```
|
|
|
|
|
2017-02-07 18:42:48 -05:00
|
|
|
### Cancel a pull
|
2015-12-09 14:26:07 -05:00
|
|
|
|
|
|
|
Killing the `docker pull` process, for example by pressing `CTRL-c` while it is
|
|
|
|
running in a terminal, will terminate the pull operation.
|
2016-03-04 09:58:07 -05:00
|
|
|
|
2021-08-21 08:54:14 -04:00
|
|
|
```console
|
2022-06-06 09:02:58 -04:00
|
|
|
$ docker pull ubuntu
|
2016-03-04 09:58:07 -05:00
|
|
|
|
|
|
|
Using default tag: latest
|
2022-06-06 09:02:58 -04:00
|
|
|
latest: Pulling from library/ubuntu
|
2016-03-04 09:58:07 -05:00
|
|
|
a3ed95caeb02: Pulling fs layer
|
|
|
|
236608c7b546: Pulling fs layer
|
|
|
|
^C
|
|
|
|
```
|
|
|
|
|
2022-06-06 09:02:58 -04:00
|
|
|
The Engine terminates a pull operation when the connection between the daemon
|
|
|
|
and the client (initiating the pull) is cut or lost for any reason or the
|
|
|
|
command is manually terminated.
|