yarn install fails "getaddrinfo EAI_AGAIN registry.yarnpkg.com"

This article is for Docker Toolbox. ** Not applicable to Docker for Windows **

Docker can't build

When I tried to build a test server on docker for web application development, it failed.

Step 10/11 : RUN cd app && yarn install
 ---> Running in d36ecd97329b
yarn install v1.22.4
[1/4] Resolving packages...
[2/4] Fetching packages...
error An unexpected error occurred: "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz: getaddrinfo EAI_AGAIN registry.yarnpkg.com".

Below is the file in question

Dcokerfile


FROM node:12.16-slim

ENV APP_DIR=/app
WORKDIR ${APP_DIR}
RUN mkdir -p ${APP_DIR}
COPY . ${APP_DIR}

ENV LANG=C.UTF-8
ENV TZ=Asia/Tokyo
ENV NODE_ENV=development
ENV HOST 0.0.0.0

RUN cd app && yarn install

EXPOSE 3000

environment

Hyper-V is not available on Windows 10 Home ** Install via Docker Toolbox **

-[Official] Install Docker Toolbox on Windows -[Qiita] Install Docker Toolbox in Windows environment

Cause

It's easy to see that the name of registry.yarnpkg.com cannot be resolved. But why? You can do nslookup from the command line normally? If you think that, there seems to be a problem with the DNS on the VirtualBox side. It is sandwiched between the OS and the container to prepare the Linux kernel, and it is surprisingly easy to overlook the problem. When you hit it on VirtualBox,

dcoker@default:~$ nslookup registry.yarnpkg.com
Server:    10.0.2.3
Address 1: 10.0.2.3
nslookup: can't resolve 'registry.yarnpkg.com'

Solution method

Quickly add 8.8.8.8 to the secondary to the DNS server.

dcoker@default:~$ sudo -i
root@default:~# vi /etc/resolv.conf

DNS settings [resolv.conf] Disable overwriting after reboot

/etc/resolv.conf


  nameserver 10.0.2.3
+ nameserver 8.8.8.8

8.8.8.8 is the address of Google Public DNS, which is a reliable ally when you have trouble with DNS. Due to the difference in keyboard layout, the colon : cannot be typed and vi cannot be terminated! If you are such a JIS array user, press '+' (Shift +';').

[Qiita] Type characters in a US layout environment even though it is a JIS keyboard

Note that this is a first aid measure and will not be a permanent solution, such as restarting VirtualBox.

Recommended Posts

yarn install fails "getaddrinfo EAI_AGAIN registry.yarnpkg.com"
When semantic-ui install fails
Install yarn in docker image