Skip to content

Instantly share code, notes, and snippets.

@peternguyen93
Last active June 17, 2024 11:49
Show Gist options
  • Save peternguyen93/4a2cd12422b450fc9bd5c230fce0c15c to your computer and use it in GitHub Desktop.
Save peternguyen93/4a2cd12422b450fc9bd5c230fce0c15c to your computer and use it in GitHub Desktop.
Using Rosetta2 in Docker on ArchLinux VM Apple Silicon

Using Rosetta2 in Docker on ArchLinux arm64 - Apple M1

  1. Start vm with tart
tart run archlinux --no-graphics --dir=shared:~/Sources --rosetta=ROSETTA
  1. mount rosetta to Linux
sudo mkdir -p /mnt/rosetta
sudo mount -t virtiofs ROSETTA /mnt/rosetta
  1. Add rosetta to systemd-binfmt.d
sudo echo ":rosetta:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x3e\x00:\xff\xff\xff\xff\xff\xfe\xfe\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/mnt/rosetta/rosetta:F" > /lib/binfmt.d/rosetta.conf
sudo systemctl restart systemd-binfmt

If you use fedora arm64, you have to setup SELinux to allow rosetta to be loaded into systemd-binfmt

sudo -i
ausearch -c 'systemd-binfmt' --raw | audit2allow -M my-systemdbinfmt
semodule -i my-systemdbinfmt.pp
semodule -X 300 -i my-systemdbinfmt.pp
  1. Run docker x86_64 image
docker pull ubuntu:latest --platform linux/amd64
docker run -it ubuntu /bin/bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment