为了账号安全,请及时绑定邮箱和手机立即绑定

Docker System Command Manage Docker

标签:
Docker

webp

昨日青空

Docker System 相关命令说明:

命令描述
docker system df显示 docker 磁盘使用情况
docker system events获取 server 实时实践
docker system info显示系统范围的信息
docker system prune删除无用数据

docker system df

这个命令显示 docker daemon 磁盘空间的使用情况。示例:

$ docker system df

TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              3                   1                   456.6MB             361.7MB (79%)
Containers          1                   1                   0B                  0B
Local Volumes       1                   1                   0B                  0B
Build Cache         0                   0                   0B                  0B

查看详情,使用加上 -v 标识:

$ docker system df -v

Images space usage:REPOSITORY                                      TAG                 IMAGE ID            CREATED ago         SIZE                SHARED SIZE         UNIQUE SiZE         CONTAINERS
redis                                           latest              1babb1dde7e1        10 days ago ago     94.91MB             0B                  94.91MB             1redis                                           4.0.9               bfcb1f6df2db        6 months ago ago    106.7MB             0B                  106.7MB             0registry.cn-hangzhou.aliyuncs.com/anoy/ubuntu   latest              e72898b400f8        15 months ago ago   254.9MB             0B                  254.9MB             0Containers space usage:CONTAINER ID        IMAGE               COMMAND                  LOCAL VOLUMES       SIZE                CREATED ago              STATUS              NAMES
b67d3fff0ccc        redis               "docker-entrypoint.s…"   1                   0B                  About a minute ago ago   Up About a minute   compassionate_leakey

Local Volumes space usage:VOLUME NAME                                                        LINKS               SIZE9efe55b2bef5d96d6584f2fe6a81834368a4a82faf0ba248e1b63e10f3c5a2a3   1                   0B

Build cache usage: 0B

相关参数说明:

  • SHARED SIZE 表示一个镜像和其他镜像共享的空间量

  • UNIQUE SiZE 表示该镜像独有的空间量

  • SIZE 表示 [shared size] + [unique size]

docker system events

这个命令获取 server 端的实时事件,这些事件因 docker 对象类型而异。

对象类型:containers

  • attach

  • commit

  • copy

  • create

  • destroy

  • detach

  • die

  • exec_create

  • exec_detach

  • exec_start

  • export

  • health_status

  • kill

  • oom

  • pause

  • rename

  • resize

  • restart

  • start

  • stop

  • top

  • unpause

  • update

对象类型:images

  • delete

  • import

  • load

  • pull

  • push

  • save

  • tag

  • untag

对象类型:plugins

  • install

  • enable

  • disable

  • remove

对象类型:volumes

  • create

  • mount

  • unmount

  • destroy

对象类型:networks

  • create

  • connect

  • disconnect

  • destroy

对象类型:daemons

  • reload

可选参数:

名称, 短名称描述
--filter , -f根据条件过滤输出
--since起始时间戳,只显示该时间后的事件
--until截止时间戳,只显示该时间前的事件

打开两个终端窗口,示例:


webp

目前支持的过滤条件如下:

  • container (container=<name or id>)

  • daemon (daemon=<name or id>)

  • event (event=<event action>)

  • image (image=<tag or id>)

  • label (label=<key> or label=<key>=<value>)

  • network (network=<name or id>)

  • plugin (plugin=<name or id>)

  • type (type=<container or image or volume or network or daemon or plugin>)

  • volume (volume=<name or id>)

打开两个终端窗口,示例:


webp

docker system info

显示系统范围的信息,与 docker info 输出结果一致

docker system prune

删除所有未使用的容器、网络、镜像以及数据卷。

基本命令,示例 docker system prune

$ 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
Total reclaimed space: 0B

提示:dangling images 表示 docker images 标签为 <none> 的镜像

基本命令,示例 docker system prune -a

$ docker system prune -a

WARNING! This will remove:
        - all stopped containers
        - all networks not used by at least one container
        - all images without at least one container associated to them
        - all build cache
Are you sure you want to continue? [y/N] y

提示:-a 会额外删除没有容器使用的镜像

删除数据卷,示例 docker system prune -a --volumes

$ docker system prune -a --volumes
WARNING! 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 images without at least one container associated to them
        - all build cache
Are you sure you want to continue? [y/N] y

提示:--volumes 会额外删除没有容器使用的数据卷



作者:Anoyi
链接:https://www.jianshu.com/p/31df07603331


点击查看更多内容
TA 点赞

若觉得本文不错,就分享一下吧!

评论

作者其他优质文章

正在加载中
  • 推荐
  • 评论
  • 收藏
  • 共同学习,写下你的评论
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦
今天注册有机会得

100积分直接送

付费专栏免费学

大额优惠券免费领

立即参与 放弃机会
意见反馈 帮助中心 APP下载
官方微信

举报

0/150
提交
取消