Skip to content

Commit

Permalink
podman: relay custom DNS servers to network stack
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
flouthoc committed Jan 22, 2023
1 parent 8252dcc commit 366e168
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libpod/networking_common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down

0 comments on commit 366e168

Please sign in to comment.