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

3.6k Views Asked by At

I have installed docker toolbox on my windows 10 home pc. I ma facing two problems.

1.When I click on docker quickstart terminal, it gives unix/linux prompt. 2.When I try to run this command docker build (on windows command prompt), I get this error :image operating system "windows" cannot be used on this platform.

docker build .
Sending build context to Docker daemon  2.584MB
Step 1/17 : FROM microsoft/aspnetcore:2.0-nanoserver-1709 AS base
2.0-nanoserver-1709: Pulling from microsoft/aspnetcore
407ada6e90de: Pulling fs layer
10288d944410: Pulling fs layer
4880fefbf99e: Pulling fs layer
df193da25173: Waiting
60ab1f0af432: Waiting
f4d477fb2108: Waiting
878954290d5e: Waiting
ae61d8e352f7: Waiting
88faab7b6014: Waiting
e7331f21ccb7: Waiting
image operating system "windows" cannot be used on this platform

How do I correct my configuration so that it accepts my windows 10 os.

How can I configure docker toolbox so that I can dockerize my dot net applications.

My question is, if docker toolbox installs a linux vm on my system, how is it going to help me with commands like " docker build ." , it gives this error :image operating system "windows" cannot be used on this platform. So, essentially, I cannot do anything.

Is that correct? or is there a way by which I can invoke docker on windows 10 home?

Thanks is advance.

3

There are 3 best solutions below

1
On

Change to FROM microsoft/aspnetcore:2.0-nanoserver-1709 to microsoft/dotnet:2.1-aspnetcore-runtime

Explanation:

microsoft/aspnetcore:2.0-nanoserver-1709 is a windows native container image. It can only be run on windows 10 or windows server.To run on Linux container, pull the similar image for Linux as described here

0
On

Based on the last answer, I changed my base to: microsoft/dotnet:2.1-aspnetcore-runtime AS base and the build to microsoft/dotnet:2.1-sdk AS build in the Dockerfile and now it works.

0
On

To be able to run Windows containers, you first need to install Hyper-V: open PowerShell as an administrator and enter Enable-WindowsOptionalFeature -Online -FeatureName $("Microsoft-Hyper-V", "Containers") -All. Restart your computer, launch Docker Desktop and then right click on Docker Desktop at the bottom right the windows task bar, and click "Switch to windows container"

enter image description here

You should now be able to run any docker image based on Windows.