我想打扰您,我正在尝试在 macOS 上的 docker 桌面中创建一个容器,但即使 docker-compose.yml 文件是正确的,当我运行命令时
sudo docker compose up -d
它会生成错误:
=> ERROR [app-api publish 1/1] RUN dotnet publish -c release --no-restore -o /app -r linux-x64 --self-contained false --no-build 40.4s
------
> [app-api publish 1/1] RUN dotnet publish -c release --no-restore -o /app -r linux-x64 --self-contained false --no-build:
1.744 MSBuild version 17.9.8+b34f75857 for .NET
14.09 AppApi -> /app/
17.33 Building image 'appapi' with tags 'latest' on top of base image 'mcr.microsoft.com/dotnet/aspnet:8.0'.
39.72 /usr/share/dotnet/sdk/8.0.204/Containers/build/Microsoft.NET.Build.Containers.targets(210,5): error: Cannot find docker/podman executable. [/src/AppApi/AppApi.csproj]
39.72 /usr/share/dotnet/sdk/8.0.204/Containers/build/Microsoft.NET.Build.Containers.targets(210,5): error CONTAINER1012: The local registry is not available, but pushing to a local registry was requested. [/src/AppApi/AppApi.csproj]
------
failed to solve: process "/bin/sh -c dotnet publish -c release --no-restore -o /app -r linux-x64 --self-contained false --no-build" did not complete successfully: exit code : 1
这是一个 .net core 8 项目,但在我看来,错误是在 docker (v4.24.2 (124339)) 中以某种方式生成的
我在另一篇文章的帮助下设法发现了问题的原因:
导致问题的是我的主解决方案 .csproj 文件中声明的属性,该属性是:
<PublishProfile>Default container</PublishProfile>
消除这个属性就可以解决问题。