专注于 JetBrains IDEA 全家桶,永久激活,教程
持续更新 PyCharm,IDEA,WebStorm,PhpStorm,DataGrip,RubyMine,CLion,AppCode 永久激活教程

Docker实战Docker常用命令之资源篇

资源命令

docker stats

显示一个或多个容器资源使用情况统计信息的实时流。

  • 帮助
[root@t32 docker]# docker stats --help

Usage:  docker stats [OPTIONS] [CONTAINER...]

Display a live stream of container(s) resource usage statistics

Options:
  -a, --all             Show all containers (default shows just running)
      --format string   Pretty-print images using a Go template
      --help            Print usage
      --no-stream       Disable streaming stats and only pull the first result
[root@t32 docker]# 

  • 例子
[root@t32 docker]# docker stats 389458e3835f  fc8412329b91

CONTAINER           CPU %               MEM USAGE / LIMIT       MEM %               NET I/O             BLOCK I/O           PIDS
389458e3835f        0.05%               18.77 MiB / 251.6 GiB   0.01%               0 B / 0 B           0 B / 0 B           67
fc8412329b91        0.00%               436 KiB / 251.6 GiB     0.00%               2.82 GB / 156 MB    0 B / 6.19 GB       1

docker system

管理docker系统

  • 帮助
[root@t32 docker]# docker system --help

Usage:  docker system COMMAND

Manage Docker

Options:
      --help   Print usage

Commands:
  df          Show docker disk usage
  events      Get real time events from the server
  info        Display system-wide information
  prune       Remove unused data

dockre system df

显示docker的硬盘使用情况

  • 帮助
[root@t32 docker]# docker system df  --help

Usage:  docker system df [OPTIONS]

Show docker disk usage

Options:
      --help      Print usage
  -v, --verbose   Show detailed information on space usage

  • 例子
[root@t32 docker]# docker system df 
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              16                  12                  4.922 GB            2.678 GB (54%)
Containers          22                  19                  1.46 GB             0 B (0%)
Local Volumes       2                   2                   47.13 MB            0 B (0%)

  • RECLAIMABLE:可回收的磁盘空间
  • SIZE:使用的磁盘空间

docker system events

和docker events用法一样,具体参见我的另外一篇文章Docker专题—Docker常用命令之基础篇

docker system info

和docker info用法一样,具体参见我的另外一篇文章Docker专题—Docker常用命令之基础篇

docker system prune

删除可回收的资源

  • 帮助
[root@t32 docker]# docker system prune --help

Usage:  docker system prune [OPTIONS]

Remove unused data

Options:
  -a, --all     Remove all unused images not just dangling ones
  -f, --force   Do not prompt for confirmation
      --help    Print usage

  • 例子
[root@t32 docker]# docker system prune -a 
WARNING! This will remove:
    - all stopped containers
    - all volumes not used by at least one container
    - all networks not used by at least one container
    - all images without at least one container associated to them
Are you sure you want to continue? [y/N] y
Deleted Containers:
fa44aaf111d88862a5eb7718f15b9a4f26b7814f9f77bf03851319acb161d75b
bd1eeaa010500f77398b4dc4437d384f688ac72571dcaf25f1339237abb48548
9d5840153e06906f054d5995c81950793f17425f9db9ed4cef11b05cb5922107

Deleted Images:
untagged: docker.io/centos:latest
untagged: docker.io/rancher/calico-cni:v3.4.0
.....

Total reclaimed space: 2.83 GB
[root@t32 docker]# docker system df 
TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
Images              10                  10                  2.092 GB            4.148 MB (0%)
Containers          19                  19                  1.46 GB             0 B (0%)
Local Volumes       2                   2                   47.13 MB            0 B (0%)
[root@t32 docker]# 

文章永久链接:https://tech.souyunku.com/44231

未经允许不得转载:搜云库技术团队 » Docker实战Docker常用命令之资源篇

JetBrains 全家桶,激活、破解、教程

提供 JetBrains 全家桶激活码、注册码、破解补丁下载及详细激活教程,支持 IntelliJ IDEA、PyCharm、WebStorm 等工具的永久激活。无论是破解教程,还是最新激活码,均可免费获得,帮助开发者解决常见激活问题,确保轻松破解并快速使用 JetBrains 软件。获取免费的破解补丁和激活码,快速解决激活难题,全面覆盖 2024/2025 版本!

联系我们联系我们