Podman 容器别名在 ping 时给出 "bad address"
Podman container aliases give "bad address" when pinged
我有一个 podman 网络。容器可以通过 IP 进行通信,但不能通过 alias/container 名称进行通信。
这是我检查时的网络设置:
[
{
"args": {
"podman_labels": {
"com.docker.compose.network": "prom-net",
"com.docker.compose.project": "printer-prometheus",
"com.docker.compose.version": "1.23.2"
}
},
"cniVersion": "0.4.0",
"name": "printer-prometheus_prom-net",
"plugins": [
{
"bridge": "cni-podman3",
"hairpinMode": true,
"ipMasq": true,
"ipam": {
"ranges": [
[
{
"gateway": "10.101.192.129",
"subnet": "10.101.192.128/26"
}
]
],
"routes": [
{
"dst": "0.0.0.0/0"
}
],
"type": "host-local"
},
"isGateway": true,
"type": "bridge"
},
{
"capabilities": {
"portMappings": true
},
"type": "portmap"
},
{
"backend": "",
"type": "firewall"
},
{
"type": "tuning"
}
]
}
]
我正在使用 docker-compose 来启动 pods。
"Networks": {
"printer-prometheus_prom-net": {
"EndpointID": "",
"Gateway": "10.101.192.129",
"IPAddress": "10.101.192.131",
"IPPrefixLen": 26,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "96:2e:67:d1:45:ec",
"NetworkID": "printer-prometheus_prom-net",
"DriverOpts": null,
"IPAMConfig": null,
"Links": null,
"Aliases": [
"5712fb063d92",
"blackbox_exporter"
]
}
}
},
如果我 ping 别名或容器名称,我会得到 ping: bad address '5712fb063d92'
。
我可以毫无问题地 ping IP。使用相同的撰写文件和 docker,一切正常。
安装 dnsname 并将以下内容添加到我在 /etc/cni/net 中的插件列表中。d/network_name 解决了问题
{
"type": "dnsname",
"domainName": "dns.podman",
"capabilities": {
"aliases": true
}
我有一个 podman 网络。容器可以通过 IP 进行通信,但不能通过 alias/container 名称进行通信。 这是我检查时的网络设置:
[
{
"args": {
"podman_labels": {
"com.docker.compose.network": "prom-net",
"com.docker.compose.project": "printer-prometheus",
"com.docker.compose.version": "1.23.2"
}
},
"cniVersion": "0.4.0",
"name": "printer-prometheus_prom-net",
"plugins": [
{
"bridge": "cni-podman3",
"hairpinMode": true,
"ipMasq": true,
"ipam": {
"ranges": [
[
{
"gateway": "10.101.192.129",
"subnet": "10.101.192.128/26"
}
]
],
"routes": [
{
"dst": "0.0.0.0/0"
}
],
"type": "host-local"
},
"isGateway": true,
"type": "bridge"
},
{
"capabilities": {
"portMappings": true
},
"type": "portmap"
},
{
"backend": "",
"type": "firewall"
},
{
"type": "tuning"
}
]
}
]
我正在使用 docker-compose 来启动 pods。
"Networks": {
"printer-prometheus_prom-net": {
"EndpointID": "",
"Gateway": "10.101.192.129",
"IPAddress": "10.101.192.131",
"IPPrefixLen": 26,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "96:2e:67:d1:45:ec",
"NetworkID": "printer-prometheus_prom-net",
"DriverOpts": null,
"IPAMConfig": null,
"Links": null,
"Aliases": [
"5712fb063d92",
"blackbox_exporter"
]
}
}
},
如果我 ping 别名或容器名称,我会得到 ping: bad address '5712fb063d92'
。
我可以毫无问题地 ping IP。使用相同的撰写文件和 docker,一切正常。
安装 dnsname 并将以下内容添加到我在 /etc/cni/net 中的插件列表中。d/network_name 解决了问题
{
"type": "dnsname",
"domainName": "dns.podman",
"capabilities": {
"aliases": true
}