weaveworks / weave

Simple, resilient multi-host containers networking and more.
https://www.weave.works
Apache License 2.0
6.62k stars 667 forks source link

Run Weave natively on Windows 10 with WSL #3261

Open stuartz-VernonCo opened 6 years ago

stuartz-VernonCo commented 6 years ago

This IS a FEATURE REQUEST

What are the benefits?

Able to run weave natively on Windows for development. While not probably a high priority. Putting this here so others can know how to use weave on WSL.

Brief summary of issue and solution

I have been able to get weave commands working on Windows 10 WSL including weave attach. However, WSL doesn't have unix sockets so I am not able to start containers running on the weave net. Have Weave net check for unix socket availiblity and if not create AF_INET. Also check if running on Windows WSL and add to weave the exports and aliases given below in steps to reproduce.

This post suggests using AF_INET for windows:

s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

What you expected to happen?

use docker-compose $(weave config) up -d to start a container attached to the weave network

What happened?

When running the command above, I get an error: module' object has no attribute 'AF_UNIX

How to reproduce it?

On Windows 10: Install Docker for Windows Enable WSL (note uses Hyper-V and cannot run Virtualbox at the same time.) Open cmd > bash >enter Install weave Add the following to both /home/username/.bashrc & /usr/local/bin/weave, exit, & reenter bash.

alias docker=docker.exe
alias dc=docker-compose.exe
alias dm=docker-machine.exe
alias dps='docker.exe ps' 
export DOCKER_HOST='tcp://0.0.0.0:2375' 

from https://blog.jayway.com/2017/04/19/running-docker-on-bash-on-windows/

Weave commands work that I have tried: launch, status *, attach

Weave commands I've tried that don't: weave env, weave config

Versions:

Windows 10 Pro 64-bit Version 1703
docker version 17.12.0-cd
docke-compose version 
version 1.18.0, build 8dd22a96
docker-py version: 2.6.1
CPython version: 2.7.14
OpenSSL version: OpenSSL 1.0.2k  26 Jan 2017
Weave version 2.2.1

Logs:

no errors in weave log or journalctl

docker-compose.yml

version: '2'
services:
  app1:
    image: nginx
    container_name: app1
    hostname: app1.weave.local
    ports:
      - "80:80"
    dns_search:
      - weave.local
    network_mode: "bridge"
bboreham commented 6 years ago

I think we have the basic request already at #976, though it's interesting to have extra data about WSL.

Weave Net is built on lots of Linux facilities like the VXLAN kernel module, netfilter, network namespaces, etc.; all of the code using them will need to be replaced with the equivalent for Windows.

stuartz-VernonCo commented 6 years ago

While #976 has to do with Windows containers rather than Linux containers on docker for windows, it appears that weave generally works on WSL for linux containers. I am able to attach to a container and communicate with other containers on the network from different hosts. Only issue was AF_UNIX error. It may be that WSL has some of the requirements since I'm able to attach and use the containers on weave net, but lacks connection to AF_UNIX...a semantic error? I'm not familiar enough with WSL to know as I just started using Windows.

chanwit commented 4 years ago

It's known to work on WSL2 (not WSL1) with addition kernel configs.

Here's the issue reported to MSFT WSL2 Kernel: https://github.com/microsoft/WSL2-Linux-Kernel/issues/47

chanwit commented 4 years ago

And waiting for this https://github.com/microsoft/WSL2-Linux-Kernel/pull/48 to get merged.

WSLUser commented 4 years ago

been fixed by an upstream patch. Guess mail list patches are expected for WSL2 as well. That is unfortunate.