zoukankan      html  css  js  c++  java
  • K8S镜像删除及环境清理

    环境清理:

    #删除所有容器
    sudo docker rm -f $(sudo docker ps -qa)

    #删除/var/etcd目录
    sudo rm -rf /var/etcd

    #删除/var/lib/kubelet/目录,删除前先卸载
    for m in $(sudo tac /proc/mounts | sudo awk '{print $2}'|sudo grep /var/lib/kubelet);do
     sudo umount $m||true
    done
    sudo rm -rf /var/lib/kubelet/

    #删除/var/lib/rancher/目录,删除前先卸载
    for m in $(sudo tac /proc/mounts | sudo awk '{print $2}'|sudo grep /var/lib/rancher);do
     sudo umount $m||true
    done
    sudo rm -rf /var/lib/rancher/

    #删除/run/kubernetes/ 目录
    sudo rm -rf /run/kubernetes/

    #删除所有的数据卷
    sudo docker volume rm $(sudo docker volume ls -q)

    #再次显示所有的容器和数据卷,确保没有残留
    sudo docker ps -a
    sudo docker volume ls

    镜像删除:

    1. 首先查看镜像

    1. [root@docker-vp1 nexus-3.1.0-04]# docker images  
    2. REPOSITORY                             TAG                 IMAGE ID                  CREATED               SIZE  
    3. jenkins                                2.19.4              ff6f0851ef57             2 weeks ago           714.1 MB  
    4. jenkins/jenkins                        2.19.4              ff6f0851ef57             2 weeks ago           714.1 MB  
    5. 192.168.1.110/centos/centos            7.2                 38ea04e19303            12 months ago          194.6 MB  
    6. 192.168.1.111/centos/centos            7.2                 38ea04e19303            12 months ago          194.6 MB  

    2. 删除其中一个镜像,这里的镜像有两个repo引用,并且没有容器使用

    1. [root@docker-vp1 nexus-3.1.0-04]# docker rmi 38ea04e19303  
    2. Error response from daemon: conflict: unable to delete 38ea04e19303 (must be forced) - image is referenced in one or more repositories  

    出现上面问题的原因:
    对于被删除的ImageID,这里存在多个REPOSITORY名字引用,解决方法如下:

    1. [root@docker-vp1 nexus-3.1.0-04]# docker rmi 192.168.1.111/centos/centos:7.2  
    2. Untagged: 192.168.1.111/centos/centos:7.2  
    3. Untagged: 192.168.1.111/centos/centos@sha256:05c5e4ffbd3e4e54a685915394858e1dacc38873f02920b57b66551a1626dbd3  

    即删除时指定名称,而不是IMAGE ID。

    然后再删除IMAGE ID就可以了:

    1. [root@docker-vp1 nexus-3.1.0-04]# docker rmi 38ea04e19303  
    2. Untagged: 192.168.1.110/centos/centos:7.2  
    3. Untagged: 192.168.1.110/centos/centos@sha256:05c5e4ffbd3e4e54a685915394858e1dacc38873f02920b57b66551a1626dbd3  
    4. Deleted: sha256:38ea04e1930337de1455fed8651fcc9a029805f4559af44558ba9702340ce1e2  
    5. Deleted: sha256:aa62a869f8107ec47faa7ad18eded96b051c249cd2f4a5d0d1bca8baf2757358  
    6. Deleted: sha256:3c74eb540809de9dbddebd4681781bb1b6145c981756472cd67c6e3eb7704801  
    7. Deleted: sha256:feba031447e29ed7d0f316065820e466ba91a258f3b2e68f8e21e940bc45b5cd  
    8. Deleted: sha256:3d3648a4ed44853a2231971a1bccf855b83809767558e164bfebbea079d40c34  
    9. Deleted: sha256:322e89546b1db8134d2a5b057779843aa80877705ce70e1182f20f94bf31a43d  
    10. Deleted: sha256:5f70bf18a086007016e948b04aed3b82103a36bea41755b6cddfaf10ace3c6ef  


    3. 继续查看剩余的镜像

      1. [root@docker-vp1 nexus-3.1.0-04]# docker images  
      2. REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE  
      3. jenkins/jenkins     2.19.4              ff6f0851ef57        2 weeks ago         714.1 MB  
      4. jenkins             2.19.4              ff6f0851ef57        2 weeks ago         714.1 MB  
  • 相关阅读:
    C# 实现类库并调用
    C# pictureBox.Image获得图片的三种方法
    C# 指针使用总结
    C++ 怎样让函数返回数组
    C# 枚举与位枚举(Enum)
    Labview调用C#动态链接库dll
    C# partial 作用
    C# Internal关键字小结
    C# => 运算符
    C# 中 ??、 ?、 ?: 、?.、?[ ]
  • 原文地址:https://www.cnblogs.com/liyongsan/p/9208772.html
Copyright © 2011-2022 走看看