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
46.37k stars 2.49k forks source link

Docker in mac Virtual machine #331

Open Animezjy opened 3 years ago

Animezjy commented 3 years ago

I want to start docker in a mac virtual machine. How do I set up hardware virtualization I have successfully installed the mac virtual machine?

omarahm3 commented 3 years ago

I'm having the same issue, running latest docker on guest will throw "Incompatible CPU detected error" and that it requires a processor with virtualization and hypervisor support. @sickcodes any idea how to have this done? i'm using Big Sur BTW

sickcodes commented 3 years ago

https://github.com/KhaosT/MacVM

This works on Monterrey M1 hardware, I would like to test it this week on virtual

Edit: failed on Ryzen, unaware of Intel results though

omarahm3 commented 3 years ago

@sickcodes It worked after applying changes from here https://github.com/sickcodes/Docker-OSX/pull/312 and just:

docker run -it --device /dev/kvm -p 50922:10022 -v ~/mac_hdd_ng_auto_big_sur.img:/image -v /tmp/.X11-unix:/tmp/.X11-unix -e 'NOPICKER=false' -e 'DISPLAY=:0' -e 'RAM=half'  sickcodes/docker-osx:naked
thematrixdev commented 3 years ago

I need to run Docker or Virtualbox on Docker-OSX as well. As far as I understand from @omarking05 's lastest message, cpu=max is already merged in the latest release. The virtual CPU could not be identified to be KVM compatible. Even I am specifying this, it does not work neither.

I am using docker-compose up instead of running the command line for ease of future modification.

version: '3.8' services: macosx: container_name: macosx image: sickcodes/docker-osx:big-sur devices:

  • /dev/kvm:/dev/kvm ports:
  • 50922:10022
  • 51820:51820/udp volumes:
  • /home/user/Downloads:/mnt/hostshare
  • /tmp/.X11-unix:/tmp/.X11-unix
  • data:/home environment:
  • CPU=max
  • RAM=4
  • NETWORKING=vmxnet3
  • DISPLAY=${DISPLAY:-:0.0}
  • GENERATE_UNIQUE=true
  • WIDTH=1280
  • HEIGHT=720
  • ADDITIONAL_PORTS=hostfwd=udp::51820-:51820
  • EXTRA=-virtfs local,path=/mnt/hostshare,mount_tag=hostshare,security_model=passthrough,id=hostshare privileged: true cap_add:
  • ALL volumes: data:

May I know what have I done wrongly?

sickcodes commented 3 years ago
qemu-system-x86
-cpu max,vendor=GenuineIntel \
-machine q35,${KVM-"accel=kvm:tcg"} \

I am considering the following changes.

VMX doesn't show up, but apparently it should work on Intel.

I will give it a test on Digital Ocean, which lets you select AMD or Intel, unless someone wants to.

thematrixdev commented 3 years ago

Making - EXTRA=-cpu max,vendor=GenuineIntel -M q35,accel=kvm, Docker-OSX "boots-loop". May you please take a look on this? image

thematrixdev commented 3 years ago

I can use QEMU without hardware acceleration. If anyone needs Docker you may take a look on this issue: https://github.com/sickcodes/Docker-OSX/issues/346

sickcodes commented 3 years ago

Making - EXTRA=-cpu max,vendor=GenuineIntel -M q35,accel=kvm, Docker-OSX "boots-loop". May you please take a look on this? image

This won't work as it's already defined above in the variable called CPU

This will work though (testing rn):

-e CPU=max \
-e CPUID_FLAGS='vendor=GenuineIntel' \
thematrixdev commented 3 years ago

It boots only without setting CPU=max. With CPU=max set it just keeps bootloop.

version: '3.8' services: osx: container_name: osx image: sickcodes/docker-osx:big-sur devices:

  • /dev/kvm ports:
  • 222:222/tcp
  • 2222:2222/tcp
  • 5999:5999/tcp
  • 51821:51821/udp volumes:
  • /home/y2kbug/Downloads:/mnt/hostshare
  • /tmp/.X11-unix:/tmp/.X11-unix
  • home:/home environment:

    - CPU=max

  • "CPUID_FLAGS=vendor=GenuineIntel"
  • RAM=4
  • SMP=4
  • NETWORKING=vmxnet3
  • DISPLAY=${DISPLAY:-:0.0}
  • WIDTH=1920
  • HEIGHT=1080
  • GENERATE_UNIQUE=true
  • ADDITIONAL_PORTS=hostfwd=tcp::222-:22,hostfwd=tcp::2222-:2222,hostfwd=udp::51821-:51821
  • "EXTRA=-M q35,accel=kvm -display none -vnc 0.0.0.0:99 -virtfs local,path=/mnt/hostshare,mount_tag=hostshare,security_model=pas> privileged: true cap_add:
  • ALL volumes: home: