I recently started learning docker, But I am facing issues while hosting a simple asp.net core web api boiler plate app created using Visual Studio Code inside a docker windows container.
I have set Docker Fie in project and run docker build --tag helloapi .
But when I run docker run -p 9000:80 helloapi I get bellow error:
It was not possible to find any compatible framework version The specified framework 'Microsoft.AspNetCore.App', version '2.1.1' was not found. - Check application dependencies and target a framework version installed at: \ - Alternatively, install the framework version '2.1.1'.
I have tried many tutorials this this and this.
I have a tried different docker images for asp.net core this this and this.
dotnet core version:
dotnet --info
.NET Core SDK (reflecting any global.json):
Version: 2.1.402
.NET Core SDKs installed:
2.1.402
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.4
Microsoft.AspNetCore.App 2.1.4
Microsoft.NETCore.App 2.1.4
helloapi.csproj file
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Folder Include="wwwroot\" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
</Project>
Docker File:
FROM microsoft/aspnetcore
ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-/publish} .
ENTRYPOINT ["dotnet", "HelloApi.dll"]
Note: I am not able to Switch to Linux Container because docker is showing some run time error, So I am using Windows Container and also IIS Server is not enabled in Turn windows features.
I am not able to figure out what wrong am I doing ?
Can anyone guide me the correct way to host api using docker in windows container.
Any help would be great.
