diff --git a/docker-compose.yml b/docker-compose.yml index fd242ea..25e34f2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,7 +8,6 @@ services: RAM_SIZE: "1G" CPU_CORES: "1" DISK_SIZE: "16G" - DISK_FMT: "qcow2" BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-standard-3.18.2-x86_64.iso" devices: - /dev/kvm diff --git a/readme.md b/readme.md index 007a31d..9df6ee5 100644 --- a/readme.md +++ b/readme.md @@ -32,8 +32,6 @@ services: image: qemux/qemu-docker:latest environment: DISPLAY: "vnc" - DISK_SIZE: "16G" - DISK_FMT: "qcow2" BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-standard-3.18.2-x86_64.iso" devices: - /dev/kvm @@ -48,7 +46,7 @@ services: Via `docker run` ```bash -docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm --cap-add NET_ADMIN qemux/qemu-docker:latest +docker run -it --rm -e "BOOT=http://www.example.com/image.iso" -p 5900:5900 --device=/dev/kvm --cap-add NET_ADMIN qemux/qemu-docker:latest ``` ## FAQ @@ -66,7 +64,7 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm * ### How do I change the size of the data disk? - To expand the default size of 16 GB, locate the `DISK_SIZE` setting in your compose file and modify it to your preferred capacity: + 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: @@ -86,17 +84,6 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm Replace the example path `/home/user/data` with the desired storage folder. - * ### How do I create a growable disk? - - By default, the entire capacity of the disk is reserved in advance. To create a growable disk that only allocates space that is actually used, add the following environment variable: - - ```yaml - environment: - DISK_FMT: "qcow2" - ``` - - This can also be used to convert any existing disks to the ```qcow2``` format. - * ### How do I increase the amount of CPU or RAM? By default, a single core and 1 GB of RAM are allocated to the container. To increase this, add the following environment variables: @@ -184,6 +171,17 @@ docker run -it --rm -e "BOOT=http://www.example.com/image.iso" --device=/dev/kvm Afterwards you can connect with any VNC client to port 5900. + * ### How do I passthrough the GPU? + + To passthrough your Intel GPU, add the following lines to your compose file: + + ```yaml + environment: + GPU: "Y" + devices: + - /dev/dri + ``` + * ### How do I provide custom arguments to QEMU? You can create the `ARGUMENTS` environment variable to provide additional arguments to QEMU at runtime: diff --git a/src/disk.sh b/src/disk.sh index ba31365..a239a73 100644 --- a/src/disk.sh +++ b/src/disk.sh @@ -4,7 +4,7 @@ set -Eeuo pipefail # Docker environment variables : ${DISK_IO:='native'} # I/O Mode, can be set to 'native', 'threads' or 'io_turing' -: ${DISK_FMT:='raw'} # Disk file format, "raw" by default for backwards compatibility +: ${DISK_FMT:=''} # Disk file format, can be set to "raw" or "qcow2" (default) : ${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 @@ -261,6 +261,14 @@ addDisk () { return 0 } +if [ -z "$DISK_FMT" ]; then + if [ -f "$STORAGE/data.img" ]; then + DISK_FMT="raw" + else + DISK_FMT="qcow2" + fi +fi + DISK_EXT="$(fmt2ext "$DISK_FMT")" || exit $? DISK1_FILE="$STORAGE/data"