无法从 MacOS 中的主机访问 tezos 节点(在 Docker 中)
Not able to access a tezos node ( in Docker ) from host machine in MacOS
尝试访问 docker 容器内的节点进程 运行 时获取 "Curl Error 52 Empty reply from server"。端口正在公开并正确映射。并且 http 服务器请求被重定向到主机。
但是当尝试获取访问 RPC 请求时出现错误,如:"Curl Error 52 Empty reply from server"。 (P.S.- 以上问题针对Mac OS X)
Docker 版本:2.3.0.0 (44472)
通道:边缘
引擎:19.03.8
Running a Tezos Node inside Docker
我们尝试从主机访问的端口是 18731:
docker port <container_name>
给出:
18733/tcp -> 0.0.0.0:18733
18731/tcp -> 0.0.0.0:18731
18732/tcp -> 0.0.0.0:18732
Docker 检查结果:
[
{
"Id": "9cad4bc213857e3e3f12c65119d8afdbe39035c7bbba571492d70a96ce314bdf",
"Created": "2020-04-28T09:01:46.5606351Z",
"Path": "/bin/bash",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 4841,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-04-28T14:43:15.27769Z",
"FinishedAt": "2020-04-28T09:06:44.4686297Z"
},
"Image": "sha256:42099ae8fd65e7526e96a6eeb79617ae71d657bce777ac5c9d61428f8b1edb04",
"ResolvConfPath": "/var/lib/docker/containers/9cad4bc213857e3e3f12c65119d8afdbe39035c7bbba571492d70a96ce314bdf/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/9cad4bc213857e3e3f12c65119d8afdbe39035c7bbba571492d70a96ce314bdf/hostname",
"HostsPath": "/var/lib/docker/containers/9cad4bc213857e3e3f12c65119d8afdbe39035c7bbba571492d70a96ce314bdf/hosts",
"LogPath": "/var/lib/docker/containers/9cad4bc213857e3e3f12c65119d8afdbe39035c7bbba571492d70a96ce314bdf/9cad4bc213857e3e3f12c65119d8afd
"Name": "/mystifying_haslett",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"18731/tcp": [
{
"HostIp": "",
"HostPort": "18731"
}
],
"18732/tcp": [
{
"HostIp": "",
"HostPort": "18732"
}
],
"18733/tcp": [
{
"HostIp": "",
"HostPort": "18733"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"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,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/5a75a97bc8b37a753b13c2a7e7f128fb723f55ae53ea2eee73994cdc383deba5-init/diff:/var/lib/docke
"MergedDir": "/var/lib/docker/overlay2/5a75a97bc8b37a753b13c2a7e7f128fb723f55ae53ea2eee73994cdc383deba5/merged",
"UpperDir": "/var/lib/docker/overlay2/5a75a97bc8b37a753b13c2a7e7f128fb723f55ae53ea2eee73994cdc383deba5/diff",
"WorkDir": "/var/lib/docker/overlay2/5a75a97bc8b37a753b13c2a7e7f128fb723f55ae53ea2eee73994cdc383deba5/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "9cad4bc21385",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"18731/tcp": {},
"18732/tcp": {},
"18733/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/bash"
],
"Image": "tezsureinc/tezster:1.0.2",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "5a1dd0e82d96429d960f9e6c71493b399e2c4bbf7efb65feb7c70f02a04d2adb",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"18731/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "18731"
}
],
"18732/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "18732"
}
],
"18733/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "18733"
}
]
},
"SandboxKey": "/var/run/docker/netns/5a1dd0e82d96",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "132040e6a80291f2965b6aa5cc45f9237c210469e747dec73446e86951b4759c",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "23456a611a031437e11780b4f58a0d1881906b4ce981647996966cee74aa6e5f",
"EndpointID": "132040e6a80291f2965b6aa5cc45f9237c210469e747dec73446e86951b4759c",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]
在 docker 中访问网络服务器 运行 与 运行 基于 RPC 的网络有何不同?
容器内有两个IP,它可能没有监听172.x.x.x IP。您必须避免在 docker 容器内的任何地方或映射端口时使用 127.0.0.1 或本地主机。而使用 0.0.0.0 将解决此问题。希望这对你有所帮助。
尝试访问 docker 容器内的节点进程 运行 时获取 "Curl Error 52 Empty reply from server"。端口正在公开并正确映射。并且 http 服务器请求被重定向到主机。
但是当尝试获取访问 RPC 请求时出现错误,如:"Curl Error 52 Empty reply from server"。 (P.S.- 以上问题针对Mac OS X)
Docker 版本:2.3.0.0 (44472) 通道:边缘 引擎:19.03.8
Running a Tezos Node inside Docker
我们尝试从主机访问的端口是 18731:
docker port <container_name>
给出:
18733/tcp -> 0.0.0.0:18733
18731/tcp -> 0.0.0.0:18731
18732/tcp -> 0.0.0.0:18732
Docker 检查结果:
[
{
"Id": "9cad4bc213857e3e3f12c65119d8afdbe39035c7bbba571492d70a96ce314bdf",
"Created": "2020-04-28T09:01:46.5606351Z",
"Path": "/bin/bash",
"Args": [],
"State": {
"Status": "running",
"Running": true,
"Paused": false,
"Restarting": false,
"OOMKilled": false,
"Dead": false,
"Pid": 4841,
"ExitCode": 0,
"Error": "",
"StartedAt": "2020-04-28T14:43:15.27769Z",
"FinishedAt": "2020-04-28T09:06:44.4686297Z"
},
"Image": "sha256:42099ae8fd65e7526e96a6eeb79617ae71d657bce777ac5c9d61428f8b1edb04",
"ResolvConfPath": "/var/lib/docker/containers/9cad4bc213857e3e3f12c65119d8afdbe39035c7bbba571492d70a96ce314bdf/resolv.conf",
"HostnamePath": "/var/lib/docker/containers/9cad4bc213857e3e3f12c65119d8afdbe39035c7bbba571492d70a96ce314bdf/hostname",
"HostsPath": "/var/lib/docker/containers/9cad4bc213857e3e3f12c65119d8afdbe39035c7bbba571492d70a96ce314bdf/hosts",
"LogPath": "/var/lib/docker/containers/9cad4bc213857e3e3f12c65119d8afdbe39035c7bbba571492d70a96ce314bdf/9cad4bc213857e3e3f12c65119d8afd
"Name": "/mystifying_haslett",
"RestartCount": 0,
"Driver": "overlay2",
"Platform": "linux",
"MountLabel": "",
"ProcessLabel": "",
"AppArmorProfile": "",
"ExecIDs": null,
"HostConfig": {
"Binds": null,
"ContainerIDFile": "",
"LogConfig": {
"Type": "json-file",
"Config": {}
},
"NetworkMode": "default",
"PortBindings": {
"18731/tcp": [
{
"HostIp": "",
"HostPort": "18731"
}
],
"18732/tcp": [
{
"HostIp": "",
"HostPort": "18732"
}
],
"18733/tcp": [
{
"HostIp": "",
"HostPort": "18733"
}
]
},
"RestartPolicy": {
"Name": "no",
"MaximumRetryCount": 0
},
"AutoRemove": false,
"VolumeDriver": "",
"VolumesFrom": null,
"CapAdd": null,
"CapDrop": null,
"Capabilities": null,
"Dns": [],
"DnsOptions": [],
"DnsSearch": [],
"ExtraHosts": null,
"GroupAdd": null,
"IpcMode": "private",
"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,
"DeviceRequests": null,
"KernelMemory": 0,
"KernelMemoryTCP": 0,
"MemoryReservation": 0,
"MemorySwap": 0,
"MemorySwappiness": null,
"OomKillDisable": false,
"PidsLimit": null,
"Ulimits": null,
"CpuCount": 0,
"CpuPercent": 0,
"IOMaximumIOps": 0,
"IOMaximumBandwidth": 0,
"MaskedPaths": [
"/proc/asound",
"/proc/acpi",
"/proc/kcore",
"/proc/keys",
"/proc/latency_stats",
"/proc/timer_list",
"/proc/timer_stats",
"/proc/sched_debug",
"/proc/scsi",
"/sys/firmware"
],
"ReadonlyPaths": [
"/proc/bus",
"/proc/fs",
"/proc/irq",
"/proc/sys",
"/proc/sysrq-trigger"
]
},
"GraphDriver": {
"Data": {
"LowerDir": "/var/lib/docker/overlay2/5a75a97bc8b37a753b13c2a7e7f128fb723f55ae53ea2eee73994cdc383deba5-init/diff:/var/lib/docke
"MergedDir": "/var/lib/docker/overlay2/5a75a97bc8b37a753b13c2a7e7f128fb723f55ae53ea2eee73994cdc383deba5/merged",
"UpperDir": "/var/lib/docker/overlay2/5a75a97bc8b37a753b13c2a7e7f128fb723f55ae53ea2eee73994cdc383deba5/diff",
"WorkDir": "/var/lib/docker/overlay2/5a75a97bc8b37a753b13c2a7e7f128fb723f55ae53ea2eee73994cdc383deba5/work"
},
"Name": "overlay2"
},
"Mounts": [],
"Config": {
"Hostname": "9cad4bc21385",
"Domainname": "",
"User": "",
"AttachStdin": false,
"AttachStdout": false,
"AttachStderr": false,
"ExposedPorts": {
"18731/tcp": {},
"18732/tcp": {},
"18733/tcp": {}
},
"Tty": true,
"OpenStdin": true,
"StdinOnce": false,
"Env": [
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
],
"Cmd": [
"/bin/bash"
],
"Image": "tezsureinc/tezster:1.0.2",
"Volumes": null,
"WorkingDir": "",
"Entrypoint": null,
"OnBuild": null,
"Labels": {}
},
"NetworkSettings": {
"Bridge": "",
"SandboxID": "5a1dd0e82d96429d960f9e6c71493b399e2c4bbf7efb65feb7c70f02a04d2adb",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"18731/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "18731"
}
],
"18732/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "18732"
}
],
"18733/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "18733"
}
]
},
"SandboxKey": "/var/run/docker/netns/5a1dd0e82d96",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "132040e6a80291f2965b6aa5cc45f9237c210469e747dec73446e86951b4759c",
"Gateway": "172.17.0.1",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"MacAddress": "02:42:ac:11:00:02",
"Networks": {
"bridge": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "23456a611a031437e11780b4f58a0d1881906b4ce981647996966cee74aa6e5f",
"EndpointID": "132040e6a80291f2965b6aa5cc45f9237c210469e747dec73446e86951b4759c",
"Gateway": "172.17.0.1",
"IPAddress": "172.17.0.2",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:11:00:02",
"DriverOpts": null
}
}
}
}
]
在 docker 中访问网络服务器 运行 与 运行 基于 RPC 的网络有何不同?
容器内有两个IP,它可能没有监听172.x.x.x IP。您必须避免在 docker 容器内的任何地方或映射端口时使用 127.0.0.1 或本地主机。而使用 0.0.0.0 将解决此问题。希望这对你有所帮助。