艾尔文森林

导航

docker笔记之镜像管理

1.查找镜像

docker search centos
NAME                               DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
centos                             The official build of CentOS.                   5556                [OK]                
ansible/centos7-ansible            Ansible on Centos7                              123                                     [OK]
jdeathe/centos-ssh                 CentOS-6 6.10 x86_64 / CentOS-7 7.6.1810 x86…   112                                     [OK]

说明:
NAME:镜像名称
DESCRIPTION:镜像描述
STARS:星标数量,类似GitHub上的星标,数量越多,获得的认可越高
OFFICIAL :是否为官方镜像
AUTOMATED:是否自动化创建

2.下载镜像

[root@heibing ~]# docker pull centos
Using default tag: latest
latest: Pulling from library/centos
d8d02d457314: Pull complete 
Digest: sha256:307835c385f656ec2e2fec602cf093224173c51119bbebd602c53c3653a3d6eb
Status: Downloaded newer image for centos:latest
docker.io/library/centos:latest

备注:此处一定要配置镜像加速,默认配置下,docker会从官方地址下载镜像,由于墙的原因,
下载速度非常缓慢,建议修改镜像地址为阿里云,登录阿里云,容器和镜像服务器,镜像加速器里有相关说明。

3.查看镜像

[root@heibing ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
centos              latest              67fa590cfc1c        3 weeks ago         202MB
nginx               latest              5a3221f0137b        3 weeks ago         126MB

说明:
REPOSITORY:镜像名称
TAG:标签
IMAGE ID: 镜像ID(唯一)
CREATED:创建时间
SIZE:镜像大小

4.删除镜像

[root@heibing ~]# docker rmi centos  
Untagged: centos:latest
Untagged: centos@sha256:307835c385f656ec2e2fec602cf093224173c51119bbebd602c53c3653a3d6eb
Deleted: sha256:67fa590cfc1c207c30b837528373f819f6262c884b7e69118d060a0c04d70ab8
Deleted: sha256:877b494a9f30e74e61b441ed84bb74b14e66fb9cc321d83f3a8a19c60d078654

#查看删除结果
[root@heibing ~]# docker images
REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
nginx               latest              5a3221f0137b        3 weeks ago         126MB

5.关于镜像操作的其他命令:

[root@heibing ~]# docker image 

Usage:	docker image COMMAND

Manage images

Commands:
  build       Build an image from a Dockerfile-->通过dockerfile文件创建一个镜像
  history     Show the history of an image-->查看某个镜像的历史信息
  import      Import the contents from a tarball to create a filesystem image-->从压缩文件导入内容创建镜像
  inspect     Display detailed information on one or more images-->显示镜像的更多信息
  load        Load an image from a tar archive or STDIN-->加载镜像
  ls          List images-->显示镜像列表
  prune       Remove unused images-->删除不在使用的镜像
  pull        Pull an image or a repository from a registry-->从库中拉取镜像
  push        Push an image or a repository to a registry-->向库中推送镜像
  rm          Remove one or more images-->删除镜像文件
  save        Save one or more images to a tar archive (streamed to STDOUT by default)-->保存容器内容到镜像
  tag         Create a tag TARGET_IMAGE that refers to SOURCE_IMAGE-->创建镜像标签

Run 'docker image COMMAND --help' for more information on a command.

posted on 2019-09-11 10:19  艾尔文森林  阅读(182)  评论(0编辑  收藏  举报