Docker error with .Net 6 runtime image

December 04, 2021

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:

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"
            ],



Profile picture

A blog about one man's journey through code… and some pictures of the Peak District
Twitter

© Paul Michaels 2024