这是我的Dockerfile
:
FROM node:7.10.0
RUN useradd --user-group --create-home --shell /bin/false app
RUN mkdir -p /usr/src/hello
ENV HOME=/usr/src/
COPY package.json $HOME/hello/
RUN chown -R app:app $HOME/*
RUN npm install -g pm2
USER app
WORKDIR $HOME/hello
RUN npm install
EXPOSE 8080
CMD ["npm", "start"]
用于从docker-compose
version: '2'
services:
hello:
build: ./hello
command: "pm2-docker server.js"
ports:
- 8080:8080
volumes:
- ./hello:/usr/src/hello
当我尝试运行docker-compose up
时,我收到以下错误:
npm ERR! Error: EACCES: permission denied, mkdir '/usr/src/.npm/hapi'
npm ERR! { Error: EACCES: permission denied, mkdir '/usr/src/.npm/hapi'
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/src/.npm/hapi',
npm ERR! parent: 'hello' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
为什么以用户npm install
运行app
会出现以下错误?