英文:
Getting Container Error while publishing inside docker file
问题
I am building the docker image with .NET7- in Azure Devops with ubuntu-latest agent. all the previous layers untill the publish are successful.but, while publishing the dll, I am getting the below error.
> /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.
Here is the docker file
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
Here is the error from 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
Here is the pipeline details
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)
英文:
I am building the docker image with .NET7- in Azure Devops with ubuntu-latest agent. all the previous layers untill the publish are successful.but, while publishing the dll, I am getting the below error.
> /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.
Here is the docker file
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
Here is the error from 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
Here is the pipeline details
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)
答案1
得分: 1
我能够解决这个问题。这个问题是我们正在尝试测试.NET7中引入的新功能,其中我们可以在没有Docker文件的情况下构建Docker镜像,这已经启用,而且我也有一个Docker文件,我在Azure DevOps中用它来构建,某处存在互操作问题。我已经在解决方案级别的Directory.build.props文件中更改了这些设置。
<PropertyGroup>
<!-- <PublishProfile>DefaultContainer</PublishProfile>
<ContainerImageTags>1.1.0</ContainerImageTags> -->
</PropertyGroup>
取消了这两个注释后,它开始工作。
英文:
I am able to sove the issue. This issue is we are trying to test the new feature introduced in .NET7 where we can build docker image without docker file, that was enabled and also I have docker file which I used to build in Azure devops, somewhere there is interoperable issue. I have changed this settings in Directory.build.props file at solution level.
<PropertyGroup>
<!--<PublishProfile>DefaultContainer</PublishProfile>
<ContainerImageTags>1.1.0</ContainerImageTags>-->
</PropertyGroup>
commented these two and it started working.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论