Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET Core docker build error

I'm new to ASP.NET Core and docker. I've created a simple ASP.NET Core 2.0 app and try to use docker with it on Windows. However, I get this error:

Your Docker server host is configured for 'Linux', however the docker-compose project targets 'Windows'.

Although it seems to be pretty informative error, I can't find where to 'configure host for Windows'

like image 891
kagetoki Avatar asked Oct 16 '17 22:10

kagetoki


2 Answers

It is docker-compose.dcproj file where you can set up the OS you want to target:

<DockerTargetOS>Linux</DockerTargetOS> 

To switch docker daemon to the same OS you can use Docker tray icon or Docker Settings window (accessible from the same menu):
enter image description here

like image 136
Pavel Agarkov Avatar answered Sep 18 '22 12:09

Pavel Agarkov


Well basically the answer of Celestin Bochis and Pavel Agarkov are great. However since .net core 2.2 at least, the os of docker is stored in the .csproj file.

<Project Sdk="Microsoft.NET.Sdk.Web">    <PropertyGroup>     <TargetFramework>netcoreapp2.2</TargetFramework>     <DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>     ...    </PropertyGroup>     ... </Project> 

And also don't forget to modify your docker file. The images should be the correct one. For .net core 2.2 That is :

Linux: Microsoft/dotnet:2.2-aspnetcore-runtime AS base microsoft/dotnet:2.2-sdk AS build  Windows: microsoft/dotnet:2.2-aspnetcore-runtime-nanoserver-1803 microsoft/dotnet:2.2-sdk-nanoserver-1803 
like image 30
Maarten Kieft Avatar answered Sep 19 '22 12:09

Maarten Kieft