1

Docker in my system tray has a menu item Switch to Linux/Windows containers.

Which should it be?

I don't need Windows because I'm writing .NET Core and using SQL Server Express.

How do I know if a Docker that I want to use (e.g., mcr.microsoft.com/dotnet/core/runtime:3.1-nanoserver-1903 or mcr.microsoft.com/dotnet/core/runtime:3.1 or mcr.microsoft.com/mssql/server) is Linux or Windows?

Richard Barraclough
  • 2,625
  • 3
  • 36
  • 54

1 Answers1

0

Many of the images will be documented for which OS they are targeting on docker hub or in their documentation. For example mcr.microsoft.com/mssql/server targets Linux so you'll need to run a Linux Containers environment (scroll to the Full Tag Listing section).


For a more programmatic solution you are able to inspect images to learn more about them from your shell if you've previously pulled them. For example if I inspect an IIS image like mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019 we can see that it is built for Windows on amd64 cpu's.

You can inspect an image using docker image inspect from the command line.

docker image inspect mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019

The results will be a large json blob describing the images you inspected:

[
  {
    ...I've left out a lot of other details here
    "Architecture": "amd64",
    "OS": "windows",
    "OsVersion": "10.0.17763.973",
    ...
  }
]

For an answer of what type of containers you should be running you'll want to look at the "OS" value - in my example that's "windows" so we'll need Windows Containers support and get an error if we try to deploy the container into a linux environment.

To simplify this command and prevent you having to dig through a json file you can include a --format flag. For example:

docker image inspect mcr.microsoft.com/windows/servercore/iis:windowsservercore-ltsc2019 --format='{{json .Os}}'

In my example I included "OSVersion" as well, this is particularly important when considering compatibility of Windows containers with the host version of Windows. You can learn more about Windows Container Compatibility in the docs. This value is less important for linux based containers and may not be present in all images.

Runewake2
  • 471
  • 1
  • 7
  • 16