docker_practice/network/dns.md

45 lines
1.8 KiB
Go
Raw Normal View History

## DNS
2017-11-23 21:25:42 +08:00
2017-11-26 11:28:55 +08:00
DNS Docker 3
使 `mount`
2017-11-22 11:13:23 +08:00
```bash
2014-09-05 15:50:54 +08:00
$ 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 ...
```
2017-11-23 21:25:42 +08:00
宿 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
2018-07-10 08:09:10 +08:00
$ docker run -it --rm ubuntu:18.04 cat etc/resolv.conf
2017-11-23 21:25:42 +08:00
nameserver 114.114.114.114
nameserver 8.8.8.8
```
2017-12-10 10:51:40 +08:00
使 `docker run`
2014-09-05 15:50:54 +08:00
`-h HOSTNAME` `--hostname=HOSTNAME` `/etc/hostname` `/etc/hosts` `docker container ls` `/etc/hosts`
2014-09-05 15:50:54 +08:00
2017-11-26 11:28:55 +08:00
`--dns=IP_ADDRESS` DNS `/etc/resolv.conf` `/etc/hosts`
2014-09-05 15:50:54 +08:00
2017-11-26 11:28:55 +08:00
`--dns-search=DOMAIN` `.example.com` host DNS host `host.example.com`
2017-11-27 14:31:01 +08:00
2017-12-10 10:51:40 +08:00
>Docker `/etc/resolv.conf`