When switching from Docker Desktop to Lima on macOS, Testcontainers integration tests fail silently due to two issues: Maven Surefire's forked JVM not inheriting DOCKER_HOST, and Ryuk being unable to start inside Lima's Docker daemon. The fix involves five steps: finding the Lima socket path, creating ~/.testcontainers.properties with the correct socket path and ryuk.disabled=true, passing DOCKER_HOST explicitly through Maven Surefire's environmentVariables config, disabling Spring Boot's docker-compose module in tests, and using @ServiceConnection for zero-config datasource wiring. The configuration is safe to commit and works both locally with Lima and in CI with standard Docker.

6m read timeFrom sergiolema.dev
Post cover image
Table of contents
Why Lima Breaks the Default Testcontainers SetupStep 1: Find Your Lima Docker Socket PathStep 2: Create ~/.testcontainers.propertiesStep 3: Pass DOCKER_HOST Through Maven SurefireStep 4: Disable Spring Boot Docker Compose in TestsStep 5: Use @ServiceConnection for Zero-Config Datasource WiringThe pom.xml Dependencies You NeedConfiguration ChecklistDoes This Configuration Work in CI?Key Takeaways

Sort: