mirror of
https://github.com/containers/podman.git
synced 2025-05-17 15:18:43 +08:00
pasta: Create /etc/hosts entries for pods using pasta networking
For pods with bridged and slirp4netns networking we create /etc/hosts entries to make it more convenient for the containers to address each other. We omitted to do this for pasta networking, however. Add the necessary code to do this. Closes: https://github.com/containers/podman/issues/17922 Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
@ -19,6 +19,7 @@ import (
|
||||
"github.com/containers/common/libnetwork/resolvconf"
|
||||
"github.com/containers/common/libnetwork/slirp4netns"
|
||||
"github.com/containers/common/libnetwork/types"
|
||||
netUtil "github.com/containers/common/libnetwork/util"
|
||||
"github.com/containers/common/pkg/netns"
|
||||
"github.com/containers/common/pkg/util"
|
||||
"github.com/containers/podman/v4/pkg/rootless"
|
||||
@ -757,3 +758,13 @@ func (c *Container) inspectJoinedNetworkNS(networkns string) (q types.StatusBloc
|
||||
})
|
||||
return result, err
|
||||
}
|
||||
|
||||
func getPastaIP(state *ContainerState) (net.IP, error) {
|
||||
var ip string
|
||||
err := ns.WithNetNSPath(state.NetNS, func(_ ns.NetNS) error {
|
||||
// get the first ip in the netns
|
||||
ip = netUtil.GetLocalIP()
|
||||
return nil
|
||||
})
|
||||
return net.ParseIP(ip), err
|
||||
}
|
||||
|
Reference in New Issue
Block a user