如何解决npm install global 在 Dockerfile 中
尝试通过 docker 安装 resume-cli,但在安装 resume-cli 时遇到一些权限错误。
Dockerfile:
FROM python:3.7-slim-buster
RUN apt-get update
RUN apt-get install -y curl
SHELL ["/bin/bash","--login","-c"]
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh | bash
RUN nvm install 15.13.0
RUN npm install -g resume-cli --unsafe-perm=true --allow-root
RUN npm install -g jsonresume-theme-paper
然后我运行:docker build -t containernpm .
我在 RUN npm install -g resume-cli --unsafe-perm=true --allow-root
上遇到错误的地方:
npm ERR! code 127
npm ERR! path /root/.nvm/versions/node/v15.13.0/lib/node_modules/resume-cli/node_modules/puppeteer
npm ERR! command failed
npm ERR! command sh -c node install.js
npm ERR! sh: 1: node: Permission denied
顺便说一句,下一行RUN npm install -g jsonresume-theme-paper
(带有-g
)正常运行,没有权限错误。
知道如何在不删除 -g
上的 RUN npm install -g resume-cli --unsafe-perm=true --allow-root
的情况下超越它
? (通过删除 -g
运行而没有错误)
解决方法
我不知道为什么会发生权限错误,但这里有一个有效的 Dockerfile。
FROM node:15.13.0-buster-slim
RUN npm install -g resume-cli
ENTRYPOINT ["resume"]
有一个相关的问题 (sh: 1: node: Permission denied),但那里得票最高的答案对我不起作用。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。