Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

apk return DNS lookup error on docker build

Tags:

docker

dns

When run any apk add ... command while docker build ... I get DNS lookup error:

fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/main/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.8/main: DNS lookup error
fetch http://dl-cdn.alpinelinux.org/alpine/v3.8/community/x86_64/APKINDEX.tar.gz
ERROR: http://dl-cdn.alpinelinux.org/alpine/v3.8/community: DNS lookup error

How do I fix this?

like image 492
zored Avatar asked Feb 04 '21 09:02

zored


1 Answers

It seems that my Dokcer inside of docker-machine had troubles resolving DNS.

I added this file /etc/docker/daemon.json into machine to make everything work correctly:

{
  "dns": ["8.8.8.8", "192.168.0.1"]
}

Also you may use docker run --dns 8.8.8.8 ... if you just run container.

like image 179
zored Avatar answered Sep 20 '22 01:09

zored