azure - 在 docker 文件内发布时出现容器错误

标签 azure docker azure-devops azure-pipelines

我正在使用 ubuntu-latest 代理在 Azure Devops 中使用 .NET7- 构建 docker 镜像。之前的所有层直到发布都成功。但是,在发布 dll 时,我收到以下错误。

/root/.nuget/packages/microsoft.net.build.containers/0.4.0/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1012: The local daem on is not available, but pushing to a local daemon was requested. Please start the daemon and try again.

这是 docker 文件

FROM mcr.microsoft.com/dotnet/aspnet:7.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 443

FROM mcr.microsoft.com/dotnet/sdk:7.0 AS build
WORKDIR /source
COPY ["src/TestAPI/TestAPI.csproj", "src/TestAPI/"]
RUN dotnet restore "src/TestAPI/TestAPI.csproj"
COPY . .
WORKDIR "/source/src/TestAPI"
RUN dotnet build "TestAPI.csproj" -c Release

FROM build AS publish
WORKDIR /source/src/TestAPI
RUN dotnet publish "TestAPI.csproj" -c Release -o /app/publish

这是来自 Azure Devops 的错误

MSBuild version 17.6.1+8ffc3fe3d for .NET Determining projects to restore... All projects are up-to-date for restore. TestAPI -> /source/src/TestAPI/bin/Release/net7.0/TestAPI.dll TestAPI -> /app/publish/ Building image 'testwebapi' with tags 1.1.0 on top of base image mcr.microsoft.com:443/dotnet/aspnet:7.0 /root/.nuget/packages/microsoft.net.build.containers/0.4.0/build/Microsoft.NET.Build.Containers.targets(195,5): error CONTAINER1012: The local daemon is not available, but pushing to a local daemon was requested. Please start the daemon and try again. [/source/src/TestAPI/TestAPI.csproj] The command '/bin/sh -c dotnet publish "TestAPI.csproj" -c Release -o /app/publish' returned a non-zero code: 1 ##[error]The command '/bin/sh -c dotnet publish "TestAPI.csproj" -c Release -o /app/publish' returned a non-zero code: 1

这是管道详细信息

variables:
- group: TestAPI_Group
- name:  imageRepository
  value: "TestAPIsvc"
- name: dockerfilePath
  value: "Dockerfile"
- name: vmImageName
  value: "ubuntu-latest"
- name: BuildConfiguration
  value: "Release"
- name: tag
  value: "1.0.0"


trigger:
- master

stages:
  - stage: Build
    displayName: Build stage
    jobs: 
      - job: Build
        displayName: Build
        pool:
          vmImage: $(vmImageName)

        steps:
        - checkout: self
          persistCredentials: true

        - task: Docker@2
          displayName: 'Build TestAPISvc Image'
          inputs:
            repository: '$(imageRepository)'
            buildContext: '**'
            command: build
            Dockerfile: $(dockerfilePath)
            tags: $(tag)

最佳答案

我可以解决这个问题。这个问题是我们正在尝试测试 .NET7 中引入的新功能,我们可以在没有 docker 文件的情况下构建 docker 镜像,该功能已启用,而且我还有用于在 Azure devops 中构建的 docker 文件,但在某个地方存在互操作问题。我已在解决方案级别的 Directory.build.props 文件中更改了此设置。

 <PropertyGroup>
      <!--<PublishProfile>DefaultContainer</PublishProfile>
      <ContainerImageTags>1.1.0</ContainerImageTags>-->
    </PropertyGroup>

评论了这两个,它开始工作。

关于azure - 在 docker 文件内发布时出现容器错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76322336/

相关文章:

git - 您如何使用 LibGit2Sharp 向 VSTS 进行身份验证?

c# - 更新到 Azure Application Insights 1.1,现在不发送数据

linux - 获取 Docker 容器名称

c# - 无法从 C# 代码连接到我的 Tfs 服务器

Azure 管道不会从具有单个 azure-pipelines.yml 文件的分支触发

通过命令行设置 docker-compose env 文件

azure - 将外部API管理实例切换到内部

azure - Get-AzureRMVmImage cmdlet 未列出所有可用的虚拟机镜像

python - 将缓冲的 csv 从 pandas 直接上传到 azure blob 存储

Docker:Dockerfile 中的默认 WORKDIR 是什么?