【问题标题】:npm install global in DockerfileDockerfile 中的 npm install global
【发布时间】:2021-06-29 14:03:36
【问题描述】:

尝试通过 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)运行正常,没有权限错误。

知道如何在不删除RUN npm install -g resume-cli --unsafe-perm=true --allow-root 上的-g 的情况下超越它 ? (通过删除-g 运行没有错误)

【问题讨论】:

  • 您是否需要在推荐之前说USER root,然后将用户设置回原来的状态?我想你可以通过RUN whoami 获得该用户。

标签: node.js docker npm dockerfile nvm


【解决方案1】:

我不能说我知道为什么会发生权限错误,但这里有一个可以工作的 Dockerfile。

FROM node:15.13.0-buster-slim
RUN npm install -g resume-cli
ENTRYPOINT ["resume"]

有一个相关问题 (sh: 1: node: Permission denied),但那里投票最多的答案对我不起作用。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-05-02
    • 1970-01-01
    • 2019-12-03
    • 2019-04-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多