内で npm を実行していDockerfileます。
FROM node:9.11-alpine
COPY ./ /usr/src/app/
WORKDIR /usr/src/app/
RUN npm install && npm run build
ENTRYPOINT [ "npm", "run", "watch"]
docker build .その場合、ビルドが正常に完了する可能性はほとんどありません。Dockerfile自分や他のものを変更せずに同じコマンドを定期的に実行すると、数分間にわたってビルドが成功します。ほとんどの場合、私はこれを取得します。
...
npm WARN tar ENOENT: no such file or directory, open '/usr/src/app/node_modules/.staging/bluebird-5b126a50/js/browser/bluebird.js'
npm ERR! code ENOTFOUND
npm ERR! errno ENOTFOUND
npm ERR! network request to https://registry.npmjs.org/json-bigint/-/json-bigint-0.2.3.tgz failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2018-06-26T08_18_44_426Z-debug.log
ビルドが失敗したため、確認できません/root/.npm/_logs/2018-06-26T08_18_44_426Z-debug.log(少なくとも私の知る限りでは)。エラーは接続の問題を示していますが、オンラインの npm リポジトリには何らかのスロットリングがありますか? または、ドッカーはプロキシのように動作していますか?
私が気付いていないこのエラーを回避するために、docker で npm を使用する方法はありますか?
編集
npm installシェルを使用してコンテナー内で手動で実行した詳細ログ
1420 verbose type system
1421 verbose stack FetchError: request to https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
1421 verbose stack at ClientRequest.req.on.err (/usr/local/lib/node_modules/npm/node_modules/pacote/node_modules/make-fetch-happen/node_modules/node-fetch-npm/src/index.js:68:14)
1421 verbose stack at ClientRequest.emit (events.js:180:13)
1421 verbose stack at TLSSocket.socketErrorListener (_http_client.js:395:9)
1421 verbose stack at TLSSocket.emit (events.js:180:13)
1421 verbose stack at emitErrorNT (internal/streams/destroy.js:64:8)
1421 verbose stack at process._tickCallback (internal/process/next_tick.js:178:19)
1422 verbose cwd /usr/src/app
1423 verbose Linux 4.14.48-2-MANJARO
1424 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install"
1425 verbose node v9.11.2
1426 verbose npm v5.6.0
1427 error code ENOTFOUND
1428 error errno ENOTFOUND
1429 error network request to https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz failed, reason: getaddrinfo ENOTFOUND registry.npmjs.org registry.npmjs.org:443
1430 error network This is a problem related to network connectivity.
1430 error network In most cases you are behind a proxy or have bad network settings.
1430 error network
1430 error network If you are behind a proxy, please make sure that the
1430 error network 'proxy' config is set properly. See: 'npm help config'
1431 verbose exit [ 1, true ]