"npm install" 在构建 Docker 图像时因 ECONNREFUSED 失败
"npm install" fails with ECONNREFUSED while building Docker image
我正在尝试构建一个包含 NPM 并安装一些工具的 Docker 映像,但是当我发出安装命令时,如:
RUN npm install -g sfdx-cli
构建挂了一会儿,然后抛出了很多错误。这是同样的错误:
npm ERR! fetch failed http://10.252.156.164:4880/@babel%2fcode-frame/-/code-frame-7.0.0.tgz
npm WARN retry will retry, error on last attempt: Error: connect ECONNREFUSED 10.252.156.164:4880
我通过搜索此错误在网络上找到的所有其他资源都会导致 answer/article 关于在代理后面使用 NPM,但这里不是这种情况。我没有代理。
我该怎么做才能停止这个错误?
运行 RUN echo "${http_proxy}" && echo "${HTTP_PROXY}"
在构建时我的 Docker 文件中我得到以下输出:
Step 8/16 : RUN echo "${http_proxy}" && echo "${HTTP_PROXY}"
---> Running in 09bfc89592ae
Removing intermediate container 09bfc89592ae
我能够成功构建 docker 图像,这是我的 Dockerfile,
FROM alpine:3.8
RUN apk add --no-cache nodejs npm
RUN npm install -g sfdx-cli
如果您不想将 alpine 作为基础映像,请共享您的 Dockerfile。
或者你也可以 运行 RUN npm config set registry https://registry.npmjs.com/
尝试docker build . --network="host"
我正在尝试构建一个包含 NPM 并安装一些工具的 Docker 映像,但是当我发出安装命令时,如:
RUN npm install -g sfdx-cli
构建挂了一会儿,然后抛出了很多错误。这是同样的错误:
npm ERR! fetch failed http://10.252.156.164:4880/@babel%2fcode-frame/-/code-frame-7.0.0.tgz
npm WARN retry will retry, error on last attempt: Error: connect ECONNREFUSED 10.252.156.164:4880
我通过搜索此错误在网络上找到的所有其他资源都会导致 answer/article 关于在代理后面使用 NPM,但这里不是这种情况。我没有代理。
我该怎么做才能停止这个错误?
运行 RUN echo "${http_proxy}" && echo "${HTTP_PROXY}"
在构建时我的 Docker 文件中我得到以下输出:
Step 8/16 : RUN echo "${http_proxy}" && echo "${HTTP_PROXY}"
---> Running in 09bfc89592ae
Removing intermediate container 09bfc89592ae
我能够成功构建 docker 图像,这是我的 Dockerfile,
FROM alpine:3.8
RUN apk add --no-cache nodejs npm
RUN npm install -g sfdx-cli
如果您不想将 alpine 作为基础映像,请共享您的 Dockerfile。
或者你也可以 运行 RUN npm config set registry https://registry.npmjs.com/
尝试docker build . --network="host"