I tried this on my Windows 10 machine:
Dockerfile:
From microsoft/nanoserver
CMD ["echo", "Hello World"]
PS
C:FSDDockerTrial1> 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
asked Apr 11, 2017 at 12:56
2
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.
miken32
41k16 gold badges105 silver badges148 bronze badges
answered Apr 11, 2017 at 19:45
BMitchBMitch
214k40 gold badges455 silver badges427 bronze badges
12
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/
miken32
41k16 gold badges105 silver badges148 bronze badges
answered Dec 15, 2017 at 12:16
pbaranskipbaranski
21.7k18 gold badges98 silver badges112 bronze badges
4
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:
-
Forum post
-
Blog post
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.
6,8243 gold badges22 silver badges44 bronze badges
answered Oct 6, 2018 at 9:19
Abhishek JainAbhishek Jain
3,5071 gold badge24 silver badges25 bronze badges
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
answered Oct 7, 2018 at 10:38
prisarprisar
2,9552 gold badges25 silver badges27 bronze badges
1
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
answered Aug 18, 2022 at 11:58
Docker is an open-source containerization platform that enables developers to package apps into containers and standardized executable components combining application source code with the operating system (OS) libraries and dependencies required to run that code in any environment. The Docker Engine and client aren’t included with Windows and need to be installed and configured individually. You need Docker in order to work with Windows Containers. Docker consists of the Docker Engine (dockerd.exe), and the Docker client (docker.exe). Kindly refer to these related guides: How to create and deploy a local Registry Server with Docker Image, how to Pull your first Nginx Container Image from Docker Hub and deploy it to your local machine, Azure DevOps and GitHub integration for Docker and Kubernetes deployment, how to create a static pod in Kubernetes, and how to install, register and start GitLab Runner on Windows.
The below error occurs when you are trying to pull Microsoft Container images from Microsoft Container Registry (MCR). The error is usually due to a lot of reasons and there are many solutions to it. I will be discussing the fix that worked for me in this troubleshooting guide.
You may also get the following error, do not freight, all you need do is to switch to Windows container as discussed below.
C:GitLab-Runner>docker run mcr.microsoft.com/windows/servercore:20H2-amd64
Unable to find image 'mcr.microsoft.com/windows/servercore:20H2-amd64' locally
20H2-amd64: Pulling from windows/servercore
18ae6bebe21d: Pulling fs layer
df018de09299: Pulling fs layer
docker: image operating system "windows" cannot be used on this platform.
See 'docker run --help'.
Solution: Switch to Windows Container
Instead of running on Linux containers, you need to switch to Windows containers as shown in the screenshot below.
– Click on the Show hidden icons and right-click on the Docker icon as shown below.
– Click on Switch to Windows Container.
Alternatively, you may have to SwitchDaemon the configuration via Command Prompt or PowerShell as shown below.
You can use the following command on PowerShell as shown below.
PS C:Program FilesDockerDocker> ./DockerCli.exe -SwitchDaemon
When these are done, and you try to run Docker again, it will be successful.
Regardless of the steps you take, this issue will be resolved. I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.
I had install the Docker On Windows,but when I run the command docker pull microsoft/azure-cosmosdb-emulator
and the error image operating system "windows" cannot be used on this platform
back.
ShaunMoloi, pratik-soni916, and jabba2324 reacted with thumbs down emoji
MiroslavMikus reacted with heart emoji
My problem is happen on windows mode.
Solve by using @abhijit838 solutions and its working now. Thanks for the info.
@ElderJames, are you still experiencing this problem? Run docker version
in cmd or powershell and take a look at what OS/Arch
is saying for both Client and Server. Hopefully it should say something similar to windows/amd64
.
because I hadn’t selected the Windows option at Install, I had to uninstall and reinstall. Then, that still didn’t work so I uninstalled, deleted the Docker and DockerDesktop folders from ProgramFiles and ProgramData, ten re-installed, then switched… and then it worked.
Having the same problem.How Win7 to Switch the Windows container
i am having the same problem, i am aware of the limitation of windows vs linux image difference because of which this is coming. But i am looking a for a solution on this because i just want to pull image from an repo and push it to another repo. That also not possible because of this limitation.
@ElderJames, are you still experiencing this problem? Run
docker version
in cmd or powershell and take a look at whatOS/Arch
is saying for both Client and Server. Hopefully it should say something similar towindows/amd64
.
My Client version says windows but Server says Linux, I have installed Docker on WIndows though. Here is my Docker version
When I hit docker pull below is the response
Thanks
@Abubakar22
I have the same problem, my docker client is running windows but my docker server is running linux. This is because I am using the WSL 2 backend, which is the only option for me since my PC is running windows 11 Home edition. However this means the engine can only support the linux architecture. UNFORTUNATELY In order to run windows based containers you HAVE to be running the hyper-v version of docker for windows (which for me means having to upgrade to windows 10/11 pro).
I tried this on my Windows 10 machine:
Содержание
- 4 Answers 4
- error:image operating system «windows» cannot be used on this platform #8
- Comments
- ElderJames commented Aug 30, 2017 •
- abhijit838 commented Sep 9, 2017
- abhijit838 commented Sep 9, 2017
- ElderJames commented Sep 9, 2017
- sumit480 commented Sep 28, 2017
- bremnes commented Oct 3, 2017
- conradmurray commented Dec 18, 2018
- hans204 commented May 7, 2019
- sumantfordev commented Aug 20, 2019
- Abubakar22 commented Aug 29, 2020
- Mixing Windows and Linux containers with Docker Compose
- Setting up your environment
- Source Code
- Docker-Compose
- 3 comments
4 Answers 4
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.
You need to go to the Taskbar → right click the Docker icon → use option Switch to Windows containers.
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!
Источник
error:image operating system «windows» cannot be used on this platform #8
I had install the Docker On Windows,but when I run the command docker pull microsoft/azure-cosmosdb-emulator and the error image operating system «windows» cannot be used on this platform back.
The text was updated successfully, but these errors were encountered:
Having the same problem.
Solved. You just have to switch to Windows container form docker menu.
Here is the reference doc. https://docs.docker.com/docker-for-windows/#switch-between-windows-and-linux-containers
My problem is happen on windows mode.
Solve by using @abhijit838 solutions and its working now. Thanks for the info.
because I hadn’t selected the Windows option at Install, I had to uninstall and reinstall. Then, that still didn’t work so I uninstalled, deleted the Docker and DockerDesktop folders from ProgramFiles and ProgramData, ten re-installed, then switched. and then it worked.
Having the same problem.How Win7 to Switch the Windows container
i am having the same problem, i am aware of the limitation of windows vs linux image difference because of which this is coming. But i am looking a for a solution on this because i just want to pull image from an repo and push it to another repo. That also not possible because of this limitation.
My Client version says windows but Server says Linux, I have installed Docker on WIndows though. Here is my Docker version
When I hit docker pull below is the response
Источник
Mixing Windows and Linux containers with Docker Compose
Premier Developer Consultant Randy Patterson explores how to mix Windows and Linux containers with Docker Compose.
Running Linux containers on a Windows host has been available for awhile now. However, getting Windows and Linux containers to communicate without Docker Compose results in using the containers’ IP Addresses. This is not a good solution since container IP Addresses change often. A better solution is to take advantage of the Docker Compose networking and use the service name instead of the IP address. A Windows host has no problem running Linux containers but Docker Compose does not automatically support multi-platform hosts.
The platform configuration option was added to Docker Compose files starting with version 2.4 and then removed beginning with version 3.x. It is a know bug and the expectation is that the platform option will return soon. When this article was written, it has not yet appeared in version 3.x so we will continue to use file format version 2.4 for our Docker Compose yaml files.
Setting up your environment
Running Linux containers on Windows and platform support in Docker Compose requires Windows 1803 or greater. I am running Windows 10 1809.
In addition, you must be running the latest version of Docker for Windows and have the experimental features enabled.
If you are running different versions of Windows or Docker your mileage may vary.
Source Code
Next, grab the source code located in the GitHub repo here containing two solutions
The application is a simple web page that displays the hostname of the Web Tier then calls the API Tier to get and display the API hostname. When running in containers, the container Id is displayed. Your Id’s will be different
Docker-Compose
The docker-compose.yml file, located in the root of the solution, adds the platform: windows parameter to the webtier service and the platform: linux parameter to the apitier service.
Next, bring up the multi-container, multi-platform application using docker-compose. Start a powershell prompt in the solutions root folder, the same folder that contains the docker-compose.yml file. Type the command:
Docker Compose will create the images if they do not already exist, then create the virtual network to host the containers and finally start the containers in the correct order.
Finally, retrieve the host port of the webtier container
Use your browser to navigate to http://localhost:38736 (your port number will be different)
If the Windows Web Tier was able to communicate with the Linux API Tier, you will see the id for each of the containers (your id’s will be different) on the web page.
Using the platform option in your configuration files allows Docker Compose to mix Windows and Linux containers when hosted on a multi-platform host like Windows. Keep in mind that this is an experimental feature and is not yet ready for production environments.
Developer Support
App Dev Customer Success Account Manager, Microsoft Developer Support
Read next
Hi,
a very nice article.
I am using LCOW for several months and it works for integration tests ina mixed environment very well.But now I have a problem using microsoft/dotnet:2.2-aspnetcore-runtime(or …-alpine) for the linux images.
Building the docker image on linux with this base image and running it in anLCOW environment works in that way that the container starts and itsfunctions are available.
But if I want to stop the container it takes several minutes to stop thecontainer.
Do you have any idea why it takes so long?
Best regardsChristian
Thanks for the comment Christian. LCOW containers taking a long time to stop is a known issue that hasn’t been fixed yet. I don’t always experience it with ‘docker stop’ but I do with ‘docker-compose down’. Just be patient for now and don’t kill the process. ‘docker-compose down’ will also remove the network it created and if that gets interupted it can be difficult to fix.
Источник
As I work with my teams to begin integrating docker into our processes, we are finding, as with anything new, a few oddities depending on the machine or user. This is a collection of some of these error messages and how we found to solve them.
For additional help when dealing with #sitecore specific errors you should check out the official documentation troubleshooting guide at https://containers.doc.sitecore.com/docs/troubleshooting.
Error About ‘Image Operating System’
ERROR: image operating system «windows» cannot be used on this platform
RESOLUTION
This error will occur if Docker is not configured to support Windows containers. The default state of Docker after installation is always for Linux-based containers.
- Go to the Notification Tray and click the whale (Docker icon)
- From the menu selection, if there is an option for Switch to Windows containers click it.
Docker An Error Occurred
While attempting to switch Docker from Linux to Windows container support the following messages may display
An error occurred: Required Windows feature(s) not enabled: Hyper-V and Containers. Docker Desktop will exit.
<br>OR
<br>An error occurred: Required Windows feature(s) not enabled: Containers. Docker Desktop will exit.
RESOLUTION
As these messages state, you need to enable the noted Windows features. This can be accomplished manually by launching Turn Windows Features On or Off or via the following PowerShell script.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Write-Host «Runnng this script will install/enable the optional Windows features of Hyper-V and Containers.« | |
Write-Host «After the Windows features are enabled this script will force a system reboot.« –ForegroundColor Magenta | |
if($(Get-WindowsOptionalFeature –FeatureName Microsoft–Hyper–V –Online).State -ieq ‘disabled‘) | |
{ | |
Write-Host «Installing Microsoft Hyper V feature.« –ForegroundColor DarkCyan | |
Enable-WindowsOptionalFeature –Online –FeatureName Microsoft–Hyper–V –All –NoRestart | |
} | |
if($(Get-WindowsOptionalFeature –FeatureName Containers –Online).State -ieq ‘disabled‘) | |
{ | |
Write-Host «Installing Containers feature.« –ForegroundColor DarkCyan | |
Enable-WindowsOptionalFeature –Online –FeatureName Containers –All –NoRestart | |
} | |
$confirmation = Read-Host «A restart is required for the changes to take effect. Restart now (y/n)?« | |
if ($confirmation -ieq ‘y‘) { | |
Restart-Computer –Force | |
} | |
else { | |
Write-Host «At a time convenient to you, restart the machine for the changes to take effect.« | |
} |
Image is Incompatible
ERROR: a Windows version 10.0.18363-based image is incompatible with a 10.0.18362 host
RESOLUTION
This message is an indication that your local system is not updated to a minimum of Windows 10 build version 1909. Please update your system and try again.
Running Scripts Is Disabled
…cannot be loaded because running scripts is disabled on this system.
RESOLUTION
The scripts used are unsigned, so you will need to ensure your execution policy is set accordingly
- Open a PowerShell prompt as ADMIN
- Run the following at the prompt
Set-ExecutionPolicy -ExecutionPolicy Unrestricted
Slow System Boot (Reboot) Time
If you are not regularly using Docker, and your boot times feel slow it is recommended to disable Docker to start on boot.
- Go to the Notification Tray and click the whale (Docker icon)
- From the menu options click Settings
- From the settings window, uncheck Start Docker Desktop when you log in
Virtual Machine could not be started
If you are attempting to run Docker on/within a VM, you may receive messages similar to the following when you go to run an image.
ERROR: for docker_solr_1 Cannot start service solr: hcsshim: CreateComputeSystem <hash value of the container>:
The virtual machine could not be started because a required feature is not installed.
RESOLUTION
Not all the windows features have been enable for your virtual machine as well as on the host to support virtualization within virtualization
- Shutdown the VM Client Machine
- Ensure the Hyper-V Windows feature on Host Machine is enabled, either manually or via the script (see above).
- On the Host Machine set the VM Processor to expose virtualization extensions via a PowerShell
Set-VMProcessor -VMName "<Your Virtual Machine Name>" -ExposeVirtualizationExtensions $true
- Start the VM Client Machine
- On the VM Client Machine enable the Hyper-V Windows feature, either manually or via the script demonstrated above.
Ваш хост Docker настроен для запуска контейнеров Linux внутри виртуальной машины. Чтобы запускать контейнеры Windows, вам необходимо «Переключиться на контейнеры Windows» в меню Docker. Документация по этому поводу доступна здесь .
microsoft/nanoserver
— это собственный образ контейнера Windows. Таким образом, вы не можете запустить это, поскольку контейнеры Linux работают изначально. Его можно запустить только на Windows 10 или Windows Server.
Если вы используете Windows 10, вы можете переключиться на контейнеры Windows, выбрав
переключиться на контейнеры Windows
Переключиться на контейнер Windows необходимо выбрать из значка докера, который находится под скрытым значком в правом нижнем углу … В тот момент, когда вы переключаетесь с Linux на Windows или Windows на Linux , демон Docker
автоматически перезагружается, чтобы рассмотреть переключенный контейнер …
Я настоятельно рекомендую вам просмотреть эти 2 ссылки, чтобы получить больше информации о том, как создавать оконные контейнеры:
-
Сообщение на форуме
-
Сообщение блога
Я действительно нашел содержимое этих ссылок очень полезным для создания оконного контейнера, который все еще совершенствуется для решения общей проблемы, с которой мы все сталкиваемся, поскольку поддержка оконных контейнеров еще не сформировалась, как контейнеры Linux!
Я хочу запускать исполняемые файлы windows в контейнере docker.
Я не могу запускать контейнеры windows в Linux docker:
$ docker run --rm microsoft/nanoserver
Unable to find image 'microsoft/nanoserver:latest' locally
latest: Pulling from microsoft/nanoserver
bce2fbc256ea: Pulling fs layer
b1b0c61be11f: Pulling fs layer
docker: image operating system "windows" cannot be used on this platform.
Я попытался запустить виртуальную машину windows 10 и установить docker для windows. Установка прошла нормально, но запуск docker выдает следующую ошибку:
Unable to start: The running command stopped because the preference variable "ErrorActionPreference" or common parameter is set to Stop: 'MobyLinuxVM' failed to start.
Failed to start the virtual machine 'MobyLinuxVM' because one of the Hyper-V components is not running.
'MobyLinuxVM' failed to start. (Virtual machine ID E8803091-3163-4906-8547-F3422532D501)
The Virtual Machine Management Service failed to start the virtual machine 'MobyLinuxVM' because one of the Hyper-V components is not running (Virtual machine ID E8803091-3163-4906-8547-F3422532D501).
at Start-MobyLinuxVM, <No file>: line 300
at <ScriptBlock>, <No file>: line 395
at Docker.Core.Pipe.NamedPipeClient.Send(String action, Object[] parameters) in C:gopathsrcgithub.comdockerpinatawinsrcDocker.CorepipeNamedPipeClient.cs:line 36
at Docker.Actions.DoStart(SynchronizationContext syncCtx, Boolean showWelcomeWindow, Boolean executeAfterStartCleanup) in C:gopathsrcgithub.comdockerpinatawinsrcDocker.WindowsActions.cs:line 77
at Docker.Actions.<>c__DisplayClass16_0.<Start>b__0() in C:gopathsrcgithub.comdockerpinatawinsrcDocker.WindowsActions.cs:line 61
at Docker.WPF.TaskQueue.<>c__DisplayClass19_0.<.ctor>b__1() in C:gopathsrcgithub.comdockerpinatawinsrcDocker.WPFTaskQueue.cs:line 59
Я проверил, что hyper-v на самом деле включен.
можно ли иметь хост linux под управлением Windows VM под управлением docker для запуска исполняемых файлов windows в контейнер, или я пытаюсь сделать что-то невозможное?
источник