Docker pull命令从docker远程仓库下载镜像。docker pull的帮助信息如下:
[root@localhost ~]# docker pull --help Usage: docker 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)
其中:
-a, --all-tags 下载仓库中所有标记的镜像
--disable-content-trust 跳过镜像验证(默认为true)
实例:从仓库下载memcached镜像。如下:
[root@localhost ~]# docker pull memcached Using default tag: latest latest: Pulling from library/memcached f5d23c7fed46: Already exists 27e1a464c1da: Pull complete bc159f1f6963: Pull complete e08722aa4a17: Pull complete 99972c010b10: Pull complete b3907400a67c: Pull complete Digest: sha256:8fc34b9672011d89e07d0bcd0b02fdcd22634340bb8697f916ceab0c46d19c5c Status: Downloaded newer image for memcached:latest
可以使用 -a 选项下载指定镜像的所有TAG版本镜像。如下:
[root@localhost ~]# docker pull memcached -a 1-alpine: Pulling from library/memcached ... Digest: sha256:4a88746154ef2ee26615ee7de00410aa0f35f974b8d7b94744d4eb22964f27fa 1.4-alpine: Pulling from library/memcached ... Digest: sha256:3741668c175a68f9fb2ba453461105534d639e9a772ef09120ce63de7f4da8c6 1.4.21: Pulling from library/memcached ... Digest: sha256:b3bc535e6d264df171df096602c96cdd0621b5e91a38701c230e771424a584c0 1.4.22: Pulling from library/memcached ... Digest: sha256:bc1fd4e6ede2d84b5ec2b47c28361189d0b26650cda4dcac41dbfc7a1ed7fad9 1.4.23: Pulling from library/memcached ... Digest: sha256:f24b652a18dc4598cc0d66430b67802ab9a1738b975e315120cc202fb9132ced 1.4.24: Pulling from library/memcached ... Digest: sha256:a23496a073d3fef620815f8a9224afb6162b7c7213e4faaf05a051c74f157605 1.4.25: Pulling from library/memcached ... 31342a34ef9f: Pull complete Digest: sha256:0a9765863d2c73a5b7ba99dc95a83cf67ac18bfacd8bcb69068c41d2ffb83775
注意:这里只截取了部分。使用 docker images memcached 去查看镜像信息。如下:
[root@localhost ~]# docker images memcached REPOSITORY TAG IMAGE ID CREATED SIZE memcached 1-alpine 077b9f827fdf 9 days ago 10.4MB memcached latest 642baa2fc479 9 days ago 82.1MB memcached 1.4-alpine 273374b463b8 2 years ago 7.68MB memcached 1.4.25 d97bb0f05e89 3 years ago 132MB memcached 1.4.24 66438aa20444 3 years ago 132MB memcached 1.4.23 973e95ed35b7 4 years ago 132MB memcached 1.4.22 971dfd921df9 4 years ago 140MB memcached 1.4.21 622897abf0a4 4 years ago 130MB
从上图得知,我们使用 -a 选项可以将 memcached 的所有tag版本全部下载下来。如果我们需要去下载指定版本的镜像呢?此时使用“镜像名称:版本”,如下:
[root@localhost ~]# docker pull tomcat:8.0 8.0: Pulling from library/tomcat f189db1b88b3: Pull complete 3d06cf2f1b5e: Pull complete edd0da9e3091: Pull complete eb7768aae14e: Pull complete e2780f585e0f: Pull complete e5ed720afeba: Pull complete d9e134700cfc: Pull complete e4804b33d02a: Pull complete b9df0c24315e: Pull complete 49fdae8eaa20: Pull complete 1aea3d9a32e6: Pull complete Digest: sha256:8ecb10948deb32c34aeadf7bf95d12a93fbd3527911fa629c1a3e7823b89ce6f Status: Downloaded newer image for tomcat:8.0
上面将下载 8.0 版本的 tomcat。
到这里本文就结束了,上面介绍了 docker pull 命令常用的用法,更多用法可以自己去琢磨。