构建 Docker 映像时 Azure 管道“权限被拒绝”

时间:2021-04-23 10:26:55

标签: azure docker dockerfile azure-pipelines

我正在尝试在 Azure Pipeline 中构建 Docker 映像。在本地一切都像黄油一样运行,在 Azure 上我得到

/bin/sh: 1: cannot create .npmrc: Permission denied

使用以下 Dockerfile:

# Build stage
FROM node:14-slim AS Build

# Pass build arguments. Sensitive information allowed
# This information is not available anymore in next build stage
ARG NPM_TOKEN

# Create app directory
USER node
WORKDIR /home/node/app

# Install app dependencies first
COPY --chown=node:node package*.json ./

# If you are building your code for production
RUN npm ci --only=production
RUN echo "//registry.npmjs.org/:_authToken=$NPM_TOKEN" > .npmrc && \
    npm ci --only=production && \
    rm -f .npmrc

[...]

我有点困惑:

  1. 在本地构建上一切正常
  2. 我正在切换到另一个用户并假设在该用户应该拥有足够权限的目录中工作..

1 个答案:

答案 0 :(得分:0)

好的,找到了。 home/node/app 不属于节点用户...

https://github.com/nodejs/docker-node/issues/740

相关问题