Is there any guidance on how to get an ASP.net Core 2.0 site working in Docker? I seem to be able to get it to work if my Docker image is using "latest", but not if it is using "runtime".
If I use "latest" it gives me an error about not being able to find libraries.
Here is my journey so far:
- Went to Docker Hub: https://hub.docker.com/r/microsoft/dotnet/
- See there are 2.0.0 images: 2.0.0-runtime, 2.0-runtime, 2-runtime, runtime
Created an asp.net core web site:
mkdir myapp cd myapp dotnet new web dotnet restore dotnet run
That worked and brought up the template web site. I used the gitignore from https://github.com/dotnet/core/blob/master/.gitignore. I'm not sure if that an okay gitignore to use for a dotnet core project.
Made a dockerfile:
FROM microsoft/dotnet:2.0.0-runtime LABEL name "myapp" WORKDIR /app COPY bin/Release/netcoreapp2.0/publish . ENV ASPNETCORE_URLS http://*:5000 EXPOSE 5000 ENTRYPOINT ["dotnet","myapp.dll"]
Made a dockerignore file:
bin/Debug/* obj/*
Published the app:
dotnet publish -c Release
Built the container(?)
docker build -t myapp .
Run the app in Docker:
docker run -p 5000:5000 -it --rm myapp
I get this error:
Error: An assembly specified in the application dependencies manifest (myapp.deps.json) was not found: package: 'Microsoft.ApplicationInsights.AspNetCore', version: '2.1.1' path: 'lib/netstandard1.6/Microsoft.ApplicationInsights.AspNetCore.dll' This assembly was expected to be in the local runtime store as the application was published using the following targe t manifest files: aspnetcore-store-2.0.0-linux-x64.xml;aspnetcore-store-2.0.0-osx-x64.xml;aspnetcore-store-2.0.0-win7-x64.xml;aspnetco re-store-2.0.0-win7-x86.xml
If I change my Dockerfile so that the first line is:
FROM microsoft/dotnet:latest
The app runs in Docker and I can see it via localhost:5000
From what I understand "runtime" is the runtime for dotnet core and "latest" includes the SDK. When I look at the Docker image I see that the "latest" image size is 1.63GB while "runtime" is around 219-222MB.
Is there an additional step or configuration I'm missing in order to run using the "runtime" image?
I'm new using Docker and ASP.net Core so any advice is welcome.