Skip to content

Commit 368a7cf

Browse files
author
David Karlsson
committed
engine: add note on name resolution with multiple nameservers
Signed-off-by: David Karlsson <david.karlsson@docker.com>
1 parent f93a018 commit 368a7cf

File tree

1 file changed

+29
-6
lines changed

1 file changed

+29
-6
lines changed

network/index.md

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,17 @@ you can use the `--alias` flag to specify an additional network alias for the co
8484
8585
## DNS services
8686
87-
By default, containers inherit the DNS settings of the host, as defined in the `/etc/resolv.conf` configuration file.
87+
By default, containers inherit the DNS settings of the host,
88+
as defined in the `/etc/resolv.conf` configuration file.
8889
Containers that attach to the default `bridge` network receive a copy of this file.
8990
Containers that attach to a
9091
[custom network](network-tutorial-standalone.md#use-user-defined-bridge-networks)
9192
use Docker's embedded DNS server.
9293
The embedded DNS server forwards external DNS lookups to the DNS servers configured on the host.
9394
94-
Custom hosts, defined in `/etc/hosts` on the host machine, aren't inherited by containers.
95-
To pass additional hosts into container, refer to
96-
[add entries to container hosts file](../engine/reference/commandline/run.md#add-host)
97-
in the `docker run` reference documentation.
98-
You can override these settings on a per-container basis.
95+
You can configure DNS resolution on a per-container basis, using flags for the
96+
`docker run` command when you start the container. The following table
97+
describes the available `docker run` flags related to DNS configuration.
9998
10099
| Flag | Description |
101100
| -------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
@@ -104,6 +103,30 @@ You can override these settings on a per-container basis.
104103
| `--dns-opt` | A key-value pair representing a DNS option and its value. See your operating system's documentation for `resolv.conf` for valid options. |
105104
| `--hostname` | The hostname a container uses for itself. Defaults to the container's ID if not specified. |
106105
106+
### Name resolution with multiple nameservers
107+
108+
When you specify multiple DNS servers using `--dns` flags, name resolution may
109+
work in a surprising or unexpected way. DNS lookup behavior depends on a number
110+
of different factors:
111+
112+
- Whether the container OS runs on [musl or glibc](https://wiki.musl-libc.org/functional-differences-from-glibc.html#Name_Resolver/DNS){: target="blank" rel="noopener" }
113+
- Whether the Docker daemon binary was [statically or dynamically linked](https://pkg.go.dev/net#hdr-Name_Resolution){: target="blank" rel="noopener" }
114+
- If dynamically linked, which version of glibc that's used
115+
- Whether or not [nsswitch.conf is present](https://tldp.org/LDP/nag2/x-087-2-resolv.library.html#X-087-2-RESOLV.NSSWITCH-CONF){: target="blank" rel="noopener" }
116+
117+
You may find that name resolution works as follows:
118+
119+
1. The container emits requests to **all** nameservers that you specify.
120+
2. The container uses the first response returned by any of the nameservers.
121+
Even if the first response is `NXDOMAIN`, or similar.
122+
123+
### Custom hosts
124+
125+
Custom hosts, defined in `/etc/hosts` on the host machine, aren't inherited by containers.
126+
To pass additional hosts into container, refer to
127+
[add entries to container hosts file](../engine/reference/commandline/run.md#add-host)
128+
in the `docker run` reference documentation.
129+
107130
## Proxy server
108131
109132
If your container needs to use a proxy server, see

0 commit comments

Comments
 (0)