class MinioContainer(image: str = 'minio/minio:RELEASE.2022-12-02T19-19-22Z', port: int = 9000, access_key: str = 'minioadmin', secret_key: str = 'minioadmin', **kwargs)ΒΆ

The example below spins up an Minio container and creates a new bucket in it. Furthermore, it demonstrates how an object is written to this bucket and then subsequently retrieved. The method get_client can be used to create a client for the Minio Python API. The method get_config can be used to retrieve the endpoint, access key and secret key of the container.

Example

>>> import io
>>> from testcontainers.minio import MinioContainer

>>> with MinioContainer() as minio:
...   client = minio.get_client()
...   client.make_bucket("test")
...   test_content = b"Hello World"
...   write_result = client.put_object(
...       "test",
...       "testfile.txt",
...       io.BytesIO(test_content),
...       length=len(test_content),
...   )
...   retrieved_content = client.get_object("test", "testfile.txt").data