While trying to set-up a docker image for a .Net 6 console application, I found that, although it built fine, I got the an error when trying to run it. Let’s imagine that I used the following commands to build and run:
docker build -t pcm-exe docker run pcm-exe
The result from the run command was the following:
It was not possible to find any compatible framework version
The framework ‘Microsoft.NETCore.App’, version ‘6.0.0’ (x64) was not found.
– The following frameworks were found:
6.0.0-rc.2.21480.5 at [/usr/share/dotnet/shared/Microsoft.NETCore.App]You can resolve the problem by installing the specified framework and/or SDK.
The specified framework can be found at:
– https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=6.0.0&arch=x64&rid=debian.11-x64
This had me stumped for a while, as I was under the impression that when images are updated, docker knows to go and download them – this is not the case. I discovered this by running an inspect on the runtime image from the dockerfile defined here:
FROM mcr.microsoft.com/dotnet/runtime:6.0 AS base
The inspect command:
docker inspect mcr.microsoft.com/dotnet/runtime:6.0
This gave the following result:
“Env”: [
“PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin”,
“ASPNETCORE_URLS=http://+:80”,
“DOTNET_RUNNING_IN_CONTAINER=true”,
“DOTNET_VERSION=6.0.0-rc.2.21480.5”
],
At this point there seemed to be two options – you can just remove the image – that would force a re-download; however, a quicker way is to pull the new version of the image:
docker pull mcr.microsoft.com/dotnet/runtime:6.0
After rebuilding the image, running a subsequent inspect shows that we’re now on the correct version:
"Env": [ "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", "ASPNETCORE_URLS=http://+:80", "DOTNET_RUNNING_IN_CONTAINER=true", "DOTNET_VERSION=6.0.0" ],