• docker查看容器占用磁盘大小


    Docker 1.13引入了docker system df命令,类似于Linux上的df命令,用于查看Docker的磁盘使用情况。

    $ docker system df
    TYPE                TOTAL     ACTIVE    SIZE          RECLAIMABLE
    Images              3         0         5.373GB       5.373GB (100%)
    Containers          0         0         0B            0B
    Local Volumes       0         0         0B            0B

    查看单个image、container大小:docker system df -v

    [root@localhost ~]# docker system df -v
    Images space usage:
     
    REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE                SHARED SIZE         UNIQUE SIZE         CONTAINERS
    mongo               latest              66c68b650ad4        5 weeks ago         387.8MB             64.21MB             323.6MB             1
    rabbitmq            management          1c1e1f201079        7 weeks ago         181.5MB             151.4MB             30.09MB             1
    rabbitmq            latest              3e5ddca64bb7        7 weeks ago         151.4MB             151.4MB             0B                  0
     
    Containers space usage:
     
    CONTAINER ID        IMAGE                 COMMAND                  LOCAL VOLUMES       SIZE                CREATED             STATUS                    NAMES
    1a0bb1ac1c52        mongo                 "docker-entrypoint.s…"   1                   2.74MB              5 weeks ago         Up 7 hours                docker_mongodb
    73417264c538        rabbitmq:management   "docker-entrypoint.s…"   1                   1.73kB              6 weeks ago         Exited (255) 2 days ago   rabbitmq
     
    Local Volumes space usage:
     
    VOLUME NAME                                                        LINKS               SIZE
    13856e3cfd4af0a2d695cca746c4039213a66901c43326a3c14391c61bf07d21   0                   285.6MB
    2e7a18c2cde8bc82ad145138d495b3bdfe7329870a130874ef11aff57df2a955   1                   0B
    556df6317f798afb15cf6bdc8c6763ab45cabf2b09304545bcd319049ff61cef   1                   338.9MB
    e7c82573f88c7e083445cbc611ed753ab26e36c73964fed323f7e38e3cb431b4   0                   440.5MB
     
    Build cache usage: 0B
     
    CACHE ID            CACHE TYPE          SIZE                CREATED             LAST USED           USAGE               SHARED

    Docker提供了docker system prune,可以用于清理dangling镜像(参考What are Docker <none>:<none> images?)和容器,以及失效的数据卷和网络。

    $ docker system prune
    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 dangling images
    Are you sure you want to continue? [y/N] y
    Deleted Containers:
    1cdf866157b4a97e151125af3c2a7f186a59b6f63807e2014ce1a00d68f44e1d
    Deleted Images:
    deleted: sha256:f59bb277...
    deleted: sha256:695b8e70...
    deleted: sha256:93b1cceb...
    deleted: sha256:c74d6bcd...
    deleted: sha256:df8b9bb1...
    deleted: sha256:dfe8340f...
    deleted: sha256:ce1ee654...
    Total reclaimed space: 3.221GB

    名称为<none>:<none>,为dangling镜像,因此会被删除。同时,所有的中间镜像也会被删除。

    更进一步,使用-a选项可以做深度清理。这时我们会看到更加严重的WARNING信息:

    $ 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 Images:
    untagged: test:latest
    deleted: sha256:c515ebfa2...
    deleted: sha256:07302c011...
    deleted: sha256:37c0c6474...
    deleted: sha256:5cc2b6bc4...
    deleted: sha256:b283b9c35...
    deleted: sha256:8a8b9bd8b...
    untagged: alpine:latest
    untagged: alpine@sha256:58e1a1bb75db1...
    deleted: sha256:4a415e366...
    deleted: sha256:23b9c7b43...
    Total reclaimed space: 2.151GB

    这个命令将清理整个系统,并且只会保留真正在使用的镜像,容器,数据卷以及网络,因此需要格外谨慎。比如,我们不能在生产环境中运行prune -a命令,因为一些备用镜像(用于备份,回滚等)有时候需要用到,如果这些镜像被删除了,则运行容器时需要重新下载。

    此时,所有未绑定容器的镜像将会被删除。由于第一次prune命令删除了所有容器,因此所有镜像(它们没有绑定任何容器)都会被删除。

    参考:

    https://blog.csdn.net/dmw412724/article/details/107126828

    http://dockone.io/article/2258

  • 相关阅读:
    angularJS 作用域
    html5的一些表单属性。
    UIScrollView 原理详解
    远程实时调试手机上的Web页面
    Web移动应用调试工具——Weinre
    WebView注入Java对象注意事项
    Android中Webview使用自定义的javascript进行回调
    [Android] Web Console: Uncaught TypeError: Object [object Object] has no method 'xxx'
    android 中 webview 怎么用 localStorage?
    iPhone 6 屏幕揭秘
  • 原文地址:https://www.cnblogs.com/sfnz/p/15975533.html
Copyright © 2020-2023  润新知