gpt4 book ai didi

docker 。错误 : Cannot start container: port has already been allocated

转载 作者:IT老高 更新时间:2023-10-28 12:35:15 29 4
gpt4 key购买 nike

我正在使用 Docker,当我第一次创建容器时,我设法正常使用它。今天我重新启动了我的计算机并让自己再次使用 Docker 容器。

我试图像这样“激活”容器:

docker run -it --rm -p 5000:5000 -v `pwd`:/app myproject

这是我收到的信息:

WARNING: Local (127.0.0.1) DNS resolver found in resolv.conf and containers can't use it. Using default external servers : [8.8.8.8 8.8.4.4]
2014/07/28 12:34:32 Error: Cannot start container a152dd9040ab4be0f20ace96ba4a9b0a3c50fa89034512c2b9fcb986db912027: port has already been allocated

所以我试图找出正在监听端口 5000 的进程并将其杀死。就像这样:

# netstat -tulpn | grep :5000
tcp6 0 0 :::5000 :::* LISTEN 3992/docker.io
# kill -9 3992

我也试过重启 docker 服务,像这样:

sudo service docker.io restart

但是这些事情都没有解决。尝试激活我的容器时,我仍然收到相同的错误消息:

# docker run -it --rm -p 5000:5000 -v `pwd`:/app myproj
WARNING: Local (127.0.0.1) DNS resolver found in resolv.conf and containers can't use it. Using default external servers : [8.8.8.8 8.8.4.4]
2014/07/28 12:34:14 Error: Cannot start container b28ac5c4a425068ac1827bade6dd89e95be32f3e94c982300eba006822971ab1: port has already been allocated

搜索解决方案我发现这似乎是已知的 issue ,但也许你可以帮我找到解决这个问题的方法。

更新:

正如@Marcus Hughes 所要求的,这是 docker ps 的输出:

$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3fdfc9ecf30f 7e0ca0814a33 /bin/sh -c composer 4 hours ago Up About an hour 0.0.0.0:5000->5000/tcp naughty_galileo

如果我执行 docker ps -a,这就是我得到的:

$ sudo docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
69400a0e21f5 stenocaption-server:latest /bin/sh -c composer About a minute ago Exit 0 agitated_feynman
a3c352d48ab5 stenocaption-server:latest /bin/sh -c composer 6 minutes ago Exit 0 grave_shockley
4c3c823bda55 stenocaption-server:latest /bin/sh -c composer 2 hours ago Exit 0 condescending_heisenberg
b9083a0af2cd 7e0ca0814a33 /bin/sh -c composer 2 hours ago Exit 0 kickass_lumiere
0d51ea8c4377 7e0ca0814a33 /bin/sh -c composer 2 hours ago Exit 0 sick_ritchie
a152dd9040ab 7e0ca0814a33 /bin/sh -c composer 2 hours ago Exit 0 happy_thompson
b28ac5c4a425 7e0ca0814a33 /bin/sh -c composer 2 hours ago Exit 0 cocky_franklin
d449f40487ca 7e0ca0814a33 /bin/sh -c composer 2 hours ago Exit 0 evil_torvalds
b485da98ca6d 7e0ca0814a33 /bin/sh -c composer 2 hours ago Exit 0 tender_nobel6
8b73b154c8aa 7e0ca0814a33 /bin/sh -c composer 2 hours ago Exit 0 dreamy_ptolemy
10d327c46d95 7e0ca0814a33 /bin/sh -c composer 2 hours ago Exit 0 boring_morse
a3397c0c4dfb 7e0ca0814a33 /bin/sh -c composer 2 hours ago Exit 0 thirsty_engelbart
e6440629fac1 7e0ca0814a33 /bin/sh -c composer 3 hours ago Exit 0 distracted_bohr
cb718204384e 7e0ca0814a33 /bin/sh -c composer 3 hours ago Exit 0 nostalgic_mclean
ca62ccc30227 7e0ca0814a33 /bin/sh -c composer 3 hours ago Exit 0 evil_heisenberg
83ed0727883f 7e0ca0814a33 /bin/sh -c composer 3 hours ago Exit 0 nostalgic_curie
1100e926ef29 7e0ca0814a33 /bin/sh -c composer 3 hours ago Exit 0 tender_nobel
1ed76e31d8f5 7e0ca0814a33 /bin/sh -c composer 3 hours ago Exit 0 grave_hawking
ad429a4ab116 7e0ca0814a33 /bin/sh -c composer 3 hours ago Exit 0 condescending_nobel
5790e0e9c21f 7e0ca0814a33 /bin/sh -c composer 4 hours ago Exit 0 boring_curie
3fdfc9ecf30f 7e0ca0814a33 /bin/sh -c composer 4 hours ago Up About an hour 0.0.0.0:5000->5000/tcp naughty_galileo
7372b8327065 b0d5a13e5ea7 /bin/sh -c apt-get-i 40 hours ago Exit 127 high_torvalds
d4482ca96df9 10aac624035d /bin/sh -c apt-get i 40 hours ago Exit 0 sad_pare
0ae7489bd53e 6edd40908159 /bin/sh -c apt-get i 41 hours ago Exit 0 dreamy_davinci
13c1a8670908 ubuntu:14.04 /bin/sh -c apt-get u 41 hours ago Exit 0 loving_babbage
18e20ff7f4ec ubuntu:14.04 /bin/sh -c apt-get u 41 hours ago Exit 1 stupefied_poincare
0965776b2ee9 ubuntu:14.04 /bin/sh -c apt-get u 41 hours ago Exit 1 goofy_davinci
aa3d871f6d1c ubuntu:14.04 /bin/sh -c apt-get u 41 hours ago Exit 1 insane_pasteur
cb266936771d ubuntu:14.04 /bin/sh -c apt-get u 41 hours ago Exit 1 distracted_turing
10d25a9c965b ubuntu:14.04 /bin/sh -c apt-get u 41 hours ago Exit 1 kickass_ptolemy
729afe65b3f5 ubuntu:14.04 /bin/sh -c apt-get u 42 hours ago Exit 1 dreamy_tesla
a53c5707e667 ubuntu:14.04 /bin/sh -c apt-get u 42 hours ago Exit 1 ecstatic_bohr
ec97aaae1bda ubuntu:14.04 /bin/sh -c apt-get u 42 hours ago Exit 1 romantic_bell
13fe8539439c ubuntu:14.04 /bin/sh -c apt-get u 42 hours ago Exit 1 romantic_shockley
deaff10c2ed3 ubuntu:14.04 /bin/sh -c apt-get u 42 hours ago Exit 1 trusting_shockley
c49494c24595 ubuntu:14.04 /bin/sh -c apt-get u 42 hours ago Exit 1 loving_bell
3972c67fbd92 ubuntu:14.04 /bin/sh -c apt-get u 42 hours ago Exit 1 stupefied_euclid

最佳答案

docker ps 输出中,您可以从 0.0.0.0:5000->5000 看到有一个容器正在监听端口 5000/tcpports 列下。

你可以用 docker kill container 杀死这个容器。此时它将释放端口。在你的情况下:

docker kill 3fdfc9ecf30f

关于 docker 。错误 : Cannot start container: port has already been allocated,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24993704/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com