Skip to content

MinIO Containers

Testcontainers can be used to automatically instantiate and manage MinIO containers.

Usage example

Create a MinIOContainer to use it in your tests:

MinIOContainer container = new MinIOContainer("minio/minio:RELEASE.2023-09-04T19-57-37Z");

The MinIO Java client can be configured with the container as such:

MinioClient minioClient = MinioClient
    .builder()
    .endpoint(container.getS3URL())
    .credentials(container.getUserName(), container.getPassword())
    .build();

If needed the username and password can be overridden as such:

MinIOContainer container = new MinIOContainer("minio/minio:RELEASE.2023-09-04T19-57-37Z")
    .withUserName("testuser")
    .withPassword("testpassword");

Adding this module to your project dependencies

Add the following dependency to your pom.xml/build.gradle file:

 testImplementation "org.testcontainers:minio:1.19.7"
<dependency>
    <groupId>org.testcontainers</groupId>
    <artifactId>minio</artifactId>
    <version>1.19.7</version>
    <scope>test</scope>
</dependency>