aspnet / aspnet-docker

[Archived] ASP.NET Core Docker images for 1.x. Go to https://github.com/dotnet/dotnet-docker for 2.1 and up.
https://asp.net
719 stars 171 forks source link

Error when running "docker run" .net core 2.0 preview project in linux #281

Closed milla closed 7 years ago

milla commented 7 years ago

I'm upgrading our project to .net core 2.0 preview now.

Our project now uses .net core 2.0 preview, in Docker container, pushed to Microsoft azure container service with orchestration of kubernetes.

Package being used in project: <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.0-preview2-final" />

dotnet runtime in (VSTS) build agent machine,

$ dotnet --version
2.0.0-preview2-006497

SDKs installed in the machine,

$ ls /usr/share/dotnet/shared/Microsoft.NETCore.App
1.0.5  1.1.2  2.0.0-preview2-25407-01

DockerFile: reference

FROM microsoft/dotnet:2.0.0-runtime-jessie

# set up network
ENV ASPNETCORE_URLS http://+:80
ENV ASPNETCORE_RUNTIMESTORE_DOWNLOAD_URL https://dist.asp.net/runtimestore/2.0.0/linux-x64/aspnetcore.runtimestore.tar.gz
ENV ASPNETCORE_PKG_VERSION 2.0.0

# set up the runtime store
RUN curl -o /tmp/runtimestore.tar.gz $ASPNETCORE_RUNTIMESTORE_DOWNLOAD_URL \
    && export DOTNET_HOME=$(dirname $(readlink $(which dotnet))) \
    && tar -x -C $DOTNET_HOME -f /tmp/runtimestore.tar.gz \
    && rm /tmp/runtimestore.tar.gz

ARG source
WORKDIR /app
EXPOSE 80
COPY ${source:-obj/Docker/publish/References.Web} .

ENTRYPOINT ["dotnet", "References.Web.dll"]

I tried some other docker images, yet, all have the below issue when running the container,

It was not possible to find any compatible framework version 
The specified framework 'Microsoft.NETCore.App', version '2.0.0-preview2-25407-01' was not found. 
  - Check application dependencies and target a framework version installed at: 
      / 
  - Alternatively, install the framework version '2.0.0-preview2-25407-01'. 

Thanks

MichaelSimons commented 7 years ago

Why not upgrade to the released .NET Core 2.0? It was released yesterday. I think the issue you encountered is that your project references a pre-release NuGet package but you are trying to run it with the released version of the runtime which doesn't include this package. I think the best path forward would be to upgrade your project and build agent to use the release .NET Core 2.0.

natemcmaster commented 7 years ago

As @MichaelSimons suggested, either upgrade Microsoft.AspNetCore.All to 2.0.0, or align your project file and docker image by using microsoft/aspnetcore:2.0.0-preview2.