如何修复拒绝 /app 的 Dockerfile 权限?
How to fix Dockerfile permission denied to /app?
我有一个节点 js 项目,这是相关的 Dockerfile:
FROM node:14.16.0-alpine3.13
RUN addgroup app && adduser -S -G app app
RUN mkdir /app && chown app:app /app
USER app
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 80
CMD ["npm", "start"]
如您所见,我授予了应用程序的相关访问权限,但是当我在 ubuntu 18 服务器上 运行 docker-compose up
时,我收到此错误:
Step 6/9 : RUN npm install
---> Running in d95487caef6b
npm WARN checkPermissions Missing write access to /app
npm WARN unihi-backend@1.0.0 No description
npm WARN unihi-backend@1.0.0 No repository field.
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /app
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/app'
npm ERR! [Error: EACCES: permission denied, access '/app'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/app'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/app/.npm/_logs/2021-11-10T10_53_06_750Z-debug.log
The command '/bin/sh -c npm install' returned a non-zero code: 243
ERROR: Service 'api' failed to build : Build failed
注意:api是我的应用服务名称。
此外,这个具有相同 dockerfile 的项目正在我的本地系统上运行 (windows)。
根据我的反复试验,我意识到不是这个命令:
$ docker-compose build
$ docker-compose up -d
我应该使用 docker-compose up -d --build
然后就可以正常工作了。
我有一个节点 js 项目,这是相关的 Dockerfile:
FROM node:14.16.0-alpine3.13
RUN addgroup app && adduser -S -G app app
RUN mkdir /app && chown app:app /app
USER app
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 80
CMD ["npm", "start"]
如您所见,我授予了应用程序的相关访问权限,但是当我在 ubuntu 18 服务器上 运行 docker-compose up
时,我收到此错误:
Step 6/9 : RUN npm install
---> Running in d95487caef6b
npm WARN checkPermissions Missing write access to /app
npm WARN unihi-backend@1.0.0 No description
npm WARN unihi-backend@1.0.0 No repository field.
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /app
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/app'
npm ERR! [Error: EACCES: permission denied, access '/app'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/app'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/app/.npm/_logs/2021-11-10T10_53_06_750Z-debug.log
The command '/bin/sh -c npm install' returned a non-zero code: 243
ERROR: Service 'api' failed to build : Build failed
注意:api是我的应用服务名称。
此外,这个具有相同 dockerfile 的项目正在我的本地系统上运行 (windows)。
根据我的反复试验,我意识到不是这个命令:
$ docker-compose build
$ docker-compose up -d
我应该使用 docker-compose up -d --build
然后就可以正常工作了。