赞
踩
镜像是Docker三大核心概念中最重要的,Docker运行容器前需要本地存在对应的镜像,如果镜像不存在,Docker会尝试从默认镜像仓库下载,用户也可以通过配置,使用自定义的镜像仓库。
docker [image] pull NAME[:TAG]
其中NAME是镜像仓库名称,TAG是镜像的标签。如果不显式指定TAG,则默认会选择latest标签。
[root@VM_0_8_centos ~]# docker pull ubuntu:18.04
Trying to pull repository docker.io/library/ubuntu ...
18.04: Pulling from docker.io/library/ubuntu
5bed26d33875: Pull complete
f11b29a9c730: Pull complete
930bda195c84: Pull complete
78bf9a5ad49e: Pull complete
Digest: sha256:bec5a2727be7fff3d308193cfde3491f8fba1a2ba392b7546b43a051853a341d
Status: Downloaded newer image for docker.io/ubuntu:18.04
可以看到,镜像文件一般由若干层(layer)组成,比如5bed26d33875
是层的唯一id,当多个镜像包括相同的层时,本地仅存储层的一部分,从而可以减少存储空间。
如果从非官方的仓库下载,则需要在仓库名称前面指定完整的仓库地址。例如:
docker pull hub.c.163.com/public/ubuntu:18.04
2.1 使用images
命令列出镜像
[root@VM_0_8_centos ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/ubuntu 18.04 4e5021d210f6 2 weeks ago 64.2 MB
docker.io/centos 7.2.1511 9aec5c5fe4ba 13 months ago 195 MB
docker.io/ansible/centos7-ansible latest 688353a31fde 3 years ago 447 MB
[root@VM_0_8_centos ~]#
2.2 使用tag
,命令添加镜像标签
[root@VM_0_8_centos ~]<
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。