docker 中的 npm 修改源怎么修改啊?

2017-02-25 21:10:23 +08:00
 noobsheldon

如何能在下面 build 时使用国内镜像啊?我在 Dockerfile 中试过添加如下几行依然无效:


RUN npm set registry https://registry.npm.taobao.org
RUN npm config set registry https://registry.npm.taobao.org
RUN npm config set disturl https://npm.taobao.org/dist

Dockerfile


FROM node:5-onbuild
RUN npm install webpack babel-cli local-web-server --global && webpack --config webpack.production.config.js

build 时,输出为如下内容=====================================


Step 1/1 : COPY package.json /usr/src/app/
 ---> Using cache
Step 1/1 : RUN npm install
 ---> Running in fb7fe947bc51
npm info it worked if it ends with ok
npm info using npm@3.8.6
npm info using node@v5.12.0
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/bootstrap
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/classnames
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/file-loader
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/foundation-sites
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/isomorphic-fetch
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/jquery
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/jwt-decode
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/react
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/react-dom
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/react-hot-loader
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/react-iframe
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/react-redux
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/react-router
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/react-router-redux
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/redux
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/redux-auth-wrapper
npm info attempt registry request try #1 at 11:47:54 AM
npm http request GET https://registry.npmjs.org/redux-form
6177 次点击
所在节点    Docker
4 条回复
chairuosen
2017-02-25 21:17:38 +08:00
npm install --registry=https://registry.npm.taobao.org xxxxx
noobsheldon
2017-02-25 21:23:27 +08:00
@chairuosen 输出还是一样的。。。
credochen
2017-02-26 09:18:42 +08:00
用 cnpm 。
darrenfang
2017-03-15 18:50:16 +08:00
npm install cnpm --registry=https://registry.npm.taobao.org

cnpm install

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/343154

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX