macOS 13 Ventura introduced support of running amd64 binaries with Rosetta inside of arm64 Linux VMs when using Apple Virtualization framework.
Lima VM v0.14.0 and later support the new feature.
Setup:
# Install Docker client and Lima
brew install docker docker-compose docker-credential-helper lima
# Link docker-compose plugin
mkdir -p ~/.docker/cli-plugins
ln -sfn /opt/homebrew/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose
# Start VM
limactl start --name=default ubuntu-docker-lima.yaml
# Lima 0.14.2 panics on first start, run start again
limactl start default
# Run the ouput of the command above to setup Docker ^
docker context create lima-default --docker "host=unix:///Users/$USER/.lima/default/sock/docker.sock"
docker context use lima-default
# Docker client can now run arm64 containers
docker run hello-world
# and amd64 containers with the help of Rosetta
docker run --platform=linux/amd64 hello-world
Note: the yaml Lima config below is a combination of docker.yaml and vz.yaml with customized mounts.
I tried it once and it successfully for me into a Docker container where I could run x86 executables. But trying it a second time I get this segmentation fault: