dockur / windows

Windows inside a Docker container.
MIT License
17.27k stars 1.47k forks source link

Documentation Hints #259

Closed avoiceofreason closed 5 months ago

avoiceofreason commented 6 months ago

A few hints that you might want to enhance your documentation with:

RDP

If you have an RDP server on the host that is running Docker then you won't be able to map port 3389 from the container to the host as 3389 is already in use on the host. You can map a different port e.g.

-p 3388:3389/tcp -p 3388:3389/udp

But remember this maps port 3388 on the Docker host but its still 3389 on the container so depending on how you want to connect it will be:

$host_ip:3388 or $container_ip:3389

If you use the linux rdesktop client then you can use CLI such as:

rdesktop -g 50%@192 -u docker -r disk:mydisk=/home/user/Windows10_Share 192.168.0.5:3387

where:

-g 50%@192 is use 50% of the local screen but 200% DPI scaling -u docker is use "docker" username -r disk:mydisk=/home/user/Windows10_Share is redirect local disk 192.168.0.1:3388 is 192.168.0.1 my docker host on port 3388

I've found RDP folder redirection more reliable and flexible than the SAMBA file share approach.

I've had no luck getting sound redirected via rdesktop to linux/ubuntu. But it does work on a windows client so is def an Ubuntu issue.

RECREATE A CONTAINER WITH PREVIOUSLY INSTALLED WINDOWS USING NEW DOCKER RUN OPTION

Useful if you need to change some port mappings or add a new USB device but don't want to reinstall windows from scratch

So, assume you have created a freshly installed win10 container with this docker run command:

docker run -d \ --name windows10 \ -e VERSION="win10" \ -p 8006:8006 \ -p 3389:3389/tcp \ -p 3389:3389/udp \ -v /local/storage:/storage \ --device=/dev/kvm \ --cap-add NET_ADMIN \ --restart unless-stopped \ dockurr/windows

Now you want to change the port mappings and add a usb device to this container:

First shutdown windows, then stop the container:

docker stop windows10

Then create a local image of the container with:

docker commit windows10 windows10_image

Then delete the existing container with:

docker rm windows10

Then create a new container using the saved image and different/extra docker options (don't change the storage mapping)

docker run -d \ --name windows10 \ -e VERSION="win10" \ -e ARGUMENTS="-device usb-host,vendorid=0x1234,productid=0x5678" \ -p 8010:8006 \ -p 3388:3389/tcp \ -p 3388:3389/udp \ -v /local/storage:/storage \ --device=/dev/kvm \ --device=/dev/bus/usb \ --cap-add NET_ADMIN \ --restart unless-stopped \ windows10_image

I'm assuming nothing much changes in the container as the windows system disk is stored on the volume map device. Anyway worked for me, Your mileage may vary.

Window 10/11 debloat

If you use the Chris Titus windows debloat scripts at https://github.com/ChrisTitusTech/winutil (I do on all win installs)

then be careful with the Tweaks section and the "Set Services to Manual" This must disable a service that the SAMBA file sharing uses and kills it after a reboot. Maybe someone can find out what that service dependency is.

WINDOWS/DOCKER LOCALES

Default install is for US. If you change the Windows locale to something else e.g. British / English is seems to mess up the keyboard mappings, maybe a mismatch between the container and windows.

kroese commented 6 months ago

Very good suggestions, thank you! The only thing not needed is to save the image, as everything is stored outside the image in the /storage folder. So you loose nothing by replacing the image (when upgrading to a newer version for example).

avoiceofreason commented 6 months ago

I've only tried it once, but even with an existing previously installed data.img disk in /storage then the dockurr/windows image kicks into the install routine and re-installs windows

My suggestion is when you want to keep the existing install but just change a few container configs.

Unless I've missed something and you can force your image to bypass install and just run windows from data.img (??)

Oh and I forgot, think its mentioned in Issues somewhere but the SAMBA share doesn't work in WinXP due to SMB 1.0. So the RDP folder redirection is a useful alternative.

kroese commented 6 months ago

If you copy the whole folder, it should not reinstall anything? If you copy only the data.img (I cannot think of any good reason to do that) you can create a file called windows.boot in that folder and it will skip the install. For XP you would also need to create a file called windows.old so its much easier to just copy the whole folder instead of trying to put all the pieces back together.

Yes I noticed that the Samba share does not work in XP. I think it might be because I configured the minimal protocol version to SMB 2.0 and XP can only handle version 1.0? So it might be easy to fix, but I didnt think many people will use this container with XP so I didnt bother.

avoiceofreason commented 6 months ago

Retested the container rebuild. You are 100% correct. Windows booted with no install. No idea what happened the first time I tried that. Maybe document what each file in /storage is/does

I've noticed that I am getting the Windows disk checking option coming up on boot whenever I restart the container even though I am shutting down Windows first. Maybe some sync issue (?)

Thanks BTW, this project is super duper good.

Vann-Dev commented 6 months ago

Hi, has anyone found the full list of environment variables accepted by dockur/windows?

kroese commented 6 months ago

@Vann-Dev

VERSION="win11"          # Windows version
MANUAL="N"          # Automatic install
REGION=""           # Locale
KEYBOARD=""      # Keyboard layout
LANGUAGE=""     # UI language
USERNAME=""     #  Default username
PASSWORD=""        # Default password
SAMBA="Y"          # Enable Samba share
DISK_IO="native"          # I/O Mode, can be set to 'native', 'threads' or 'io_turing'
DISK_FMT="raw"               # Disk file format, can be set to "raw" (default) or "qcow2"
DISK_FLAGS=""             # Specifies the options for use with the qcow2 disk format
DISK_CACHE="none"         # Caching mode, can be set to 'writeback' for better performance
DISK_DISCARD="on"         # Controls whether unmap (TRIM) commands are passed to the host.
DISK_ROTATION="1"         # Rotation rate, set to 1 for SSD storage and increase for HDD
GPU="N"         # GPU passthrough
VGA="virtio"    # VGA adaptor
DISPLAY="web"   # Display type
MAC=""          # MAC address
DHCP="N"          # Disable DHCP mode
NETWORK="Y"          # Enable networkcard
HOST_PORTS=""
VM_NET_DEV=""
VM_NET_TAP="qemu"
VM_NET_HOST="QEMU"
DNSMASQ_OPTS=""
DNSMASQ="/usr/sbin/dnsmasq"
DNSMASQ_CONF_DIR="/etc/dnsmasq.d"
HV="Y"          # Enable Hyper-V enlightments
KVM="Y"          # Enable KVM acceleration
CPU_FLAGS=""
CPU_MODEL=""
DEBUG="N"         # Disable debugging
VERIFY="N"       # No checksum verification
MACHINE="q35"     # Machine selection
ALLOCATE="N"       # Preallocate diskspace
ARGUMENTS=""      # Extra QEMU parameters
CPU_CORES="1"     # Amount of CPU cores
RAM_SIZE="1G"     # Maximum RAM amount
DISK_SIZE="16G"            # Initial data disk size
BOOT_INDEX="10"            # Boot index of CD drive
TPM="Y"                  # Enable TPM
BOOT_MODE="windows"           # Boot mode
SERIAL="mon:stdio"
USB="qemu-xhci,id=xhci"
MONITOR="telnet:localhost:7100,server,nowait,nodelay"

You can see most of those in the code from https://github.com/qemus/qemu-docker if you want to see how they are used.