sickcodes / Docker-OSX

Run macOS VM in a Docker! Run near native OSX-KVM in Docker! X11 Forwarding! CI/CD for OS X Security Research! Docker mac Containers.
https://hub.docker.com/r/sickcodes/docker-osx
GNU General Public License v3.0
36.13k stars 1.78k forks source link

Question about persistent setup and docker commit #461

Open sebbekarlsson opened 2 years ago

sebbekarlsson commented 2 years ago

Some background: I'm using this to work on an IOS app in XCode.

I really need my setup to be persistent so that I don't need to re-install OSX everytime. Do I understand things correctly, I need to run "docker commit" everytime before I shut down the OSX machine in order to save the state?

Cheers, Sebastian

Julioevm commented 2 years ago

What you need to do is extract the HDD image and use it when you create a new container, so you always keep the same data.

You can find the image like this:

sudo find /var/lib/docker -size +10G | grep mac_hdd_ng.img

Move it somewhere you want to have it accessible. Then start a new container with the parameter.

-v "the-location-you-pick/mac_hdd_ng.img:/image" \

maltegrosse commented 2 years ago

perhaps there are some use cases where avoiding docker and using osx-kvm directly makes more sense..

Julioevm commented 2 years ago

Yes for a simple persisten setup, osx-kvm can be enough. But I think Docker-OSX is easier to setup these days. Up to him to decide :slightly_smiling_face:

satmandu commented 1 year ago

For those trying to do this with the High Sierra image, this is what I had to do:

#!/bin/bash
docker run \
    --privileged -i \
    --device /dev/kvm \
    -p 50922:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -v /LOCAL_PERSISTENT_PATH/mac_hdd_ng.img:/home/arch/OSX-KVM/mac_hdd_ng.img \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    -e AUDIO_DRIVER=pa,server=unix:/tmp/pulseaudio.socket \
    -v "/run/user/$(id -u)/pulse/native:/tmp/pulseaudio.socket" \
    sickcodes/docker-osx:high-sierra