110

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
Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
Lea A
  • 1,151
  • 2
  • 8
  • 8

4 Answers4

155

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

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
BMitch
  • 148,146
  • 27
  • 334
  • 317
  • 1
    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. – arame3333 Nov 29 '17 at 10:19
  • 1
    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) – mat007 Feb 15 '18 at 14:30
  • Can you run both Windows and Linux containers at the same time on the same Windows 10 machine? – styfle Aug 10 '18 at 19:09
  • @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: https://blogs.msdn.microsoft.com/premier_developer/2018/04/20/running-docker-windows-and-linux-containers-simultaneously/ – BMitch Aug 10 '18 at 20:19
  • 1
    I have installed docker on Windows using `Docker toolbox`, I don't see docker icon in system tray. How can I do it? – paul Jan 29 '19 at 10:12
  • 1
    @paul docker toolbox uses docker machine to run Linux containers. Windows containers requires Docker for Windows, which requires newer Windows versions with HyperV enabled. – BMitch May 11 '19 at 12:20
  • Good answer. I wonder why such functionality has been buried into that popup menu and not available under Settings... – Ville Laitila Mar 15 '21 at 16:01
  • This isn't available on Windows 10 Home - it is grayed out. – Scotty H Apr 26 '21 at 16:11
36

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

Peter Mortensen
  • 28,342
  • 21
  • 95
  • 123
pbaranski
  • 17,946
  • 16
  • 88
  • 101
  • I have installed docker on Windows using `Docker toolbox`, I don't see docker icon in system tray. How can I do it? – paul Jan 29 '19 at 10:12
  • @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) – pbaranski Jan 30 '19 at 11:24
  • `Docker for Windows` is preferred over `Docker Toolbox`? Why so? – paul Jan 31 '19 at 16:54
  • @paul Just relaying on docker staff response here: https://forums.docker.com/t/docker-for-windows-or-docker-toolbox/30387 , for contradiction I will add this resource: https://medium.com/short-stories-on-software/fixing-docker-to-run-smooth-on-windows-9e71dcc7c128 so you need to decide depending on your judgment :D – pbaranski Feb 01 '19 at 12:40
7

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!

Dzenis H.
  • 4,658
  • 2
  • 17
  • 39
Abhishek Jain
  • 2,305
  • 17
  • 19
6

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

prisar
  • 2,246
  • 1
  • 18
  • 24