Working with Windows and Linux Containers in Docker Compose

Hi All,

I am looking for a solution to deploy and manage Windows and Linux containers simultaneously on a Windows host. I currently have large-scale solutions in k8s but I am seeking to setup a dev/test solution that must be contained in a single node.

I currently have a compose file that deploys two linux containers, configures networking, variables, etc. I now need to introduce a Windows container into this mix that must be able to communicate with the two linux containers. Some brief research showed that docker-compose used to have a “platform” option that was later removed, so I’m not sure what my solutions are here.

Does anyone have experience or could offer some resources on working with mixed linux and windows containers with Docker Compose?

Docker Compose is just a client that lets you define the containers in a YAML file. Containers are not running “in Docker Compose” and the “platform” options still exists in the yaml but it was never for running Linux containers on Windows or Windows containers on Linux. It is only for running (for example) amd64 binaries on an arm64 CPU or arm64 binaries on amd64 CPU. ON Linux you can only run Linux containers and on Windows you can only run Windows containers. Docker Desktop creates a virtual machine. This is why you can run Linux containers inside that VM, but you can’t use it for running Windows containers and Linux containers at the same time. Since you will always need to run a virtual machine for Linux containers on Windows an Windows containers are almost always using the “hyperv” isolation not the “process” isolation you will most likely run virtual machines, You could never run Windows containers and Linux containers “on the same node” in the sense that you could run Linux containers on the same node.

If you need Linux containers and Windows containers you can use Docker Desktop to run Windows containers and WSL to run Linux containers and forward the necessary ports to the WSL host from the Windows host.

Defining these containers in the same yaml will not work since Docker can connect to only one endpoint at a time…

I appreciate the response. I am aware of the underlying principles of isolation. By “node” here I mean a single piece of hardware/vm/host. I do have the containers running together simultaneously on the same Win 10 host using DD and the respective vms that it creates, just looking for a solution to connect them, and ideally an easy solution to deploy them.

Could you expand on your port forwarding concept? Is it possible to just create a docker network to connect the windows and linux containers managed by DD?

I know that you could run Kubernetes on different operating systems and Microsoft’s documentation mentions “mixed-OS clusters” in Docker Swarm. If you don’t want a cluster, you could try to find a docker network plugin. Since I am using Calico with Kubernetes, I searched it in the context of Docker and I found an old post:

Then I searched for “calico docker network plugin” on Google and found this in the project-calico project.

but you can also use the search function on Docker Hub

These are old plugins, including the sourcode on GitHub, so I don’t know if they still work and if these plugins are platform independent or not.

Docker Desktop forwards ports automatically to its virtual machine. In case of WSL you would need to do that manually using a command on Windows that I can’t remember now.

Awesome. Well I appreciate the insight and the resources you’ve provided. I’ll chime back in here if I ultimately integrate a solution, thanks!