昨日青空
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 1
- Redis 4.0.9 bfcb1f6df2db 6 months ago ago 106.7MB 0B 106.7MB 0
- registry.cn-hangzhou.aliyuncs.com/anoy/Ubuntu latest e72898b400f8 15 months ago ago 254.9MB 0B 254.9MB 0
- Containers 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 SIZE
- 9efe55b2bef5d96d6584f2fe6a81834368a4a82faf0ba248e1b63e10f3c5a2a3 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 | 截止时间戳,只显示该时间前的事件 |
打开两个终端窗口, 示例:
目前支持的过滤条件如下:
- 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>)
打开两个终端窗口, 示例:
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 会额外删除没有容器使用的数据卷
来源: http://www.jianshu.com/p/31df07603331