Docker system

docker system --help

bash 复制代码
siqi@aliyun-sh-001:~/images$ sudo docker system --help

Usage:  docker system COMMAND

Manage Docker

Commands:
  df          Show docker disk usage(显示docker磁盘使用情况)
  events      Get real time events from the server(从服务器获取实时事件)
  info        Display system-wide information (显示系统信息)
  prune       Remove unused data(删除不使用的数据)

Run 'docker system COMMAND --help' for more information on a command.

docker system df

提供Docker整体磁盘使用率的概况,包括镜像、容器和(本地)volume。所以我们现在随时都可以查看Docker使用了多少资源

bash 复制代码
siqi@aliyun-sh-001:~/code/data-analysis/api$ sudo docker system df
TYPE            TOTAL     ACTIVE    SIZE      RECLAIMABLE
Images          48        22        48.73GB   38.21GB (78%)
Containers      29        29        10.44MB   0B (0%)
Local Volumes   107       4         93.68GB   93.62GB (99%)
Build Cache     116       0         3.66MB    3.66MB

docker system prune

删除所有未使用的容器、网络、映像(包括悬挂的和未引用的),以及卷(可选)

  • 未使用的容器:所有已停止的容器将被删除
  • 未使用的镜像:只有悬挂的镜像(未被任何容器引用)将被删除,除非使用了 -a 或 --all 参数
  • 未使用的网络:所有未被容器使用的自定义网络将被删除
  • 未使用的卷(如果使用 --volumes 或 -v 选项):所有未被容器引用的卷将被删除

相关参数:

  • -a, --all:删除未被任何容器引用的所有镜像,而不仅仅是悬挂的镜像
  • --filter:根据提供的条件过滤要删除的内容
  • --force, -f:跳过确认步骤,直接执行删除,不加的话在执行步骤时需要手动确认,建议不用。手动容错率高一点
  • --volumes, -v:删除所有未被至少一个容器引用的卷

删除所有未使用的容器、镜像、网络:docker system prune

删除所有未使用的容器、镜像(包括未被引用的)、网络:docker system prune -a

删除所有未使用的容器、镜像、网络、卷:docker system prune --volumes

bash 复制代码
siqi@aliyun-sh-001:~/images$ sudo docker system prune
WARNING! This will remove:
  - all stopped containers
  - all networks not used by at least one container
  - all dangling images
  - all dangling build cache

Are you sure you want to continue? [y/N] y
Deleted Images:
deleted: sha256:d66359a5ae191ca285bc1167518dea4fd83536e5135c017503205637ef365ffe

Deleted build cache objects:
76d2jytvsnm5zni5k03nb1nlq
ndsu19mwql70b6kt9yktrpwon
q9tsol0v4tkfzfoszvo2x9zvx
vrwfqcagz7r8ifu5cnlhdfrt4
syi02l2bsnvzrwjpweaulu8re

Total reclaimed space: 5.618GB

docker container prune

删除所有未运行的容器

bash 复制代码
siqi@aliyun-sh-001:~/images$ sudo docker container prune
WARNING! This will remove all stopped containers.
Are you sure you want to continue? [y/N] y
Total reclaimed space: 0B

docker image prune

要删除所有未使用的镜像

bash 复制代码
siqi@aliyun-sh-001:~/images$ sudo docker image prune
WARNING! This will remove all dangling images.
Are you sure you want to continue? [y/N] y
Total reclaimed space: 0B

docker network prune

要删除所有未使用的网络

bash 复制代码
siqi@aliyun-sh-001:~/images$ sudo docker network prune
WARNING! This will remove all custom networks not used by at least one container.
Are you sure you want to continue? [y/N] y

docker volume prune

删除所有未使用的卷

