首页 > 其他分享 >如果正确清理docker可用回收资源

如果正确清理docker可用回收资源

时间:2024-02-27 18:12:18浏览次数:27  
标签:ago pause 清理 回收 0B dev01 docker k8s minutes

正确清理Docker可用回收资源


必须条件

  1. docker.service正常运行
  2. 执行docker system prune,如下
    <root@DEV-K8S-WN4 ~># 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 Containers:
    674d9473dc2fc4c0b0c8361d2401a2611ea236a18a208e3d4bbe4c184b2c7045
    d17bde2fe41f8f38f91cc5ce9aaef09f80f6cfca5eee115ea9d75e93cbe8c880
    0aacedbb922026e9d83ca56278d05c1f6fc3be941d4edc29b1dcc45a22063e53
    8562ea163ada849bccb23f4b4ee0761c79ac1500e775a1db00091136bbef7f6c
    62212eb72838f94c8b181c1249565f010e8dd32fd32b0448ffa437ef8fa4d9a4
    05169ab3427be6fdf40abad7480f217e7a82bb97a576d499adf4884e84c1d518
    96e47a6793a533fabe7d6137fde21d39c6666890c24255ed9790475dd4f120da
    
    Total reclaimed space: 40.31kB
  3. 使用docker system df命令校验资源是否释放,如下
    <root@DEV-K8S-WN4 ~># docker system df
    TYPE                TOTAL               ACTIVE              SIZE                RECLAIMABLE
    Images              12                  9                   4.329GB             1.74GB (40%)
    Containers          29                  28                  178.6kB             6.656kB (3%)
    Local Volumes       0                   0                   0B                  0B
    Build Cache         0                   0                   0B                  0B
  4. 显示详细信息,如下
    <root@DEV-K8S-WN4 ~># docker system df -v
    Images space usage:
    
    REPOSITORY                                             TAG                        IMAGE ID            CREATED             SIZE                SHARED SIZE         UNIQUE SIZE         CONTAINERS
    imagehub.qiangyun.com/nfsp/fin-custom-entrance         SNAPSHOT-JobWarning-36     b63f9000f747        3 weeks ago         1.353GB             203.6MB             1.15GB              2
    imagehub.qiangyun.com/xy/xy-trade                      SNAPSHOT-BRP-7556-187      d329674a5d9a        5 weeks ago         1.308GB             1.145GB             162.3MB             2
    imagehub.qiangyun.com/basic-service/xianxiang-eureka   SNAPSHOT-k8sformaster-59   ea177f74814a        8 months ago        1.234GB             1.145GB             88.34MB             1
    imagehub.qiangyun.com/xy/xy-manage                     SNAPSHOT-master-187        a5cbd5b15109        14 months ago       1.38GB              1.145GB             234.4MB             1
    imagehub.qiangyun.com/xc/xc-fund                       SNAPSHOT-vesta-test-171    efcb9af70ff9        24 months ago       1.403GB             1.145GB             257.5MB             0
    imagehub.qiangyun.com/nfsp/nflc-core-server            SNAPSHOT-master-9          7b5de94bc784        3 years ago         856.6MB             203.6MB             653MB               1
    k8s.gcr.io/kube-proxy                                  v1.18.5                    a1daed4e2b60        3 years ago         117.1MB             0B                  117.1MB             1
    quay.io/prometheus/node-exporter                       v1.0.1                     0e0218889c33        3 years ago         26.43MB             0B                  26.43MB             1
    calico/node                                            v3.14.1                    04a9b816c753        3 years ago         263.1MB             105.7MB             157.3MB             1
    calico/pod2daemon-flexvol                              v3.14.1                    7f93af2e7e11        3 years ago         112.4MB             0B                  112.4MB             1
    calico/cni                                             v3.14.1                    35a7136bc71a        3 years ago         225.1MB             105.7MB             119.3MB             2
    k8s.gcr.io/pause                                       3.2                        80d28bedfe5d        4 years ago         682.7kB             0B                  682.7kB             21
    
    Containers space usage:
    
    CONTAINER ID        IMAGE                                                  COMMAND                  LOCAL VOLUMES       SIZE                CREATED              STATUS                            NAMES
    5c116a8d8ff4        7f93af2e7e11                                           "/usr/local/bin/flex…"   0                   0B                  4 seconds ago        Exited (0) 4 seconds ago          k8s_flexvol-driver_calico-node-sdgc8_kube-system_ca7fd327-6333-455a-8bca-88a3490429ae_0
    16a5dde61673        35a7136bc71a                                           "/install-cni.sh"        0                   0B                  6 seconds ago        Exited (0) 5 seconds ago          k8s_install-cni_calico-node-sdgc8_kube-system_ca7fd327-6333-455a-8bca-88a3490429ae_0
    a039bf06f51d        35a7136bc71a                                           "/opt/cni/bin/calico…"   0                   0B                  7 seconds ago        Exited (0) 6 seconds ago          k8s_upgrade-ipam_calico-node-sdgc8_kube-system_ca7fd327-6333-455a-8bca-88a3490429ae_0
    d45b71b61d86        imagehub.qiangyun.com/xy/xy-trade                      "start.sh"               0                   39.4kB              31 seconds ago       Up 31 seconds                     k8s_dev01-xy-trade_dev01-xy-trade-657c6b4c99-fnxfz_dev_6e14c4e2-0815-4892-ac9d-4981effb06c6_4
    5f63104027f6        imagehub.qiangyun.com/nfsp/fin-custom-entrance         "start.sh"               0                   42.8kB              About a minute ago   Up About a minute                 k8s_dev01-fin-custom-entrance_dev01-fin-custom-entrance-7f9788c687-5swfk_dev_2b0abdd3-ee02-4495-b1d6-1ce23209e87f_2
    2caebebecb36        imagehub.qiangyun.com/nfsp/nflc-core-server            "start.sh"               0                   7.66kB              About a minute ago   Exited (1) 32 seconds ago         k8s_dev01-nflc-core-server_dev01-nflc-core-server-6b69768447-96lc8_dev_518e6527-1bbf-49b9-be4a-c9254683fd94_0
    ba77ab9a648f        imagehub.qiangyun.com/xy/xy-manage                     "start.sh"               0                   62.9kB              About a minute ago   Up About a minute                 k8s_dev01-xy-manage_dev01-xy-manage-68846595fd-jrtd2_dev_9a380879-0a5f-49ad-a537-5fa4c57cb07f_2
    7fa44e0a2261        imagehub.qiangyun.com/xy/xy-trade                      "start.sh"               0                   6.66kB              3 minutes ago        Exited (1) About a minute ago     k8s_dev01-xy-trade_dev01-xy-trade-657c6b4c99-fnxfz_dev_6e14c4e2-0815-4892-ac9d-4981effb06c6_3
    3b8b34f2ea9f        imagehub.qiangyun.com/nfsp/fin-custom-entrance         "start.sh"               0                   10.1kB              6 minutes ago        Exited (143) About a minute ago   k8s_dev01-fin-custom-entrance_dev01-fin-custom-entrance-7f9788c687-5swfk_dev_2b0abdd3-ee02-4495-b1d6-1ce23209e87f_1
    46f54ce337f1        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  10 minutes ago       Up 10 minutes                     k8s_POD_dev01-nflc-core-server-6b69768447-96lc8_dev_518e6527-1bbf-49b9-be4a-c9254683fd94_0
    8238df374621        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-fin-custom-entrance-7f9788c687-5swfk_dev_2b0abdd3-ee02-4495-b1d6-1ce23209e87f_0
    a02194c57c73        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-nisp-manage-59f75bd78f-prm5r_dev_55194061-2828-42ec-8083-45451232b954_0
    92e27a3b7eb4        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-xy-manage-68846595fd-jrtd2_dev_9a380879-0a5f-49ad-a537-5fa4c57cb07f_0
    67a5808f843e        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-common-trust-service-5d7c546665-dbwp8_dev_2afd6b9c-59aa-44f0-ac64-41e0d7e7c87a_0
    0784a9148532        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-xy-loan-6ff8f6776c-qzq7q_dev_fe54357c-010f-4165-8508-e66e5aebc955_0
    2c9e3ec7ef2b        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-xc-event-b967dd46b-8hn9k_dev_95953d68-ea7a-428d-acb4-513f896078db_0
    fb7f6acbbdd2        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-xy-loan-7cc56448b-mmkr2_dev_a312f2a6-52ed-4c92-8cdf-9582ccd46faf_0
    97683a358d32        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-nisp-manager-service-b9b56597f-bd75s_dev_a319e46f-fb8a-4feb-bd23-1b2ec03a7958_0
    c90a894748c9        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-payment-service-984664869-96jrx_dev_04a2a495-4dc3-4755-ada0-d10c77f39b61_0
    d080652bd12a        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-common-gateway-6fc7c7dd6f-tbjdb_dev_dfd638f9-7eb9-4bb8-835f-2afdc9083777_0
    2375b8ba10a9        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-xianxiang-zuul-7895997fdc-55qs7_dev_d089afda-e924-4d30-b23c-1f95acc91204_0
    e7b35935840f        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-fin-bank-outbound-75564f4f95-7tp89_dev_c9482ea4-55e2-4a23-9345-cf6128a94035_0
    50ede9c5c426        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-common-service-5b547f9776-njzz6_dev_48096fa1-9f17-4be6-b8f5-d2eca9caa192_0
    fba81f96e1e2        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-fin-core-746f4c85c-v7bnm_dev_26015c4d-b378-415c-b276-cf0fc9bdbd1f_0
    90608ec0c8ee        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  13 minutes ago       Up 13 minutes                     k8s_POD_dev01-xy-trade-657c6b4c99-fnxfz_dev_6e14c4e2-0815-4892-ac9d-4981effb06c6_0
    18665a1a1790        calico/node                                            "start_runit"            0                   12.6kB              About an hour ago    Up About an hour                  k8s_calico-node_calico-node-sdgc8_kube-system_ca7fd327-6333-455a-8bca-88a3490429ae_0
    2e19cbc83956        imagehub.qiangyun.com/basic-service/xianxiang-eureka   "start.sh"               0                   32.8kB              About an hour ago    Up About an hour                  k8s_dev01-eureka_dev01-eureka-0_dev_a0ccfd91-8b7e-42f6-ac29-c743bbad86f2_0
    09cbb0cb3d14        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  About an hour ago    Up About an hour                  k8s_POD_dev01-eureka-0_dev_a0ccfd91-8b7e-42f6-ac29-c743bbad86f2_1
    91956caf4f19        k8s.gcr.io/kube-proxy                                  "/usr/local/bin/kube…"   0                   2.29kB              About an hour ago    Up About an hour                  k8s_kube-proxy_kube-proxy-z2qzg_kube-system_5fcf18c7-0cc6-4369-acfa-1b8e8277e5a0_0
    fbf4791f44c4        quay.io/prometheus/node-exporter                       "/bin/node_exporter …"   0                   0B                  About an hour ago    Up About an hour                  k8s_prometheus-node-exporter_prometheus-node-exporter-7vhs9_default_f4c7322b-bd4f-444b-bd57-de7f21f5a747_0
    3218d80f5cac        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  About an hour ago    Up About an hour                  k8s_POD_calico-node-sdgc8_kube-system_ca7fd327-6333-455a-8bca-88a3490429ae_0
    f492d6167c3b        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  About an hour ago    Up About an hour                  k8s_POD_kube-proxy-z2qzg_kube-system_5fcf18c7-0cc6-4369-acfa-1b8e8277e5a0_0
    99c990d4de07        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  About an hour ago    Up About an hour                  k8s_POD_logtail-ds-pd6kl_kube-system_33603cc0-f069-4858-ab0b-fcfbcdad2ce1_0
    f2eb9ed40b2a        k8s.gcr.io/pause:3.2                                   "/pause"                 0                   0B                  About an hour ago    Up About an hour                  k8s_POD_prometheus-node-exporter-7vhs9_default_f4c7322b-bd4f-444b-bd57-de7f21f5a747_0
    
    Local Volumes space usage:
    
    VOLUME NAME         LINKS               SIZE
    
    Build cache usage: 0B
    
    CACHE ID            CACHE TYPE          SIZE                CREATED             LAST USED           USAGE               SHARED

     

