docker_practice/network/dns.md

45 lines
1.8 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

## DNS
DNS Docker 3
使 `mount`
```bash
$ mount
/dev/disk/by-uuid/1fec...ebdf on /etc/hostname type ext4 ...
/dev/disk/by-uuid/1fec...ebdf on /etc/hosts type ext4 ...
tmpfs on /etc/resolv.conf type tmpfs ...
```
宿 DNS Docker DNS `/etc/resolv.conf`
DNS `/etc/docker/daemon.json`
```json
{
"dns" : [
"114.114.114.114",
"8.8.8.8"
]
}
```
DNS `114.114.114.114` `8.8.8.8`使
```bash
$ docker run -it --rm ubuntu:18.04 cat etc/resolv.conf
nameserver 114.114.114.114
nameserver 8.8.8.8
```
使 `docker run`
`-h HOSTNAME` `--hostname=HOSTNAME` `/etc/hostname` `/etc/hosts` `docker container ls` `/etc/hosts`
`--dns=IP_ADDRESS` DNS `/etc/resolv.conf` `/etc/hosts`
`--dns-search=DOMAIN` `.example.com` host DNS host `host.example.com`
>Docker `/etc/resolv.conf`