简体   繁体   English

从 azure 中的 Dockerfile 向私人 npm 注册表进行身份验证?

[英]Authenticate to private npm registry from Dockerfile in azure?

提示:本站提供中英文对照查看,鼠标放在中文字句上可显示英文原文。 若本文未解决您的问题,推荐您尝试使用帮您解决。

I have the below Dockerfile:我有以下 Dockerfile:

FROM node:alpine

WORKDIR ./usr/local/lib/node_modules/npm/

COPY .npmrc ./

COPY package.json ./
COPY package-lock.json ./
RUN npm ci

COPY . .


EXPOSE 3000

CMD ["npm", "run", "start-prod"]

This file is used in an azure pipeline like so:此文件在 azure 管道中使用,如下所示:

variables:
  - name: NPMRC_LOCATION
    value: $(Agent.TempDirectory)
    
  - stage: BuildPublishDockerImage
    displayName: Build and publish Docker image
    dependsOn: Build
    jobs:
      - job: BuildPublishDockerImage
        steps:
          - checkout: self
          - task: DownloadSecureFile@1
            name: npmrc
            inputs:
              secureFile: .npmrc
          - task: npmAuthenticate@0
            inputs:
              workingFile: $(NPMRC_LOCATION)/.npmrc
          - task: Docker@2
            displayName: Build a Docker image
            inputs:
              command: build
              arguments: --no-cache

I know .npmrc should be in that location (I run RUN ls in the Dockerfile and its there).我知道.npmrc应该在那个位置(我在 Dockerfile 和那里运行RUN ls )。
However when I run it I keep getting this error:但是,当我运行它时,我不断收到此错误:

failed to solve with frontend dockerfile.v0: failed to build LLB: failed to compute cache key: "/.npmrc" not found: not found无法使用前端 dockerfile.v0 解决:构建 LLB 失败:计算缓存键失败:“/.npmrc”未找到:未找到

I just want to authenticate to a private npm registry.我只想对私有 npm 注册表进行身份验证。 I'm mystified by this.我对此感到困惑。 Grateful for any help.感谢您的帮助。

You can in Dockerfile set registry你可以在Dockerfile设置注册表

npm config set registry 
问题未解决?试试使用:帮您解决问题。
暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用私有 Azure Container Registry 创建一个 Azure APP Service? - How to create a Azure APP Service with a private Azure Container Registry? 来自私有容器注册表的 azureiotedge-diagnostics - azureiotedge-diagnostics from private Container Registry Azure Container Registry 无法解析连接在同一个 .NET 中的私有端点 - Azure Container Registry unable to resolve Private Endpoints connected in same VNET 无法从 docker 构建中的工件注册表安装私有依赖项 - Cannot install private dependency from artifact registry inside docker build 从 npm 私人仓库在 gitlabci 中安装 npm package - installing a npm package in gitlabci from npm private repo 无法从 Azure 注册表中的 docker 图像运行 Azure Web 服务 - Unable to run Azure Web Service from a docker image in an Azure Registry 如何将 docker 图像从私有第三方注册表迁移到 Google 神器注册表? - How to migrate docker images from private third party registry to Google artifact registry? 如何让我的 Dockerfile 使用来自 ECR 注册表而不是 Dockerhub 的基础映像? - How do I make my Dockerfile use base images from ECR registry instead of Dockerhub? 验证 Google Compute Engine (GCE) 以从 Google Container Registry (GCR) 中提取图像 - Authenticate Google Compute Engine (GCE) to Pull Image from Google Container Registry (GCR) 如何从 Google Cloud Composer 的 Kube.netesPodOperator 中的私有 Docker 注册表中提取图像? - How to pull image from private Docker registry in KubernetesPodOperator of Google Cloud Composer?
 
粤ICP备18138465号  © 2020-2023 STACKOOM.COM