Docker配置host地址

前言
在配置服务器的时候经常会修改域名映射, 也就是/etc/hosts文件,

1.命令行配置
–add-host 使用该参数可以配置多个host.
docker run -it --add-host host1:192.168.1.1 --add-host host2:192.168.1.2 alpine

/ # cat /etc/hosts
127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2
ip6-allrouters
192.168.1.1 host1
192.168.1.2 host2
172.17.0.2 c91f741f3370
https://jingsam.github.io/2018/10/16/host-in-docker.html

参考:https://jingsam.github.io/2018/10/16/host-in-docker.html

发布了223 篇原创文章 · 获赞 145 · 访问量 29万+

猜你喜欢

转载自blog.csdn.net/zzhuan_1/article/details/100164922
今日推荐