标签:ago,pause,清理,回收,0B,dev01,docker,k8s,minutes
From: https://www.cnblogs.com/apink/p/18037496

相关文章

  • Docker-Overlay2磁盘空间爆满清理方法
    Docker-Overlay2磁盘空间爆满清理方法在日常线上环境中,我们通常会来做利用Docker来做容器化管理,通过运行容器来执行任务等。但是,随着业务量的不断增大,容器的不断启动,往往会出现磁盘空间不足,1、第一种情况:是因为docker中部署的系统中日志内容的不断扩大。这种情况下,我们可手动,或定......
  • Docker_学习记录2
    本篇随笔为Docker学习记录(2),所有内容均参考尚硅谷Docker实战教程以及云原生开发安装mysql主从复制新建主服务器容器实例3307dockerrun-p3307:3306\ --namemysql-master\ --privileged=true\ -v/yiran/mysql-master/log:/var/log/mysql\ -v/yir......
  • Docker部署达梦数据库
    下载下载地址安装#导入镜像dockerload-idm8_20230808_rev197096_x86_rh6_64_single.tar#运行容器dockerrun-d-p5236:5236--namedm8--privileged=true-eCASE_SENSITIVE=N-ePAGE_SIZE=16-eLD_LIBRARY_PATH=/opt/dmdbms/bin-eEXTENT_SIZE=32-eBLANK_......
  • Docker
    docker总结和实例常用命令镜像管理镜像搜索dockerseartch镜像名或者关键词镜像拉取dockerpull镜像名:标签镜像罗列dockerimages镜像删除dockerrmi镜像id或者镜像名:标签镜像导出dockersave-o文件名.tar镜像名:标签镜像导入dockerload......
  • Docker环境安装细步骤
    如果之前已有安装有docker需要重新安装,先进行卸载,如果没安装忽略此步骤yumremovedockerdocker-clientdocker-client-latestdocker-commondocker-latestdocker-latest-logrotatedocker-logrotatedocker-engine安装Docker服务安装yum-utils安装所需的依赖组件软件包,执......
  • Dockerfile构建出错:Error response from daemon: pull access denied for hwjdk, rep
    原因:FROMhwjdk这样写,其实默认查找的是hwjdk:latest,而如果你的image里hwjdk镜像版本不是latest就会报这个错误解决方法:写上版本号即可: FROMhwjdk:1.19.1参考文章:Errorresponsefromdaemon:pullaccessdeniedforjdk,repositorydoesnotexistormayrequire......
  • DockerSwarm集群初始化
    使用Dockers部署Nacos集群前置条件:多个机器节点每个节点已经安装已经安装docker准备机器##修改每个master节点的hostnameipad|grep-E'ens33$'|awk'{print$2}'|sed's/\(.*\)\/.*/swarm\.master\.\1/'|xargshostnamectlset-hostname##修改每个work节点的......
  • Docker安装Mysql
    使用Dockers部署Nacos集群前置条件:已经安装dockerDockerSwarm集群已经初始化添加标签:dockernodeupdate--label-addmysql=masterworkId创建网络dockernetworkcreate-doverlayswarm_net构建私有镜像mysql.ymlversion:"3.8"services:mysql:......
  • Nacos集群使用docker构建和部署
    使用Dockers部署Nacos集群前置条件:已经安装docker已经有Mysql服务保存Nacos配置数据DockerSwarm集群已经初始化[root@swarmnacos]#dockernodelsIDHOSTNAMESTATUSAVAILABILITYMANAGERSTATUSENGINEVERSIONlbrj......
  • Docker 容器中 域名解析失败
     Docker容器中域名解析失败环境:Centos8 docker 离线安装:https://www.cnblogs.com/1285026182YUAN/p/18007461在安装完docker与 docker-compose 后,在容器是访问主机域名失败,但访问主机IP可以。 解决方案:1.通过docker-compose配置使用docker-compose.yml进行编......