dockur / windows

Windows inside a Docker container.
MIT License
17.89k stars 1.56k forks source link

Both interfaces stops working when adding a second #780

Open Curtis-Lockley opened 2 weeks ago

Curtis-Lockley commented 2 weeks ago

Operating system

Ubuntu 22.04.4

Description

I have the following requirements for the VM:

1 - Send and receive traffic through the broadcast address 192.168.127.255 over a macvlan 2 - Has access to the internet through a bridge network.

My issue is that I am only able to achieve 1 out of the 2 of those requirements at any given time. If I comment out the ARGUMENTS and the bridge network, I meet the first requirement. If I instead comment out the macvlan, ARGUMENTS and DHCP I can meet the second requirement.

When doing ipconfig on Windows, neither interface has an ip assigned.

C:\Users\Docker>ipconfig

Windows IP Configuration

Ethernet adapter Ethernet:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::73df:c498:46b5:9d8c%7
   Autoconfiguration IPv4 Address. . : 169.254.239.94
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . :

Ethernet adapter Ethernet 2:

   Connection-specific DNS Suffix  . :
   Link-local IPv6 Address . . . . . : fe80::12d1:7444:2c46:79b8%6
   Autoconfiguration IPv4 Address. . : 169.254.247.80
   Subnet Mask . . . . . . . . . . . : 255.255.0.0
   Default Gateway . . . . . . . . . : 192.168.5.201

For the macvlan, I have tried setting a static IP to the windows VM, but it made no difference

The docker container itself is able to meet both requirements. Below is the result of ip a

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: qemu@eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 500
    link/ether 02:fb:b4:d3:0d:20 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fb:b4ff:fed3:d20/64 scope link 
       valid_lft forever preferred_lft forever
3: tap0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UNKNOWN group default qlen 1000
    link/ether d2:80:f4:b1:e4:99 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::d080:f4ff:feb1:e499/64 scope link 
       valid_lft forever preferred_lft forever
29: eth0@if30: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:ac:12:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 172.18.0.2/16 brd 172.18.255.255 scope global eth0
       valid_lft forever preferred_lft forever
31: eth1@if3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default 
    link/ether 02:42:c0:a8:05:ce brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 192.168.5.206/17 brd 192.168.127.255 scope global eth1
       valid_lft forever preferred_lft forever

Docker compose

services:
  windows:
    privileged: true
    image: dockurr/windows
    networks:
     bridge:
     private:
        ipv4_address: "192.168.5.206"
    container_name: windows
    environment:
      VERSION: "win10"
      DHCP: "Y"
      ARGUMENTS: "-netdev tap,id=hostnet1 -device virtio-net-pci,romfile=,netdev=hostnet1,id=net1"
    devices:
      - /dev/vhost-net
    device_cgroup_rules:
      - 'c *:* rwm'      
    cap_add:
      - NET_ADMIN
    ports:
      - 8006:8006
      - 3389:3389/tcp
      - 3389:3389/udp
    stop_grace_period: 2m
    volumes:
      - /var/win:/storage 
      -  /home/curtis:/shared
networks:
  bridge:
   driver: bridge
  private:
    driver: macvlan
    driver_opts:
      parent: enp0s8
    attachable: true
    ipam:
     config:
        - subnet: "192.168.0.0/17"
          gateway: "192.168.5.201"  

Docker log

BdsDxe: loading Boot0004 "Windows Boot Manager" from HD(1,GPT,6EBB240B-2394-4518-B1FC-3050C4356924,0x800,0x40000)/\EFI\Microsoft\Boot\bootmgfw.efi
windows  | BdsDxe: starting Boot0004 "Windows Boot Manager" from HD(1,GPT,6EBB240B-2394-4518-B1FC-3050C4356924,0x800,0x40000)/\EFI\Microsoft\Boot\bootmgfw.efi
windows  | ❯ Windows started succesfully, visit http://localhost:8006/ to view the screen...

Screenshots (optional)

No response

kroese commented 1 week ago

Can you try with:

environment:
  ARGUMENTS: "-netdev user,id=hostnet1 -device virtio-net-pci,romfile=,netdev=hostnet1,id=net1"

This creates the second LAN adaptor as usermode/slirp instead of a TAP device.