I have an Ubuntu VM using Hyper-V, specialized for server development with Docker daemon and docker compose already installed on it; is there any way to connect Docker Desktop on the Windows machine to the docker daemon in the Ubuntu VM?
2 Answers
Well, if I'm understanding correctly, you can't really 'connect' Windows Docker Desktop to the Linux Docker daemon; but, you can use various methods to control both of the daemons, and also link them into a single 'unit'.
To control them, my favorite way is to use Portainer (including the Portainer Agent), and to join the daemons I personally created a Docker Swarm for my small home network of Docker daemons on various OS's (I currently have 1 on Win 10, 1 on Raspberry Pi, and 1 on Kubuntu).
Docker Swarm is from my understanding, fading away these days though, in favor of Kubernetes. In my use case swarm was just easier, and had all I needed, so I opted for it over Kubernetes; you'll have to feel them both out on your own for your preference.

- 4,013
- 15
- 58
- 94
-
FYI, Visual Studio Code actually supports Docker management. The reason why I'm asking such question because every time my friend who uses WSL2 need help, I can demonstrate it with Docker Desktop from my laptop. – Thor-x86_128 Dec 27 '20 at 18:26
As mentioned in the other answer, this isn't really possible in docker for windows. You should probably migrate from your VM to WSL2 anyway now. It'll only get harder in the future. If your work is in git then you just have to reclone your repos and rebuild/pull your images.
However, I use docker professionally every day and I don't see a need for docker desktop. Which suggests that you probably don't need it either. What is it really? A UI that shows you what containers are running? Big deal -- I have docker ps
to do that in bash...
I use windows because I'm working on a number of windows projects for clients and dual-boot into Linux for a reality check when windows is driving me insane or whenever I'm not being forced to run windows. I do all my server development in my pure-ubuntu environment (using K3D).
I'm also thinking of dumping ubuntu -- because of 'snap' -- I find it every bit as irritating as windows and I've been looking for an alternative for some time. I only use 3 GUI tools: a browser, postman, and IntelliJ -- if it wasn't for them I'd just install alpine on my laptop and be done.

- 15,457
- 7
- 74
- 102
-
It's really hard to expose server from my laptop to local network with WSL2. So I'll stay with Hyper-V until WSL2 able to expose network officially. – Thor-x86_128 Dec 27 '20 at 18:31
-
netsh interface portproxy add v4tov4 listenport=4000 listenaddress=0.0.0.0 connectport=4000 connectaddress=192.168.101.100 – Software Engineer Dec 27 '20 at 19:43
-
You know that wsl is just hyper-v anyway don't you? Plus some extra integration. – Software Engineer Dec 27 '20 at 19:45
-
It's not going to work. The real problem is WSL2 random IP assignment to host OS. There is a script to do that but need to be executed every time Windows booted up. See [this post](https://stackoverflow.com/questions/61002681/connecting-to-wsl2-server-via-local-network). – Thor-x86_128 Dec 28 '20 at 04:15
-
Also speaking of integration, Hyper-v can be integrated with virtual NIC and samba. Similar as integrating with a real server. – Thor-x86_128 Dec 28 '20 at 04:22