Docker - image operating system "windows" cannot be used on this platform

72,409

Solution 1

Your Docker host is configured to run Linux containers inside of a VM. To run Windows containers, you need to "Switch to Windows containers" in the Docker menu. Documentation on that is available here.


Enter image description here

Enter image description here

Solution 2

You need to go to the Taskbar → right click the Docker icon → use option Switch to Windows containers...

Source https://docs.docker.com/docker-for-windows/

Enter image description here

Solution 3

Switch to Windows Container needs to selected from docker icon running under hidden icon from the bottom right... The moment you switch from Linux to Windows or Windows to Linux, Docker daemon automatically restarts to consider switched container...


I would highly recommend you to view these 2 links to get more insight into how to create window containers:


I really found the content of these links very helpful to make a window container which is still being enhanced for the generic issue we are all are facing since support for window container is yet to mature like Linux containers!

Solution 4

microsoft/nanoserver is a windows native container image. So you cannot run this as linux containers run natively. It can only be run on windows 10 or windows server.

If you are in windows 10, you can switch to windows containers by selecting

switch to windows containers

Share:
72,409
Lea A
Author by

Lea A

Updated on December 20, 2020

Comments

  • Lea A
    Lea A over 3 years

    I tried this on my Windows 10 machine:

    Dockerfile:

    From microsoft/nanoserver
    CMD ["echo", "Hello World"]
    

    PS

    C:\FSD\Docker\Trial1> docker build -t lea/leatest .
    Sending build context to Docker daemon  2.048kB
    Step 1/2 : FROM microsoft/nanoserver
    latest: Pulling from microsoft/nanoserver
    bce2fbc256ea: Pulling fs layer
    58f68fa0ceda: Pulling fs layer
    image operating system "windows" cannot be used on this platform
    
  • arame3333
    arame3333 over 6 years
    I am completely new to Docker, and for anyone likewise you need to find the Docker ** mini ** icon in the toolbar, right click and then select "Switch to Windows containers" in the Docker menu. Bear in mind that you need to reboot your workstation to complete the process.
  • mat007
    mat007 about 6 years
    For what it's worth I just switched to windows containers and I didn't need to reboot or anything. (Docker version 17.12.0-ce, build c97c6d6)
  • styfle
    styfle over 5 years
    Can you run both Windows and Linux containers at the same time on the same Windows 10 machine?
  • BMitch
    BMitch over 5 years
    @styfle The above is a toggle, you can only do one at a time. There's been work to allow picking different runtimes so you could use both concurrently: blogs.msdn.microsoft.com/premier_developer/2018/04/20/…
  • paul
    paul over 5 years
    I have installed docker on Windows using Docker toolbox, I don't see docker icon in system tray. How can I do it?
  • paul
    paul over 5 years
    I have installed docker on Windows using Docker toolbox, I don't see docker icon in system tray. How can I do it?
  • pbaranski
    pbaranski over 5 years
    @paul I'm afraid that this solution is for Docker for Windows not the Toolbox. Just to add Docker for Windows is recommended software over Toolbox regarding interface (like mentioned Windows containers option)
  • paul
    paul over 5 years
    Docker for Windows is preferred over Docker Toolbox? Why so?
  • pbaranski
    pbaranski over 5 years
    @paul Just relaying on docker staff response here: forums.docker.com/t/docker-for-windows-or-docker-toolbox/303‌​87 , for contradiction I will add this resource: medium.com/short-stories-on-software/… so you need to decide depending on your judgment :D
  • BMitch
    BMitch almost 5 years
    @paul docker toolbox uses docker machine to run Linux containers. Windows containers requires Docker for Windows, which requires newer Windows versions with HyperV enabled.
  • Ville Laitila
    Ville Laitila about 3 years
    Good answer. I wonder why such functionality has been buried into that popup menu and not available under Settings...
  • Scotty H
    Scotty H about 3 years
    This isn't available on Windows 10 Home - it is grayed out.
  • Agorreca
    Agorreca almost 3 years
    After switching to Windows container, I had to run Enable-WindowsOptionalFeature -Online -FeatureName $("Microsoft-Hyper-V", "Containers") -All on Windows PowerShell with elevated privileges
  • warchantua
    warchantua over 2 years
    This requires Windows PRO or Windows Enterprise.
  • Dmitri Larionov
    Dmitri Larionov about 2 years
    It's a bit hidden as it's not in the docker desktop UI but your system task bar in the "hidden icons". Bring up running apps with the up arrow and right click the docker icon, then select that option.
  • bmitc
    bmitc almost 2 years
    @Agorreca: Thank you! I had done all of these steps and still could not figure out why I could not pull a Windows Docker image. Even though I am currently on Windows 11 Home, the toggle to switch between Linux and Windows containers is not grayed out for me and appears to work. So that was extra confusing. Thanks again for pointing this out
  • bmitc
    bmitc almost 2 years
    @warchantua: Thank you as well for pointing out that this requires Windows Pro or Enterprise. I'm going to upgrade and hopefully this all works for me.