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

5

149

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
Parliament answered 11/4, 2017 at 12:56 Comment(2)
It looks like your Docker environment is currently set up to use Linux containers, not Windows containers.Endosmosis
What is the question?Interviewee
P
212

Your Docker host is configured to run Linux containers inside of a VM. To run Windows containers, you need to right click on the Docker icon in the system tray, and select "Switch to Windows containers…" in the Docker menu. This option is not available in "Home" versions of Windows. Documentation is available here.


A screenshot showing the location of the Docker icon in the taskbar

Perfervid answered 11/4, 2017 at 19:45 Comment(12)
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.Ethelda
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)Galata
Can you run both Windows and Linux containers at the same time on the same Windows 10 machine?Sternmost
@Sternmost 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/…Perfervid
I have installed docker on Windows using Docker toolbox, I don't see docker icon in system tray. How can I do it?Toolis
@Toolis docker toolbox uses docker machine to run Linux containers. Windows containers requires Docker for Windows, which requires newer Windows versions with HyperV enabled.Perfervid
Good answer. I wonder why such functionality has been buried into that popup menu and not available under Settings...Gawlas
This isn't available on Windows 10 Home - it is grayed out.Sibylsibylla
After switching to Windows container, I had to run Enable-WindowsOptionalFeature -Online -FeatureName $("Microsoft-Hyper-V", "Containers") -All on Windows PowerShell with elevated privilegesHic
This requires Windows PRO or Windows Enterprise.Gilcrest
@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 outShibboleth
@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.Shibboleth
S
50

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/

Sack answered 15/12, 2017 at 12:16 Comment(4)
I have installed docker on Windows using Docker toolbox, I don't see docker icon in system tray. How can I do it?Toolis
@Toolis 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)Sack
Docker for Windows is preferred over Docker Toolbox? Why so?Toolis
@Toolis Just relaying on docker staff response here: forums.docker.com/t/docker-for-windows-or-docker-toolbox/30387 , for contradiction I will add this resource: medium.com/short-stories-on-software/… so you need to decide depending on your judgment :DSack
B
12

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!

Broca answered 6/10, 2018 at 9:19 Comment(0)
A
8

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

Abnaki answered 7/10, 2018 at 10:38 Comment(1)
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.Mayweed
O
0

Just to add to what the other's have answered before switching to windows containers, depending on how you installed docker ensure Microsoft Hyper-V containers are enabled.

Run as Administration on Powershell

Enable-WindowsOptionalFeature -Online -FeatureName $("Microsoft-Hyper-V", "Containers") -All

Note: this will aslo restart your PC

Oakland answered 18/8, 2022 at 11:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.