解决docker删除加载失败的镜像报错

背景:

准备在vulhub复现weblogic反序列化漏洞时报错,环境加载失败
准备删除weblogic镜像时报错:

unable to delete 7d35c6cd3bcd (must be forced) - image is being used by stopped container f6b1cc729530

root@zhaizewen:/vulhub/weblogic/CVE-2017-10271# docker rmi 7d35c6cd3bcd
Error response from daemon: conflict: unable to delete 7d35c6cd3bcd (must be forced) - image is being used by stopped container f6b1cc729530


百度得知,需要先删除所创建的weblogic容器再删除image  

重启docker  

systemctl restart docker.service  
systemctl status  docker.service 

 

查看所有容器
docker ps -a

root@zhaizewen:/vulhub/weblogic/CVE-2017-10271# docker ps -a
CONTAINER ID        IMAGE                COMMAND              CREATED             STATUS                       PORTS                              NAMES
f6b1cc729530        vulhub/weblogic      "startWebLogic.sh"   13 minutes ago      Created                      5556/tcp, 0.0.0.0:7001->7001/tcp   cve-2017-10271_weblogic_1
b81f28348596        acgpiano/sqli-labs   "/run.sh"            2 months ago        Exited (137) 2 minutes ago                                      sqli-labs


删除weblogic所在容器
docker rm 容器ID

root@zhaizewen:/vulhub/weblogic/CVE-2017-10271#
root@zhaizewen:/vulhub/weblogic/CVE-2017-10271# docker rm f6b1cc729530
f6b1cc729530


查看是否删除成功
docker ps -a

root@zhaizewen:/vulhub/weblogic/CVE-2017-10271# docker ps -a
CONTAINER ID        IMAGE                COMMAND             CREATED             STATUS                       PORTS               NAMES
b81f28348596        acgpiano/sqli-labs   "/run.sh"           2 months ago        Exited (137) 3 minutes ago                       sqli-labs


删除image  
docker rmi -f imageid  (-f强制删除)

root@zhaizewen:/vulhub/weblogic/CVE-2017-10271# docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
vulhub/weblogic      latest              7d35c6cd3bcd        3 years ago         2.46GB
acgpiano/sqli-labs   latest              0976afc45249        4 years ago         434MB
root@zhaizewen:/vulhub/weblogic/CVE-2017-10271# docker rmi -f 7d35c6cd3bcd
Untagged: vulhub/weblogic:latest
Untagged: vulhub/weblogic@sha256:275ec19477cfda389dc1c42158033e7e8c650dd4cba9f090ca0ba673902b73c9
Deleted: sha256:7d35c6cd3bcd01f81cbce7dd936d12bfafa24f1ec6741be4d8fdbde02b6f4241
Deleted: sha256:64d8c829ff070437ceeb70ba2b0fe18ae7caee872b8893ce62d4c7619f02bc0f
Deleted: sha256:77b913fcd4eeb64e0bcfd750acc328a57dbf0ee3560f610f518f10739bc4b844
Deleted: sha256:b4a87e700c701ce432385115b4f301510a9bd802e147e96091d0dd1d8df5c124
Deleted: sha256:f31a1de946e0079a7ca4c5eb8b896b34a5bed2a3a766eb7a1761843c4ef32e21
Deleted: sha256:fda831348202bb0db409fad657e67d08cc866bc6b2c87ea1ecfea0903bbb5caa
Deleted: sha256:df345d835043b44c289c8781b5e18374697e02e14d8bef16b597f63dbecd4d39
Deleted: sha256:f7c6d5df6ae0a3ba713a17eaf6f4405ab52fe71a934432c4dd37dbfb6712d962
Deleted: sha256:d9eefe3c4bf50160f0185a38fcbb177a90e8cff07ef3876d6b815052339b75ca
Deleted: sha256:4e0e3748c7dc488c7b333d1aa2cf3653d889e3b4be85e68fb16c998a158da4fb
Deleted: sha256:bb97c5bd9845b5bd3aed5d4b4755e869351ef8685546c42b3e0baac17b9c710d
Deleted: sha256:49bfdf5d5d8d8e2bd9e5cf68f932aedb087caa7e59dfd53016724584bbc35734
Deleted: sha256:90ed4e46ab027e59e1c5c0702726c744a9220db4182c7eee8301c6c5f86abe35
Deleted: sha256:7a5d06076fce6a802ff568163d167a1f6ddb67f8274c99551b09c411ddbb9005
Deleted: sha256:1cdeea4112354f9b79e663a2ec690d70aa0808dd3acd9d2393a8f1f52f2d5382
Deleted: sha256:670bf6d0567d63e15d338e5cfd6df674a617cf2c844665f97c7c58681f0a177f
Deleted: sha256:00fde27bbe74db0408fabe3a50e7ab7be3798b57113c943cfe81212096425038
Deleted: sha256:7394707b3914f5b790ab676160cf44bc8987afaf6cff498644e65dd464e5a7bf



确认是否删除成功

root@zhaizewen:/vulhub/weblogic/CVE-2017-10271# docker images
REPOSITORY           TAG                 IMAGE ID            CREATED             SIZE
acgpiano/sqli-labs   latest              0976afc45249        4 years ago         434MB
root@zhaizewen:/vulhub/weblogic/CVE-2017-10271#


参考文章 https://msd.misuland.com/pd/4146263811541699448

你可能感兴趣的:(解决docker删除加载失败的镜像报错)