docker image pullでDockerイメージを取得する方法
Dockerイメージを取得するには、取得したいイメージ名を指定してdocker image pullコマンドを実行します。
コマンドの説明
$ docker image pull --help Usage: docker image pull [OPTIONS] NAME[:TAG|@DIGEST] Pull an image or a repository from a registry Options: -a, --all-tags Download all tagged images in the repository --disable-content-trust Skip image verification (default true) -q, --quiet Suppress verbose output
実行例
タグを指定しない場合は最新(latest)のイメージを取得できます。
$ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE $ docker image pull centos Using default tag: latest latest: Pulling from library/centos 8a29a15cefae: Pull complete Digest: sha256:fe8d824220415eed5477b63addf40fb06c3b049404242b31982106ac204f6700 Status: Downloaded newer image for centos:latest docker.io/library/centos:latest $ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE centos latest 470671670cac 3 months ago 237MB $ docker run -it centos:latest cat /etc/redhat-release CentOS Linux release 8.1.1911 (Core)
タグを指定すると、指定したバージョンのDockerイメージを取得できます。
$ docker image pull centos:7.7.1908 7.7.1908: Pulling from library/centos f34b00c7da20: Pull complete Digest: sha256:50752af5182c6cd5518e3e91d48f7ff0cba93d5d760a67ac140e2d63c4dd9efc Status: Downloaded newer image for centos:7.7.1908 docker.io/library/centos:7.7.1908 $ docker image ls REPOSITORY TAG IMAGE ID CREATED SIZE centos latest 470671670cac 3 months ago 237MB centos 7.7.1908 08d05d1d5859 5 months ago 204MB $ docker run -it centos:7.7.1908 cat /etc/redhat-release ✘ 1 CentOS Linux release 7.7.1908 (Core)