微服務之——docker 鏡像操作常用命令

docker 鏡像操作常用命令

(1)、搜索鏡像(在dockerhub倉庫中查找centos的鏡像)

[root@localhost docker]#docker search centos

找出一堆centos鏡像

微服務之——docker 鏡像操作常用命令

鏡像的結構: registry_name/repository_name/image_name:tag_name

列如: docjer.io/library/alpine:3.10.1

(2)、鏡像 下載、查看、打標籤、推送

[root@localhost docker]#docker pull nginx (不指定版本下載的話,默認下載最新的latest)

微服務之——docker 鏡像操作常用命令

也可以指定版本下載:

[root@localhost ~]# docker pull nginx:1.16 下載Nginx1.16 版本

微服務之——docker 鏡像操作常用命令

還可以寫全下載

[root@localhost ~]# docker pull docker.io/library/nginx:1.16

查看本地鏡像

[root@localhost ~]# docker images 或者 [root@localhost ~]# docker image ls

微服務之——docker 鏡像操作常用命令

鏡像打標籤

[root@localhost ~]# docker tag nginx:1.16 nginx:local

可以看到多了一個鏡像名,且標籤名為local

微服務之——docker 鏡像操作常用命令

如果要把打標籤的鏡像上傳到dockerhub上 就要嚴格遵守鏡像的格式要求:

[root@localhost ~]# docker tag nginx:latest docker.io/feixiangkeji974907/nginx:myfirst

這裡的feixiangkeji974907 要和 用戶名一樣

微服務之——docker 鏡像操作常用命令

推送鏡像

[root@localhost ~]# docker push docker.io/feixiangkeji974907/hello-world:test

微服務之——docker 鏡像操作常用命令

微服務之——docker 鏡像操作常用命令

刪除標籤

[root@localhost ~]# docker rmi docker.io/fxkj/alpine:latest

刪除鏡像(加INAME ID )

[root@localhost ~]# docker rmi fce289e99eb9

Error response from daemon: conflict: unable to delete fce289e99eb9 (must be forced) – image is being used by stopped container 3c431d073dc1

[root@localhost ~]# docker rmi -f fce289e99eb9 #-f 強制刪除

查看鏡像製作歷史、查看鏡像底層信息

[root@localhost ~]#docker history centos7:laster

[root@localhost ~]# docker inspect nginx:laster


分享到:


相關文章: