docker--镜像操作

5 docker 镜像操作

Docker 镜像是容器的基础。镜像是一个有序集合,其中包含根文件系统更改和在容器运 行时中使用的相应执行参数。镜像通常 包含堆叠在彼此之上的联合分层文件系统。镜像 没有状态并且始终不会发生更改。 当运行容器时,使用的镜像如果在本地中不存在, docker 就会自动从 docker 镜像仓库中下载,默认是从 Docker Hub 公共镜像源下载。

5.1 列出镜像

docker images
REPOSITORY          TAG                 IMAGE ID            CREATED      
      SIZE
hello‐world         latest              fce289e99eb9        5 months ago
       1.84kB
这些镜像都是存储在Docker宿主机的/var/lib/docker目录下。
  • REPOSITORY :表示镜像的仓库源

  • TAG :镜像的标签(版本),同一仓库源可以有多个 TAG,代表这个仓库源的不同 个版本,如ubuntu仓库源里,有15.10、14.04等多个不同的版本。

  • IMAGE ID :镜像ID

  • CREATED :镜像创建时间

  • SIZE :镜像大小

5.2 查找镜像 --docker search 镜像名称

[root@docker1 ~]# docker search centos
NAME                               DESCRIPTION                                     STARS               OFFICIAL           AUTOMATED
centos                             The official build of CentOS.                   5685               [OK]                
ansible/centos7-ansible           Ansible on Centos7                             125                                     [OK]
jdeathe/centos-ssh                 OpenSSH / Supervisor / EPEL/IUS/SCL Repos - …   114                                     [OK]
consol/centos-xfce-vnc             Centos container with "headless" VNC session…   100                                     [OK]
centos/mysql-57-centos7           MySQL 5.7 SQL database server                   64                                      
imagine10255/centos6-lnmp-php56   centos6-lnmp-php56                             57                                     [OK]
tutum/centos                       Simple CentOS docker image with SSH access     44                                      
centos/postgresql-96-centos7       PostgreSQL is an advanced Object-Relational …   39                                      
kinogmt/centos-ssh                 CentOS with SSH                                 29                                     [OK]
pivotaldata/centos-gpdb-dev       CentOS image for GPDB development. Tag names…   10                                      
guyton/centos6                     From official centos6 container with full up…   9                                       [OK]
nathonfowlie/centos-jre           Latest CentOS image with the JRE pre-install…   8                                       [OK]
drecom/centos-ruby                 centos ruby                                     6                                       [OK]
darksheer/centos                   Base Centos Image -- Updated hourly             3                                       [OK]
mamohr/centos-java                 Oracle Java 8 Docker image based on Centos 7   3                                       [OK]
pivotaldata/centos                 Base centos, freshened up a little with a Do…   3                                      
pivotaldata/centos-mingw           Using the mingw toolchain to cross-compile t…   2                                      
miko2u/centos6                     CentOS6 日本語環境                                   2                                       [OK]
pivotaldata/centos-gcc-toolchain   CentOS with a toolchain, but unaffiliated wi…   2                                      
indigo/centos-maven               Vanilla CentOS 7 with Oracle Java Developmen…   1                                       [OK]
mcnaughton/centos-base             centos base image                               1                                       [OK]
blacklabelops/centos               CentOS Base Image! Built and Updates Daily!     1                                       [OK]
pivotaldata/centos6.8-dev         CentosOS 6.8 image for GPDB development         0                                      
pivotaldata/centos7-dev           CentosOS 7 image for GPDB development           0                                      
smartentry/centos                 centos with smartentry                         0                                       [OK]
  • NAME :镜像仓库源的名称

  • DESCRIPTION:镜像的描述

  • starts:用户评价,反应一个镜像的受欢迎程度

  • OFFICIAL:是否docker官方发布

  • auto commit:自动构建,表示该镜像由Docker Hub自动构建流程创建的

5.3 拉取镜像

docker pull 镜像名称[:version]

Docker镜像首页,包括官方镜像和其它公开镜像。Docker Hub上最受欢迎的10大镜像 (通过Docker registry API获取不了镜像被pull的个数,只能通过镜像的stars数量,来衡 量镜像的流行度。毫无疑问,拥有最高stars数量的库都是官方库。国情的原因,国内下 载 Docker HUB 官方的相关镜像比较慢,可以使用国内(docker.io)的一些镜像加速 器,镜像保持和官方一致,关键是速度块,推荐使用。

配置镜像加速器:

PS:配置镜像加速器(参考该网站具体的文档操作)
‐ 阿里云(先加入阿里云开发者平台:https://dev.aliyun.com)
‐ docker中国加速器(https://www.docker‐cn.com)
‐ USTC加速器(https://lug.ustc.edu.cn/wiki/ )  真正的公共服务(无需任何操
作)
‐ daocloud、网易蜂巢加速器:略
步骤:
sudo vim /etc/docker/daemon.json
配置内容:    
{    
   "registry‐mirrors": ["https://cs913o6k.mirror.aliyuncs.com"]      
}    
sudo systemctl daemon‐reload
sudo systemctl restart docker

Error1:在拉取镜像时候,出现如下错误,可以配置镜像加速器
Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

5.4 删除镜像

1、删除一个镜像
docker rmi 镜像名称/id
2、删除多个镜像
docker rmi 镜像名称1/id1 镜像名称2/id2 ...
3、删除所有镜像
docker rmi `docker images ‐q` 

 

  没有英汉互译结果
   请尝试网页搜索

猜你喜欢

转载自www.cnblogs.com/eadela/p/11910690.html