I have a .NET Core web app generated by dotnet new web -o foo
, and the following (multi-stage) Dockerfile
:
FROM microsoft/dotnet:2.0-sdk AS builder
WORKDIR /build
COPY ./foo/foo.csproj .
RUN dotnet restore
COPY ./foo/*.cs ./
RUN dotnet publish --configuration Release --output ./app
FROM microsoft/dotnet:2.0-runtime
WORKDIR /app
COPY --from=builder /build/app/* ./
ENTRYPOINT ["dotnet", "./foo.dll"]
Building the image works fine, but running it does not:
PS> docker build . -t foo
# ...
Successfully built <hash>
Successfully tagged foo:latest
PS> docker run --rm foo
Error:
An assembly specified in the application dependencies manifest (foo.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 target 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;aspnetcore-store-2.0.0-win7-x86.xml
It seems that not all required assets are published to the output directory; what more do I have to do to make this work?
There is a github issue and another on the same problem one solution is:
If you want a smaller image and can change the code you can do: