From efa190a3fbf4e564cac6221771692986600cc3f8 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 20 Nov 2023 11:11:20 +0100 Subject: [PATCH 1/9] build: Remove wildcard --- Dockerfile | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Dockerfile b/Dockerfile index 96895ba..2914f67 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,12 +18,7 @@ RUN apt-get update && apt-get -y upgrade && \ && apt-get clean \ && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* -# Using a wildcard causes caching problems on some systems -COPY src/disk.sh /run/ -COPY src/display.sh /run/ -COPY src/entry.sh /run/ -COPY src/install.sh /run/ -COPY src/network.sh /run/ +COPY ./src /run/ RUN chmod +x /run/*.sh VOLUME /storage From 9111c0f419c82c3f0b93e02a845dcb6d2883fffe Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 20 Nov 2023 12:13:08 +0100 Subject: [PATCH 2/9] fix: Map SSH to alternative port --- docker-compose.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker-compose.yml b/docker-compose.yml index 3fa57b3..46a155b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -18,7 +18,7 @@ services: cap_add: - NET_ADMIN ports: - - 22:22 + - 2222:22 - 5900:5900 restart: on-failure stop_grace_period: 1m From a60b3cdd77dee0f7d9ac577a7809fc27138ea88e Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 20 Nov 2023 12:23:42 +0100 Subject: [PATCH 3/9] docs: Add VNC to compose file --- readme.md | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/readme.md b/readme.md index 6da3ff9..2a79a99 100644 --- a/readme.md +++ b/readme.md @@ -28,6 +28,7 @@ services: container_name: qemu image: qemux/qemu-docker:latest environment: + DISPLAY: "vnc" DISK_SIZE: "16G" BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-standard-3.18.2-x86_64.iso" devices: @@ -35,7 +36,8 @@ services: cap_add: - NET_ADMIN ports: - - 22:22 + - 2222:22 + - 5900:5900 restart: on-failure ``` @@ -124,8 +126,19 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm ``` If you receive an error from `kvm-ok` indicating that KVM acceleration can't be used, check your BIOS settings. + + * ### How can I connect with VNC? + + To enable VNC, add the following lines to your compose file: + + ```yaml + environment: + DISPLAY: "vnc" + ports: + 5900:5900 + ``` - * ### How do I provide extra arguments to QEMU? + * ### How do I provide custom arguments to QEMU? You can create the `ARGUMENTS` environment variable to provide additional arguments to QEMU at runtime: @@ -187,17 +200,6 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm Please note that even if you don't need DHCP, it's still recommended to enable this feature as it prevents NAT issues and increases performance by using a `macvtap` interface. - * ### How can I connect with VNC? - - To enable VNC, add the following lines to your compose file: - - ```yaml - ports: - "5900:5900" - environment: - DISPLAY: "vnc" - ``` - [build_url]: https://github.com/qemu-tools/qemu-docker/ [hub_url]: https://hub.docker.com/r/qemux/qemu-docker/ [tag_url]: https://hub.docker.com/r/qemux/qemu-docker/tags From eb48ae4555ac8c97191283b6b9d2ff65034e9782 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 20 Nov 2023 12:31:32 +0100 Subject: [PATCH 4/9] fix: Empty line --- src/entry.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/src/entry.sh b/src/entry.sh index 2ba5d3e..00f41b1 100755 --- a/src/entry.sh +++ b/src/entry.sh @@ -69,7 +69,6 @@ ARGS=$(echo "$ARGS" | sed 's/\t/ /g' | tr -s ' ') trap - ERR info "Booting image using ${VERS}..." - [[ "${DEBUG}" == [Yy1]* ]] && set -x exec qemu-system-x86_64 ${ARGS:+ $ARGS} { set +x; } 2>/dev/null From 46c456dafcb33577a22b4104432806abf02ec73c Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 20 Nov 2023 12:41:54 +0100 Subject: [PATCH 5/9] fix: Display configuration --- src/entry.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entry.sh b/src/entry.sh index 00f41b1..9074d69 100755 --- a/src/entry.sh +++ b/src/entry.sh @@ -33,8 +33,8 @@ cd /run . install.sh # Get bootdisk . disk.sh # Initialize disks -. network.sh # Initialize network . display.sh # Initialize display +. network.sh # Initialize network KVM_ERR="" KVM_OPTS="" From 899a9cf6c45900b9b44975d24fcbfab1345912c4 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 20 Nov 2023 12:45:37 +0100 Subject: [PATCH 6/9] fix: Ignore casing --- src/display.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/display.sh b/src/display.sh index 3e6f758..237b184 100644 --- a/src/display.sh +++ b/src/display.sh @@ -5,7 +5,7 @@ set -Eeuo pipefail : ${DISPLAY:='none'} # Display type -case "$DISPLAY" in +case "${DISPLAY,,}" in vnc) DISPLAY_OPTS="-nographic -vga std -vnc :0" ;; From 12335bd7433cea738af6ac653fb89c88c787c109 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 20 Nov 2023 12:53:16 +0100 Subject: [PATCH 7/9] fix: Automaticly set controlport --- src/network.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/network.sh b/src/network.sh index 6ae1cef..30f2fc1 100644 --- a/src/network.sh +++ b/src/network.sh @@ -148,6 +148,10 @@ configureNAT () { ip link set dev "${VM_NET_TAP}" master dockerbridge + if [[ -z "${CONTROL_PORTS}" ]] && [[ "${DISPLAY,,}" == "vnc" ]]; then + CONTROL_PORTS='5900' + fi + CONTROL_PORT_ARGS='' for PORT in $CONTROL_PORTS ; do CONTROL_PORT_ARGS="$CONTROL_PORT_ARGS ! --dport $PORT" From 81c218e28ad29f9263759ee73199dc05b8a8e3b8 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 20 Nov 2023 12:55:47 +0100 Subject: [PATCH 8/9] fix: Remove controlport --- docker-compose.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index 46a155b..43e0c37 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,12 +4,11 @@ services: container_name: qemu image: qemux/qemu-docker:latest environment: + DISPLAY: "vnc" CPU_CORES: "1" RAM_SIZE: "512M" DISK_SIZE: "16G" BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-standard-3.18.2-x86_64.iso" - DISPLAY: "vnc" - CONTROL_PORTS: "5900" devices: - /dev/kvm - /dev/vhost-net From 0e96abc54ec2b0031b4d6a710403afe91d92f815 Mon Sep 17 00:00:00 2001 From: Kroese Date: Mon, 20 Nov 2023 12:58:33 +0100 Subject: [PATCH 9/9] docs: Ports --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 2a79a99..4eba695 100644 --- a/readme.md +++ b/readme.md @@ -135,7 +135,7 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm environment: DISPLAY: "vnc" ports: - 5900:5900 + - 5900:5900 ``` * ### How do I provide custom arguments to QEMU?