本节将会涉及Docker的镜像操作。
1. 获取镜像
如何获取Docker Hub上的镜像?可通过docker pull命令获取,其格式为: docker pull [选项] [Docker Registry 地址[:端口号]/]仓库名[:标签],具体可通过docker pull --help命令查看。
Docker镜像仓库地址的格式一般为<域名/IP>[:端口号],仓库名一般为两段式名称,即<用户名>/<软件名>,对于Docker Hub,默认的用户名为library。
例:获取ubuntu:16.04镜像,其中可看到默认用户library,16.04位镜像标签。
$ docker pull ubuntu:16.04 16.04: Pulling from library/ubuntu 8f7c85c2269a: Pull complete 9e72e494a6dd: Pull complete 3009ec50c887: Pull complete 9d5ffccbec91: Pull complete e872a2642ce1: Pull complete Digest: sha256:d3fdf5b1f8e8a155c17d5786280af1f5a04c10e95145a515279cf17abdf0191f Status: Downloaded newer image for ubuntu:16.04