Use -e OSX_COMMANDS to run commands in OSX at runtime in :auto. Add docker start -i instructions.

pull/140/head
sickcodes 4 years ago
parent 8db77770b0
commit 27d7496a70

@ -115,32 +115,34 @@ CMD echo "${BOILERPLATE}" \
; [[ "${DISPLAY}" = ':99' ]] && { nohup Xvfb :99 -screen 0 1920x1080x16 \ ; [[ "${DISPLAY}" = ':99' ]] && { nohup Xvfb :99 -screen 0 1920x1080x16 \
& until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 0.1 ; done ; } \ & until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 0.1 ; done ; } \
; case "$(file --brief /image)" in \ ; case "$(file --brief /image)" in \
QEMU*) export IMAGE_PATH=/image;; \ QEMU*) export IMAGE_PATH=/image && sudo chown "$(id -u)":"$(id -g)" "${IMAGE_PATH}" 2>/dev/null || true;; \
directory*) export IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img;; \ directory*) export IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img;; \
esac \ esac \
; stat "${IMAGE_PATH}" \ ; stat "${IMAGE_PATH}" \
; echo "Large image is being copied between layers, please wait a minute..." \ ; echo "Large image is being copied between layers, please wait a minute..." \
; sudo chown "$(id -u)":"$(id -g)" "${IMAGE_PATH}" 2>/dev/null || true \
; ./enable-ssh.sh \ ; ./enable-ssh.sh \
; /usr/bin/ssh-keygen -t rsa -f ~/.ssh/id_docker_osx -q -N "" \ ; [[ -e ~/.ssh/id_docker_osx ]] || { \
; chmod 600 ~/.ssh/id_docker_osx \ /usr/bin/ssh-keygen -t rsa -f ~/.ssh/id_docker_osx -q -N "" \
&& chmod 600 ~/.ssh/id_docker_osx \
; } \
; envsubst < ./Launch.sh | bash \ ; envsubst < ./Launch.sh | bash \
& echo "Booting Docker-OSX in the background. Please wait..." \ & echo "Booting Docker-OSX in the background. Please wait..." \
; until [[ "$(sshpass -palpine ssh-copy-id -f -i ~/.ssh/id_docker_osx.pub -p 10022 user@127.0.0.1)" ]]; do \ ; until [[ "$(sshpass -palpine ssh-copy-id -f -i ~/.ssh/id_docker_osx.pub -p 10022 user@127.0.0.1)" ]]; do \
scrotcat \ echo "Disk is being copied between layers. Repeating until able to copy SSH key into OSX..." \
; echo "Waiting to copy SSH key into OSX..." \
; sleep 1 \ ; sleep 1 \
; done \ ; done \
; tee -a ~/.ssh/config <<< 'Host 127.0.0.1' \ ; grep id_docker_osx ~/.ssh/config || { \
; tee -a ~/.ssh/config <<< ' User user' \ tee -a ~/.ssh/config <<< 'Host 127.0.0.1' \
; tee -a ~/.ssh/config <<< ' Port 10022' \ ; tee -a ~/.ssh/config <<< ' User user' \
; tee -a ~/.ssh/config <<< ' IdentityFile ~/.ssh/id_docker_osx' \ ; tee -a ~/.ssh/config <<< ' Port 10022' \
; tee -a ~/.ssh/config <<< ' StrictHostKeyChecking no' \ ; tee -a ~/.ssh/config <<< ' IdentityFile ~/.ssh/id_docker_osx' \
; tee -a ~/.ssh/config <<< ' UserKnownHostsFile=/dev/null' \ ; tee -a ~/.ssh/config <<< ' StrictHostKeyChecking no' \
; echo 'Default username: user' \ ; tee -a ~/.ssh/config <<< ' UserKnownHostsFile=/dev/null' \
; echo 'Default password: alpine' \ ; } \
; echo 'Change it immediately using the command: passwd' \ && echo 'Default username: user' \
; ssh -i ~/.ssh/id_docker_osx user@127.0.0.1 -p 10022 && echo 'Default password: alpine' \
&& echo 'Change it immediately using the command: passwd' \
&& ssh -i ~/.ssh/id_docker_osx user@127.0.0.1 -p 10022 "${OSX_COMMANDS}"
# username: user # username: user
# password: alpine # password: alpine

