Home:ALL Converter>Arch Linux - dotnet core 2 with docker

Arch Linux - dotnet core 2 with docker

Ask Time:2017-09-10T17:13:07         Author:PWFraley

Json Formatter

Update Ok I figured something out, but I still do not have a solution. This problem seems to only occur on Arch based systems (Antergos, Manjaro, Arch).

If I install a clean system with xfce and docker and dotnet core 2 I can build and run docker images using dotnet core.

After installing VirtualBox, the problem below starts happening, so I suspect it has something to do with some obscure kernel module???

Also uninstaling virtualbox does not fix the problem, only solution is to reinstall Arch fresh, which is a pain. Also it is not possible to run docker and virtualbox on the same system, while trying to develop dotnet core with docker.

End update

I am trying to get dotnet core 2 running with docker, based on microsofts dokumentation (https://github.com/dotnet/dotnet-docker-samples/tree/master/aspnetapp):

My Dockerfile looks like this:

FROM microsoft/aspnetcore-build:2.0.0 AS build-env
WORKDIR /app

# copy csproj and restore as distinct layers
COPY *.csproj ./
RUN dotnet restore

# copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out

# build runtime image
FROM microsoft/aspnetcore:2.0.0
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "api.bauernsuche.de.dll"]

I then start the image build process by:

docker build -t bauernsucheapi .

After the build is finished I am trying to start the new image by:

docker run -it --rm -p 5000:80 --name bauernsuche_api bauernsucheapi

Expected: Container running

IS: Error Message: Did you mean to run dotnet SDK commands? Please install dotnet SDK from: http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409

Now since I am using the Microsoft Docker iage I would expect the SDK to be available on this. Also my Dockerfile is a straight copy from the Microsoft Example with one change: The Versionnumber was changed from 2.0 to 2.0.0 which seems to be the correct one, since 2.0 gives me errors about not finding an image.

So what am I doing wrong?

My .csproj file:

<Project Sdk="Microsoft.NET.Sdk.Web">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <PublishWithAspNetCoreTargetManifest>false</PublishWithAspNetCoreTargetManifest>
  </PropertyGroup>
  <ItemGroup>
    <Folder Include="wwwroot\" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.TestHost" Version="2.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.0" />
    <PackageReference Include="Moq" Version="4.7.99" />
    <PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="2.0.0" />
    <PackageReference Include="Swashbuckle.AspNetCore" Version="1.0.0" />
    <PackageReference Include="xunit" Version="2.3.0-beta4-build3742" />
  </ItemGroup>
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.0" />
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.0" />
    <DotNetCliToolReference Include="dotnet-xunit" Version="2.3.0-beta4-build3742" />
    <DotNetCliToolReference Include="Microsoft.DotNet.Watcher.Tools" Version="2.0.0" />
  </ItemGroup>
</Project>

Author:PWFraley,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/46139064/arch-linux-dotnet-core-2-with-docker
Bruno Garcia :

Edit:\nAs I answered here:\n\n\n One reason why you can see this error message is when the argument\n passed to dotnet is unknown.\n \n The runtime doesn't recognize the argument you are passing to it and\n wonder if you perhaps should be using the sdk instead.\n \n Make sure the name of the dll and the path to it are correct in:\n\nENTRYPOINT [\"dotnet\", \"api.bauernsuche.de.dll\"]\n\n \n Also, make sure the COPY instruction works as expected so the dll is at the WORKDIR location.\n\n\nOriginal answer:\n\nYou are using an image that doesn't have the SDK.\n\nHere's an example shows building the app within an image, then creating a new one with the result:\n\nFROM microsoft/dotnet:2.0-sdk AS build-env\nWORKDIR /app\n\n# copy csproj and restore as distinct layers\nCOPY *.csproj ./\nRUN dotnet restore\n\n# copy everything else and build\nCOPY . ./\nRUN dotnet publish -c Release -o out -r debian.8-x64\n\n# build runtime image\nFROM microsoft/dotnet:2.0-runtime\n\nWORKDIR /app\nCOPY --from=build-env /app/out ./\nEXPOSE 5000/tcp\nENTRYPOINT [\"dotnet\", \"api.dll\"]\n# To be able to pass parameters (e.g.: override configuration)\nCMD []\n\n\nTaken from here.\n\nNote the first one is a sdk image and the second is a runtime. Just as you can choose when downloading from the website.",
2017-09-12T21:55:29
Tarun Lalwani :

So I am not sure what the issue is, but switching between sh and bash helps. This I would attribute mostly as a bug in the base image and your should report it. But below should fix it for you\n\nFROM microsoft/aspnetcore-build:2.0.0 AS build-env\nWORKDIR /app\n\n# copy csproj and restore as distinct layers\nCOPY *.csproj ./\nRUN dotnet restore\n\n# copy everything else and build\nCOPY . ./\nRUN dotnet publish -c Release -o out\n\n# build runtime image\nFROM microsoft/aspnetcore:2.0.0\nWORKDIR /app\nCOPY --from=build-env /app/out .\nENTRYPOINT [\"/bin/bash\", \"-lc\", \"dotnet api.bauernsuche.de.dll\"]\n",
2017-09-12T17:15:15
jrk :

I'm doing something similar running a Dotnet Core 2.x web service written in F# and packaged with Docker. I also build the app using publish with a run-id as you have but the way I'm starting it is different. \n\nRather than use dotnet as the runner, you can directly specify the executable binary that gets produced in the publish output folder. In my case the, the executable is call \"Main\" and I just run it directly. It's basically a bootstrapper that is native to the host platform which starts up the Dotnet app that is included with all the accompanying dlls that got included. You don't need the SDK for this to work, as you can see from my Docker file here:\n\nFROM microsoft/dotnet:2-runtime\nWORKDIR /opt/dotnetservice\nADD Main/publish .\nENV PATH=\"/opt/dotnetservice:${PATH}\"\nEXPOSE 8080\nCMD [\"Main\"]\n\n\nThere is a complete mini-example in the linked question",
2018-01-07T18:47:41
yy