我正在尝试使用以下Dockerfile基于node:8.1
图像为我的应用创建容器:
FROM node:8.1.4
RUN mkdir /home/node/.npm-global ; \
mkdir -p /home/node/app ; \
chown -R node:node /home/node/app ; \
chown -R node:node /home/node/.npm-global
ENV PATH=/home/node/.npm-global/bin:$PATH
ENV NPM_CONFIG_PREFIX=/home/node/.npm-global
USER node
WORKDIR /home/node/app
# Just for dev
RUN npm install mocha knex nodemon -g --quiet
# Opting for COPY over ADD as there is no need of auto extracting any compressed file
COPY . /home/node/app
RUN npm install --quiet
CMD node
但是,当它运行npm install --quiet
时,我收到以下消息:
npm WARN deprecated node-uuid@1.4.7: Use uuid module instead
npm WARN checkPermissions Missing write access to /home/node/app/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist
npm WARN checkPermissions Missing write access to /home/node/app/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/mkdirp
npm WARN checkPermissions Missing write access to /home/node/app/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/nopt/node_modules/abbrev
npm WARN checkPermissions Missing write access to /home/node/app/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/nopt
npm WARN checkPermissions Missing write access to /home/node/app/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/npmlog/node_modules/are-we-there-yet/node_modules/delegates
对package.json中的每个包重复该消息。
结束时:
npm ERR! path /home/node/app/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/home/node/app/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist'
npm ERR! { Error: EACCES: permission denied, access '/home/node/app/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/home/node/app/node_modules/sqlite3/node_modules/node-pre-gyp/node_modules/mkdirp/node_modules/minimist' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/node/.npm/_logs/2017-07-12T15_51_42_496Z-debug.log
ERROR: Service 'api' failed to build: The command '/bin/sh -c npm install --quiet' returned a non-zero code: 243
以前使用node:7.1我已经能够使其工作而无需将当前用户更改为node
。
如何让我的应用部署使用此图像的最新版本?
答案 0 :(得分:2)
通过移动USER
指令正下方的FROM
指令并从主机卷中删除现有的node_modules
文件夹来解决问题。