Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I run Windows containers on Docker Desktop for Mac? [duplicate]

I want to be able to run Windows Docker Containers on my Mac, it seems this was sort of supported using Docker Toolbox How can I run a docker windows container on osx?

But it seems that this is now deprecated and we should be using Docker Desktop now.

Docker Desktop has a better and New Hypervisor called HyperKit instead of Virtual Box https://docs.docker.com/docker-for-mac/docker-toolbox/

Docker toolbox allowed starting Windows Containers using VirtualBox, so not sure if that mean's that this is still possible?

I have found a reference to putting Docker Desktop into "Windows Container Mode" here https://www.clearpeople.com/insights/blog/2018/june/sitecore-demo-in-a-docker-container

But I cannot find anywhere to enable this, any help or insight would be very much appreciated.

There is a related question here How can I run a docker windows container on osx? but it's so old that is irrelevant and should not be a reason to lock this question.

like image 921
Lenny D Avatar asked Feb 12 '19 13:02

Lenny D


People also ask

Can Docker containers run on both Windows and Mac operating systems?

You can run both Linux and Windows programs and executables in Docker containers. The Docker platform runs natively on Linux (on x86-64, ARM and many other CPU architectures) and on Windows (x86-64). Docker Inc. builds products that let you build and run containers on Linux, Windows and macOS.

Can I run Windows Docker container on Mac?

The answer is no, and for the same reason it won't work on ARM. A “container” is not a virtual machine, you can only run the same Linux executables you would on a normal Linux system.

Is Docker for Windows the same as Docker Desktop?

Docker Desktop is for Mac and Windows and includes the Docker Dashboard for working with local and remote container images, Dev Environments and more new features are being delivered every month such as Volume Management.

Can I run Windows Desktop on Docker?

In general, Docker recommends running Docker Desktop natively on either Mac, Linux, or Windows. However, Docker Desktop for Windows can run inside a virtual desktop provided the virtual desktop is properly configured.


2 Answers

Docker only runs natively on Linux machines because it needs Linux kernel features called namespaces and control groups. Docker containers are built from cut down Linux distributions.

The original solution to running Docker on OS X and Windows was Docker Toolkit. This was actually a Linux virtual machine running in the VirtualBox Hypervisor. The VM had Docker installed and could run containers.

Docker Desktop for Mac still makes use of a virtual machine running Linux running in the HyperKit Hypervisor. This virtual machine is lightweight and effectively hidden from the user.

Likewise Docker Desktop for Windows makes use of a virtual machine running in the Hyper-V Hypervisor. It can also run Windows containers.

To run Windows containers you need to have a Windows machine running Docker. The Windows machine can be virtual machine running on a Mac or Linux machine.

like image 50
Phill Edwards Avatar answered Sep 30 '22 20:09

Phill Edwards


I know I am late to the party but as of 2021, this is the easiest setup to get a windows container running on macOS:

https://github.com/StefanScherer/windows-docker-machine

  1. Install vagrant and virtual box
  2. Clone the repository above and change directory into it
  3. vagrant up --provider virtualbox 2019-box
  4. docker context use 2019-box

I followed this setup and I could use the following windows image

mcr.microsoft.com/windows/servercore:ltsc2019

Please note that the windows version of your host must match the container image. This is mentioned here: https://hub.docker.com/_/microsoft-windows

Windows requires the host OS version to match the container OS version. If you want to run a container based on a newer Windows build, make sure you have an equivalent host build.

like image 34
binford Avatar answered Sep 30 '22 19:09

binford