Colima, Apple M1 and Testcontainers

Colima, Apple M1 and Testcontainers

After Docker changed the terms of using Docker Desktop, developers working for large businesses are looking for free alternatives. Colima and Rancher Desktop are common choices for macOS users.

My choice is Colima.

Set up Colima

Installing Colima is very easy with Homebrew:

brew install colima

Then start Colima with specified CPU and memory:

colima start --cpu 4 --memory 8

Colima server is available at the sock address unix:///Users/${HOME}/.colima/default/docker.sock.

You can use docker client to connect to Colima server.

Use docker context ls to list all contexts, then use docker context use colima to switch to Colima.


Apple M1

If you are using macOS on Apple M1 chip, you need to make sure at least JNA 5.7.0 is used. Elasticsearch old versions have its own JNA distribution. Make sure the version is also upgraded if it's included as transitive dependency.

Configure Testcontainers

The following environment variables are required to run Testcontainers using Colima.

  • DOCKER_HOST=unix://${HOME}/.colima/default/docker.sock

Here is why these environment variables are required:

  • DOCKER_HOST specifies the sock address of Colima.
  • TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE specifies the sock address inside of the container.
  • TESTCONTAINERS_RYUK_DISABLED disables Ryuk, otherwise the container won't exit and the test will eventually time-out.
© 2023 VividCode