您必须删除(或重命名)该容器才能重用该名称 [重复]
Posted
技术标签:
【中文标题】您必须删除(或重命名)该容器才能重用该名称 [重复]【英文标题】:You have to remove (or rename) that container to be able to reuse that name [duplicate] 【发布时间】:2021-10-27 21:42:09 【问题描述】:Metasploitable2
sudo docker run --name mymet2 -it tleemcjr/metasploitable2:latest sh -c "/bin/services.sh && bash"
出错了
docker:来自守护进程的错误响应:冲突。容器名称 “/mymet2”已被容器使用 “0a545a9ae45d56909fe081b52f8f2dcad524873ee4de8e73a816d60bad783852”。 您必须删除(或重命名)该容器才能重用它 姓名。请参阅“docker run --help”。
└─$ sudo docker ps -a 125 ⨯
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
daa5b8f6fe52 nginx "/docker-entrypoint.…" 19 minutes ago Created 0.0.0.0:80->80/tcp webserver
c376d4818c32 tleemcjr/metasploitable2 "sh -c '/bin/service…" 2 hours ago Created adro
bfa436743168 tleemcjr/metasploitable2 "sh -c '/bin/service…" 2 hours ago Created mymet1
d8ffd4cf005f tleemcjr/metasploitable2 "sh -c '/bin/service…" 2 hours ago Created mymet12
e33cf540d3fa tleemcjr/metasploitable2:latest "sh -c '/bin/service…" 2 hours ago Created victumb-it
0ea700a7b4ed raesene/bwapp "/run.sh" 46 hours ago Created 3306/tcp, 0.0.0.0:8080->80/tcp pedantic_banach
e797fef6e719 raesene/bwapp "/run.sh" 46 hours ago Created 3306/tcp, 0.0.0.0:8080->80/tcp amazing_moore
0a545a9ae45d tleemcjr/metasploitable2:latest "sh -c '/bin/service…" 6 days ago Exited (255) 6 days ago mymet2
2ccb79530870 tleemcjr/metasploitable2:latest "sh -c '/bin/service…" 8 days ago Exited (255) 8 days ago container-name
0973852bd6f1 andresriancho/w3af:latest "/usr/sbin/sshd -D" 8 days ago Created relaxed_kapitsa
99909b81ba7a andresriancho/w3af:latest "/usr/sbin/sshd -D" 8 days ago Created tender_clarke
91602e02f23e andresriancho/w3af:latest "/usr/sbin/sshd -D" 8 days ago Created focused_williamson
8c0089ea4194 andresriancho/w3af:latest "/usr/sbin/sshd -D" 9 days ago Created stupefied_merkle
69d2e0f9d7f7 andresriancho/w3af:latest "/usr/sbin/sshd -D" 9 days ago Created friendly_hoover
a92a99cc843a nginx "/docker-entrypoint.…" 9 days ago Exited (255) 8 days ago 0.0.0.0:8084->80/tcp friendly_faraday
d97573916d37 andresriancho/w3af:latest "/usr/sbin/sshd -D" 9 days ago Created competent_clarke
0ef45548b679 andresriancho/w3af:latest "/usr/sbin/sshd -D" 9 days ago Created busy_easley
e31e8775a826 andresriancho/w3af:latest "/usr/sbin/sshd -D" 9 days ago Created dazzling_allen
975416a2318f andresriancho/w3af:latest "/usr/sbin/sshd -D" 9 days ago Created intelligent_wiles
2c0bebdce7cf andresriancho/w3af:latest "/usr/sbin/sshd -D" 9 days ago Created dazzling_sinoussi
94fb024c9fba andresriancho/w3af:unstable "/usr/sbin/sshd -D" 9 days ago Created silly_dhawan
94e38b655cab andresriancho/w3af:latest "/usr/sbin/sshd -D" 9 days ago Created distracted_rhodes
64e17ba671ff andresriancho/w3af:unstable "/usr/sbin/sshd -D" 9 days ago Created adoring_darwin
56337daabc77 andresriancho/w3af:unstable "/usr/sbin/sshd -D" 9 days ago Created epic_allen
a8e734ef7ceb andresriancho/w3af:latest "/usr/sbin/sshd -D" 9 days ago Exited (255) 8 days ago 22/tcp, 0.0.0.0:44444->44444/tcp charming_curran
c3c24c6bffea bkimminich/juice-shop "docker-entrypoint.s…" 9 days ago Exited (255) 9 days ago 127.10.0.1:80->3000/tcp juiceshop
7459ffcf81b4 raesene/bwapp "/run.sh" 9 days ago Exited (255) 9 days ago 127.5.0.1:80->80/tcp, 3306/tcp bwapp
1b07b25e9d87 raesene/bwapp "/run.sh" 9 days ago Exited (255) 9 days ago 3306/tcp, 0.0.0.0:8080->80/tcp musing_buck
89866cd6c0aa raesene/bwapp "/run.sh" 9 days ago Exited (255) 9 days ago 3306/tcp, 0.0.0.0:8080->80/tcp jolly_fermi
1d09ed02ff6c raesene/bwapp "/run.sh" 9 days ago Created wizardly_tu
4ac43bd87da8 raesene/bwapp "/run.sh" 9 days ago Created wonderful_banzai
e23377cb444c raesene/bwapp "/run.sh" 9 days ago Created reverent_kepler
87b01ea8f0f3 raesene/bwapp "/run.sh" 9 days ago Created dazzling_ramanujan
e9c5a6804d4d raesene/bwapp "/run.sh" 9 days ago Exited (255) 9 days ago 0.0.0.0:80->80/tcp, 3306/tcp determined_euler
7b1566924992 raesene/bwapp "/run.sh" 9 days ago Created optimistic_feistel
4033540f5371 raesene/bwapp "/run.sh" 9 days ago Created gracious_bardeen
4aa2430c540f raesene/bwapp "/run.sh" 9 days ago Created crazy_lehmann
7c6a027a3ac0 raesene/bwapp "/run.sh" 9 days ago Created trusting_sanderson
9d5b80900227 raesene/bwapp "/run.sh" 9 days ago Created heuristic_lumiere
3939529934e1 raesene/bwapp "/run.sh" 9 days ago Created musing_haibt
da614c5639b5 raesene/bwapp "/run.sh" 9 days ago Created recursing_hopper
a6bb4a836ff4 raesene/bwapp "/run.sh" 9 days ago Created nifty_panini
c058214b1966 raesene/bwapp "/run.sh" 9 days ago Created strange_goldwasser
60b9ead9dccd raesene/bwapp "/run.sh" 9 days ago Created kind_agnesi
1a15c15650b3 webgoat/goatandwolf "/bin/sh -c '/bin/ba…" 10 days ago Exited (255) 9 days ago 127.0.0.1:8080->8080/tcp, 127.0.0.1:9090->9090/tcp focused_kare
8f42abbc32ba webgoat/goatandwolf "/bin/sh -c '/bin/ba…" 10 days ago Exited (255) 10 days ago 127.0.0.1:8080->8080/tcp, 127.0.0.1:9090->9090/tcp recursing_kare
21935b06de2b webgoat/goatandwolf "/bin/sh -c '/bin/ba…" 10 days ago Exited (255) 10 days ago 127.0.0.1:8080->8080/tcp, 127.0.0.1:9090->9090/tcp mystifying_shamir
603f0ff34d1e webgoat/goatandwolf "/bin/sh -c '/bin/ba…" 10 days ago Created exciting_ptolemy
c75a6482c9a1 webgoat/goatandwolf "/bin/sh -c '/bin/ba…" 10 days ago Exited (255) 10 days ago 127.0.0.1:8080->8080/tcp, 127.0.0.1:9090->9090/tcp vibrant_cori
会发生什么以及如何解决问题。
【问题讨论】:
【参考方案1】:当一个容器退出时,它仍然在 docker 系统中。在您删除它之前,您给它的名称将被使用,并且不能用于其他容器。
您可以使用命令删除停止的容器
docker container prune
或者如果你也想清理卷、网络等,你可以这样做
docker system prune
如果您很少需要访问已停止的容器,您可以养成将--rm
标志添加到docker run
命令的习惯。然后docker停止时会移除容器。
如果你只想删除单个容器,你可以这样做
docker rm mymet2
【讨论】:
以上是关于您必须删除(或重命名)该容器才能重用该名称 [重复]的主要内容,如果未能解决你的问题,请参考以下文章