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    修改鏡像名 

實例一、查看鏡像中有沒有鏡像

[root@localhost ~]# docker search nginx

實例二、拉取/下載鏡像

[root@localhost ~]# docker image pull nginx/docker pull busybox           #image能夠省略

  

實例三、查看鏡像

[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

實例四、查看鏡像的構建歷史

[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:把鏡像製做成壓縮包(方便存儲和分享)
  方法一: nginx

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

  方法二:sql

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

例子6:從壓縮包中導入鏡像
  方法一:docker

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

  方法二:ui

[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

相關文章
相關標籤/搜索