dockur / windows

Windows inside a Docker container.
MIT License
17.49k stars 1.5k forks source link

I installed Windows 7 in Docker on OpenWRT, and the installation was completed successfully. However, Windows 7 cannot connect to the internet. Why? #606

Open hb5588973 opened 3 months ago

hb5588973 commented 3 months ago

Operating system

Openwrt

Description

I installed Windows 7 in Docker on OpenWRT, and the installation was completed successfully. However, Windows 7 cannot connect to the internet. Why?

docker network create -d macvlan \ --subnet=192.168.1.0/24 \ --gateway=192.168.1.1 \ -o parent=br-lan macvlan_net

docker run --name windows -d \ -e VERSION="win7" \ -v /mnt/sda3/win:/storage \ -v /mnt/sda3/share:/shared \ -e DISK_SIZE=15G \ -e RAM_SIZE=1G \ -p 8006:8006 \ --device=/dev/kvm \ --cap-add NET_ADMIN \ --stop-timeout 120 \ --net=macvlan_net \ --ip=192.168.1.20 \ dockurr/windows

Docker compose

docker network create -d macvlan \ --subnet=192.168.1.0/24 \ --gateway=192.168.1.1 \ -o parent=br-lan macvlan_net

docker run --name windows -d \ -e VERSION="win7" \ -v /mnt/sda3/win:/storage \ -v /mnt/sda3/share:/shared \ -e DISK_SIZE=15G \ -e RAM_SIZE=1G \ -p 8006:8006 \ --device=/dev/kvm \ --cap-add NET_ADMIN \ --stop-timeout 120 \ --net=macvlan_net \ --ip=192.168.1.20 \ dockurr/windows

Docker log

2024-06-14 21:59:03] network create Container ID: unknown Network Name: macvlan_net Network type: macvlan [2024-06-14 21:59:31] container create Container ID: 4a6ed11831abbca642214df1702535b175699193b4e9f56cc008570082a95049 Container Name: windows [2024-06-14 21:59:31] network connect Container ID: 4a6ed11831abbca642214df1702535b175699193b4e9f56cc008570082a95049 Network Name: macvlan_net Network type: macvlan [2024-06-14 21:59:31] container start Container ID: 4a6ed11831abbca642214df1702535b175699193b4e9f56cc008570082a95049 Container Name: windows

Screenshots (optional)

No response

kroese commented 3 months ago

This logfile is not from the container, but from Docker itself.

Does it work when you use it without macvlan? But in the default mode?

hb5588973 commented 3 months ago

This logfile is not from the container, but from Docker itself.

Does it work when you use it without macvlan? But in the default mode?

Both methods cannot connect to the internet.

kroese commented 3 months ago

Add this to your run command: -e "DEBUG=Y" and show me the output of the log.

hb5588973 commented 3 months ago

stdout: ❯ Starting Windows for Docker v3.12... stdout: ❯ For support visit https://github.com/dockur/windows stdout: ❯ CPU: Intel Core TM i3 6100U CPU | RAM: 3/4 GB | DISK: 70 GB (ext4) | HOST: 6.6.32... stdout: stdout: [1;34m❯ [1;36mHost: 415e7a876ad6 IP: 192.168.1.20 Gateway: 192.168.1.1 Interface: eth0 MAC: 02:77:01:CA:E1:57[0m stdout: nameserver 127.0.0.11 stdout: stdout: Arguments: stdout: stdout: -nodefaults stdout: -cpu host,kvm=on,l3-cache=on,+hypervisor,migratable=no,hv_passthrough,-hv-apicv,-hv-evmcs stdout: -smp 2,sockets=1,dies=1,cores=2,threads=1 stdout: -m 1G stdout: -machine type=q35,smm=off,graphics=off,vmport=off,dump-guest-core=off,hpet=off,accel=kvm stdout: -enable-kvm stdout: -global kvm-pit.lost_tick_policy=discard stdout: -display vnc=:0,websocket=5700 stdout: -vga virtio stdout: -monitor telnet:localhost:7100,server,nowait,nodelay stdout: -daemonize stdout: -D /run/shm/qemu.log stdout: -pidfile /run/shm/qemu.pid stdout: -name windows,process=windows,debug-threads=on stdout: -serial pty stdout: -device usb-ehci,id=ehci stdout: -device usb-tablet stdout: -netdev tap,id=hostnet0,ifname=qemu,script=no,downscript=no stdout: -device virtio-net-pci,romfile=,netdev=hostnet0,mac=02:77:01:CA:E1:57,id=net0 stdout: -drive file=/storage/data.img,id=data3,format=raw,cache=none,aio=native,discard=on,detect-zeroes=on,if=none stdout: -device virtio-scsi-pci,id=data3b,bus=pcie.0,addr=0xa,iothread=io2 stdout: -device scsi-hd,drive=data3,bus=data3b.0,channel=0,scsi-id=0,lun=0,rotation_rate=1,bootindex=3 stdout: -object iothread,id=io2 stdout: -rtc base=localtime stdout: -global ICH9-LPC.disable_s3=1 stdout: -global ICH9-LPC.disable_s4=1 stdout: -object rng-random,id=objrng0,filename=/dev/urandom stdout: -device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c stdout: [1;34m❯ [1;36mBooting Windows (legacy) using QEMU v8.2.4...[0m stdout: c[?7l[2J[0mSeaBIOS (version 1.16.3-debian-1.16.3-2) stdout: Booting from Hard Disk... stdout: [01;01H[1;34m❯ [1;36mWindows started succesfully, visit http://localhost:8006/ to view the screen...[0m

kroese commented 3 months ago

It looks like this is with macvlan. I would not advice to use macvlan unless you are sure that normal networking works first.

Also, you should be able to do some troubleshooting from within Windows. Can you ping local IP adresses, can you ping remote addresses? Because then you know that the problem is with the DNS server for example, and not with the connection itself.

Also, does internet work in your other containers? As this really seems like some Docker configuration issue that has nothing to do with this container specificly.

hb5588973 commented 3 months ago

Yes, other containers are functioning normally. This issue seems to stem from OpenWrt, not specifically related to this container.

OliverPereira commented 3 months ago

I am having exactly the same issue with exactly the same setup under Ubuntu 22.x

EDIT: I noticed that my IP address is 20.20.20.21 and gateway 20.20.20.1

EDIT2: Added DHCP: "Y in environment and I can get the ipaddress but it still can't connect to the internet.

EDIT3: Chrome works.

tensorgpu commented 1 week ago

I tried the macvlan network option in OpenWRT, hit this error:

Cannot create macvtap interface. Please make sure the network type is 'macvlan' and not 'ipvlan', windows