mirror of
https://github.com/sickcodes/Docker-OSX.git
synced 2024-12-22 14:01:33 -06:00
Merge pull request #145 from sickcodes/mac_address
Add -e MAC_ADDRESS to change MAC_ADDRESS at runtime.
This commit is contained in:
commit
70744ea3e3
@ -1,5 +1,11 @@
|
|||||||
|Version|Date|Notes|
|
|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.|
|
||||||
|
| |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|
|
|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-22|Add additional helm chart instructions and files.|
|
||||||
| |2021-01-15|Fix helm initial disk creation process and add installation instructions.|
|
| |2021-01-15|Fix helm initial disk creation process and add installation instructions.|
|
||||||
|
19
Dockerfile
19
Dockerfile
@ -43,6 +43,7 @@
|
|||||||
# -e CORES=4
|
# -e CORES=4
|
||||||
# -e EXTRA=
|
# -e EXTRA=
|
||||||
# -e INTERNAL_SSH_PORT=10022
|
# -e INTERNAL_SSH_PORT=10022
|
||||||
|
# -e MAC_ADDRESS=
|
||||||
#
|
#
|
||||||
# Extra QEMU args:
|
# Extra QEMU args:
|
||||||
#
|
#
|
||||||
@ -64,7 +65,8 @@ ARG VERSION=10.15.6
|
|||||||
ARG RANKMIRRORS
|
ARG RANKMIRRORS
|
||||||
ARG MIRROR_COUNTRY=US
|
ARG MIRROR_COUNTRY=US
|
||||||
ARG MIRROR_COUNT=10
|
ARG MIRROR_COUNT=10
|
||||||
RUN if [[ "${RANKMIRRORS}" ]]; then { pacman -Sy wget --noconfirm || pacman -Syu wget --noconfirm ; } \
|
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 ./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" \
|
; wget -O- "https://www.archlinux.org/mirrorlist/?country=${MIRROR_COUNTRY:-US}&protocol=https&use_mirror_status=on" \
|
||||||
| sed -e 's/^#Server/Server/' -e '/^#/d' \
|
| sed -e 's/^#Server/Server/' -e '/^#/d' \
|
||||||
@ -73,7 +75,8 @@ RUN if [[ "${RANKMIRRORS}" ]]; then { pacman -Sy wget --noconfirm || pacman -Syu
|
|||||||
&& tee -a /etc/pacman.d/mirrorlist <<< 'Server = http://mirrors.evowise.com/archlinux/$repo/os/$arch' \
|
&& 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 = http://mirror.rackspace.com/archlinux/$repo/os/$arch' \
|
||||||
&& tee -a /etc/pacman.d/mirrorlist <<< 'Server = https://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
|
&& cat /etc/pacman.d/mirrorlist \
|
||||||
|
; fi
|
||||||
|
|
||||||
# This fails on hub.docker.com, useful for debugging in cloud
|
# 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; }
|
# RUN [[ $(egrep -c '(svm|vmx)' /proc/cpuinfo) -gt 0 ]] || { echo KVM not possible on this host && exit 1; }
|
||||||
@ -81,9 +84,7 @@ RUN if [[ "${RANKMIRRORS}" ]]; then { pacman -Sy wget --noconfirm || pacman -Syu
|
|||||||
RUN tee -a /etc/pacman.conf <<< '[community-testing]' \
|
RUN tee -a /etc/pacman.conf <<< '[community-testing]' \
|
||||||
&& tee -a /etc/pacman.conf <<< 'Include = /etc/pacman.d/mirrorlist'
|
&& tee -a /etc/pacman.conf <<< 'Include = /etc/pacman.d/mirrorlist'
|
||||||
|
|
||||||
RUN pacman -Syu --noconfirm \
|
RUN pacman -Syu sudo git vim nano alsa-utils openssh --noconfirm \
|
||||||
&& pacman -S sudo git vim nano alsa-utils openssh --noconfirm \
|
|
||||||
&& yes | pacman -Scc \
|
|
||||||
&& ln -s /bin/vim /bin/vi \
|
&& ln -s /bin/vim /bin/vi \
|
||||||
&& useradd arch -p arch \
|
&& useradd arch -p arch \
|
||||||
&& tee -a /etc/sudoers <<< 'arch ALL=(ALL) NOPASSWD: ALL' \
|
&& tee -a /etc/sudoers <<< 'arch ALL=(ALL) NOPASSWD: ALL' \
|
||||||
@ -137,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 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 \
|
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 libvirtd.service
|
||||||
# RUN sudo systemctl enable virtlogd.service
|
# RUN sudo systemctl enable virtlogd.service
|
||||||
@ -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=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 <<< '-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 <<< '-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 <<< '-monitor stdio \' \
|
||||||
&& tee -a Launch.sh <<< '-vga vmware \' \
|
&& tee -a Launch.sh <<< '-vga vmware \' \
|
||||||
&& tee -a Launch.sh <<< '${EXTRA:-}'
|
&& tee -a Launch.sh <<< '${EXTRA:-}'
|
||||||
@ -187,12 +188,12 @@ RUN grep -v InstallMedia ./Launch.sh > ./Launch-nopicker.sh \
|
|||||||
&& chmod +x ./Launch-nopicker.sh \
|
&& chmod +x ./Launch-nopicker.sh \
|
||||||
&& sed -i -e s/OpenCore\.qcow2/OpenCore\-nopicker\.qcow2/ ./Launch-nopicker.sh
|
&& sed -i -e s/OpenCore\.qcow2/OpenCore\-nopicker\.qcow2/ ./Launch-nopicker.sh
|
||||||
|
|
||||||
|
USER arch
|
||||||
|
|
||||||
ENV USER arch
|
ENV USER arch
|
||||||
|
|
||||||
ENV DISPLAY=:0.0
|
ENV DISPLAY=:0.0
|
||||||
|
|
||||||
USER arch
|
|
||||||
|
|
||||||
ENV IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img
|
ENV IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img
|
||||||
|
|
||||||
VOLUME ["/tmp/.X11-unix"]
|
VOLUME ["/tmp/.X11-unix"]
|
||||||
|
@ -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' \
|
&& tee -a /etc/pacman.d/mirrorlist <<< 'Server = https://mirror.rackspace.com/archlinux/$repo/os/$arch' \
|
||||||
&& cat /etc/pacman.d/mirrorlist ; fi
|
&& 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 \
|
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 \
|
&& cd imcat \
|
||||||
&& make \
|
&& make \
|
||||||
&& sudo cp imcat /usr/bin/imcat \
|
&& sudo cp imcat /usr/bin/imcat \
|
||||||
&& touch /usr/bin/scrotcat \
|
&& touch /usr/bin/scrotcat \
|
||||||
&& tee -a /usr/bin/scrotcat <<< '/usr/bin/imcat <(scrot -o /dev/stdout)' \
|
&& tee -a /usr/bin/scrotcat <<< '/usr/bin/imcat <(scrot -o /dev/stdout)' \
|
||||||
&& chmod +x /usr/bin/scrotcat
|
&& 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
|
USER arch
|
||||||
|
|
||||||
@ -79,16 +89,17 @@ RUN mkdir -p ~/.ssh \
|
|||||||
|
|
||||||
WORKDIR /home/arch/OSX-KVM
|
WORKDIR /home/arch/OSX-KVM
|
||||||
|
|
||||||
ARG NOPICKER=true
|
ENV NOPICKER=true
|
||||||
|
|
||||||
RUN [[ "${NOPICKER}" = true ]] && mv ./Launch-nopicker.sh ./Launch.sh
|
|
||||||
|
|
||||||
ENV DISPLAY=:99
|
ENV DISPLAY=:99
|
||||||
|
|
||||||
ENV IMAGE_PATH=/image
|
ENV IMAGE_PATH=/image
|
||||||
|
|
||||||
CMD [[ "${DISPLAY}" = ':99' ]] && { nohup Xvfb :99 -screen 0 1920x1080x16 \
|
CMD [[ "${DISPLAY}" = ':99' ]] && { \
|
||||||
& until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 1 ; done ; } \
|
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 \
|
; sudo chown "$(id -u)":"$(id -g)" "${IMAGE_PATH}" 2>/dev/null || true \
|
||||||
; ./enable-ssh.sh \
|
; ./enable-ssh.sh \
|
||||||
|
; [[ "${NOPICKER}" == true ]] && mv ./Launch-nopicker.sh ./Launch.sh \
|
||||||
; envsubst < ./Launch.sh | bash
|
; envsubst < ./Launch.sh | bash
|
||||||
|
39
README.md
39
README.md
@ -66,8 +66,25 @@ docker run -it \
|
|||||||
|
|
||||||
# Wait 2-3 minutes until you drop into the shell.
|
# Wait 2-3 minutes until you drop into the shell.
|
||||||
```
|
```
|
||||||
|
|
||||||
```bash
|
```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
|
# boot to OSX shell + display (19GB) + commands to run inside OSX
|
||||||
docker run -it \
|
docker run -it \
|
||||||
--device /dev/kvm \
|
--device /dev/kvm \
|
||||||
@ -94,7 +111,10 @@ docker start -i containerid
|
|||||||
# Quick Start Own Image
|
# 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
|
```bash
|
||||||
docker pull sickcodes/docker-osx:naked
|
docker pull sickcodes/docker-osx:naked
|
||||||
@ -107,6 +127,17 @@ docker run -it \
|
|||||||
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
||||||
-e "DISPLAY=${DISPLAY:-:0.0}" \
|
-e "DISPLAY=${DISPLAY:-:0.0}" \
|
||||||
sickcodes/docker-osx:naked
|
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
|
```bash
|
||||||
# run your own image headless + SSH
|
# run your own image headless + SSH
|
||||||
@ -581,12 +612,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.
|
Pass any devices/directories to the Docker container & the QEMU arguments using the handy `-e EXTRA=` runtime options.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
|
# example customizations
|
||||||
docker run \
|
docker run \
|
||||||
-e RAM=4 \
|
-e RAM=4 \
|
||||||
-e SMP=4 \
|
-e SMP=4 \
|
||||||
-e CORES=4 \
|
-e CORES=4 \
|
||||||
-e EXTRA='-usb -device usb-host,hostbus=1,hostaddr=8' \
|
-e EXTRA='-usb -device usb-host,hostbus=1,hostaddr=8' \
|
||||||
-e INTERNAL_SSH_PORT=23 \
|
-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/kvm \
|
||||||
--device /dev/snd \
|
--device /dev/snd \
|
||||||
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
-v /tmp/.X11-unix:/tmp/.X11-unix \
|
||||||
|
Loading…
Reference in New Issue
Block a user