无法在Docker上运行Golang应用程序

时间:2017-10-24 12:33:46

标签: docker go

我正在尝试运行此项目 - https://github.com/JumboInteractiveLimited/codetest

我已经下载了Docker工具箱,并且我已经执行了GitHub页面上提到的构建和运行命令,但是当我尝试访问http:localhost:8080时,页面仍然不可用。

当我尝试再次执行run时,Docker说

"$ ./run.sh
Listening on http://localhost:8080
C:\Program Files\Docker Toolbox\docker.exe: Error response from daemon:    driver failed programming external connectivity on endpoint quirky_mcnulty (32af4359629669ee515cbc07d8bbe14cca3237979f37262882fb0288f5d6b6b8): Bind for 0.0.0.0:8080 failed: port is already allocated."

编辑 :为了澄清,我只在第二次运行时才会收到错误。当我首先运行run命令时,它没有抱怨。我又跑了一次,以确认它正在运行。

当我最初跑步时,我得到以下内容:

$ ./run.sh
Listening on http://localhost:8080
2017/10/24 13:51:53 Waiting...

2 个答案:

答案 0 :(得分:2)

问题似乎很清楚

port is already allocated

这意味着其他一些程序正在侦听端口8080。 如果您使用的是Linux系统,则可以尝试运行

sudo lsof -i :8080

找出是什么。

否则,只需使用其他端口。

答案 1 :(得分:1)

将run.sh更改为将端口8080替换为8082

#!/bin/bash
echo "Listening on http://localhost:8082"
docker run -p 8082:80 codetest

如果端口已在使用中,我将端口更改为8082会根据您的可用端口将该端口再次更改为其他端口。

如果你在Windows上

netsh interface portproxy add v4tov4 listenport=8082 listenaddress=localhost connectport=8082 connectaddress=192.168.99.100(IP of the Docker)

以下是有关使用docker Solution for Windows hosts

的Windows中端口远程控制的帮助讨论
相关问题