菜鸟系列docker——docker镜像中(4)

docker镜像命令

该章节主要介绍docker image相关命令实践操作,建议都一起跑一边

1. docker images

列举本机docker镜像

[centos@jiliguo docker]$ docker images
REPOSITORY                     TAG                                 IMAGE ID            CREATED             SIZE
mysql                          wasabi                              8913c9fb0d59        27 hours ago        372MB
hyperledger/fabric-yxbaseos    amd64-latest                        c932070cd73f        2 weeks ago         156MB
hyperledger/fabric-yxbaseos    amd64-raft-1.2.1-snapshot-1f9bec2   c932070cd73f        2 weeks ago         156MB
hyperledger/fabric-yxbaseos    latest                              c932070cd73f        2 weeks ago         156MB

REPOSITORY:表示镜像的仓库源
TAG:镜像的标签
IMAGE ID:镜像ID
CREATED:镜像创建时间
SIZE:镜像大小

查找镜像

[centos@jiliguo docker]$ docker search  hello-world
NAME                                       DESCRIPTION                                     STARS               OFFICIAL            AUTOMATED
hello-world                                Hello World! (an example of minimal Dockeriz…   890                 [OK]                
kitematic/hello-world-nginx                A light-weight nginx container that demonstr…   124                                     
tutum/hello-world                          Image to test docker deployments. Has Apache…   60                                      [OK]
dockercloud/hello-world                    Hello World!                                    15                                      [OK]

3. docker pull

获取镜像

[centos@jiliguo docker]$ docker pull hello-world
Using default tag: latest
latest: Pulling from library/hello-world
1b930d010525: Already exists 
Digest: sha256:92695bc579f31df7a63da6922075d0666e565ceccad16b59c3374d2cf4e8e50e
Status: Downloaded newer image for hello-world:latest
[centos@jiliguo docker]$ 

4. docker tag

设置镜像标签,这里只是多了个标签,并不是新的镜像

[centos@jiliguo docker]$ docker tag hello-world hello-world:v2

[centos@jiliguo docker]$ docker images
hello-world                    latest                              fce289e99eb9        3 months ago        1.84kB
hello-world                    v2                                  fce289e99eb9        3 months ago        1.84kB

5. docker save

把指定镜像保存成一个文件


[centos@jiliguo docker]$ docker save -o hello-world.tar或者 docker save hello-world:v2>hello-world.tar  
[centos@jiliguo docker]$ ls
Dockerfile  hello-world.tar
[centos@jiliguo docker]$ 

6. docker rmi

删除镜像

[centos@jiliguo docker]$ docker rmi hello-world:v2
Untagged: hello-world:v2

7. docker load

加载镜像

[centos@jiliguo docker]$ docker load<hello-world.tar 或者docker load -i hello-world.tar
Loaded image: hello-world:v2
如果你觉得写的不错,请移步www.itkezhan.top或者关注公众号IT程序员客栈
原文地址:https://www.cnblogs.com/i-dandan/p/10752924.html