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.01k stars 1.78k forks source link

The way to customize cpu core number in Readme not working #754

Open 7feigao opened 3 months ago

7feigao commented 3 months ago

Hi, I have tried to provide more cpu cores to container by follow the description in Readme, but it don't work, here is my full container creation cmd:

docker run -it \
    --device /dev/kvm \
    -p 43276:10022 \
    --name 'Macos' \
    -v /mnt/wslg/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    -e GENERATE_UNIQUE=true \
    -e WIDTH=2560 \
    -e HEIGHT=1440 \
    -e RAM=24 \
    -v "/mnt/c/Users/qigao:/mnt/hostshare" \
    -e EXTRA='-smp 16,sockets=8,cores=2' \
    sickcodes/docker-osx:latest

After review the Launch.sh script in container:

exec qemu-system-x86_64 -m ${RAM:-4}000 \
-cpu ${CPU:-Penryn},${CPUID_FLAGS:-vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check,}${BOOT_ARGS} \
-machine q35,${KVM-"accel=kvm:tcg"} \
-smp ${CPU_STRING:-${SMP:-4},cores=${CORES:-4}} \
-usb -device usb-kbd -device usb-tablet \
-device isa-applesmc,osk=ourhardworkbythesewordsguardedpleasedontsteal\(c\)AppleComputerInc \
-drive if=pflash,format=raw,readonly=on,file=/home/arch/OSX-KVM/OVMF_CODE.fd \
-drive if=pflash,format=raw,file=/home/arch/OSX-KVM/OVMF_VARS-1024x768.fd \
-smbios type=2 \
-audiodev ${AUDIO_DRIVER:-alsa},id=hda -device ich9-intel-hda -device hda-duplex,audiodev=hda \
-device ich9-ahci,id=sata \
-drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file=${BOOTDISK:-/home/arch/OSX-KVM/OpenCore/OpenCore.qcow2} \
-device ide-hd,bus=sata.2,drive=OpenCoreBoot \
-device ide-hd,bus=sata.3,drive=InstallMedia \
-drive id=InstallMedia,if=none,file=/home/arch/OSX-KVM/BaseSystem.img,format=${BASESYSTEM_FORMAT:-qcow2} \
-drive id=MacHDD,if=none,file=${IMAGE_PATH:-/home/arch/OSX-KVM/mac_hdd_ng.img},format=${IMAGE_FORMAT:-qcow2} \
-device ide-hd,bus=sata.4,drive=MacHDD \
-netdev user,id=net0,hostfwd=tcp::${INTERNAL_SSH_PORT:-10022}-:22,hostfwd=tcp::${SCREEN_SHARE_PORT:-5900}-:5900,${ADDITIONAL_PORTS} \
-device ${NETWORKING:-vmxnet3},netdev=net0,id=net0,mac=${MAC_ADDRESS:-52:54:00:09:49:17} \
-monitor stdio \
-boot menu=on \
-vga vmware \
${EXTRA:-} 

I find we need customize the cpu core number by provide ENV CPU_STRING or SMP and CORES, and all setting related to smp provided in ENV EXTRA will not working in my case. so the workable container creation cmd can be looks like:

docker run -it \
    --device /dev/kvm \
    -p 43276:10022 \
    --name 'Macos' \
    -v /mnt/wslg/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    -e GENERATE_UNIQUE=true \
    -e WIDTH=2560 \
    -e HEIGHT=1440 \
    -e SMP=16 \
    -e CORES=16 \
    -e RAM=24 \
    sickcodes/docker-osx:latest

Please help correct me if my miss something or we may can update the Readme?

Regards,