23

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.

1
  • 1
    Enabling Windows Container Mode is what i have seen in Windows installation of Docker Desktop, where you can switch between Linux and Windows Container modes. If you want to run windows container on MAC refer this link. github.com/StefanScherer/docker-windows-box
    – Srini M
    Commented Nov 25, 2019 at 6:37

2 Answers 2

15

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.

10

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.

2
  • "windows version of your host must match the container image" -- what does that mean? The host is running macOS, not windows. Am I misunderstanding the context here?
    – btk
    Commented Oct 20, 2021 at 16:11
  • 2
    @btk: When using windows-docker-machine, you are creating a windows VM to serve as docker host. The OS version of the container you are running on that host, has to match the OS of the VM.
    – binford
    Commented Oct 21, 2021 at 8:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.