diff --git a/Dockerfile.m4 b/Dockerfile.m4 index 3c6f94a..bd78245 100644 --- a/Dockerfile.m4 +++ b/Dockerfile.m4 @@ -59,16 +59,13 @@ RUN export DEBIAN_FRONTEND=noninteractive \ && rm -rf /var/lib/apt/lists/* # Environment -ENV QEMU_VM_CPU=2 -ENV QEMU_VM_RAM=1024M -ENV QEMU_VM_DISK_SIZE=16G -ENV QEMU_VM_DISK_FORMAT=qcow2 -ENV QEMU_VM_KEYBOARD=en-us -ENV QEMU_VM_NET_DEVICE=e1000 -ENV QEMU_VM_NET_OPTIONS=hostfwd=tcp::13389-:3389,hostfwd=tcp::15900-:5900 -ENV QEMU_VM_BOOT_ORDER=cd -ENV QEMU_VM_BOOT_MENU=off -ENV QEMU_VM_KVM=false +ENV VM_CPU=2 +ENV VM_RAM=1024M +ENV VM_DISK_SIZE=16G +ENV VM_KEYBOARD=en-us +ENV VM_NET_OPTIONS=hostfwd=tcp::13389-:3389,hostfwd=tcp::15900-:5900 +ENV VM_BOOT_ORDER=cd +ENV VM_KVM=false # Create some directories for QEMU RUN mkdir -p /var/lib/qemu/iso/ /var/lib/qemu/images/ @@ -85,12 +82,7 @@ COPY --from=build --chown=root:root /tmp/reactos.iso /var/lib/qemu/iso/reactos.i # Copy services COPY --chown=root:root ./scripts/service/ /etc/service/ -# Copy scripts +# Copy bin scripts COPY --chown=root:root ./scripts/bin/ /usr/local/bin/ -# VNC -EXPOSE 5900/tcp -# noVNC -EXPOSE 6080/tcp - -CMD ["/usr/local/bin/container-foreground-cmd"] +ENTRYPOINT ["/usr/local/bin/container-init"] diff --git a/README.md b/README.md index e25ae59..7b48409 100644 --- a/README.md +++ b/README.md @@ -6,39 +6,31 @@ A Docker image for the [ReactOS](https://www.reactos.org) operating system. ```sh docker run --detach \ --name qemu-reactos \ - --restart on-failure:3 \ --publish 127.0.0.1:6080:6080/tcp \ - --env QEMU_VM_KVM=true --device /dev/kvm \ + --env VM_KVM=true --device /dev/kvm \ docker.io/hectormolinero/qemu-reactos:latest ``` -> The instance will be available through a web browser from: http://localhost:6080/vnc.html + +> The instance can be accessed from: +> * 6080/TCP (noVNC): http://127.0.0.1:6080/vnc.html ## Environment variables -#### `QEMU_VM_CPU` +#### `VM_CPU` Number of cores the VM is permitted to use (`2` by default). -#### `QEMU_VM_RAM` +#### `VM_RAM` Amount of memory the VM is permitted to use (`1024M` by default). -#### `QEMU_VM_DISK_SIZE` +#### `VM_DISK_SIZE` VM disk size (`16G` by default). -#### `QEMU_VM_DISK_FORMAT` -VM disk format (`qcow2` by default). - -#### `QEMU_VM_KEYBOARD` +#### `VM_KEYBOARD` VM keyboard layout (`en-us` by default). -#### `QEMU_VM_NET_DEVICE` -VM network device (`e1000` by default). - -#### `QEMU_VM_BOOT_ORDER` +#### `VM_BOOT_ORDER` VM boot order (`cd` by default). -#### `QEMU_VM_BOOT_MENU` -VM boot menu (`off` by default). - -#### `QEMU_VM_KVM` +#### `VM_KVM` Start QEMU in KVM mode (`false` by default). > The `--device /dev/kvm` option is required to use KVM in the container. diff --git a/run.sh b/run.sh index a521757..0a47654 100755 --- a/run.sh +++ b/run.sh @@ -39,8 +39,7 @@ printf -- '%s\n' "Creating \"${CONTAINER_NAME:?}\" container..." --log-opt max-size=32m \ --publish '127.0.0.1:5900:5900/tcp' \ --publish '127.0.0.1:6080:6080/tcp' \ - --publish '127.0.0.1:15900:15900/tcp' \ - --env QEMU_VM_KVM=true --device /dev/kvm \ + --env VM_KVM=true --device /dev/kvm \ "${IMAGE_NAME:?}" "$@" >/dev/null printf -- '%s\n\n' 'Done!' diff --git a/scripts/bin/container-foreground-cmd b/scripts/bin/container-init similarity index 58% rename from scripts/bin/container-foreground-cmd rename to scripts/bin/container-init index e74504a..fc88c9a 100755 --- a/scripts/bin/container-foreground-cmd +++ b/scripts/bin/container-init @@ -4,7 +4,7 @@ set -eu # Create ReactOS disk if [ ! -f /var/lib/qemu/images/reactos.img ]; then - qemu-img create -f "${QEMU_VM_DISK_FORMAT:?}" /var/lib/qemu/images/reactos.img "${QEMU_VM_DISK_SIZE:?}" + qemu-img create -f qcow2 /var/lib/qemu/images/reactos.img "${VM_DISK_SIZE:?}" fi # Start all services diff --git a/scripts/service/qemu/run b/scripts/service/qemu/run index e39d019..f7ad789 100755 --- a/scripts/service/qemu/run +++ b/scripts/service/qemu/run @@ -2,20 +2,23 @@ set -eu -QEMU=$(command -v qemu-system-x86_64) -QEMU_ARGS="${QEMU_ARGS-} -smp ${QEMU_VM_CPU:?} -m ${QEMU_VM_RAM:?}" -QEMU_ARGS="${QEMU_ARGS-} -vga std -display vnc=:0" -QEMU_ARGS="${QEMU_ARGS-} -drive file=/var/lib/qemu/images/reactos.img,index=0,media=disk,format=${QEMU_VM_DISK_FORMAT:?}" -QEMU_ARGS="${QEMU_ARGS-} -drive file=/var/lib/qemu/iso/reactos.iso,index=2,media=cdrom,format=raw" -QEMU_ARGS="${QEMU_ARGS-} -boot order=${QEMU_VM_BOOT_ORDER:?},menu=${QEMU_VM_BOOT_MENU:?},splash-time=5000" -QEMU_ARGS="${QEMU_ARGS-} -netdev user,id=n0,${QEMU_VM_NET_OPTIONS:?} -device ${QEMU_VM_NET_DEVICE:?},netdev=n0" -QEMU_ARGS="${QEMU_ARGS-} -usb -device usb-tablet" -QEMU_ARGS="${QEMU_ARGS-} -k ${QEMU_VM_KEYBOARD:?}" +set -- +set -- "$@" -smp "${VM_CPU:?}" -m "${VM_RAM:?}" +set -- "$@" -serial stdio -device VGA -display vnc=:0 +set -- "$@" -drive file=/var/lib/qemu/images/reactos.img,index=0,media=disk,format=qcow2 +set -- "$@" -drive file=/var/lib/qemu/iso/reactos.iso,index=2,media=cdrom,format=raw +set -- "$@" -boot order="${VM_BOOT_ORDER:?}",menu=off +set -- "$@" -netdev user,id=n0,"${VM_NET_OPTIONS:?}" +set -- "$@" -device e1000,netdev=n0 +set -- "$@" -usb -device usb-tablet +set -- "$@" -k "${VM_KEYBOARD:?}" -if [ "${QEMU_VM_KVM:?}" = true ] && [ -c /dev/kvm ]; then - QEMU_ARGS="${QEMU_ARGS-} -enable-kvm" +if [ "${VM_KVM:?}" = true ] && [ -c /dev/kvm ]; then + set -- "$@" -accel kvm +else + set -- "$@" -accel tcg fi cd /var/lib/qemu/ exec 2>&1 -exec "${QEMU:?}" ${QEMU_ARGS:?} +exec /usr/bin/qemu-system-x86_64 "$@"