Skip to content

Commit

Permalink
feat: Add web-based VNC viewer (#308)
Browse files Browse the repository at this point in the history
  • Loading branch information
kroese authored Jan 7, 2024
1 parent 361f605 commit a32bc2d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 29 deletions.
61 changes: 36 additions & 25 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,27 +64,29 @@ docker run -it --rm -e "DISPLAY=vnc" -e "BOOT=http://example.com/image.iso" -p 5

It will be downloaded only once, during the initial run of the container.

* ### How do I change the size of the data disk?
* ### How do I interact with the VM?

To expand the default size of 16 GB, add the `DISK_SIZE` setting to your compose file and set it to your preferred capacity:
If you just need text-based output you can use the Docker console, or connect via SSH.

If you need graphical output, you can enable VNC by adding the following lines to your compose file:

```yaml
environment:
DISK_SIZE: "128G"
DISPLAY: "vnc"
ports:
- 5900:5900
```

This can also be used to resize the existing disk to a larger capacity without any data loss.

* ### How do I change the location of the data disk?

To change the location of the data disk, include the following bind mount in your compose file:
If you want to enable the web-based VNC viewer, so that you do not need to install any client software, add the following lines to your compose file instead:

```yaml
volumes:
- /var/qemu:/storage
environment:
DISPLAY: "web"
ports:
- 8006:8006
```

Replace the example path `/var/qemu` with the desired storage folder.
Afterwards you can visit [http://localhost:8006/vnc.html](http://localhost:8006/vnc.html) using any webbrowser to view the screen of the VM and interact with it via the keyboard/mouse.

* ### How do I increase the amount of CPU or RAM?

Expand All @@ -98,6 +100,28 @@ docker run -it --rm -e "DISPLAY=vnc" -e "BOOT=http://example.com/image.iso" -p 5
CPU_CORES: "4"
```

* ### How do I change the size of the data disk?

To expand the default size of 16 GB, add the `DISK_SIZE` setting to your compose file and set it to your preferred capacity:

```yaml
environment:
DISK_SIZE: "128G"
```

This can also be used to resize the existing disk to a larger capacity without any data loss.

* ### How do I change the location of the data disk?

To change the location of the data disk, include the following bind mount in your compose file:

```yaml
volumes:
- /var/qemu:/storage
```

Replace the example path `/var/qemu` with the desired storage folder.

* ### How do I verify if my system supports KVM?

To verify if your system supports KVM, run the following commands:
Expand Down Expand Up @@ -160,19 +184,6 @@ docker run -it --rm -e "DISPLAY=vnc" -e "BOOT=http://example.com/image.iso" -p 5

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
environment:
DISPLAY: "vnc"
ports:
- 5900:5900
```

Afterwards you can connect with any VNC client to port 5900.

* ### How do I boot with UEFI?

To enable UEFI booting, add the following line to your compose file:
Expand All @@ -182,7 +193,7 @@ docker run -it --rm -e "DISPLAY=vnc" -e "BOOT=http://example.com/image.iso" -p 5
BOOT_MODE: "uefi"
```

You can also set this to ```secure``` to enable secure boot, or to ```windows``` to enable Windows 11 booting.
You can also set this to ```windows``` to enable Windows booting.

* ### How do I provide custom arguments to QEMU?

Expand Down
3 changes: 1 addition & 2 deletions src/display.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ case "${DISPLAY,,}" in
DISPLAY_OPTS="-display vnc=:0 -vga virtio"
;;
web)
addPackage "novnc" "NoVNC"
addPackage "websockify" "Websockify"
addPackage "novnc" "web-based VNC client"
DISPLAY_OPTS="-display vnc=:0 -vga virtio"
;;
*)
Expand Down
4 changes: 2 additions & 2 deletions src/entry.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
set -Eeuo pipefail

echo "❯ Starting QEMU for Docker v$(</run/version)..."
echo "❯ For support visit https://github.com/qemus/qemu-docker/"
echo "❯ For support visit https://github.com/qemus/qemu-docker"

cd /run

Expand All @@ -18,7 +18,7 @@ cd /run
trap - ERR

if [[ "${DISPLAY,,}" == "web" ]]; then
websockify -D --web /usr/share/novnc/ 8006 localhost:5900
websockify -D --web /usr/share/novnc/ 8006 localhost:5900 >/dev/null
fi

info "Booting image using $VERS..."
Expand Down

0 comments on commit a32bc2d

Please sign in to comment.