docker volume刪除卷的操作

2022-09-21 18:03:09 字數 2779 閱讀 2398

要使用此命令,客戶端和守護程式api版本都必須至少為1.25。在客戶端上使用docker version命令可以檢查客戶端和守護程式api版本。

docker volume prune [options]

刪除未被任何容器使用的本地卷。

名稱,簡寫

說明--filter

提供過濾值。

程式設計客棧

--force , -f

不提示確認資訊,直接刪除。

要使用此命令,客戶端和守護程式api版本都必須至少為1.21。在客戶端上使用docker version命令可以檢查客戶端和守護程式api版本。

docker volume rm [options] volume [volume...]

刪除乙個或多個卷。從1.25版本起,支援乙個選項--force , -f,強制刪除乙個或多個卷。

補充:docker 移除,裁剪,刪除(prune)不使用的映象、容器、卷、網路

參考docker prune

提供 prune命令,用於移除不使用的映象、容器、卷、網路。

docker image prune移除沒有標籤並且沒有被容器引用的映象,這種映象稱為 dangling(搖晃的) 映象。

刪除了redis,無標籤且無引用

#docker ps -a

container id image command created status ports names

# docker imagwww.cppcns.comes

repository tag image id created size

nginx latest ae2feff98a0c 4 days ago 133mb

redis ef47f3b6dc11 8 days ago 104mb

centos latest 300e315adb2f 12 days ago 209mb

ubuntu latest f643c72bc252 3 weeks ago 72.9mb

docs/docker.github.io latest 32ed84d97e30 6 months ago 1gb

# docker image prune

# docker images

repository tag image id created size

nginx latest ae2feff98a0c 4 days ago 133mb

centos latest 300e315adb2f 12 days ago 209mb

ubuntu latest f643c72bc252 3 weeks ago 72.9mb

docs/docker.github.io latest 32ed84d97e30 6 months ago 1gb

docker image prune -a

跳過警告提示:--force或-f

docker image prune -f

超過24小時建立的映象

docker image prune -a --filter "until=24h"

關於過濾器的內容,檢視 docker image prune手冊

當停止容器,不會自動刪除,除非在 docker run 時指定了 --rm。乙個停止的容器可寫層仍然會占用磁碟空間,所以清除它,使用 docker container prune命令。

其他引數類似 docker images prune

捲會被乙個或多個容器使用,並且占用主機空間。卷不會自動移除,因為自動移除,會破壞資料。

docker volume prune

其他引數類似 docker images prune

docker 網路不會占用磁碟空間,但是他們建立了 iptables規則,橋接網路服務,路由entries。清除未被容器使用的網路,這麼做

docker network prune

其他引數類似 docker images prune

docker system prune 命令是乙個快捷方式,用於移除映象,容器,網路。

在 docker 17.06.0程式設計客棧 和更早,卷也是可以移除的。在docker 17.06.1或更高版本,需要指定引數--volumes。

# docker system prune

warning! this will remove:

- all stopped containers

- all networks not used by at least one container

- all dangling images

- all build cache

are you sure you want to continue? [y/n] y

# docker system prune --volumes

warning! this will remove:

- all s containers

- all networks not used by at least one container

- all volumes not used by at least one container

- all dangling images

- all build cache

are you sure you want to continue? [y/n] y

其他引數類似 docker images prune

本文標題: docker volume刪除卷的操作

本文位址:

Docker volume 掛載卷的實現方法

最簡單的hello world輸出映象的製作是最簡單的開始,但是如果我們需要修改我們的執行 或者有輸入kqlrncuxhz輸出檔案的時候,我們就沒有辦法了,每乙個container執行完畢後,其kqlrncuxhz分配的資源以及檔案系統都會消失,那麼我們就需要在本地給docker container...

docker volume資料掛載

背景 未解決多個應用資料共享,docker有自己非常好的解決方案。即通過volume掛載,將硬碟上的資料或者檔案對映到映象容器中,達到乙份資料多處使用,即時修改,即時生效。下面介紹兩種docker資料掛載的方法 1.在執行執行時掛載 將本地目錄掛載到映象虛擬目錄 不足之處在於每次都要寫本地目錄,不容...

深入理解 Docker Volume

本文主要介紹了docker volume的原理以及使用方式,是docker入門教程的延伸。作者通過從資料的共享 資料容器 備份 許可權以及刪除volume五方面深入介紹了volume的工作原理,從實戰中幫助讀者了解volume。從docker irc頻道以及 stackoverflow 的問題來看,...