e-tipsmemo

ごった煮

docker build中にresolveに失敗する場合の対処方法 EAI_AGAIN registry.yarnpkg.com

問題

Docker版のKonomiTVのインストール中にyarnのリポジトリへのアクセスが失敗したり、
それ以降のubuntuリポジトリへのアクセスが失敗することでインストールが完了しないことが多々あった。


=> CANCELED [konomitv thirdparty-downloader 2/5] RUN apt-get update && apt->get install -y --no-install-recommend  1.0s
 => CANCELED [konomitv stage-2 2/9] RUN apt-get update && apt-get install -y --no-install-recommends ca-certifica  1.0s
 => [konomitv client-builder 3/6] COPY ./client/package.json ./client/yarn.lock /code/client/                      0.1s
 => ERROR [konomitv client-builder 4/6] RUN yarn install --frozen-lockfile                                         0.6s
------
 > [konomitv client-builder 4/6] RUN yarn install --frozen-lockfile:
0.333 yarn install v1.22.19
0.366 [1/4] Resolving packages...
0.508 [2/4] Fetching packages...
0.567 error An unexpected error occurred: "https://registry.yarnpkg.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz: getaddrinfo EAI_AGAIN registry.yarnpkg.com".
0.567 info If you think this is a bug, please open a bug report with the information provided in "/code/client/yarn-error.log".
0.567 info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
------
failed to solve: process "/bin/sh -c yarn install --frozen-lockfile" did not complete successfully: exit code: 1
────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

  ┌──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Docker                                                                                                           │
  │ イメージのビルド中に予期しないエラーが発生しました。お手数をおかけしますが、上記のログを開発者に報告してください │
  │ 。                                                                                                               │
  └──────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘

  ────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
7.358 W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/jammy/InRelease  Temporary failure resolving 'archive.ubuntu.com'

対処

dockerがnetwork mode : hostの時に使用するDNSを指定するには以下のディレクトリに設定ファイルを設置すればいよいらしい。

sudo vim /etc/docker/daemon.json

以下を作成、または追記

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

これでKonomiTVのインストールが進んだ。