Skip to content

Unable to run ASP.NET Web API on jammy-chiseled docker image #5025

@Arclight3

Description

@Arclight3

Describe the Bug

I have a .net 7 Web API with this config:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>net7.0</TargetFramework>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
    <UserSecretsId>MySecretGuid</UserSecretsId>
    <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
    <GenerateDocumentationFile>true</GenerateDocumentationFile>
    <NoWarn>$(NoWarn);1591</NoWarn>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.13" />
    <PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.19.5" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
  </ItemGroup>
</Project>

I am using the latest version of Visual Studio (17.8.1) and Docker (4.25.2).
I have the .net 7 (7.0.311) and .net 8 (8.0.100) SDKs installed (latest patches).

I have this Dockerfile:

# Build stage/image
FROM mcr.microsoft.com/dotnet/sdk:7.0-jammy AS build

WORKDIR /source
COPY ["nuget.config", "."]
COPY ["MyApp/MyApp.Api.csproj", "MyApp.Api/"]

ENV NUGET_XMLDOC_MODE none
RUN dotnet restore "MyApp.Api/MyApp.Api.csproj" --configfile nuget.config

COPY [".", "."]
WORKDIR "/source/MyApp.Api"
ARG buildnumber
RUN dotnet publish "MyApp.Api.csproj" --no-restore -c Release -p:Version=$buildnumber -o /app

# Final stage/image
FROM mcr.microsoft.com/dotnet/aspnet:7.0-jammy-chiseled as final
WORKDIR /app
COPY --from=build /app .

EXPOSE 8080
ENV ASPNETCORE_URLS=http://*:8080

ENTRYPOINT ["./MyApp.Api"]

My launchSettings.json is:

{
  "profiles": {
    "Docker": {
      "commandName": "Docker",
      "launchBrowser": true,
      "launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
      "environmentVariables": {
        "ASPNETCORE_ENVIRONMENT": "dev",
        "ASPNETCORE_URLS": "http://+:8080"
      },
      "publishAllPorts": true
    }
  },
  "$schema": "https://json.schemastore.org/launchsettings.json",
  "iisSettings": {
    "windowsAuthentication": false,
    "anonymousAuthentication": true,
    "iisExpress": {
      "applicationUrl": "http://localhost:51940",
      "sslPort": 0
    }
  }
}

Initially I was using the mcr.microsoft.com/dotnet/aspnet:7.0 base image and everything worked fine.
After I update the Dockerfile to use the mcr.microsoft.com/dotnet/aspnet:7.0-jammy-chiseled image (or the 8.0-jammy-chiseled), I get this error in Visual Studio when I run the application in Docker:

vs_log_0.txt

I have read and followed the instructions from this page: https://github.com/dotnet/dotnet-docker/blob/main/documentation/ubuntu-chiseled.md and I think my Dockerfile looks ok. I think it's a support problem with Visual Studio or the Microsoft.VisualStudio.Azure.Containers.Tools.Targets NuGet package regarding the new jammy-chiseled Docker images.

Please let me know if I can provide more information.

Steps to Reproduce

Other Information

Output of docker version

docker_version_output.txt

Output of docker info

docker_info_output.txt

Metadata

Metadata

Assignees

Labels

area-externalIssues in external projects or services that affect .NET container images

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions