Solve the DNS issue when play docker on ubuntu

Solve the DNS issue when play docker on ubuntu

Docker 在Ubuntu上面的dns问题

Issue description

Recently, I met an issue during dockerfile building. When I try to build a docker image on Ubuntu 16.04.3, it always failed. After a few checking, I found that the DNS does not work in container.

The impact is that, if my dockerfile has update actions (apt updat/apk update), it never works. In this case, I can't install any software during docker image building.

Environment

Ubuntu 16.04.3
docker-ce 17.09.0-ce

Solve docker DNS issue on ubuntu

I checked many solution online, there is a simple way to solve this.

  1. Check you local DNS
nmcli dev show|grep "IP4.DNS"
IP4.DNS[1]:                             xxx.xxx.xxx.xxx
  1. Create or modify /etc/docker/daemon.json
sudo vim /etc/docker/daemon.json
{
  "dns": ["xxx.xxx.xxx.xxx","8.8.8.8"]
}
  1. Restart docker service
sudo service docker restart

Extend learning

How docker DNS works? see this article

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 在人生的旅途中,十几岁时,说要好好读书,才能上好大学,于是我们放下兴趣奔上读书路.二十几岁时,说该成家了,...
    阿元阅读 1,381评论 0 1
  • 你为什么还是单身,单身久了就觉得一个人的状态挺好的:想看书了就看书,累了就睡觉,想吃啥就吃啥,不想联系谁就自己安静...
    最美林州阅读 273评论 1 0
  • *导读: * 如果你只会UITabelView的性能优化,请不要说你懂iOS性能优化,下面是我开发这么多年项目中会...
    柳骏阅读 2,800评论 4 80
  • 文/龙猫苒苒 最近,我有点烦,甚至有点焦躁。 因为有人质疑我,认为我做事的目的性太强。 他们这样劝我,工作中,努力...
    龙猫苒苒阅读 7,146评论 3 11
  • 眼泪和鼻涕横飞的季节 雨一直下 草正在疯长 你轻轻叩门的一刹那 我从梦里清醒 一米阳光洒在屋顶 我知道眼泪和鼻涕总...
    吴爪爪阅读 396评论 0 0