baks-testcontainers-colima
Use when running tests with Maven (mvn test, mvn verify, mvn package, mvn install) or other JVM tools on macOS with Colima/Docker Desktop. Automatically configures Testcontainers to connect to PostgreSQL containers through Colima's Docker socket.
- License 许可
- MIT
- 最近更新
- 2026-06-23
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- baks-testcontainers-colima
- description
- Use when running tests with Maven (mvn test, mvn verify, mvn package, mvn install) or other JVM tools on macOS with Colima/Docker Desktop. Automatically configures Testcontainers to connect to PostgreSQL containers through Colima's Docker socket.
03 SKILL.md 正文
Testcontainers Colima Configuration
On macOS with Colima/Docker Desktop, Testcontainers needs special environment variables to connect to Docker containers from the host machine. This skill configures those automatically.
Problem
Without proper configuration, integration tests using Testcontainers fail with:
java.net.SocketException: Operation not permitted
or:
Timed out waiting for Ryuk container to start
This happens because Testcontainers can't find the Docker socket or reach containers from the host.
Maven Phases That Run Tests
These Maven phases all include test execution and require the environment variables below:
mvn test- runs unit and integration testsmvn package- runs tests and builds a JARmvn verify- runs tests including integration tests and verifies the packagemvn install- runs all of the above and installs the artifact to the local Maven repository
Solution
Set these environment variables before running any Maven command that includes tests:
export DOCKER_HOST=unix://${HOME}/.colima/default/docker.sock
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
export TESTCONTAINERS_HOST_OVERRIDE=$(colima ls -j | jq -r '.address')
Then run, for example:
mvn test -Dkotlin.compiler.daemon=false
mvn package -Dkotlin.compiler.daemon=false
mvn verify -Dkotlin.compiler.daemon=false
mvn install -Dkotlin.compiler.daemon=false
Permanent Setup
Add these lines to ~/.zshrc or ~/.bashrc so the variables are set automatically in every new terminal session:
# Colima/Testcontainers configuration
export DOCKER_HOST=unix://${HOME}/.colima/default/docker.sock
export TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE=/var/run/docker.sock
export TESTCONTAINERS_HOST_OVERRIDE=$(colima ls -j | jq -r '.address' 2>/dev/null || echo "127.0.0.1")
What Each Variable Does
- DOCKER_HOST: Points to Colima's Unix socket instead of the default Docker socket
- TESTCONTAINERS_DOCKER_SOCKET_OVERRIDE: Ensures the Ryuk cleanup container uses the correct socket
- TESTCONTAINERS_HOST_OVERRIDE: Sets the correct IP address for container communication (retrieved from
colima ls -j)
Expected Output
BUILD SUCCESS
Troubleshooting
If colima ls -j fails, the fallback value 127.0.0.1 is used, but this may not work. Check that Colima is running:
colima status
If Colima is not running, start it:
colima start
Then restart your terminal or source your shell config to pick up the environment variables.
04 同仓库更多 Skills
baks-spring-boot-best-practices
Spring Boot best practices for Kotlin — injection, transactions, proxy annotations, JPA entities, naming, and REST API design. Use when writing or reviewing Spring Boot code in Kotlin.
baks-maven-kotlin-build
Use when running Maven builds (mvn) in this project. The Kotlin compiler daemon fails with "cannot connect to registry: Operation not permitted" in this environment. Always add -Dkotlin.compiler.daemon=false to all mvn commands.
baks-hello-project-skill
Dummy skill – prints its own name
baks-testcontainers-colima
Bruk når du kjører tester med Maven (mvn test, mvn verify, mvn package, mvn install) eller andre JVM-verktøy på macOS med Colima/Docker Desktop. Konfigurerer automatisk Testcontainers til å koble til PostgreSQL-containere via Colimas Docker-socket.
baks-spring-boot-best-practices
Spring Boot best practices for Kotlin — injection, transactions, proxy annotations, JPA entities, naming, and REST API design. Use when writing or reviewing Spring Boot code in Kotlin.
baks-maven-kotlin-build
Bruk når du kjører Maven-bygg (mvn) i dette prosjektet. Kotlin compiler daemon feiler med "cannot connect to registry: Operation not permitted" i dette miljøet. Legg alltid til -Dkotlin.compiler.daemon=false i alle mvn-kommandoer.