zoukankan      html  css  js  c++  java
  • docker镜像的操作

    [root@ken1 ~]# docker image --help #获取docker镜像有关操作信息
    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   从压缩归档包中导入镜像export
    inspect    Display detailed information on one or more images    显示镜像的详细信息
    load       Load an image from a tar archive or STDIN    从一个压缩包中导入镜像save
    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    修改镜像名 

    实例1、查看镜像中有没有镜像

    [root@localhost ~]# docker search nginx
    

    实例2、拉取/下载镜像

    [root@localhost ~]# docker image pull nginx/docker pull busybox           #image可以省略
    

      

    实例3、查看镜像

    [root@localhost ~]# docker image ls
    REPOSITORY         TAG         IMAGE ID             CREATED             SIZE
    busybox           latest      020584afccce         5 days ago         1.22MB    
    仓库名       标签信息     镜像ID           更新时间       镜像大小

      

    [root@localhost docker-image]# docker image ls -q    #仅查看镜像ID

    实例4、查看镜像的构建历史

    [root@ken1 ~]# docker history busybox
    IMAGE         CREATED       CREATED BY                             SIZE         COMMENT
    020584afccce   5 days ago   /bin/sh -c #(nop)   CMD ["sh"] 0B 
    <missing>     5 days ago   /bin/sh -c #(nop)   ADD file:1141b81e5149cc37c…     1.22MB 

    例子5:把镜像制作成压缩包(方便存储和分享)
      方法一:

    [root@ken1 ~]# docker save busybox > busybox.tar.gz

      方法二:

    [root@ken1 ~]# docker save busybox:latest -o busybox1.tar.gz
    

    例子6:从压缩包中导入镜像
      方法一:

    [root@ken1 ~]# docker load -i httpd_img.tar.gz 

      方法二:

    [root@ken1 ~]# docker load < httpd_img.tar.gz 
    

    例子7:删除镜像

    [root@ken1 ~]# docker image rm busybox
    [root@localhost docker-image]# docker image rm -f $(docker image ls -q)         #强行删除所有镜像
    

     例子8:删除不经常使用镜像

    [root@ken1 ~]# docker image prune -f
    Total reclaimed space: 0B
    

      

    例子9:查看镜像详细信息

    [root@ken1 ~]# docker inspect busybox
    

      

    例子10:镜像改名

    [root@ken1 ~]# docker tag busybox:latest busybox1:ken
    

  • 相关阅读:
    第十一周上机作业
    第十三周作业 张垚
    第十三周上机 张垚
    十二周作业 张垚
    第十二周上机 张垚
    第十一周作业 张垚
    第十一周上机 张垚
    第十周 上机 张垚
    第九周上机 张垚
    第八周 下 张垚
  • 原文地址:https://www.cnblogs.com/twoo/p/11815325.html
Copyright © 2011-2022 走看看