Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Run windows containers from WSL2 ? #6742

Closed
rreilly-edr opened this issue Mar 31, 2021 · 6 comments
Closed

Run windows containers from WSL2 ? #6742

rreilly-edr opened this issue Mar 31, 2021 · 6 comments
Labels

Comments

@rreilly-edr
Copy link

rreilly-edr commented Mar 31, 2021

Environment

Windows build number: [run `cmd.exe /c ver`]
**Microsoft Windows [Version 10.0.19042.804]**
Your Distribution version: [On Debian or Ubuntu run `lsb_release -r` in WSL]
**Release:        20.04**
Whether the issue is on WSL 2 and/or WSL 1: [run `cat /proc/version` in WSL]
**WSL2**

Steps to reproduce

I will apologize for asking this question in the form of a bug report but i have spent the better part of a day trying to find a solution with no luck, all the articles i have found are about running linux containers.

I am attempting to run windows based containers from wsl2, I am doing both linux and windows development but i prefer to work in WSL. I can run linux containers from windows and WSL2 but I want to test a chef cookbook on windows from WSL.
I have tried switching to windows containers and If i remove the WSL2 integration i get
docker not found

if i enable the WSL2 integration i get

docker pull mcr.microsoft.com/windows/servercore:10.0.19042.867-amd64
10.0.19042.867-amd64: Pulling from windows/servercore
18ae6bebe21d: Pulling fs layer
b67d61f938f3: Pulling fs layer
image operating system "windows" cannot be used on this platform

docker does not seem available to WSL via the network i.e tcp://localhost:2375 ( i have enabled that via docker desktop).
also from test-kitchen if i try to start the windows machine i get

---- Begin output of docker -H npipe:////./pipe/docker_engine build -f Dockerfile-kitchen20210331-14863-1a6c3mm . ----
STDOUT:
STDERR: protocol not available
---- End output of docker -H npipe:////./pipe/docker_engine build -f Dockerfile-kitchen20210331-14863-1a6c3mm . ----
Ran docker -H npipe:////./pipe/docker_engine build -f Dockerfile-kitchen20210331-14863-1a6c3mm . returned 1] on default-windows

TIA

@shawnz
Copy link

shawnz commented Mar 31, 2021

As a workaround, what if you use docker.exe instead?

It won't work to access the docker socket at "tcp://localhost" because the WSL2 environment has a different IP address than Windows. You can get the IP of the Windows host using a method like this: #4619 (comment) That might allow you to access the docker socket over the network like that.

@rreilly-edr
Copy link
Author

I have tried using the ip of windows and 2375 is not available

telnet 172.25.208.1 2375
Trying 172.25.208.1...
telnet: Unable to connect to remote host: Connection refused

@shawnz
Copy link

shawnz commented Mar 31, 2021

Is the problem perhaps that its being firewalled?

@rreilly-edr
Copy link
Author

rreilly-edr commented Mar 31, 2021

I added a firewall rule for 2375, all nets, all interfaces, on windows I can connect to localhost:2375 but not the wsl ip because it is only being shared on localhost

@rreilly-edr
Copy link
Author

adding this port forward

netsh interface portproxy add v4tov4 listenaddress=172.25.208.1 listenport=2375 connectaddress=127.0.0.1 connectport=2375

allows me to switch to windows containers and start them from WSL2 when specifying the -H tcp://172.25.208.1:2375

@therealkenc
Copy link
Collaborator

I haven't reproduced, but this is in all likelihood #5211. Docker is a TCP service running on the Windows side in this scenario. If you are unblocked, please close and subscribe #5211. There is also docker forum discussion here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants