docker volume刪除卷的操作
要使用此命令,客戶端和守護(hù)程序API版本都必須至少為1.25。在客戶端上使用docker version命令可以檢查客戶端和守護(hù)程序API版本。
docker volume prune [OPTIONS]
刪除未被任何容器使用的本地卷。
OPTIONS 名稱,簡寫 說明 --filter 提供過濾值。 --force , -f 不提示確認(rèn)信息,直接刪除。 rm要使用此命令,客戶端和守護(hù)程序API版本都必須至少為1.21。在客戶端上使用docker version命令可以檢查客戶端和守護(hù)程序API版本。
docker volume rm [OPTIONS] VOLUME [VOLUME...]
刪除一個(gè)或多個(gè)卷。從1.25版本起,支持一個(gè)選項(xiàng)--force , -f,強(qiáng)制刪除一個(gè)或多個(gè)卷。
補(bǔ)充:docker 移除,裁剪,刪除(prune)不使用的鏡像、容器、卷、網(wǎng)絡(luò)
參考docker prune
提供 prune命令,用于移除不使用的鏡像、容器、卷、網(wǎng)絡(luò)。
Prune imagesdocker image prune移除沒有標(biāo)簽并且沒有被容器引用的鏡像,這種鏡像稱為 dangling(搖晃的) 鏡像。
示例1:docker image prune刪除了redis,無標(biāo)簽且無引用
#docker ps -aCONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEnginx latest ae2feff98a0c 4 days ago 133MBredis <none> ef47f3b6dc11 8 days ago 104MBcentos latest 300e315adb2f 12 days ago 209MBubuntu latest f643c72bc252 3 weeks ago 72.9MBdocs/docker.github.io latest 32ed84d97e30 6 months ago 1GB# docker image prune# docker imagesREPOSITORY TAG IMAGE ID CREATED SIZEnginx latest ae2feff98a0c 4 days ago 133MBcentos latest 300e315adb2f 12 days ago 209MBubuntu latest f643c72bc252 3 weeks ago 72.9MBdocs/docker.github.io latest 32ed84d97e30 6 months ago 1GB示例2:移除所有沒有容器使用的鏡像 -a
docker image prune -a
跳過警告提示:--force或-f
docker image prune -f示例3:執(zhí)行過濾刪除:
超過24小時(shí)創(chuàng)建的鏡像
docker image prune -a --filter 'until=24h'
關(guān)于過濾器的內(nèi)容,查看 docker image prune手冊
移除容器s當(dāng)停止容器,不會(huì)自動(dòng)刪除,除非在 docker run 時(shí)指定了 --rm。一個(gè)停止的容器可寫層仍然會(huì)占用磁盤空間,所以清除它,使用 docker container prune命令。
其他參數(shù)類似 docker images prune
移除卷卷會(huì)被一個(gè)或多個(gè)容器使用,并且占用主機(jī)空間。卷不會(huì)自動(dòng)移除,因?yàn)樽詣?dòng)移除,會(huì)破壞數(shù)據(jù)。
docker volume prune
其他參數(shù)類似 docker images prune
移除網(wǎng)絡(luò)Docker 網(wǎng)絡(luò)不會(huì)占用磁盤空間,但是他們創(chuàng)建了 iptables規(guī)則,橋接網(wǎng)絡(luò)服務(wù),路由entries。清除未被容器使用的網(wǎng)絡(luò),這么做
docker network prune
其他參數(shù)類似 docker images prune
移除 Everythingdocker system prune 命令是一個(gè)快捷方式,用于移除鏡像,容器,網(wǎng)絡(luò)。
在 Docker 17.06.0 和更早,卷也是可以移除的。在Docker 17.06.1或更高版本,需要指定參數(shù)--volumes。
示例(沒有移除卷):# docker system pruneWARNING! This will remove: - all stopped containers - all networks not used by at least one container - all dangling images - all build cacheAre you sure you want to continue? [y/N] y示例(有了移除卷功能):添加--volumes
# docker system prune --volumesWARNING! This will remove: - all stopped containers - all networks not used by at least one container - all volumes not used by at least one container - all dangling images - all build cacheAre you sure you want to continue? [y/N] y
其他參數(shù)類似 docker images prune
以上為個(gè)人經(jīng)驗(yàn),希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教。
相關(guān)文章:
1. ASP實(shí)現(xiàn)加法驗(yàn)證碼2. 詳細(xì)分析css float 屬性以及position:absolute 的區(qū)別3. HTML DOM setInterval和clearInterval方法案例詳解4. 阿里前端開發(fā)中的規(guī)范要求5. ASP基礎(chǔ)知識(shí)Command對象講解6. 得到XML文檔大小的方法7. ASP刪除img標(biāo)簽的style屬性只保留src的正則函數(shù)8. ASP中格式化時(shí)間短日期補(bǔ)0變兩位長日期的方法9. PHP循環(huán)與分支知識(shí)點(diǎn)梳理10. PHP設(shè)計(jì)模式中工廠模式深入詳解