@ -88,7 +88,7 @@ ENV DISPLAY=:99
ENV IMAGE_PATH=/image ENV IMAGE_PATH=/image
CMD [[ "${DISPLAY}" = ':99' ]] && { nohup Xvfb :99 -screen 0 1920x1080x16 \ CMD [[ "${DISPLAY}" = ':99' ]] && { nohup Xvfb :99 -screen 0 1920x1080x16 \
& until [[ "$(xrandr --query 2>/dev/null)" ]]; do sleep 0.1 ; done ; } \ & 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 \
; envsubst < ./Launch.sh | bash ; envsubst < ./Launch.sh | bash

@ -21,10 +21,10 @@ Docker Hub: https://hub.docker.com/r/sickcodes/docker-osx
# Quick Start Docker-OSX # Quick Start Docker-OSX
`sickcodes/docker-osx:latest`
```bash ```bash
docker pull sickcodes/docker-osx:latest
docker run -it \ docker run -it \
--device /dev/kvm \ --device /dev/kvm \
-p 50922:10022 \ -p 50922:10022 \
@ -38,13 +38,15 @@ docker run -it \
# Quick Start 22GB Pre-Made Image # Quick Start 22GB Pre-Made Image
`sickcodes/docker-osx:auto`
You will need around 50GB of space: half for the base image + half for your runtime image. You will need around 50GB of space: half for the base image + half for your runtime image.
If you run out of space, you can nuke your Docker images/history/cache by simply deleting `/var/lib/docker` If you run out of space, you can nuke your Docker images/history/cache by simply deleting `/var/lib/docker`
```bash ```bash
docker pull sickcodes/docker-osx:auto
# boot straight to OSX shell with no display (19GB) # boot straight to OSX shell with no display (19GB)
docker run -it \ docker run -it \
--device /dev/kvm \ --device /dev/kvm \
@ -55,25 +57,37 @@ docker run -it \
``` ```
```bash ```bash
# boot to OSX shell + display (19GB) # boot to OSX shell + display (19GB) + commands to run inside OSX
docker run -it \ docker run -it \
--device /dev/kvm \ --device /dev/kvm \
-p 50922:10022 \ -p 50922:10022 \
-v /tmp/.X11-unix:/tmp/.X11-unix \ -v /tmp/.X11-unix:/tmp/.X11-unix \
-e "DISPLAY=${DISPLAY:-:0.0}" \ -e "DISPLAY=${DISPLAY:-:0.0}" \
-e "OSX_COMMANDS=/bin/bash -c \"pwd && uname -a\""
sickcodes/docker-osx:auto sickcodes/docker-osx:auto
# Boots in a minute or two! # Boots in a minute or two!
```
### Restart an auto container
```bash
# find last container
docker ps -a
# docker start old container with -i for interactive
docker start -i containerid
``` ```
# Quick Start Own Image # Quick Start Own Image
`sickcodes/docker-osx:naked`
Supply your image with `-v "${PWD}/mac_hdd_ng.img:/image"` and use `sickcodes/docker-osx:naked` Supply your image with `-v "${PWD}/mac_hdd_ng.img:/image"` and use `sickcodes/docker-osx:naked`
```bash ```bash
docker pull sickcodes/docker-osx:naked
# run your own image + SSH # run your own image + SSH
docker run -it \ docker run -it \
--device /dev/kvm \ --device /dev/kvm \
@ -97,7 +111,6 @@ docker run -it \
- sickcodes/docker-osx:latest - original base recovery image (safe) - sickcodes/docker-osx:latest - original base recovery image (safe)
- sickcodes/docker-osx:naked - supply your own .img file (safe) - sickcodes/docker-osx:naked - supply your own .img file (safe)
- sickcodes/docker-osx:auto - 22gb image boot to OSX shell (must trust @sickcodes) - sickcodes/docker-osx:auto - 22gb image boot to OSX shell (must trust @sickcodes)
- Full auto mode: boot straight to OSX shell.
- Supply your own image using -v $PWD/disk.img:/image - Supply your own image using -v $PWD/disk.img:/image
- Kubernetes Helm Chart. [See ./helm](https://github.com/sickcodes/Docker-OSX/tree/master/helm) - Kubernetes Helm Chart. [See ./helm](https://github.com/sickcodes/Docker-OSX/tree/master/helm)
- OSX-KVM - OSX-KVM

@ -121,10 +121,4 @@ RUN printf '\n\n\n\n%s\n%s\n\n\n\n' '===========VNC_PASSWORD========== ' "$(<vnc
WORKDIR /home/arch/OSX-KVM WORKDIR /home/arch/OSX-KVM
VOLUME /image CMD ./enable-ssh.sh && envsubst < ./Launch_custom.sh | bash
CMD case "$(file --brief /image)" in \
QEMU*) export IMAGE_PATH=/image;; \
directory*) export IMAGE_PATH=/home/arch/OSX-KVM/mac_hdd_ng.img;; \
esac \
; ./enable-ssh.sh && envsubst < ./Launch_custom.sh | bash

Loading…
Cancel
Save