docs: Mention qcow2 (#229)

* docs: Mention qcow2
This commit is contained in:
Kroese 2023-12-09 03:14:56 +01:00 committed by GitHub
parent 16b285fd24
commit 8d21f0e5f9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 37 additions and 33 deletions

View file

@ -8,6 +8,7 @@ services:
RAM_SIZE: "1G" RAM_SIZE: "1G"
CPU_CORES: "1" CPU_CORES: "1"
DISK_SIZE: "16G" 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" BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-standard-3.18.2-x86_64.iso"
devices: devices:
- /dev/kvm - /dev/kvm

View file

@ -33,6 +33,7 @@ services:
environment: environment:
DISPLAY: "vnc" DISPLAY: "vnc"
DISK_SIZE: "16G" 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" BOOT: "https://dl-cdn.alpinelinux.org/alpine/v3.18/releases/x86_64/alpine-standard-3.18.2-x86_64.iso"
devices: devices:
- /dev/kvm - /dev/kvm
@ -85,6 +86,17 @@ 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. Replace the example path `/home/user/data` with the desired storage folder.
* ### How do I create a growable disk?
By default, the entire disk space 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? * ### 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: By default, a single core and 1 GB of RAM are allocated to the container. To increase this, add the following environment variables:
@ -106,37 +118,6 @@ 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. 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
```
Afterwards you can connect with any VNC client to port 5900.
* ### How do I provide custom arguments to QEMU?
You can create the `ARGUMENTS` environment variable to provide additional arguments to QEMU at runtime:
```yaml
environment:
ARGUMENTS: "-usbdevice tablet"
```
* ### How can I use qcow2 disk files?
Add the following lines to your compose file
```yaml
environment:
DISK_FMT: "qcow2"
```
* ### How do I assign an individual IP address to the container? * ### How do I assign an individual IP address to the container?
By default, the container uses bridge networking, which shares the IP address with the host. By default, the container uses bridge networking, which shares the IP address with the host.
@ -190,6 +171,28 @@ 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. 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 provide custom arguments to QEMU?
You can create the `ARGUMENTS` environment variable to provide additional arguments to QEMU at runtime:
```yaml
environment:
ARGUMENTS: "-usbdevice tablet"
```
[build_url]: https://github.com/qemu-tools/qemu-docker/ [build_url]: https://github.com/qemu-tools/qemu-docker/
[hub_url]: https://hub.docker.com/r/qemux/qemu-docker/ [hub_url]: https://hub.docker.com/r/qemux/qemu-docker/
[tag_url]: https://hub.docker.com/r/qemux/qemu-docker/tags [tag_url]: https://hub.docker.com/r/qemux/qemu-docker/tags

View file

@ -107,7 +107,7 @@ resizeDisk() {
if (( REQ > SPACE )); then if (( REQ > SPACE )); then
error "Not enough free space to resize ${DISK_DESC} to ${DISK_SPACE} in ${DIR}, it has only ${SPACE_GB} GB available.." error "Not enough free space to resize ${DISK_DESC} to ${DISK_SPACE} in ${DIR}, it has only ${SPACE_GB} GB available.."
error "Specify a smaller ${DISK_DESC^^}_SIZE or disable preallocation with ALLOCATE=N." && exit 84 error "Specify a smaller ${DISK_DESC^^}_SIZE or switch to a growable disk with DISK_FMT=qcow2." && exit 84
fi fi
# Resize file by allocating more space # Resize file by allocating more space
@ -173,7 +173,7 @@ createDisk() {
if (( DATA_SIZE > SPACE )); then if (( DATA_SIZE > SPACE )); then
error "Not enough free space to create ${DISK_DESC} of ${DISK_SPACE} in ${DIR}, it has only ${SPACE_GB} GB available.." error "Not enough free space to create ${DISK_DESC} of ${DISK_SPACE} in ${DIR}, it has only ${SPACE_GB} GB available.."
error "Specify a smaller ${DISK_DESC^^}_SIZE or disable preallocation with ALLOCATE=N." && exit 86 error "Specify a smaller ${DISK_DESC^^}_SIZE or switch to a growable disk with DISK_FMT=qcow2." && exit 86
fi fi
# Create an empty file # Create an empty file