public class MongoDBContainer extends org.testcontainers.containers.GenericContainer<MongoDBContainer>
To construct a multi-node MongoDB cluster, consider the mongodb-replica-set project on GitHub
Tested on a MongoDB version 4.0.10+ (that is the default version if not specified).
| Modifier and Type | Class and Description |
|---|---|
static class |
MongoDBContainer.ReplicaSetInitializationException |
| Constructor and Description |
|---|
MongoDBContainer()
Deprecated.
use
MongoDBContainer(DockerImageName) instead |
MongoDBContainer(org.testcontainers.utility.DockerImageName dockerImageName) |
MongoDBContainer(@NonNull java.lang.String dockerImageName) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
containerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse containerInfo) |
java.lang.String |
getReplicaSetUrl()
Gets a replica set url for the default database.
|
java.lang.String |
getReplicaSetUrl(java.lang.String databaseName)
Gets a replica set url for a provided
databaseName. |
addEnv, addExposedPort, addExposedPorts, addFileSystemBind, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, configure, containerIsCreated, 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, isPrivilegedMode, isShouldBeReused, logger, setBinds, setCommand, setCommand, setCommandParts, setCopyToFileContainerPathMap, setDockerImageName, setEnv, setExposedPorts, setExtraHosts, setImage, setLabels, setLinkedContainers, setLogConsumers, setNetwork, setNetworkAliases, setNetworkMode, setPortBindings, setPrivilegedMode, setShmSize, setStartupAttempts, setStartupCheckStrategy, setTmpFsMapping, setVolumesFroms, setWaitStrategy, setWorkingDirectory, start, starting, stop, succeeded, toString, waitingFor, waitUntilContainerStarted, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withFileSystemBind, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectoryclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddFileSystemBind, followOutput, followOutput, self, withEnv, withFileSystemBindcopyFileFromContainer, copyFileToContainer, copyFileToContainer, execInContainer, execInContainer, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isHealthy, isRunning@Deprecated public MongoDBContainer()
MongoDBContainer(DockerImageName) insteadpublic MongoDBContainer(@NonNull
@NonNull java.lang.String dockerImageName)
public MongoDBContainer(org.testcontainers.utility.DockerImageName dockerImageName)
public java.lang.String getReplicaSetUrl()
public java.lang.String getReplicaSetUrl(java.lang.String databaseName)
databaseName.databaseName - a database name.protected void containerIsStarted(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
containerIsStarted in class org.testcontainers.containers.GenericContainer<MongoDBContainer>