From 9228312eba29e7916d098add64205cff2f64a474 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sun, 7 Feb 2021 17:27:02 +0000 Subject: [PATCH 1/3] Add -e MAC_ADDRESS to change MAC_ADDRESS at runtime. --- CHANGELOG.md | 5 +++++ Dockerfile | 7 ++++--- README.md | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d3d5f98..2f3d60e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ |Version|Date|Notes| |---|---|---| +| |2021-02-07|Add MAC_ADDRESS environment variable.| +| |2021-02-03|Employ wget --no-verbose to avoid buffer overload in hub.docker.com.| +| |2021-02-03|Reduce build size.| +| |2021-01-27|Add OSX_COMMANDS to allow runtime commands on :auto image.| +| |2021-01-26|Removed most pointless VOLUME build commands.| |3.0|2021-01-23|Add fast mode boot straight to shell. And -v $PWD/disk.img:/image for all Dockerfiles| | |2021-01-22|Add additional helm chart instructions and files.| | |2021-01-15|Fix helm initial disk creation process and add installation instructions.| diff --git a/Dockerfile b/Dockerfile index 5eff72a..428ab5f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,6 +43,7 @@ # -e CORES=4 # -e EXTRA= # -e INTERNAL_SSH_PORT=10022 +# -e MAC_ADDRESS= # # Extra QEMU args: # @@ -177,7 +178,7 @@ RUN touch Launch.sh \ && tee -a Launch.sh <<< '-drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=qcow2 \' \ && tee -a Launch.sh <<< '-drive id=MacHDD,if=none,file=${IMAGE_PATH:-/home/arch/OSX-KVM/mac_hdd_ng.img},format=qcow2 \' \ && tee -a Launch.sh <<< '-device ide-hd,bus=sata.4,drive=MacHDD \' \ - && tee -a Launch.sh <<< '-netdev user,id=net0,hostfwd=tcp::${INTERNAL_SSH_PORT:-10022}-:22,hostfwd=tcp::${SCREEN_SHARE_PORT:-5900}-:5900, -device e1000-82545em,netdev=net0,id=net0,mac=52:54:00:09:49:17 \' \ + && tee -a Launch.sh <<< '-netdev user,id=net0,hostfwd=tcp::${INTERNAL_SSH_PORT:-10022}-:22,hostfwd=tcp::${SCREEN_SHARE_PORT:-5900}-:5900, -device e1000-82545em,netdev=net0,id=net0,mac=${MAC_ADDRESS:-52:54:00:09:49:17} \' \ && tee -a Launch.sh <<< '-monitor stdio \' \ && tee -a Launch.sh <<< '-vga vmware \' \ && tee -a Launch.sh <<< '${EXTRA:-}' @@ -187,12 +188,12 @@ RUN grep -v InstallMedia ./Launch.sh > ./Launch-nopicker.sh \ && chmod +x ./Launch-nopicker.sh \ && sed -i -e s/OpenCore\.qcow2/OpenCore\-nopicker\.qcow2/ ./Launch-nopicker.sh +USER arch + ENV USER arch ENV DISPLAY=:0.0 -USER arch - ENV IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img VOLUME ["/tmp/.X11-unix"] diff --git a/README.md b/README.md index 49a5ba0..8134bbd 100644 --- a/README.md +++ b/README.md @@ -66,8 +66,25 @@ docker run -it \ # Wait 2-3 minutes until you drop into the shell. ``` + ```bash +docker pull sickcodes/docker-osx:auto + +# boot to OSX shell + display (19GB) +docker run -it \ + --device /dev/kvm \ + -p 50922:10022 \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + sickcodes/docker-osx:auto + +``` + +```bash + +docker pull sickcodes/docker-osx:auto + # boot to OSX shell + display (19GB) + commands to run inside OSX docker run -it \ --device /dev/kvm \ @@ -581,12 +598,18 @@ docker build -t docker-osx:latest \ Pass any devices/directories to the Docker container & the QEMU arguments using the handy `-e EXTRA=` runtime options. ```bash +# example customizations docker run \ -e RAM=4 \ -e SMP=4 \ -e CORES=4 \ -e EXTRA='-usb -device usb-host,hostbus=1,hostaddr=8' \ -e INTERNAL_SSH_PORT=23 \ + -e MAC_ADDRESS="$(xxd -c1 -p -l 6 /dev/urandom | tr '\n' ':' | cut -c1-17)" \ + -e AUDIO_DRIVER=alsa \ + -e IMAGE_PATH=/image \ + -e SCREEN_SHARE_PORT=5900 \ + -e DISPLAY=:0 \ --device /dev/kvm \ --device /dev/snd \ -v /tmp/.X11-unix:/tmp/.X11-unix \ From 9a1cbbff9500bd2c07efcc45cbc3637910ae327e Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sun, 7 Feb 2021 17:59:24 +0000 Subject: [PATCH 2/3] Remove pacman -Scc until later. --- Dockerfile | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Dockerfile b/Dockerfile index 428ab5f..fb1f86a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -65,16 +65,18 @@ ARG VERSION=10.15.6 ARG RANKMIRRORS ARG MIRROR_COUNTRY=US ARG MIRROR_COUNT=10 -RUN if [[ "${RANKMIRRORS}" ]]; then { pacman -Sy wget --noconfirm || pacman -Syu wget --noconfirm ; } \ - ; wget -O ./rankmirrors "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/rankmirrors" \ - ; wget -O- "https://www.archlinux.org/mirrorlist/?country=${MIRROR_COUNTRY:-US}&protocol=https&use_mirror_status=on" \ - | sed -e 's/^#Server/Server/' -e '/^#/d' \ - | head -n "$((${MIRROR_COUNT:-10}+1))" \ - | bash ./rankmirrors --verbose --max-time 5 - > /etc/pacman.d/mirrorlist \ - && tee -a /etc/pacman.d/mirrorlist <<< 'Server = http://mirrors.evowise.com/archlinux/$repo/os/$arch' \ - && tee -a /etc/pacman.d/mirrorlist <<< 'Server = http://mirror.rackspace.com/archlinux/$repo/os/$arch' \ - && tee -a /etc/pacman.d/mirrorlist <<< 'Server = https://mirror.rackspace.com/archlinux/$repo/os/$arch' \ - && cat /etc/pacman.d/mirrorlist ; fi +RUN if [[ "${RANKMIRRORS}" ]]; then \ + { pacman -Sy wget --noconfirm || pacman -Syu wget --noconfirm ; } \ + ; wget -O ./rankmirrors "https://raw.githubusercontent.com/sickcodes/Docker-OSX/master/rankmirrors" \ + ; wget -O- "https://www.archlinux.org/mirrorlist/?country=${MIRROR_COUNTRY:-US}&protocol=https&use_mirror_status=on" \ + | sed -e 's/^#Server/Server/' -e '/^#/d' \ + | head -n "$((${MIRROR_COUNT:-10}+1))" \ + | bash ./rankmirrors --verbose --max-time 5 - > /etc/pacman.d/mirrorlist \ + && tee -a /etc/pacman.d/mirrorlist <<< 'Server = http://mirrors.evowise.com/archlinux/$repo/os/$arch' \ + && tee -a /etc/pacman.d/mirrorlist <<< 'Server = http://mirror.rackspace.com/archlinux/$repo/os/$arch' \ + && tee -a /etc/pacman.d/mirrorlist <<< 'Server = https://mirror.rackspace.com/archlinux/$repo/os/$arch' \ + && cat /etc/pacman.d/mirrorlist \ + ; fi # This fails on hub.docker.com, useful for debugging in cloud # RUN [[ $(egrep -c '(svm|vmx)' /proc/cpuinfo) -gt 0 ]] || { echo KVM not possible on this host && exit 1; } @@ -82,9 +84,7 @@ RUN if [[ "${RANKMIRRORS}" ]]; then { pacman -Sy wget --noconfirm || pacman -Syu RUN tee -a /etc/pacman.conf <<< '[community-testing]' \ && tee -a /etc/pacman.conf <<< 'Include = /etc/pacman.d/mirrorlist' -RUN pacman -Syu --noconfirm \ - && pacman -S sudo git vim nano alsa-utils openssh --noconfirm \ - && yes | pacman -Scc \ +RUN pacman -Syu sudo git vim nano alsa-utils openssh --noconfirm \ && ln -s /bin/vim /bin/vi \ && useradd arch -p arch \ && tee -a /etc/sudoers <<< 'arch ALL=(ALL) NOPASSWD: ALL' \ @@ -138,7 +138,7 @@ RUN touch enable-ssh.sh \ # RUN yes | sudo pacman -Syu qemu libvirt dnsmasq virt-manager bridge-utils edk2-ovmf netctl libvirt-dbus --overwrite --noconfirm RUN yes | sudo pacman -Syu qemu libvirt dnsmasq virt-manager bridge-utils openresolv jack ebtables edk2-ovmf netctl libvirt-dbus --overwrite --noconfirm \ - ; yes | sudo pacman -Scc + && yes | sudo pacman -Scc # RUN sudo systemctl enable libvirtd.service # RUN sudo systemctl enable virtlogd.service From 7eb821dcc3145d5f3f39075327f0cf2804526480 Mon Sep 17 00:00:00 2001 From: sickcodes Date: Sun, 7 Feb 2021 19:25:59 +0000 Subject: [PATCH 3/3] Add -e NOPICKER=false for the :naked image to be able to enter boot menu. --- CHANGELOG.md | 1 + Dockerfile.naked | 37 ++++++++++++++++++++++++------------- README.md | 16 +++++++++++++++- 3 files changed, 40 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2f3d60e..5b9b64c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ |Version|Date|Notes| |---|---|---| +| |2021-02-07|Add NOPICKER environment variable to :naked image for effortless boot toggling.| | |2021-02-07|Add MAC_ADDRESS environment variable.| | |2021-02-03|Employ wget --no-verbose to avoid buffer overload in hub.docker.com.| | |2021-02-03|Reduce build size.| diff --git a/Dockerfile.naked b/Dockerfile.naked index 9966c33..feae2b4 100644 --- a/Dockerfile.naked +++ b/Dockerfile.naked @@ -55,15 +55,25 @@ RUN if [[ "${RANKMIRRORS}" ]]; then { pacman -Sy wget --noconfirm || pacman -Syu && tee -a /etc/pacman.d/mirrorlist <<< 'Server = https://mirror.rackspace.com/archlinux/$repo/os/$arch' \ && cat /etc/pacman.d/mirrorlist ; fi -RUN pacman -Syu xorg-server-xvfb xterm xorg-xhost xorg-xrandr xdotool sshpass scrot base-devel --noconfirm +# For taking screenshots of the Xfvb screen, useful during development. +ARG SCROT -RUN git clone https://github.com/stolk/imcat.git \ - && cd imcat \ - && make \ - && sudo cp imcat /usr/bin/imcat \ - && touch /usr/bin/scrotcat \ - && tee -a /usr/bin/scrotcat <<< '/usr/bin/imcat <(scrot -o /dev/stdout)' \ - && chmod +x /usr/bin/scrotcat +RUN pacman -Syu xorg-server-xvfb wget xterm xorg-xhost xorg-xrandr sshpass --noconfirm \ + && if [[ "${SCROT}" ]]; then \ + pacman -Syu scrot base-devel --noconfirm \ + && git clone https://github.com/stolk/imcat.git \ + && cd imcat \ + && make \ + && sudo cp imcat /usr/bin/imcat \ + && touch /usr/bin/scrotcat \ + && tee -a /usr/bin/scrotcat <<< '/usr/bin/imcat <(scrot -o /dev/stdout)' \ + && chmod +x /usr/bin/scrotcat \ + ; else \ + touch /usr/bin/scrotcat \ + && echo echo >> /usr/bin/scrotcat \ + && chmod +x /usr/bin/scrotcat \ + ; fi \ + ; yes | pacman -Scc USER arch @@ -79,16 +89,17 @@ RUN mkdir -p ~/.ssh \ WORKDIR /home/arch/OSX-KVM -ARG NOPICKER=true - -RUN [[ "${NOPICKER}" = true ]] && mv ./Launch-nopicker.sh ./Launch.sh +ENV NOPICKER=true ENV DISPLAY=:99 ENV IMAGE_PATH=/image -CMD [[ "${DISPLAY}" = ':99' ]] && { nohup Xvfb :99 -screen 0 1920x1080x16 \ - & until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 1 ; done ; } \ +CMD [[ "${DISPLAY}" = ':99' ]] && { \ + nohup Xvfb :99 -screen 0 1920x1080x16 \ + & until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 1 ; done \ + ; } \ ; sudo chown "$(id -u)":"$(id -g)" "${IMAGE_PATH}" 2>/dev/null || true \ ; ./enable-ssh.sh \ + ; [[ "${NOPICKER}" == true ]] && mv ./Launch-nopicker.sh ./Launch.sh \ ; envsubst < ./Launch.sh | bash diff --git a/README.md b/README.md index 8134bbd..57ad3fc 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,10 @@ docker start -i containerid # Quick Start Own Image -Supply your image with `-v "${PWD}/mac_hdd_ng.img:/image"` and use `sickcodes/docker-osx:naked` +Supply your own local image with `-v "${PWD}/mac_hdd_ng.img:/image"` and use `sickcodes/docker-osx:naked` + +- Naked image is for booting any existing .img file. +- By default, this image has a variable called `NOPICKER` which is `"true"`. Use `-e NOPICKER=false` or any other string than the word `true` to enter the boot menu. This lets you use other disks instead of skipping the boot menu, e.g. recovery disk. ```bash docker pull sickcodes/docker-osx:naked @@ -124,6 +127,17 @@ docker run -it \ -v /tmp/.X11-unix:/tmp/.X11-unix \ -e "DISPLAY=${DISPLAY:-:0.0}" \ sickcodes/docker-osx:naked + +# run local copy of the auto image + SSH + Boot menu +docker run -it \ + --device /dev/kvm \ + -p 50922:10022 \ + -v "${PWD}/mac_hdd_ng_auto.img:/image" \ + -v /tmp/.X11-unix:/tmp/.X11-unix \ + -e "DISPLAY=${DISPLAY:-:0.0}" \ + -e "NOPICKER=false" \ + sickcodes/docker-osx:naked + ``` ```bash # run your own image headless + SSH