docker_practice/network/dns.md

45 lines
1.8 KiB
Go
Raw Permalink Normal View History

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