mirror of
https://github.com/podman-container-tools/podman.git
synced 2026-10-20 12:57:35 +00:00
Merge pull request #12517 from Luap99/machine-dns
podman machine: use gvproxy for host.containers.internal
This commit is contained in:
commit
1aeb61cf5c
1 changed files with 29 additions and 25 deletions
|
|
@ -2022,33 +2022,37 @@ func (c *Container) getHosts() string {
|
|||
}
|
||||
}
|
||||
|
||||
// Add gateway entry
|
||||
var depCtr *Container
|
||||
if c.config.NetNsCtr != "" {
|
||||
// ignoring the error because there isn't anything to do
|
||||
depCtr, _ = c.getRootNetNsDepCtr()
|
||||
} else if len(c.state.NetworkStatus) != 0 {
|
||||
depCtr = c
|
||||
} else {
|
||||
depCtr = nil
|
||||
}
|
||||
|
||||
if depCtr != nil {
|
||||
for _, pluginResultsRaw := range depCtr.state.NetworkStatus {
|
||||
pluginResult, _ := cnitypes.GetResult(pluginResultsRaw)
|
||||
for _, ip := range pluginResult.IPs {
|
||||
hosts += fmt.Sprintf("%s host.containers.internal\n", ip.Gateway)
|
||||
}
|
||||
}
|
||||
} else if c.config.NetMode.IsSlirp4netns() {
|
||||
gatewayIP, err := GetSlirp4netnsGateway(c.slirp4netnsSubnet)
|
||||
if err != nil {
|
||||
logrus.Warn("failed to determine gatewayIP: ", err.Error())
|
||||
// Add gateway entry if we are not in a machine. If we use podman machine
|
||||
// the gvproxy dns server will take care of host.containers.internal.
|
||||
// https://github.com/containers/gvisor-tap-vsock/commit/1108ea45162281046d239047a6db9bc187e64b08
|
||||
if !c.runtime.config.Engine.MachineEnabled {
|
||||
var depCtr *Container
|
||||
if c.config.NetNsCtr != "" {
|
||||
// ignoring the error because there isn't anything to do
|
||||
depCtr, _ = c.getRootNetNsDepCtr()
|
||||
} else if len(c.state.NetworkStatus) != 0 {
|
||||
depCtr = c
|
||||
} else {
|
||||
hosts += fmt.Sprintf("%s host.containers.internal\n", gatewayIP.String())
|
||||
depCtr = nil
|
||||
}
|
||||
|
||||
if depCtr != nil {
|
||||
for _, pluginResultsRaw := range depCtr.state.NetworkStatus {
|
||||
pluginResult, _ := cnitypes.GetResult(pluginResultsRaw)
|
||||
for _, ip := range pluginResult.IPs {
|
||||
hosts += fmt.Sprintf("%s host.containers.internal\n", ip.Gateway)
|
||||
}
|
||||
}
|
||||
} else if c.config.NetMode.IsSlirp4netns() {
|
||||
gatewayIP, err := GetSlirp4netnsGateway(c.slirp4netnsSubnet)
|
||||
if err != nil {
|
||||
logrus.Warn("failed to determine gatewayIP: ", err.Error())
|
||||
} else {
|
||||
hosts += fmt.Sprintf("%s host.containers.internal\n", gatewayIP.String())
|
||||
}
|
||||
} else {
|
||||
logrus.Debug("network configuration does not support host.containers.internal address")
|
||||
}
|
||||
} else {
|
||||
logrus.Debug("network configuration does not support host.containers.internal address")
|
||||
}
|
||||
|
||||
return hosts
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue