First, get a mirror
Fetching an image command from the Docker mirror warehouse docker pull
. The command format is:
docker pull [选项] [Docker Registry 地址[:端口号]/]仓库名[:标签]
such as:
$ docker pull ubuntu:16.04
16.04: Pulling from library/ubuntu
bf5d46315322: Pull complete
9f13e0ac480c: Pull complete
e8988b5b3097: Pull complete
40af181810e7: Pull complete
e6f7c7e5c03e: Pull complete
Digest: sha256:147913621d9cdea08853f6ba9116c2e27a3ceffecf3b492983ae97c3d643fbbe
Status: Downloaded newer image for ubuntu:16.04
The above command is not given warehouse address Docker mirror, the mirror will therefore be acquired from Docker Hub. The name is a mirror ubuntu:16.04
, so the mirror will get the official library/ubuntu
repository for the label 16.04
's image.
Second, the run-time image
To the above ubuntu:16.04
example, if we're going to start inside bash
and interactive operation, you can execute the following command.
$ docker run -it --rm \
ubuntu:16.04 \
bash
root@e7009c6ce357:/# cat /etc/os-release
NAME="Ubuntu"
VERSION="16.04.4 LTS, Trusty Tahr"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 16.04.4 LTS"
VERSION_ID="16.04"
HOME_URL="http://www.ubuntu.com/"
SUPPORT_URL="http://help.ubuntu.com/"
BUG_REPORT_URL="http://bugs.launchpad.net/ubuntu/"
docker run
Is the command to run the container, here we briefly explain the parameters used above.
-it
: These are two parameters, a is-i
: interactive operation, one is-t
terminal. We intend to enter herebash
to execute commands and return the results to see, so we need interactive terminals.--rm
: This parameter is to say after the vessel exit will be deleted. By default, the demand for troubleshooting, exit the container does not delete immediately, unless manuallydocker rm
. We are here only just execute a command, look at the results, does not require troubleshooting and retention results, so use--rm
to avoid wasting space.ubuntu:16.04
: This is aubuntu:16.04
mirror image basis starting container.bash
: The image name is placed in command , here we want to have an interactive Shell, so use isbash
.
After entering the container, we can operate under the Shell, execute any desired command. Here, we have implemented cat /etc/os-release
, which is commonly used Linux command to view the current version of the system, from the returned results can be seen within the container is a Ubuntu 16.04.4 LTS
system.
Finally, exit
exit the container.
Third, the listed mirrors
To list already downloaded the image, you can use the docker image ls
command.
$ docker image ls
REPOSITORY TAG IMAGE ID CREATED SIZE
redis latest 5f515359c7f8 5 days ago 183 MB
nginx latest 05a60462f8ba 5 days ago 181 MB
mongo 3.2 fe9198c04d62 5 days ago 342 MB
<none> <none> 00285df0df87 5 days ago 342 MB
ubuntu 16.04 f753707788c5 4 weeks ago 127 MB
ubuntu latest f753707788c5 4 weeks ago 127 MB
ubuntu 14.04 1e0c3dd64ccd 4 weeks ago 188 MB
The list contains the 仓库名
, 标签
, 镜像 ID
, 创建时间
and 所占用的空间
.
Fourth, delete local mirror
If you want to delete the local mirror, you can use the docker image rm
command in the format:
$ docker image rm [选项] <镜像1> [<镜像2> ...]
Wherein, <镜像>
it may be 镜像短 ID
, 镜像长 ID
, 镜像名
or 镜像摘要
.