I am using the following:
- m2 Mac (OS X Ventura 13.3)
- Spring Boot v3.1.2
- Test Containers v1.19.1
- Docker Desktop v4.24.2
When I run my integration tests individually they pass but when running them with the following command:
mvn -f pom.xml clean package I get the following error
Could not find a valid Docker environment. Please check configuration
I have tried everything in this post but nothing seems to be working.
Has anybody else managed to get it to work on an m2 Mac ?
Here is a sample of the integration test configuration
@Testcontainers @AutoConfigureWebTestClient(timeout = "36000") @AutoConfigureTestDatabase(replace = AutoConfigureTestDatabase.Replace.NONE) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) class MyServiceIntegrationTests { @Container static PostgreSQLContainer<?> postgresqlContainer = new PostgreSQLContainer<>("postgres:15.1-alpine"); @BeforeAll static void beforeAll() { postgresqlContainer.start(); } @AfterAll static void afterAll() { postgresqlContainer.stop(); } @DynamicPropertySource static void setProperties(DynamicPropertyRegistry registry) { registry.add("spring.datasource.url", postgresqlContainer::getJdbcUrl); registry.add("spring.datasource.username", postgresqlContainer::getUsername); registry.add("spring.datasource.password", postgresqlContainer::getPassword); } This is my docker file
FROM maven:3.8.5-openjdk-18-slim AS build RUN mkdir -p workspace WORKDIR workspace COPY pom.xml /workspace COPY src /workspace/src RUN mvn -f pom.xml clean package FROM openjdk:18-alpine COPY --from=build /workspace/target/*.jar app.jar EXPOSE 8080 ENTRYPOINT ["java","-jar","app.jar"] It is being run using docker-compose and fails on this command
RUN mvn -f pom.xml clean package
However, it works if I dont run the tests using docker-compose
docker ps?