Class MinioContainer
- All Implemented Interfaces:
AutoCloseable,org.junit.rules.TestRule,org.testcontainers.containers.Container<MinioContainer>,org.testcontainers.containers.ContainerState,org.testcontainers.containers.traits.LinkableContainer,org.testcontainers.containers.wait.strategy.WaitStrategyTarget,org.testcontainers.lifecycle.Startable
We use it primarily to test compatibility with our S3 backup store, as it's lightweight and popular.
When using this, keep in mind that you will need to add a network alias per bucket that you
want to create. You should use withDomain(String, String...) for this, and read the
method's documentation.
In most cases, it's expected you will configure the domain as above.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.testcontainers.containers.Container
org.testcontainers.containers.Container.ExecResult -
Field Summary
Fields inherited from class org.testcontainers.containers.GenericContainer
CONTAINER_RUNNING_TIMEOUT_SEC, dependencies, dockerClient, INTERNAL_HOST_HOSTNAME, waitStrategyFields inherited from interface org.testcontainers.containers.ContainerState
STATE_HEALTHY -
Constructor Summary
ConstructorsConstructorDescriptionCreates a default container with a pinned image version.MinioContainer(String version) Creates a new container with the specific image version. -
Method Summary
Modifier and TypeMethodDescriptionReturns the configured Minio access key.org.testcontainers.containers.wait.strategy.WaitStrategyReturns the S3 accessible endpoint for a client running on the host machine.Returns the internal endpoint, i.e.region()Returns the configured Minio region.Returns the configured Minio secret key.withDomain(String domain, String... buckets) Configures Minio to use the specific domain as its internal hostname and virtual wild card host, allowing subdomain access for buckets.Methods inherited from class org.testcontainers.containers.GenericContainer
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, configure, containerIsCreated, containerIsStarted, containerIsStarted, containerIsStarting, containerIsStarting, containerIsStopped, containerIsStopping, copyFileFromContainer, createVolumeDirectory, dependsOn, dependsOn, dependsOn, doStart, equals, failed, finished, getBinds, getCommandParts, getContainerId, getContainerInfo, getContainerName, getCopyToFileContainerPathMap, getCreateContainerCmdModifiers, getDependencies, getDockerClient, getDockerImageName, getEnv, getEnvMap, getExposedPorts, getExtraHosts, getImage, getIpAddress, getLabels, getLinkedContainers, getLivenessCheckPort, getLivenessCheckPortNumbers, getLivenessCheckPorts, getLogConsumers, getNetwork, getNetworkAliases, getNetworkMode, getPortBindings, getShmSize, getStartupAttempts, getStartupCheckStrategy, getTestHostIpAddress, getTmpFsMapping, getVolumesFroms, getWaitStrategy, getWorkingDirectory, hashCode, isHostAccessible, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setContainerDef, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setHostAccessible, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, starting, stop, succeeded, toString, waitingFor, waitUntilContainerStarted, withAccessToHost, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCopyToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectoryMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.testcontainers.containers.Container
addFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBindMethods inherited from interface org.testcontainers.containers.ContainerState
copyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, execInContainer, execInContainer, execInContainerWithUser, execInContainerWithUser, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunningMethods inherited from interface org.testcontainers.lifecycle.Startable
close
-
Constructor Details
-
MinioContainer
public MinioContainer()Creates a default container with a pinned image version. It's unlikely we ever need to change this. -
MinioContainer
Creates a new container with the specific image version.- Parameters:
version- the minio version to use
-
-
Method Details
-
defaultWaitStrategy
public org.testcontainers.containers.wait.strategy.WaitStrategy defaultWaitStrategy() -
externalEndpoint
Returns the S3 accessible endpoint for a client running on the host machine. Note that this may use a hostname. If you wish to use path-style access (e.g. you don't know your buckets beforehand), then you can format the endpoint yourself using 127.0.0.1 as the IP address instead of the host.NOTE: if this is a common use case, we can add a method here that does so.
-
internalEndpoint
Returns the internal endpoint, i.e. the S3 accessible endpoint used when your client is running in a container in the same network as this one. If you wish to use path-style access (e.g. you don't know your buckets beforehand), then you can format the endpoint yourself using the container's internal IP address. You can fetch that by inspecting the container viaGenericContainer.getContainerInfo()and checking the network settings for the IP address.NOTE: if this is a common use case, we can add a method here that does so.
-
region
Returns the configured Minio region. You can pass this to your S3 client builder. -
accessKey
Returns the configured Minio access key. You can pass this to your S3 client builder. -
secretKey
Returns the configured Minio secret key. You can pass this to your S3 client builder. -
withDomain
Configures Minio to use the specific domain as its internal hostname and virtual wild card host, allowing subdomain access for buckets. In order for the bucket subdomain to be resolvable, you must provide them here, so they can be added as routes to the network.So if you pass, say,
minio.local, and two buckets calledbucketAandbucketB, you can access the following domains:http://minio.local,http://bucketA.minio.local, andhttp://bucketB.minio.local. This is the default operating mode for an S3 client.If you do not know your bucket names in advance, then you will need to find to use the container's IP address as the endpoint; this will force your client to use the path-style access to access your buckets.
- Parameters:
domain- the root domain accessible from the container's networkbuckets- a list of bucket names which will be added as subdomains for the root domain- Returns:
- this container for chaining
-