Docker Macos

Don’t have a Mac and need MacOS? No problem, run it in a docker container.

Credit goes to this twitter user:


Install Docker Ubuntu 22.04

sudo apt install apt-transport-https ca-certificates curl software-properties-common -y
curl -fsSL | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] jammy stable"
sudo apt install docker-ce -y
sudo usermod -aG docker $USER

Reboot or logout/login

(Optional) GUI Webpage for Managing Docker - Portainer

docker volume create portainer_data
docker run -d -p 8000:8000 -p 9443:9443 --name portainer \
--restart=always \
-v /var/run/docker.sock:/var/run/docker.sock \
-v portainer_data:/data \

Open up browser and navigate to https://localhost:9443

Click Advanced and proceed with any certificate errors

MacOS Docker Setup

Setup the MacOS Docker Container with the following docker command

docker run -it \
    --device /dev/kvm \
    -p 50922:10022 \
    -v /tmp/.X11-unix:/tmp/.X11-unix \
    -e "DISPLAY=${DISPLAY:-:0.0}" \
    -e GENERATE_UNIQUE=true \
    -e MASTER_PLIST_URL='' \

# docker build -t docker-osx --build-arg SHORTNAME=monterey .

Use Disk Utility to “erase” the 270GB virtual disk: Note: This is just virtual and doesn’t erase your drive

Start MacOS Docker Container

Before we start the container find the name with:

docker ps -a

Look for the NAMES column and pick the container name.

Start with the following command NAME = Name from column above

docker start NAME

Portainer Method for Starting

I love portainer because you can easily manage your containers. Start, Stop, and see resource usage… Portainer does it all! Here is what mine looks like:

Optimize the Container


Run the following from Root Prompt # sudo su

defaults write autoLoginUser -bool true
mdutil -i off -a
nvram boot-args="serverperfmode=1 $(nvram boot-args 2>/dev/null | cut -f 2-)"
defaults write /Library/Preferences/ DesktopPicture ""
defaults write DifferentiateWithoutColor -int 1
defaults write ReduceMotionEnabled -int 1
defaults write reduceMotion -int 1
defaults write reduceTransparency -int 1
defaults write ReduceMotionEnabled -int 1
defaults write /Library/Preferences/ AutomaticDownload -bool false
defaults write AutomaticCheckEnabled -bool false
defaults write AutoUpdate -bool false
defaults write AutoUpdateRestartRequired -bool false
defaults write ConfigDataInstall -int 0
defaults write CriticalUpdateInstall -int 0
defaults write ScheduleFrequency -int 0
defaults write AutomaticDownload -int 0
defaults write DisableScreenLock -bool true
defaults write TALLogoutSavesState -bool false

Final Result

Walkthrough Video