dockur / windows

Windows inside a Docker container.
MIT License
29.22k stars 1.99k forks source link

Can't get ip from router #725

Closed LemonZuo closed 1 month ago

LemonZuo commented 2 months ago

Operating system

Ubuntu 24.04

Description

When I try to obtain an IP from the router, I find that it fails and I cannot access it using the static IP I set. Other machines on the local network also cannot access it. My physical machine's IP is 172.16.10.41, and the static IP I set for the container is 172.16.10.85. I have confirmed that 172.16.10.85 is not occupied.

Docker compose

networks:
  vlan:
    driver: macvlan
    driver_opts:
      parent: enp4s0
    ipam:
      config:
        - subnet: 172.16.10.0/24
          gateway: 172.16.10.1

services:
  windows:
    image: dockurr/windows
    container_name: win10
    restart: unless-stopped
    networks:
      vlan:
        ipv4_address: 172.16.10.85
    environment:
      TZ: "Asia/Shanghai"
      VERSION: "win10e"
      LANGUAGE: "Chinese"
      CPU_CORES: "4"
      RAM_SIZE: "4G"
      DISK_SIZE: "128G"
      USERNAME: "Lemon"
      PASSWORD: "980808"
      MANUAL: "Y"
      DHCP: "Y"
      DEBUG: "Y"
    volumes:
      - ./storage:/storage
      - ./shared:/shared
      - ./win10.iso:/custom.iso
    devices:
      - /dev/kvm
      - /dev/vhost-net
    device_cgroup_rules:
      - 'c *:* rwm'
    cap_add:
      - NET_ADMIN
    ports:
      - 8006:8006
    stop_grace_period: 2m

Docker log

❯ Starting Windows for Docker v3.12...
❯ For support visit https://github.com/dockur/windows
❯ CPU: 12th Gen Intel Core TM i5 12400F | RAM: 13/32 GB | DISK: 650 GB (ext4) | HOST: 6.8.0-40...
❯ Host: b772620dfdfe  IP: 172.16.10.85  Gateway: 172.16.10.1  Interface: eth0  MAC: 02:7A:BF:00:2B:D1
nameserver 127.0.0.11
❯ Warning: container IP starts with 172.* which is often a sign that you are not on a macvlan network (required for DHCP)!
Arguments:
-nodefaults
-cpu host,kvm=on,l3-cache=on,+hypervisor,migratable=no,+invtsc,hv_passthrough
-smp 4,sockets=1,dies=1,cores=4,threads=1
-m 4G
-machine type=q35,smm=off,graphics=off,vmport=off,dump-guest-core=off,hpet=off,accel=kvm
-enable-kvm
-global kvm-pit.lost_tick_policy=discard
-display vnc=:0,websocket=5700
-vga virtio
-monitor telnet:localhost:7100,server,nowait,nodelay
-daemonize
-D /run/shm/qemu.log
-pidfile /run/shm/qemu.pid
-name windows,process=windows,debug-threads=on
-serial pty
-device qemu-xhci,id=xhci
-device usb-tablet
-netdev tap,id=hostnet0,vhost=on,vhostfd=40,fd=30
-device virtio-net-pci,romfile=,netdev=hostnet0,mac=02:7A:BF:00:2B:D1,id=net0
-drive file=/storage/data.img,id=data3,format=raw,cache=none,aio=native,discard=on,detect-zeroes=on,if=none
-device virtio-scsi-pci,id=data3b,bus=pcie.0,addr=0xa,iothread=io2
-device scsi-hd,drive=data3,bus=data3b.0,channel=0,scsi-id=0,lun=0,rotation_rate=1,bootindex=3
-object iothread,id=io2
-rtc base=localtime
-global ICH9-LPC.disable_s3=1
-global ICH9-LPC.disable_s4=1
-drive file=/storage/windows.rom,if=pflash,unit=0,format=raw,readonly=on
-drive file=/storage/windows.vars,if=pflash,unit=1,format=raw
-object rng-random,id=objrng0,filename=/dev/urandom
-device virtio-rng-pci,rng=objrng0,id=rng0,bus=pcie.0,addr=0x1c 
❯ Booting Windows using QEMU v8.2.4...
3h3h3hBdsDxe: loading Boot0004 "Windows Boot Manager" from HD(1,GPT,939D8615-43AF-4781-AE31-A83C981E728A,0x800,0x32000)/\EFI\Microsoft\Boot\bootmgfw.efi
BdsDxe: starting Boot0004 "Windows Boot Manager" from HD(1,GPT,939D8615-43AF-4781-AE31-A83C981E728A,0x800,0x32000)/\EFI\Microsoft\Boot\bootmgfw.efi
❯ Windows started succesfully, visit http://localhost:8006/ to view the screen...

Screenshots (optional)

No response

kroese commented 1 month ago

You set DHCP=Y so the IP for Windows will be retrieved from your router (DHCP server). The container will get 172.16.10.85