Skip to content

Run windows containers from WSL2 ? #6742

Closed

Description

@rreilly-edr

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

Activity

  1. shawnz commented on Mar 31, 2021

    @shawnz

    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.

  2. rreilly-edr commented on Mar 31, 2021

    @rreilly-edr
    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
    
  3. shawnz commented on Mar 31, 2021

    @shawnz

    Is the problem perhaps that its being firewalled?

  4. rreilly-edr commented on Mar 31, 2021

    @rreilly-edr
    Author

    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

  5. rreilly-edr commented on Mar 31, 2021

    @rreilly-edr
    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

  6. therealkenc commented on Mar 31, 2021

    @therealkenc

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions