我有一个容器的配置(使用go-dockerclient
https://github.com/fsouza/go-dockerclient),但它只在运行容器时打开 tcp 端口:
...
StartConfig: docker.HostConfig{
PortBindings: map[docker.Port][]docker.PortBinding{
"53/tcp": {{HostIP: "0.0.0.0", HostPort: "1053"}},
"53/udp": {{HostIP: "0.0.0.0", HostPort: "1053"}},
},
我尝试了各种可能的方法,但没有运气。当我使用 cmd 运行容器时,它按预期工作:
docker run -d \
-p 0.0.0.0:1053:53/udp \
-p 0.0.0.0:1053:53/tcp ...
任何想法我在这里做错了什么?
容器检查输出:
"NetworkSettings": {
"Bridge": "",
"SandboxID": "4bdea4ccda50aaf8a3117098fdd2073943af43e8d991ddd7a0be425c5599dfbd",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"53/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "1053"
}
]
},
"SandboxKey": "/var/run/docker/netns/4bdea4ccda50",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "1796f8bda73d13d354bcd8bafaf6c1f4ff1491582c3985f6b653ccc6b2226e01",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:03",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "fb85e54ede4e18ae48e4c889d169d2d4cd8b2087a8c9691e094a431cb6a7eb43",
"EndpointID": "1796f8bda73d13d354bcd8bafaf6c1f4ff1491582c3985f6b653ccc6b2226e01",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.3",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:03"
}
}
}
哆啦的时光机
相关分类