From 366e1686a0ee4c6d71aeaf60d84a8cef284f7d8b Mon Sep 17 00:00:00 2001 From: Aditya R Date: Sun, 20 Nov 2022 07:33:19 +0530 Subject: [PATCH] podman: relay custom DNS servers to network stack Aardvark-dns and netavark now accepts custom DNS servers for containers via new config field `dns_servers`. New field allows containers to use custom resolvers instead of host's default resolvers. Following commit instruments libpod to pass these custom DNS servers set via `--dns` or central config to the network stack. Depends-on: * Common: containers/common#1189 * Netavark: containers/netavark#452 * Aardvark-dns: containers/aardvark-dns#240 Signed-off-by: Aditya R --- libpod/networking_common.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libpod/networking_common.go b/libpod/networking_common.go index ac914493b2..816e1d1c08 100644 --- a/libpod/networking_common.go +++ b/libpod/networking_common.go @@ -39,9 +39,15 @@ func (c *Container) convertPortMappings() []types.PortMapping { } func (c *Container) getNetworkOptions(networkOpts map[string]types.PerNetworkOptions) types.NetworkOptions { + nameservers := make([]string, 0, len(c.runtime.config.Containers.DNSServers)+len(c.config.DNSServer)) + nameservers = append(nameservers, c.runtime.config.Containers.DNSServers...) + for _, ip := range c.config.DNSServer { + nameservers = append(nameservers, ip.String()) + } opts := types.NetworkOptions{ ContainerID: c.config.ID, ContainerName: getNetworkPodName(c), + DNSServers: nameservers, } opts.PortMappings = c.convertPortMappings()