我已经使用过官方CentOS 7 映像来自 Docker Hub 并创建了一个运行Solr 8.4.1版本。我能够启动并运行 Solr,没有任何问题。我担心的是,Solr 管理 UI 加载时本地主机网址(http://本地主机:7574/solr/)但不具有为容器分配的 IP(http://172.18.0.6:7574/solr/)。
/etc/hosts容器中的文件如下所示。
[solr@solrtwo solr-8.4.1]$ cat /etc/hosts
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.18.0.6 solrtwo
另外我已经启用了以下行solr.in.sh以及
SOLR_HOST="172.18.0.6"
此外,容器的 docker 检查结果如下所示。
"NetworkSettings": {
"Bridge": "",
"SandboxID": "87cf51134d0b4bc3068ab8e294f5dc91bfc2db79528064002135beaa6c84b074",
"HairpinMode": false,
"LinkLocalIPv6Address": "",
"LinkLocalIPv6PrefixLen": 0,
"Ports": {
"7574/tcp": [
{
"HostIp": "0.0.0.0",
"HostPort": "7574"
}
]
},
"SandboxKey": "/var/run/docker/netns/87cf51134d0b",
"SecondaryIPAddresses": null,
"SecondaryIPv6Addresses": null,
"EndpointID": "",
"Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"MacAddress": "",
"Networks": {
"zone1": {
"IPAMConfig": null,
"Links": null,
"Aliases": [
"095f310ec70f"
],
"NetworkID": "c9ab125d4c36228a46447514f0e13867bff50607c6c1e4b726172b5c3393a9fb",
"EndpointID": "19a143b947bab68fe058e87f130bd1dd2e3b89b32c27d826c9ee4b3b55d30474",
"Gateway": "172.18.0.1",
"IPAddress": "172.18.0.6",
"IPPrefixLen": 16,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "02:42:ac:12:00:06",
"DriverOpts": null
}
}
}
我想使用容器 IP 地址而不是本地主机来加载 Solr 管理 UI。我该怎么做?