yteraoka / blog-1q77-com

https://blog.1q77.com/
1 stars 0 forks source link

Lima で vz + rosetta #155

Closed yteraoka closed 7 months ago

yteraoka commented 8 months ago
limactl create --name=default --vm-type=vz --cpus=2 --memory=2 --rosetta /opt/homebrew/share/lima/templates/experimental/vz.yaml
lima nerdctl run -it --rm --platform=linux/amd64 debian

docker

limactl create --name=default \
   --cpus=2 --memory=2 \
  --vm-type=vz --mount-type=virtiofs --rosetta \
  template://docker

VM は aarch64

$ lima uname -m
aarch64

amd64 の container image を試す

$ docker run -it --rm --platform=linux/amd64 debian uname -m
x86_64

arm64 の container image を試す

$ docker run -it --rm --platform=linux/arm64 debian uname -m
aarch64
limactl create --name=default \
   --cpus=2 --memory=2 \
  template://docker
$ lima uname -m
aarch64

image は pull できるが実行でコケる exec format error

$ docker run -it --rm --platform=linux/amd64 debian uname -m

Unable to find image 'debian:latest' locally
latest: Pulling from library/debian
8457fd5474e7: Pull complete 
Digest: sha256:fab22df37377621693c68650b06680c0d8f7c6bf816ec92637944778db3ca2c0
Status: Downloaded newer image for debian:latest
exec /usr/bin/uname: exec format error

arm64 の image なら実行可能

$ docker run -it --rm --platform=linux/arm64 debian uname -m
Unable to find image 'debian:latest' locally
latest: Pulling from library/debian
8024d4fb53b2: Pull complete 
Digest: sha256:fab22df37377621693c68650b06680c0d8f7c6bf816ec92637944778db3ca2c0
Status: Downloaded newer image for debian:latest
aarch64
yteraoka commented 8 months ago

aarch64 + vz + rosetta

limactl create --name=default \
  --cpus=2 --memory=2 \
  --vm-type=vz --mount-type=virtiofs --rosetta \
  template://docker

aarch64 (arm64)

limactl create --name=arm64 \
  --arch=aarch64 \
  --cpus=2 --memory=2 \
  --vm-type=vz --mount-type=virtiofs \
  template://docker

x86_64 (amd64)

limactl create --name=amd64 \
  --arch=x86_64 \
  --cpus=2 --memory=2 \
  --vm-type=qemu --mount-type=9p \
  template://docker

Apple silicon で arch=x86_64 を指定する場合には vm-type=vz が使えない

field `arch` must be "aarch64" for VZ

また、mount-type=virtiofs も使えず、reverse-sshfs9p を指定する必要がある

field `mountType` must be "reverse-sshfs" or "9p" for QEMU driver on non-Linux