bash 复制代码
siqi@aliyun-sh-001:~/images$ sudo docker volume prune
WARNING! This will remove all local volumes not used by at least one container.
Are you sure you want to continue? [y/N] y
Deleted Volumes:
22522c1e24da1fb2826c5d3f58248a5c0b2886813c2298a5c196bb8632c3bc31
4b1900b4f3c40bb3c85a0c68cae8ac2b888529482879abd18c8390c4f2dd6ac8
8bb0075d091b1c2fde3b955de96e47695f93191e09e71eee403e5c6edcb827de
415f3d9b5a229d615a734c7488ca1f29b0e7abc2adb6544229078c5cfdba7d4b
c3bfd05a31061f8e48fecf85dd7277a3498ae322dfb053b2fb6372c02bee88f6
b1c5f43ade5237ca757bf6075ed7ff259f4967a0235589fbc083e7fe64c47503
9f8841f01afd7f6b23408d04ae1b58b5c34102b63787dc8fc997782fae76e222
38e9235262c538ee4debeff1fe92f2cada6013daa42a13584e4003441f95a64b
8f0c9ba87d77a9f812283a0d03299557c79322a8149385ac52c4023afea73961
1f6c0a82e016e8b2024ab8d8d14b569fca5514092f05eea665754b3b84d02f82
4789f8d09149739a6b3898a4dc05e1a508da4ba58354ffbf4c178aa6d200f8cd
1cb3a882f4c7d7f43394318d69cc7882fe419cd00495f959f4fcdb90e36a4a5c
6f1a57c764e2b9c542ceea16bed4c0f418e9da6f38d06f9217b49b780ea845b2
61fa635ee216502ace3cce349f9b8bea3530349f97bbc96fd3bc0284e568f70f
692d6655178c3e03739742820ed14b7a254ca74219de2fe0022aa7eb7e45286c
3c63057faee65ebb8726d238c9e5c4e1eeffbb0a292736a45aed7b44eddb6f79
ff680dc86b395e25ea60c75a65aa437086e6886e04e7bd75cc3c118362bdf32e
0c18d949fe762fcb9bcbd296f05f20542c7120f4ae16b1bf6ca02bf3adfd2402
e872c660f770e3c54f582e35f7eb401cb400cfcb48328ae57ea8f16e875402b9
97767c652ff164883d80fd01ff5e323793cb519ddce0ef9c95b82823ac3943d9
3b2902e6c30747c1c8b67e94ff31872189bc100cfe81c89a1c8f9e174bb97eeb
9248123749c8525a06c650e0bac2900f35285d9c8dad51262978f350d1ea700d
9439364ecd0d1161714e1123041eef6b95c4e37f28194ba6fa2c3d469c7136c5
b2bb414b4e75fd570a07e36ba612e8b5eb65158b5f26c54922a33a647dbd0180
0160e74f7b174c08532e396adadbac1b40b250bc2f0a01e27bc8d96c20f007d2
a11b9f5477bac6a07e1fc9bf45384e320d15f8d9f6ecd3487b2d4a4726753c81
bca4251b76d8c709177e666a6375e640d3120fb55484924de05bc81cf1f2ca0e

Total reclaimed space: 1.286MB
相关推荐
jugt1 小时前
CentOS 7.9安装Nginx1.24.0时报 checking for LuaJIT 2.x ... not found
linux·运维·centos
21号 13 小时前
9.进程间通信
linux·运维·服务器
阿福不是狗5 小时前
Python使用总结之Mac安装docker并配置wechaty
python·macos·docker
叶落闲庭8 小时前
【k8s】k8s集群搭建
云原生·容器·kubernetes
搬码临时工8 小时前
电脑同时连接内网和外网的方法,附外网连接局域网的操作设置
运维·服务器·网络
藥瓿亭8 小时前
K8S认证|CKS题库+答案| 3. 默认网络策略
运维·ubuntu·docker·云原生·容器·kubernetes·cks
xyhshen8 小时前
k8s下离线搭建elasticsearch
elasticsearch·容器·kubernetes
Gaoithe8 小时前
ubuntu 端口复用
linux·运维·ubuntu
椰汁菠萝9 小时前
k8s集群安装坑点汇总
云原生·容器·kubernetes
背太阳的牧羊人10 小时前
sudo docker exec -it backend bash 以交互方式(interactive)进入正在运行的 Docker 容器的命令行环境
docker·容器·bash