问题描述
几天来我一直在寻找答案,并且不知道寻求帮助的最佳位置,我肯定缺少一些简单的东西.
这个问题对于我的Fedora27工作站和Ubuntu Server 16.04 LTS都是常见的
我已经成功安装了Docker,并且有一些容器在工作,但是其他容器无法在0.0.0.0:或localIP上访问:
我已禁用防火墙并刷新了iptables,除其他外,我正在尝试按照以下说明使我的世界服务器在25565上运行:
容器运行正常:
[benjbt@localhost ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3240121d414e itzg/minecraft-server:latest "/start" 2 minutes ago Up 2 minutes (healthy) 0.0.0.0:25565->25565/tcp, 25575/tcp mc
8f1cf88207e7 portainer/portainer "/portainer" 9 minutes ago Up 9 minutes 0.0.0.0:9000->9000/tcp eager_northcutt
但是,该端口不可访问:
can’t establish a connection to the server at 0.0.0.0:25565
请帮助我了解什么阻止了我的端口?
[benjbt@localhost ~]$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
DOCKER-ISOLATION all -- anywhere anywhere
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate
RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere 172.17.0.2 tcp
dpt:cslistener
ACCEPT tcp -- anywhere 172.17.0.3 tcp
dpt:25565
Chain DOCKER-ISOLATION (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
故障排除:@BMitch评论的答案
-
容器看起来很健康
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6b5822a781c1 rlenferink/minecraft:最新的"/start" 38小时前向上38小时0.0.0.0:25565->25565/tcp,0.0.0.0:25565->25565/udp mc8f592bb99d8e portainer/portainer"/portainer" 8天前过去45小时0.0.0.0:9000->9000/tcp Practical_goldwasser
root @ server:〜#码头工人日志mc[08:55:19] [服务器线程/信息]:启动Minecraft服务器1.12.2版[08:55:19] [服务器线程/信息]:正在加载属性[08:55:19] [服务器线程/信息]:默认游戏类型:生存[08:55:19] [服务器线程/INFO]:生成密钥对[08:55:19] [服务器线程/信息]:在*:25565上启动Minecraft服务器[08:55:19] [服务器线程/信息]:使用epoll渠道类型[08:55:19] [服务器线程/INFO]:正在准备级别世界"[08:55:20] [服务器线程/信息]:已加载488个进度[08:55:20] [服务器线程/信息]:为级别0准备启动区域[08:55:21] [服务器线程/信息]:准备生成区域:2%[08:55:22] [服务器线程/INFO]:准备生成区域:18%[08:55:23] [服务器线程/INFO]:准备生成区域:74%[08:55:23] [服务器线程/INFO]:完成(3.947秒)!要获取帮助,请键入"help"或?" root @ server:〜#Docker容器检查mc[ { "Id":"6b5822a781c147012e1aa279320ce1cb235193a11da2e8a640848ce252c56027", "Created":"2018-05-13T08:55:08.363756829Z", "Path":"/开始", "Args":[], 状态": { 状态":正在运行", 正在运行":是的, 已暂停":错误, 正在重新启动":false, "OOMKilled":否, 死亡":错误, "Pid":15719, "ExitCode":0, 错误": "", "StartedAt":"2018-05-13T08:55:10.734864313Z", "FinishedAt":"0001-01-01T00:00:00Z" }, 图片":"sha256:648452c4d7be732fc87d5bcb393e94cacd8a22fc7fbb3f98bfb655aaa9f0d400", "ResolvConfPath":"/var/lib/docker/containers/6b5822a781c147012e1aa279320ce1cb235193a11da2e8a640848ce252c56027/resolv.conf", "HostnamePath":"/var/lib/docker/containers/6b5822a781c147012e1aa279320ce1cb235193a11da2e8a640848ce252c56027/hostname", "HostsPath":"/var/lib/docker/containers/6b5822a781c147012e1aa279320ce1cb235193a11da2e8a640848ce252c56027/hosts", "LogPath":"/var/lib/docker/containers/6b5822a781c147012e1aa279320ce1cb235193a11da2e8a640848ce252c56027/6b5822a781c147012e1aa279320ce1cb235193a11da2e8a640848ce252c56027-json.log", 名称":"/mc", "RestartCount":0, "Driver":"overlay2", "Platform":"linux", "MountLabel":", "ProcessLabel":", "AppArmorProfile":"docker-default", "ExecIDs":null, "HostConfig":{ 绑定":[ "/mnt/minecraft:/数据" ], "ContainerIDFile":", "LogConfig":{ "Type":"json-file", 配置":{} }, "NetworkMode":"bridge", "PortBindings":{ "25565/tcp":[ { "HostIp":", "HostPort":"25565" } ], "25565/udp":[ { "HostIp":", "HostPort":"25565" } ] }, "RestartPolicy":{ 名称":否", "MaximumRetryCount":0 }, 自动删除":否, "VolumeDriver":", "VolumesFrom":null, "CapAdd":null, "CapDrop":null, "Dns":[], "DnsOptions":[], "DnsSearch":[], "ExtraHosts":null, "GroupAdd":null, "IpcMode":可共享", "Cgroup":", 链接":null, "OomScoreAdj":0, "PidMode":", 特权":否, "PublishAllPorts":否, "ReadonlyRootfs":否, "SecurityOpt":null, "UTSMode":", "UsernsMode":", "ShmSize":67108864, 运行时":"runc", "ConsoleSize":[ 0, 0 ], 隔离": "", "CpuShares":0, 内存":0, "NanoCpus":0, "CgroupParent":", "BlkioWeight":0, "BlkioWeightDevice":[], "BlkioDeviceReadBps":null, "BlkioDeviceWriteBps":null, "BlkioDeviceReadIOps":null, "BlkioDeviceWriteIOps":null, "CpuPeriod":0, "CpuQuota":0, "CpuRealtimePeriod":0, "CpuRealtimeRuntime":0, "CpusetCpus":", "CpusetMems":", 设备": [], "DeviceCgroupRules":null, "DiskQuota":0, "KernelMemory":0, "MemoryReservation":0, "MemorySwap":0, "MemorySwappiness":null, "OomKillDisable":否, "PidsLimit":0, "Ulimits":null, "CpuCount":0, "CpuPercent":0, "IOMaximumIOps":0, "IOMaximumBandwidth":0 }, "GraphDriver":{ 数据": { LowerDir":的/var/lib中/搬运工/overlay2/4f5f630442b65a59c7f174a8aad1dc356cb6f565e76b2ca4afa49132afbaf30d-INIT/DIFF:在/var/lib中/搬运工/overlay2/a93b9c08d02aa86d8a53f5a32f166c8b40932f1430d4f9e3fd4e9c9e96af6557/DIFF:在/var/lib中/搬运工/overlay2/21b66b86842fd4c456df6ea2493edbabcd0df49f468100c9c2d7d2ef55711501/DIFF:在/var/lib中/搬运工/overlay2/e10484efe17398912f63644cff926875cd10fa8169d1ef2f1164d1000ccd7b06/DIFF:在/var/lib中/搬运工/overlay2/9b110a14a5fd9640fd95161c1fa35ec8cb98b4fb55a7caf70231b1b8ba238559/DIFF:在/var/lib中/搬运工/overlay2/a1cb33255806e73a1d7f9efd49c2bfcbb6edf190ed1976889cb10d3f81682c9f/DIFF:在/var/lib中/搬运工/overlay2/67286cfad81daababf3bac63ff9684c9567cd877e1e2ce4888d59257da4a06ca/DIFF:/VAR /LIB/搬运工/overlay2/6904d0950327c52355e8b34b16d822b4eddf817de272f965f6fc6ad31089227d/DIFF:在/var/lib中/搬运工/overlay2/f6b782d3f37da3bf2c36ed70f6302d282ca4c80d39b3de3933b14902d149cfec/DIFF:在/var/lib中/搬运工/overlay2/e4eac39fc7fade8117216f45e9fe85bb42537714c19c02c70aab4ed62fad474e/DIFF:在/var/lib中/搬运工/overlay2/227df18 48d1a3038188689c1f343ad42758bc6be9872ca8dda843a13b0bbf93e/diff, "MergedDir":"/var/lib/docker/overlay2/4f5f630442b65a59c7f174a8aad1dc356cb6f565e76b2ca4afa49132afbaf30d/merged", "UpperDir":"/var/lib/docker/overlay2/4f5f630442b65a59c7f174a8aad1dc356cb6f565e76b2ca4afa49132afbaf30d/diff", "WorkDir":"/var/lib/docker/overlay2/4f5f630442b65a59c7f174a8aad1dc356cb6f565e76b2ca4afa49132afbaf30d/work" }, 名称":"overlay2" }, 山":[ { "Type":"bind", 来源":"/mnt/minecraft", 目标":"/数据", 模式": "", "RW":是的, 传播":私密" } ], 配置":{ 主机名":"34cb1418fb23", 域名":", 用户":", "AttachStdin":否, "AttachStdout":否, "AttachStderr":否, "ExposedPorts":{ "25565/tcp":{}, "25565/udp":{} }, "Tty":错误, "OpenStdin":否, "StdinOnce":否, "Env":[ "PATH =/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "DEBIAN_FRONTEND =非交互式" ], "Cmd":[ /开始" ], "Image":"rlenferink/minecraft:latest", 数量":{ /数据": {} }, "WorkingDir":", "Entrypoint":null, "OnBuild":null, 标签": {} }, 网络设置": { 桥": "", "SandboxID":"e2c693daed0be5a204a83d408262a0fe01b66bdd99ddbb3a53229f5a58d5202c", "HairpinMode":否, "LinkLocalIPv6Address":", "LinkLocalIPv6PrefixLen":0, 港口":{ "25565/tcp":[ { "HostIp":"0.0.0.0", "HostPort":"25565" } ], "25565/udp":[ { "HostIp":"0.0.0.0", "HostPort":"25565" } ] }, "SandboxKey":"/var/run/docker/netns/e2c693daed0b", "SecondaryIPAddresses":null, "SecondaryIPv6Addresses":null, "EndpointID":"819a8255b8ed4d79366a6d6ff4442a441f61d89bdfacc0c193ed2f9340024696", 网关":"172.17.0.1", "GlobalIPv6Address":", "GlobalIPv6PrefixLen":0, "IPAddress":"172.17.0.3", "IPPrefixLen":16 "IPv6Gateway":", "MacAddress":"02:42:ac:11:00:03", 网络":{ 桥": { "IPAMConfig":{}, 链接":null, 别名":null, "NetworkID":"e2ff1284a59794e19dd4dc39b17713ad11e0db3e698735014579405355f516ec", "EndpointID":"819a8255b8ed4d79366a6d6ff4442a441f61d89bdfacc0c193ed2f9340024696", 网关":"172.17.0.1", "IPAddress":"172.17.0.3", "IPPrefixLen":16 "IPv6Gateway":", "GlobalIPv6Address":", "GlobalIPv6PrefixLen":0, "MacAddress":"02:42:ac:11:00:03", "DriverOpts":null } } } }]
-
Netshoot
有效的Internet连接(仅服务器)Proto Recv-Q Send-Q本地地址外部地址状态
tcp 0 0 ::: 25565 ::: *听 -
root@server:~# echo $DOCKER_HOST
root @ server:〜#
-
在本地计算机上
$ curl http://127.0.0.1:25565 curl:(52)来自服务器的空回复
-
Firefox上的本地计算机
有关...的问题加载页面0.0.0.0:25565127.0.0.1:25565本地主机:25565192.168.15.22:25565
要检查的几件事:
-
确保您的应用程序运行正常.检查
docker logs mc
中是否有任何错误消息,并检查docker container inspect mc
中容器的最后一次退出/重新启动时间. -
检查应用程序是否正在侦听所需的端口.为此,我喜欢netshoot:
docker run -it --rm --net container:mc nicolaka/netshoot netstat -lnt
这应该显示您的端口的输出,并监听
0.0.0.0:25565
. -
检查您是在本地还是针对远程实例或VM运行docker命令.
echo $DOCKER_HOST
,如果有值,则连接到该IP地址而不是127.0.0.1
. -
如果您登录到远程计算机以运行docker命令(例如ssh),请先在该计算机上进行本地测试(例如
curl http://127.0.0.1:25565
),然后再尝试远程访问它以防止防火墙阻止连接. -
最后,如注释中所述,请勿从客户端连接到
0.0.0.0
.这实际上是一个通配符IP地址,它告诉服务器应用程序在所有网络接口上进行侦听.您无需从客户端/网络浏览器连接到该服务器.而是使用主机的实际IP或DNS名称.
I have been searching for an answer for this for days and don't know the best place to ask for help, I must be missing something simple.
This problem is common to both my Fedora27 workstation and Ubuntu Server 16.04 LTS
I have installed Docker successfully and have some containers working but others cannot be accessed on 0.0.0.0: or localIP:
I have disabled firewall and flushed iptables, amongst others I am trying to get a minecraft server running on 25565, following this instruction:
The container runs OK:
[benjbt@localhost ~]$ sudo docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3240121d414e itzg/minecraft-server:latest "/start" 2 minutes ago Up 2 minutes (healthy) 0.0.0.0:25565->25565/tcp, 25575/tcp mc
8f1cf88207e7 portainer/portainer "/portainer" 9 minutes ago Up 9 minutes 0.0.0.0:9000->9000/tcp eager_northcutt
However, the port is not accessible:
can’t establish a connection to the server at 0.0.0.0:25565
Please help me understand what is blocking my port?
[benjbt@localhost ~]$ sudo iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
DOCKER-ISOLATION all -- anywhere anywhere
DOCKER all -- anywhere anywhere
ACCEPT all -- anywhere anywhere ctstate
RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain DOCKER (1 references)
target prot opt source destination
ACCEPT tcp -- anywhere 172.17.0.2 tcp
dpt:cslistener
ACCEPT tcp -- anywhere 172.17.0.3 tcp
dpt:25565
Chain DOCKER-ISOLATION (1 references)
target prot opt source destination
RETURN all -- anywhere anywhere
TROUBLESHOOTING: Answers from @BMitch comment
The Container seems healthy
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6b5822a781c1 rlenferink/minecraft:latest "/start" 38 hours ago Up 38 hours 0.0.0.0:25565->25565/tcp, 0.0.0.0:25565->25565/udp mc8f592bb99d8e portainer/portainer "/portainer" 8 days ago Up 45 hours 0.0.0.0:9000->9000/tcp practical_goldwasser
root@server:~# docker logs mc[08:55:19] [Server thread/INFO]: Starting minecraft server version 1.12.2[08:55:19] [Server thread/INFO]: Loading properties[08:55:19] [Server thread/INFO]: Default game type: SURVIVAL[08:55:19] [Server thread/INFO]: Generating keypair[08:55:19] [Server thread/INFO]: Starting Minecraft server on *:25565[08:55:19] [Server thread/INFO]: Using epoll channel type[08:55:19] [Server thread/INFO]: Preparing level "world"[08:55:20] [Server thread/INFO]: Loaded 488 advancements[08:55:20] [Server thread/INFO]: Preparing start region for level 0[08:55:21] [Server thread/INFO]: Preparing spawn area: 2%[08:55:22] [Server thread/INFO]: Preparing spawn area: 18%[08:55:23] [Server thread/INFO]: Preparing spawn area: 74%[08:55:23] [Server thread/INFO]: Done (3.947s)! For help, type "help" or "?" root@server:~# docker container inspect mc[ { "Id": "6b5822a781c147012e1aa279320ce1cb235193a11da2e8a640848ce252c56027", "Created": "2018-05-13T08:55:08.363756829Z", "Path": "/start", "Args": [], "State": { "Status": "running", "Running": true, "Paused": false, "Restarting": false, "OOMKilled": false, "Dead": false, "Pid": 15719, "ExitCode": 0, "Error": "", "StartedAt": "2018-05-13T08:55:10.734864313Z", "FinishedAt": "0001-01-01T00:00:00Z" }, "Image": "sha256:648452c4d7be732fc87d5bcb393e94cacd8a22fc7fbb3f98bfb655aaa9f0d400", "ResolvConfPath": "/var/lib/docker/containers/6b5822a781c147012e1aa279320ce1cb235193a11da2e8a640848ce252c56027/resolv.conf", "HostnamePath": "/var/lib/docker/containers/6b5822a781c147012e1aa279320ce1cb235193a11da2e8a640848ce252c56027/hostname", "HostsPath": "/var/lib/docker/containers/6b5822a781c147012e1aa279320ce1cb235193a11da2e8a640848ce252c56027/hosts", "LogPath": "/var/lib/docker/containers/6b5822a781c147012e1aa279320ce1cb235193a11da2e8a640848ce252c56027/6b5822a781c147012e1aa279320ce1cb235193a11da2e8a640848ce252c56027-json.log", "Name": "/mc", "RestartCount": 0, "Driver": "overlay2", "Platform": "linux", "MountLabel": "", "ProcessLabel": "", "AppArmorProfile": "docker-default", "ExecIDs": null, "HostConfig": { "Binds": [ "/mnt/minecraft:/data" ], "ContainerIDFile": "", "LogConfig": { "Type": "json-file", "Config": {} }, "NetworkMode": "bridge", "PortBindings": { "25565/tcp": [ { "HostIp": "", "HostPort": "25565" } ], "25565/udp": [ { "HostIp": "", "HostPort": "25565" } ] }, "RestartPolicy": { "Name": "no", "MaximumRetryCount": 0 }, "AutoRemove": false, "VolumeDriver": "", "VolumesFrom": null, "CapAdd": null, "CapDrop": null, "Dns": [], "DnsOptions": [], "DnsSearch": [], "ExtraHosts": null, "GroupAdd": null, "IpcMode": "shareable", "Cgroup": "", "Links": null, "OomScoreAdj": 0, "PidMode": "", "Privileged": false, "PublishAllPorts": false, "ReadonlyRootfs": false, "SecurityOpt": null, "UTSMode": "", "UsernsMode": "", "ShmSize": 67108864, "Runtime": "runc", "ConsoleSize": [ 0, 0 ], "Isolation": "", "CpuShares": 0, "Memory": 0, "NanoCpus": 0, "CgroupParent": "", "BlkioWeight": 0, "BlkioWeightDevice": [], "BlkioDeviceReadBps": null, "BlkioDeviceWriteBps": null, "BlkioDeviceReadIOps": null, "BlkioDeviceWriteIOps": null, "CpuPeriod": 0, "CpuQuota": 0, "CpuRealtimePeriod": 0, "CpuRealtimeRuntime": 0, "CpusetCpus": "", "CpusetMems": "", "Devices": [], "DeviceCgroupRules": null, "DiskQuota": 0, "KernelMemory": 0, "MemoryReservation": 0, "MemorySwap": 0, "MemorySwappiness": null, "OomKillDisable": false, "PidsLimit": 0, "Ulimits": null, "CpuCount": 0, "CpuPercent": 0, "IOMaximumIOps": 0, "IOMaximumBandwidth": 0 }, "GraphDriver": { "Data": { "LowerDir": "/var/lib/docker/overlay2/4f5f630442b65a59c7f174a8aad1dc356cb6f565e76b2ca4afa49132afbaf30d-init/diff:/var/lib/docker/overlay2/a93b9c08d02aa86d8a53f5a32f166c8b40932f1430d4f9e3fd4e9c9e96af6557/diff:/var/lib/docker/overlay2/21b66b86842fd4c456df6ea2493edbabcd0df49f468100c9c2d7d2ef55711501/diff:/var/lib/docker/overlay2/e10484efe17398912f63644cff926875cd10fa8169d1ef2f1164d1000ccd7b06/diff:/var/lib/docker/overlay2/9b110a14a5fd9640fd95161c1fa35ec8cb98b4fb55a7caf70231b1b8ba238559/diff:/var/lib/docker/overlay2/a1cb33255806e73a1d7f9efd49c2bfcbb6edf190ed1976889cb10d3f81682c9f/diff:/var/lib/docker/overlay2/67286cfad81daababf3bac63ff9684c9567cd877e1e2ce4888d59257da4a06ca/diff:/var/lib/docker/overlay2/6904d0950327c52355e8b34b16d822b4eddf817de272f965f6fc6ad31089227d/diff:/var/lib/docker/overlay2/f6b782d3f37da3bf2c36ed70f6302d282ca4c80d39b3de3933b14902d149cfec/diff:/var/lib/docker/overlay2/e4eac39fc7fade8117216f45e9fe85bb42537714c19c02c70aab4ed62fad474e/diff:/var/lib/docker/overlay2/227df1848d1a3038188689c1f343ad42758bc6be9872ca8dda843a13b0bbf93e/diff", "MergedDir": "/var/lib/docker/overlay2/4f5f630442b65a59c7f174a8aad1dc356cb6f565e76b2ca4afa49132afbaf30d/merged", "UpperDir": "/var/lib/docker/overlay2/4f5f630442b65a59c7f174a8aad1dc356cb6f565e76b2ca4afa49132afbaf30d/diff", "WorkDir": "/var/lib/docker/overlay2/4f5f630442b65a59c7f174a8aad1dc356cb6f565e76b2ca4afa49132afbaf30d/work" }, "Name": "overlay2" }, "Mounts": [ { "Type": "bind", "Source": "/mnt/minecraft", "Destination": "/data", "Mode": "", "RW": true, "Propagation": "rprivate" } ], "Config": { "Hostname": "34cb1418fb23", "Domainname": "", "User": "", "AttachStdin": false, "AttachStdout": false, "AttachStderr": false, "ExposedPorts": { "25565/tcp": {}, "25565/udp": {} }, "Tty": false, "OpenStdin": false, "StdinOnce": false, "Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "DEBIAN_FRONTEND=noninteractive" ], "Cmd": [ "/start" ], "Image": "rlenferink/minecraft:latest", "Volumes": { "/data": {} }, "WorkingDir": "", "Entrypoint": null, "OnBuild": null, "Labels": {} }, "NetworkSettings": { "Bridge": "", "SandboxID": "e2c693daed0be5a204a83d408262a0fe01b66bdd99ddbb3a53229f5a58d5202c", "HairpinMode": false, "LinkLocalIPv6Address": "", "LinkLocalIPv6PrefixLen": 0, "Ports": { "25565/tcp": [ { "HostIp": "0.0.0.0", "HostPort": "25565" } ], "25565/udp": [ { "HostIp": "0.0.0.0", "HostPort": "25565" } ] }, "SandboxKey": "/var/run/docker/netns/e2c693daed0b", "SecondaryIPAddresses": null, "SecondaryIPv6Addresses": null, "EndpointID": "819a8255b8ed4d79366a6d6ff4442a441f61d89bdfacc0c193ed2f9340024696", "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": {}, "Links": null, "Aliases": null, "NetworkID": "e2ff1284a59794e19dd4dc39b17713ad11e0db3e698735014579405355f516ec", "EndpointID": "819a8255b8ed4d79366a6d6ff4442a441f61d89bdfacc0c193ed2f9340024696", "Gateway": "172.17.0.1", "IPAddress": "172.17.0.3", "IPPrefixLen": 16, "IPv6Gateway": "", "GlobalIPv6Address": "", "GlobalIPv6PrefixLen": 0, "MacAddress": "02:42:ac:11:00:03", "DriverOpts": null } } } }]
Netshoot
Active Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 :::25565 :::* LISTENroot@server:~# echo $DOCKER_HOST
root@server:~#
On local machine
$ curl http://127.0.0.1:25565curl: (52) Empty reply from server
Local machine on firefox
Problem loading page on...0.0.0.0:25565127.0.0.1:25565localhost:25565192.168.15.22:25565
Several things to check:
Make sure your application is healthy. Check
docker logs mc
for any error messages anddocker container inspect mc
for the last exit/restart time of the container.Check that the application is listening on the desired port. For this, I like netshoot:
docker run -it --rm --net container:mc nicolaka/netshoot netstat -lnt
This should show output with your port, listening on
0.0.0.0:25565
.Check if you are running your docker commands locally or against a remote instance or VM.
echo $DOCKER_HOST
and if that has a value, connect to that IP address instead of127.0.0.1
.If you are logged into a remote machine to run docker commands (e.g. ssh), test locally on that machine first (e.g.
curl http://127.0.0.1:25565
) before trying to access it remotely where firewalls may block the connectivity.Lastly, as mentioned in the comments, don't connect to
0.0.0.0
from the client. This is effectively a wildcard IP address that tells the server application to listen on all network interfaces. You don't connect to that from your client/web browser. Instead, use the actual IP or DNS name of the host.
这篇关于即使从本地主机也无法从暴露的端口访问Docker容器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!