- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试通过 azure pipelines 构建 Linux docker 镜像。
主要问题是从私有(private)提要恢复。
我读了很多文章如何做到这一点,但仍然遇到同样的错误“错误:响应状态代码并不表示成功:401(未经授权)。”
我的文件看起来怎么样
Dockerfile:
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443
FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
WORKDIR /src
COPY MyAppService/MyAppService.csproj MyAppService/
COPY NuGet.Config .
ARG NUGET_PAT
ARG AZURE_FEED
ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS "{\"endpointCredentials\": [{\"endpoint\":\"${AZURE_FEED}\", \"username\":\"docker\", \"password\":\"${NUGET_PAT}\"}]}"
RUN wget -O - https://aka.ms/install-artifacts-credprovider.sh
# check env are ok
RUN printenv
RUN dotnet restore --configfile NuGet.Config "MyAppService/MyAppService.csproj"
COPY MyAppService/. MyAppService/
RUN dotnet build "MyAppService/MyAppService.csproj" -c Release -o /app/build
FROM build AS publish
RUN dotnet publish "MyAppService/MyAppService.csproj" -c Release -o /app/publish
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "MyAppService.dll"]
NuGet.Config:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="mytestorganization" value="https://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json" />
</packageSources>
</configuration>
尝试构建图像时来自 azure 管道的日志文件:
2021-05-20T11:36:22.7867465Z ##[section]Starting: build
2021-05-20T11:36:22.7875209Z ==============================================================================
2021-05-20T11:36:22.7875497Z Task : Docker
2021-05-20T11:36:22.7875990Z Description : Build or push Docker images, login or logout, start or stop containers, or run a Docker command
2021-05-20T11:36:22.7876270Z Version : 2.185.0
2021-05-20T11:36:22.7876466Z Author : Microsoft Corporation
2021-05-20T11:36:22.7876713Z Help : https://aka.ms/azpipes-docker-tsg
2021-05-20T11:36:22.7876983Z ==============================================================================
2021-05-20T11:36:27.0474614Z [command]/usr/bin/docker build -f /home/vsts/work/1/s/Dockerfile --label com.azure.dev.image.system.teamfoundationcollectionuri=https://dev.azure.com/mytestorganization/ --label com.azure.dev.image.system.teamproject=TestProject --label com.azure.dev.image.build.repository.name=MyAppService --label com.azure.dev.image.build.sourceversion=63bc9999e1005c9aec016231dcc0f15cf9ec83da --label com.azure.dev.image.build.repository.uri=https://<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="630e1a170610170c1104020d0a1902170a0c0d230706154d02191611064d000c0e" rel="noreferrer noopener nofollow">[email protected]</a>/mytestorganization/TestProject/_git/MyAppService --label com.azure.dev.image.build.sourcebranchname=testbranch --label com.azure.dev.image.build.definitionname=TestProject-CI --label com.azure.dev.image.build.buildnumber=144 --label com.azure.dev.image.build.builduri=vstfs:///Build/Build/144 --build-arg AZURE_FEED=http://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json --build-arg NUGET_PAT=wz2ilhvt2urpzqlqlldd2f2hl6do77jkmreydrpmskwco3fc7sva /home/vsts/work/1/s
2021-05-20T11:36:30.9509673Z Sending build context to Docker daemon 203.3kB
2021-05-20T11:36:30.9510485Z
2021-05-20T11:36:31.0442686Z Step 1/32 : FROM mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine AS base
2021-05-20T11:36:31.2889870Z 3.1-alpine: Pulling from dotnet/core/aspnet
2021-05-20T11:36:31.2907305Z 540db60ca938: Already exists
2021-05-20T11:36:31.3239989Z 9c2872b91813: Pulling fs layer
2021-05-20T11:36:31.3240441Z 8628df474c5d: Pulling fs layer
2021-05-20T11:36:31.3240760Z b54f4c6d2c91: Pulling fs layer
2021-05-20T11:36:31.3981063Z 9c2872b91813: Verifying Checksum
2021-05-20T11:36:31.3981449Z 9c2872b91813: Download complete
2021-05-20T11:36:31.4335354Z b54f4c6d2c91: Verifying Checksum
2021-05-20T11:36:31.4339309Z b54f4c6d2c91: Download complete
2021-05-20T11:36:31.6869948Z 8628df474c5d: Verifying Checksum
2021-05-20T11:36:31.6870377Z 8628df474c5d: Download complete
2021-05-20T11:36:32.0023325Z 9c2872b91813: Pull complete
2021-05-20T11:36:33.1851800Z 8628df474c5d: Pull complete
2021-05-20T11:36:33.5201247Z b54f4c6d2c91: Pull complete
2021-05-20T11:36:33.5262719Z Digest: sha256:97c4986a2f9c8d2bc40443eb0baac59f35c43c267fc59ecc626b449701152df9
2021-05-20T11:36:33.5294596Z Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/aspnet:3.1-alpine
2021-05-20T11:36:33.5314476Z ---> f039e2539446
2021-05-20T11:36:33.5314887Z Step 2/32 : WORKDIR /app
2021-05-20T11:36:33.5511196Z ---> Running in 935279916ded
2021-05-20T11:36:34.0084321Z Removing intermediate container 935279916ded
2021-05-20T11:36:34.0085263Z ---> acbf5abca7a7
2021-05-20T11:36:34.0085629Z Step 3/32 : EXPOSE 80
2021-05-20T11:36:34.0265101Z ---> Running in f7fa1a4dd856
2021-05-20T11:36:35.0147354Z Removing intermediate container f7fa1a4dd856
2021-05-20T11:36:35.0148907Z ---> ac616daad00f
2021-05-20T11:36:35.0152411Z Step 4/32 : EXPOSE 443
2021-05-20T11:36:35.0322549Z ---> Running in b3850b437c79
2021-05-20T11:36:36.0098236Z Removing intermediate container b3850b437c79
2021-05-20T11:36:36.0099219Z ---> cb4e679d3e31
2021-05-20T11:36:36.0099779Z Step 5/32 : FROM mcr.microsoft.com/dotnet/core/sdk:3.1-alpine AS build
2021-05-20T11:36:36.5177448Z 3.1-alpine: Pulling from dotnet/core/sdk
2021-05-20T11:36:36.5178298Z 540db60ca938: Already exists
2021-05-20T11:36:36.5178735Z 9c2872b91813: Already exists
2021-05-20T11:36:36.5179120Z 8628df474c5d: Already exists
2021-05-20T11:36:36.5179575Z b54f4c6d2c91: Already exists
2021-05-20T11:36:36.5180041Z c1b534528ba7: Pulling fs layer
2021-05-20T11:36:36.5180819Z db0b8f999807: Pulling fs layer
2021-05-20T11:36:36.5181265Z 668300e8efd0: Pulling fs layer
2021-05-20T11:36:36.5181785Z 668300e8efd0: Verifying Checksum
2021-05-20T11:36:36.5182381Z 668300e8efd0: Download complete
2021-05-20T11:36:36.5182681Z c1b534528ba7: Verifying Checksum
2021-05-20T11:36:36.5182991Z c1b534528ba7: Download complete
2021-05-20T11:36:36.9095207Z db0b8f999807: Verifying Checksum
2021-05-20T11:36:36.9095902Z db0b8f999807: Download complete
2021-05-20T11:36:37.5777094Z c1b534528ba7: Pull complete
2021-05-20T11:36:41.4075714Z db0b8f999807: Pull complete
2021-05-20T11:36:42.0343103Z 668300e8efd0: Pull complete
2021-05-20T11:36:42.0398152Z Digest: sha256:468b7f80a5ddad15081eddf072ea67d2d003e82c7937392bf927692b134633f5
2021-05-20T11:36:42.0430106Z Status: Downloaded newer image for mcr.microsoft.com/dotnet/core/sdk:3.1-alpine
2021-05-20T11:36:42.0445206Z ---> a08ae6c8a2aa
2021-05-20T11:36:42.0445502Z Step 6/32 : WORKDIR /src
2021-05-20T11:36:42.0748860Z ---> Running in 6dae098fc8ed
2021-05-20T11:36:43.0138598Z Removing intermediate container 6dae098fc8ed
2021-05-20T11:36:43.0139677Z ---> e151bdc4004f
2021-05-20T11:36:43.0140964Z Step 7/32 : COPY MyAppService/MyAppService.csproj MyAppService/
2021-05-20T11:36:44.0159585Z ---> 30c607bb8a6e
2021-05-20T11:36:44.0159936Z Step 8/32 : COPY NuGet.Config .
2021-05-20T11:36:45.0146826Z ---> 21b4b5d1f04c
2021-05-20T11:36:45.0147184Z Step 9/32 : ARG NUGET_PAT
2021-05-20T11:36:45.0460635Z ---> Running in 88d83e60cf3a
2021-05-20T11:36:46.0172444Z Removing intermediate container 88d83e60cf3a
2021-05-20T11:36:46.0173490Z ---> 58d9dde29d1d
2021-05-20T11:36:46.0173821Z Step 10/32 : ARG AZURE_FEED
2021-05-20T11:36:46.0360209Z ---> Running in f10912b5009e
2021-05-20T11:36:47.0134976Z Removing intermediate container f10912b5009e
2021-05-20T11:36:47.0135971Z ---> e792f313ec6c
2021-05-20T11:36:47.0136338Z Step 11/32 : ENV NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED true
2021-05-20T11:36:47.0340003Z ---> Running in dc9e064c144a
2021-05-20T11:36:48.0165125Z Removing intermediate container dc9e064c144a
2021-05-20T11:36:48.0166236Z ---> 2cb8ce18a003
2021-05-20T11:36:48.0166823Z Step 12/32 : ENV VSS_NUGET_EXTERNAL_FEED_ENDPOINTS "{\"endpointCredentials\": [{\"endpoint\":\"${AZURE_FEED}\", \"username\":\"docker\", \"password\":\"${NUGET_PAT}\"}]}"
2021-05-20T11:36:48.0346391Z ---> Running in 06e748e76592
2021-05-20T11:36:49.0167180Z Removing intermediate container 06e748e76592
2021-05-20T11:36:49.0168216Z ---> 21dff5c2a393
2021-05-20T11:36:49.0168806Z Step 13/32 : RUN wget -O - https://aka.ms/install-artifacts-credprovider.sh
2021-05-20T11:36:49.0331863Z ---> Running in 653d535fd87e
2021-05-20T11:36:50.5360687Z [91mConnecting to aka.ms (104.67.209.176:443)
2021-05-20T11:36:50.9255227Z [0m[91mConnecting to raw.githubusercontent.com (185.199.109.133:443)
2021-05-20T11:36:51.0266615Z [0m[91mwriting to stdout
2021-05-20T11:36:51.0269224Z [0m#!/usr/bin/env bash
2021-05-20T11:36:51.0269620Z # DESCRIPTION: A simple shell script designed to fetch the latest version
2021-05-20T11:36:51.0270020Z # of the artifacts credential provider plugin for dotnet and
2021-05-20T11:36:51.0270333Z # install it into $HOME/.nuget/plugins.
2021-05-20T11:36:51.0270979Z # SEE: https://github.com/Microsoft/artifacts-credprovider/blob/master/README.md
2021-05-20T11:36:51.0271177Z
2021-05-20T11:36:51.0271529Z REPO="Microsoft/artifacts-credprovider"
2021-05-20T11:36:51.0271833Z FILE="Microsoft.NuGet.CredentialProvider.tar.gz"
2021-05-20T11:36:51.0272080Z VERSION="latest"
2021-05-20T11:36:51.0272612Z # URL pattern documented at https://help.github.com/en/articles/linking-to-releases as of 2019-03-29
2021-05-20T11:36:51.0273028Z URI="https://github.com/$REPO/releases/$VERSION/download/$FILE"
2021-05-20T11:36:51.0273327Z NUGET_PLUGIN_DIR="$HOME/.nuget/plugins"
2021-05-20T11:36:51.0273475Z
2021-05-20T11:36:51.0273677Z # Ensure plugin directory exists
2021-05-20T11:36:51.0274069Z if [ ! -d "${NUGET_PLUGIN_DIR}" ]; then
2021-05-20T11:36:51.0274767Z echo "INFO: Creating the nuget plugin directory (i.e. ${NUGET_PLUGIN_DIR}). "
2021-05-20T11:36:51.0275283Z if ! mkdir -p "${NUGET_PLUGIN_DIR}"; then
2021-05-20T11:36:51.0275655Z echo "ERROR: Unable to create nuget plugins directory (i.e. ${NUGET_PLUGIN_DIR})."
2021-05-20T11:36:51.0275955Z exit 1
2021-05-20T11:36:51.0276136Z fi
2021-05-20T11:36:51.0276320Z fi
2021-05-20T11:36:51.0276403Z
2021-05-20T11:36:51.0276599Z echo "Downloading from $URI"
2021-05-20T11:36:51.0276893Z # Extract netcore from the .tar.gz into the plugin directory
2021-05-20T11:36:51.0277180Z
2021-05-20T11:36:51.0277502Z #Fetch the file
2021-05-20T11:36:51.0278259Z curl -H "Accept: application/octet-stream" \
2021-05-20T11:36:51.0278673Z -s \
2021-05-20T11:36:51.0279032Z -S \
2021-05-20T11:36:51.0279377Z -L \
2021-05-20T11:36:51.0279833Z "$URI" | tar xz -C "$HOME/.nuget/" "plugins/netcore"
2021-05-20T11:36:51.0280016Z
2021-05-20T11:36:51.0280338Z echo "INFO: credential provider netcore plugin extracted to $HOME/.nuget/"
2021-05-20T11:36:51.0291723Z [91m- 100% |********************************| 1213[0m[91m 0:00:00 ETA
2021-05-20T11:36:51.0292150Z written to stdout
2021-05-20T11:36:52.0145556Z [0mRemoving intermediate container 653d535fd87e
2021-05-20T11:36:52.0146179Z ---> 90962e0fe2f3
2021-05-20T11:36:52.0146481Z Step 14/32 : RUN printenv
2021-05-20T11:36:52.0341626Z ---> Running in de688137dee7
2021-05-20T11:36:52.3685737Z DOTNET_SYSTEM_GLOBALIZATION_INVARIANT=false
2021-05-20T11:36:52.3686185Z NUGET_CREDENTIALPROVIDER_SESSIONTOKENCACHE_ENABLED=true
2021-05-20T11:36:52.3686469Z HOSTNAME=de688137dee7
2021-05-20T11:36:52.3686745Z DOTNET_USE_POLLING_FILE_WATCHER=true
2021-05-20T11:36:52.3686993Z SHLVL=1
2021-05-20T11:36:52.3687187Z HOME=/root
2021-05-20T11:36:52.3687432Z DOTNET_RUNNING_IN_CONTAINER=true
2021-05-20T11:36:52.3687794Z AZURE_FEED=http://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json
2021-05-20T11:36:52.3688201Z NUGET_PAT=wz2ilhvt2urpzqlqlldd2f2hl6do77jkmreydrpmskwco3fc7sva
2021-05-20T11:36:52.3689296Z POWERSHELL_DISTRIBUTION_CHANNEL=PSDocker-DotnetCoreSDK-Alpine-3.13
2021-05-20T11:36:52.3689701Z PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
2021-05-20T11:36:52.3690173Z LANG=en_US.UTF-8
2021-05-20T11:36:52.3690539Z LC_ALL=en_US.UTF-8
2021-05-20T11:36:52.3690774Z ASPNETCORE_URLS=
2021-05-20T11:36:52.3691003Z PWD=/src
2021-05-20T11:36:52.3691618Z VSS_NUGET_EXTERNAL_FEED_ENDPOINTS={"endpointCredentials": [{"endpoint":"http://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json", "username":"docker", "password":"wz2ilhvt4ghjrpzqlqllxsda2hl6do77jkmreyvotsaskwco3fc7sva"}]}
2021-05-20T11:36:52.3692283Z NUGET_XMLDOC_MODE=skip
2021-05-20T11:36:53.0269908Z Removing intermediate container de688137dee7
2021-05-20T11:36:53.0277361Z ---> 47c3745c86a9
2021-05-20T11:36:53.0278468Z Step 15/32 : RUN dotnet restore --configfile NuGet.Config "MyAppService/MyAppService.csproj"
2021-05-20T11:36:53.0300480Z ---> Running in 7cb2aad61823
2021-05-20T11:36:54.4782539Z Determining projects to restore...
2021-05-20T11:36:55.5458935Z /usr/share/dotnet/sdk/3.1.409/NuGet.targets(128,5): error : Unable to load the service index for source https://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json. [/src/MyAppService/MyAppService.csproj]
2021-05-20T11:36:55.5459838Z /usr/share/dotnet/sdk/3.1.409/NuGet.targets(128,5): error : Response status code does not indicate success: 401 (Unauthorized). [/src/MyAppService/MyAppService.csproj]
2021-05-20T11:36:55.7208436Z The command '/bin/sh -c dotnet restore --configfile NuGet.Config "MyAppService/MyAppService.csproj"' returned a non-zero code: 1
2021-05-20T11:36:55.7348351Z ##[error]The command '/bin/sh -c dotnet restore --configfile NuGet.Config "MyAppService/MyAppService.csproj"' returned a non-zero code: 1
2021-05-20T11:36:55.7359274Z ##[error]The process '/usr/bin/docker' failed with exit code 1
2021-05-20T11:36:55.7376406Z ##[section]Finishing: build
我尝试了很多想法,比如提供完整的访问 token 。那么我做错了什么?
最佳答案
尝试将验证信息添加到您的包源中。使用packageSourceCredentials在自定义 nuget.config
文件下:
将您的 nuget.config
修改为:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<packageSources>
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" protocolVersion="3" />
<add key="mytestorganization" value="https://pkgs.dev.azure.com/mytestorganization/_packaging/mytestorganization/nuget/v3/index.json" />
</packageSources>
<packageSourceCredentials>
<mytestorganization>
<add key="Username" value="xxxx" />
<add key="Password" value="xxxx" />
</mytestorganization>
</packageSourceCredentials>
</configuration>
关于image - 使用azure pipelines构建docker镜像仍然是401(未经授权),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67619820/
我正在使用以下dockerfile: FROM ubuntu:14.04 MAINTAINER xxx xxx # SSH RUN apt-get update && apt-get install
我运行了docker-compose build celery,(经过数小时的尝试,我的连接不良)成功了。 app Dockerfile的前80%是相同的,但不会重复使用缓存。从我可以浏览的内容来看,
我可以使用以下命令成功创建 Docker 注册表 v2 服务:docker service create 然后我使用 docker Push 将一些图像推送到该服务。 当我通过 curl localh
我正在尝试使用 gitlab 构建 CI,我从 docker 的 docker 镜像开始,我的前端存储库没有任何问题,但现在使用相同的 gitlab-ci 配置文件,我有此守护程序错误。 这是构建的输
用例: 我们在 Jenkins 中有几个“发布作业”build 和 push 应用程序的 Docker 镜像到 docker registry,更新各种文件中的项目版本,最后将发布标签推送到相应的 G
当我尝试构建我的 docker 文件时,docker 返回以下错误: [+] Building 0.0s (1/2)
docker-in-docker 的作者在此博客中建议不要将此图像用于 CI 目的: jpetazzo/Using Docker-in-Docker for your CI or testing en
我创建了一个 Dockerfile 来在 Docker 中运行 Docker: FROM ubuntu:16.04 RUN apt-get update && \ apt-get in
我尝试为 Docker 镜像定位一个特定标签。我怎样才能在命令行上做到这一点?我想避免下载所有图像,然后删除不需要的图像。 在 Ubuntu 官方版本中,https://registry.hub.do
我正在尝试在docker中运行docker。唯一的目的是实验性的,我绝不尝试实现任何功能,我只想检查docker从另一个docker运行时的性能。 我通过Mac上的boot2docker启动docke
docker-compose.yml version: "3" services: daggr: image: "docker.pvt.com/test/daggr:stable"
我有一个非常具体的开发环境用例。在一些代码中,我启动了一个容器来抓取页面并检索在容器中运行的服务(Gitlab)的 token 。 现在,我希望 Dockerize 运行它的代码。具体来说,类似: o
之前已经问过这个问题,但我不确定当时是否可以使用docker-compose文件完成docker堆栈部署。 由于最新版本支持使用compose将服务部署到堆栈,因此,我无法理解dab文件的值。 我检查
我在一次采访中被问到这个问题,但无法回答。也没有找到任何相关信息。 最佳答案 正如 Docker 文档中所述,Docker 注册表是: [...] a hosted service containin
有没有一种方法可以将具有给定扩展名的所有文件复制到Docker中的主机?就像是 docker cp container_name:path/to/file/in/docker/*.png path/o
我的日志驱动程序设置为journald。使用日志记录驱动程序时,daemon.json文件中的日志级别配置会影响日志吗?使用docker logs 时仅会影响容器日志? 例如,docker和journ
我最近开始使用Docker + Celery。我还共享了full sample codes for this example on github,以下是其中的一些代码段,以帮助解释我的观点。 就上下文
运行docker build .命令后,尝试提交构建的镜像,但收到以下错误 Step 12 : CMD activator run ---> Using cache ---> efc82ff1ca
我们有docker-compose.yml,其中包含Kafka,zookeeper和schema registry的配置 当我们启动docker compose时,出现以下错误 docker-comp
我是Docker的新手。是否可以在Docker Hub外部建立Docker基本镜像存储库?假设将它们存储在您的云中,而不是拥有DH帐户?谢谢。 最佳答案 您可以根据需要托管自己的注册表。可以在Depl
我是一名优秀的程序员,十分优秀!