Docker镜像操作手册

Docker镜像操作手册

1.镜像命令详解

docker image --help
Commands:
  build       Build an image from a 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

2.历史镜像查询

#语法:docker image history +镜像名称
#例如:
[root@DogMan ~]# docker image history nginx
IMAGE               CREATED             CREATED BY                                      SIZE                COMMENT
bc9a0695f571        2 weeks ago         /bin/sh -c #(nop)  CMD ["nginx" "-g" "daemon…   0B          
<missing>           2 weeks ago         /bin/sh -c #(nop)  STOPSIGNAL SIGQUIT           0B          
<missing>           2 weeks ago         /bin/sh -c #(nop)  EXPOSE 80                    0B          
<missing>           2 weeks ago         /bin/sh -c #(nop)  ENTRYPOINT ["/docker-entr…   0B          
<missing>           2 weeks ago         /bin/sh -c #(nop) COPY file:0fd5fca330dcd6a7…   1.04kB       
<missing>           2 weeks ago         /bin/sh -c #(nop) COPY file:08ae525f517706a5…   1.95kB      
<missing>           2 weeks ago         /bin/sh -c #(nop) COPY file:e7e183879c35719c…   1.2kB        
<missing>           2 weeks ago         /bin/sh -c set -x     && addgroup --system -…   63.6MB      
<missing>           2 weeks ago         /bin/sh -c #(nop)  ENV PKG_RELEASE=1~buster     0B          
<missing>           2 weeks ago         /bin/sh -c #(nop)  ENV NJS_VERSION=0.4.4        0B          
<missing>           2 weeks ago         /bin/sh -c #(nop)  ENV NGINX_VERSION=1.19.5     0B          
<missing>           3 weeks ago         /bin/sh -c #(nop)  LABEL maintainer=NGINX Do…   0B       
<missing>           3 weeks ago         /bin/sh -c #(nop)  CMD ["bash"]                 0B          
<missing>           3 weeks ago         /bin/sh -c #(nop) ADD file:d2abb0e4e7ac17737…   69.2MB      

3.镜像搜索

选择镜像建议:
1.优先选择官方的
2.选择星星多的

docker search centos

4.获取镜像

####语法:docker pull +镜像名称:版本(默认最新版本)
docker pull centos
docker pull busybox
docker pull busybox:1.29

5.查看镜像

docker images
docker image ls --no-trunc    ---查看镜像ID详细信息
docker image inspect nginx:latest 
docker image inspect bc9a0695f571(镜像ID)  --镜像详细信息查看

只查看镜像ID号:
docker images -q

6.删除镜像

docker rmi centos

7.导出镜像

docker save -o centos.tar centos:latest

8.导入镜像

docker load  < centos.tar   (#推荐使用绝对路径)
posted @ 2022-01-13 14:55  婷婷~玉立  阅读(4)  评论(0编辑  收藏  举报