2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Docker build時のpnpm installで名前解決ができない

Last updated at Posted at 2022-12-16

request to https://registry.npmjs.org/pnpm failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org への対処

詰まったのでメモ

概要

docker build時に以下のようなエラーが出た。筆者はDockerをUbuntuのsystemdで動かしている。

pnpm の場合

 > [builder 4/4] RUN corepack enable pnpm && pnpm install && pnpm build:
#0 5.617 Internal Error: Error when performing the request
#0 5.617     at ClientRequest.<anonymous> (/usr/local/lib/node_modules/corepack/dist/corepack.js:16064:20)
#0 5.617     at ClientRequest.emit (node:events:513:28)
#0 5.617     at TLSSocket.socketErrorListener (node:_http_client:494:9)
#0 5.617     at TLSSocket.emit (node:events:513:28)
#0 5.617     at emitErrorNT (node:internal/streams/destroy:151:8)
#0 5.617     at emitErrorCloseNT (node:internal/streams/destroy:116:3)
#0 5.617     at process.processTicksAndRejections (node:internal/process/task_queues:82:21)

npmの場合

 > [builder 3/5] RUN npm install -g pnpm:
#0 85.86 npm ERR! code EAI_AGAIN
#0 85.86 npm ERR! syscall getaddrinfo
#0 85.86 npm ERR! errno EAI_AGAIN
#0 85.86 npm ERR! request to https://registry.npmjs.org/pnpm failed, reason: getaddrinfo EAI_AGAIN registry.npmjs.org
#0 85.86 
#0 85.86 npm ERR! A complete log of this run can be found in:
#0 85.86 npm ERR!     /root/.npm/_logs/2022-12-16T16_03_50_258Z-debug-0.log

解決策

以下の記事に詳しく書かれていた。

daemon.jsonを作成して

$ sudo vim /etc/docker/daemon.json

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

再起動するだけ

sudo service docker restart

まとめ

筆者はpnpmを利用しており、エラー内容でピッタリ探せる記事を見つけられす解決に時間がかかってしまった。

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?