feedback
feedback copied to clipboard
[cloud-kubernetes-aspnetcore]:wrong dotnet SDK version
When I run docker build command, I met error.
[+] Building 1.5s (11/15) docker:default
=> [internal] load build definition from Dockerfile 0.0s
=> => transferring dockerfile: 836B 0.0s
=> [internal] load metadata for mcr.microsoft.com/dotnet/aspnet:6.0-alpine-amd64 0.3s
=> [internal] load metadata for mcr.microsoft.com/dotnet/sdk:6.0-alpine 0.3s
=> [internal] load .dockerignore 0.0s
=> => transferring context: 2B 0.0s
=> [build 1/7] FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine@sha256:f8a27715995b21ff0e7 0.0s
=> [runtime 1/3] FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine-amd64@sha256:eceeb165 0.0s
=> [internal] load build context 0.0s
=> => transferring context: 10.13kB 0.0s
=> CACHED [runtime 2/3] WORKDIR /app 0.0s
=> CACHED [build 2/7] WORKDIR /app 0.0s
=> CACHED [build 3/7] COPY *.csproj ./ 0.0s
=> ERROR [build 4/7] RUN dotnet restore 1.1s
------
> [build 4/7] RUN dotnet restore:
0.997 Determining projects to restore...
1.010 /usr/share/dotnet/sdk/6.0.427/Sdks/Microsoft.NET.Sdk/targets/Microsoft.NET.TargetFrameworkInference.targets(144,5): error NETSDK1045: The current .NET SDK does not support targeting .NET 8.0. Either target .NET 6.0 or lower, or use a version of the .NET SDK that supports .NET 8.0. [/app/HelloWorldAspNetCore.csproj]
------
1 warning found (use docker --debug to expand):
- LegacyKeyValueFormat: "ENV key=value" should be used instead of legacy "ENV key value" format (line 25)
Dockerfile:9
--------------------
7 | # Copy csproj and restore as distinct layers.
8 | COPY *.csproj ./
9 | >>> RUN dotnet restore
10 |
11 | # Copy local code to the container image.
--------------------
ERROR: failed to solve: process "/bin/sh -c dotnet restore" did not complete successfully: exit code: 1
I fixed Dockerfile and completed build.
FROM mcr.microsoft.com/dotnet/sdk:6.0-alpine AS build
↓
FROM mcr.microsoft.com/dotnet/sdk:8.0-alpine AS build
FROM mcr.microsoft.com/dotnet/aspnet:6.0-alpine-amd64 AS runtime
↓
FROM mcr.microsoft.com/dotnet/aspnet:8.0-alpine-amd64 AS runtime