Name resolution failing during docker build

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Name resolution failing during docker build



I am experiencing an issue where I receive the following error when issuing the docker build command:-


curl: (6) Could not resolve host: dl.yarnpkg.com
gpg: no valid OpenPGP data found.



Here is my Dockerbuild file


# Base image
FROM ruby:2.5.0

RUN curl -sL https://deb.nodesource.com/setup_8.x | bash -
RUN curl -fsSL https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add -
RUN echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee
/etc/apt/sources.list.d/yarn.lisT
RUN apt-get update
RUN apt-get install -qq -y build-essential libpq-dev nodejs yarn



The commands complete successfully when run outside of docker.



In order to resolve the issues I have tried the following



I have tried DNS servers from Google and OpenDNS, as well as multiple ISPs depending on the location im running the command from



Laptop is running Ubuntu 16:04 with Docker version 18.06.0-ce, build 0ffa825 installed.



Using the following also fails


FROM ruby:2.5.0
RUN apt-get update -qq && apt-get install -y build-essential libpq-dev nodejs



causing the following error


W: Failed to fetch http://deb.debian.org/debian/dists/stretch/InRelease Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://deb.debian.org/debian/dists/stretch-updates/InRelease Temporary failure resolving 'deb.debian.org'
W: Failed to fetch http://security.debian.org/dists/stretch/updates/InRelease Temporary failure resolving 'security.debian.org'
W: Some index files failed to download. They have been ignored, or old ones used instead.



So I know this isnt just a problem iwth the dl.yarnpkg.com host.



Running the docker build command with the no-cache option makes no difference.





What happens if you run nslookup dl.yarnpkg.com 8.8.8.8 on your docker host outside of a container?
– BMitch
Aug 10 at 12:41


nslookup dl.yarnpkg.com 8.8.8.8





Server: 8.8.8.8 Address: 8.8.8.8#53 Non-authoritative answer: Name: dl.yarnpkg.com Address: 104.16.60.173 Name: dl.yarnpkg.com Address: 104.16.63.173 Name: dl.yarnpkg.com Address: 104.16.61.173 Name: dl.yarnpkg.com Address: 104.16.62.173 Name: dl.yarnpkg.com Address: 104.16.59.173 As i said i have tried different DNS providers, and the problem occurs with them all.
– user2099762
Aug 10 at 13:29






I have also tried disabling dnsmasq in the ubuntu dns settings....no luck,...
– user2099762
Aug 10 at 13:33





Did you reload the docker engine after changing the daemon.json? What happens if you run docker run -it --rm alpine cat /etc/resolv.conf and docker run -it --rm alpine nslookup dl.yarnpkg.com?
– BMitch
Aug 10 at 13:54


docker run -it --rm alpine cat /etc/resolv.conf


docker run -it --rm alpine nslookup dl.yarnpkg.com





# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8) # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 8.8.8.8 nameserver 8.8.4.4 nameserver 192.168.0.1 nameserver 208.67.222.222 search Home nameserver 8.8.8.8 nameserver 8.8.4.4
– user2099762
Aug 10 at 14:03




1 Answer
1



I am using Docker with Ubuntu 16.04 and sometimes I have name resolution problems too.



The only thing that made it through was adding --network=host when building. I'm not really sure what's going on but it seems it needs this to use your computer name resolution capabilities. I hope it helps.


--network=host






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard