Skip to content

Instantly share code, notes, and snippets.

@KyleAure
Created March 22, 2024 19:47
Show Gist options
  • Save KyleAure/6238eab4c4c9d08d90418e0c8153fcdf to your computer and use it in GitHub Desktop.
Save KyleAure/6238eab4c4c9d08d90418e0c8153fcdf to your computer and use it in GitHub Desktop.

Setup colima on ARM Mac to Run x86 Docker Images

Prerequisites

Install Rosetta for x86 instruction support on Mac

$ softwareupdate --install-rosetta

Install colima, docker, and docker-compose

$ brew install colima
$ brew install docker docker-desktop

Set docker-desktop as a plugin for docker-cli

$ mkdir -p ~/.docker/cli-plugins
$ ln -sfn $(brew --prefix)/opt/docker-compose/bin/docker-compose ~/.docker/cli-plugins/docker-compose

Test installation

If you want to run ARM based containers do the following

$ colima start
INFO[0000] starting colima
INFO[0000] runtime: docker
INFO[0000] starting ...                                  context=vm
INFO[0023] provisioning ...                              context=docker
INFO[0023] starting ...                                  context=docker
INFO[0029] done

$ docker version
Client: Docker Engine - Community
 Version:           24.0.6
 API version:       1.42 (downgraded from 1.43)
 Go version:        go1.21.0
 Git commit:        ed223bc820
 Built:             Thu Aug 31 17:24:32 2023
 OS/Arch:           darwin/arm64
 Context:           colima
...

$ docker compose help
Usage:  docker compose [OPTIONS] COMMAND
...

$ docker pull icr.io/appcafe/open-liberty:22.0.0.12-full-java11-openj9-ubi
Digest: sha256:ab429c169a8f313141c63fafd0bc3b207f30b66bdac2a5cf6f911166d7ab6841
Status: Downloaded newer image for icr.io/appcafe/open-liberty:22.0.0.12-full-java11-openj9-ubi
icr.io/appcafe/open-liberty:22.0.0.12-full-java11-openj9-ubi

If you try to pull an image that does not have an ARM based image you will see this error:

$ docker pull icr.io/appcafe/websphere-traditional:9.0.5.8
9.0.5.8: Pulling from appcafe/websphere-traditional
no matching manifest for linux/arm64/v8 in the manifest list entries

Run x86 only images

You will first need to wipe out your previous configuration.

NOTE: colima delete will wipe out your existing image cache.

$ colima stop
INFO[0000] stopping colima
INFO[0000] stopping ...                                  context=docker
INFO[0001] stopping ...                                  context=vm
INFO[0005] done

$ colima delete
are you sure you want to delete colima and all settings? [y/N] y
INFO[0003] deleting colima
INFO[0003] done

Now start colima with the following command:

$ colima start --arch x86_64 --vm-type=vz --vz-rosetta
INFO[0000] starting colima
INFO[0000] runtime: docker
INFO[0000] creating and starting ...                     context=vm
INFO[0023] provisioning ...                              context=docker
INFO[0023] starting ...                                  context=docker
INFO[0029] done

Verify your setup. Your client will have an OS of arm64 while your server will have a OS of amd64

$ docker version
Client: Docker Engine - Community
 Version:           24.0.6
 API version:       1.42 (downgraded from 1.43)
 Go version:        go1.21.0
 Git commit:        ed223bc820
 Built:             Thu Aug 31 17:24:32 2023
 OS/Arch:           darwin/arm64
 Context:           colima

Server:
 Engine:
  Version:          23.0.6
  API version:      1.42 (minimum version 1.12)
  Go version:       go1.20.4
  Git commit:       9dbdbd4b6d7681bd18c897a6ba0376073c2a72ff
  Built:            Fri May 12 13:54:36 2023
  OS/Arch:          linux/amd64
  Experimental:     false

Now try to pull an image:

$docker pull icr.io/appcafe/websphere-traditional:9.0.5.8
9.0.5.8: Pulling from appcafe/websphere-traditional
Digest: sha256:5eae2026a58477f04cada290e4f94a7b5ad8e3eb2e28e524afe6619b104956eb
Status: Downloaded newer image for icr.io/appcafe/websphere-traditional:9.0.5.8
icr.io/appcafe/websphere-traditional:9.0.5.8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment