Class DockerContainer

  • All Implemented Interfaces:
    AutoCloseable, org.junit.rules.TestRule, org.testcontainers.containers.Container<DockerContainer>, org.testcontainers.containers.ContainerState, org.testcontainers.containers.traits.LinkableContainer, org.testcontainers.containers.wait.strategy.WaitStrategyTarget, org.testcontainers.lifecycle.Startable

    public class DockerContainer
    extends org.testcontainers.containers.FixedHostPortGenericContainer<DockerContainer>
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static class  DockerContainer.OutputMode  
      • 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, waitStrategy
      • Fields inherited from interface org.testcontainers.containers.ContainerState

        STATE_HEALTHY
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addFileSystemBind​(String hostPath, String containerPath, org.testcontainers.containers.BindMode mode)  
      void addFileSystemBind​(String hostPath, String containerPath, org.testcontainers.containers.BindMode mode, org.testcontainers.containers.SelinuxContext selinuxContext)  
      static void cleanOrCreateHostPath​(Path path)  
      protected void containerIsStarted​(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)  
      protected void containerIsStarting​(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)  
      protected void containerIsStopped​(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)  
      protected void containerIsStopping​(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)  
      void copyFileToContainer​(org.testcontainers.images.builder.Transferable transferable, String containerPath)  
      void copyLogsToHostPath​(Path hostPath)  
      static void ensurePathExists​(Path path)  
      String execCommand​(String... command)  
      String getLogicalName()  
      StatisticsFetcher.Stats getStats()  
      boolean isHealthy()  
      void reset()  
      String toString()  
      void tryStop()  
      DockerContainer waitingForAll​(org.testcontainers.containers.wait.strategy.WaitStrategy... strategies)  
      DockerContainer withEnvironmentListener​(Optional<EnvironmentListener> listener)  
      DockerContainer withExposedLogPaths​(String... logPaths)  
      DockerContainer withFileSystemBind​(String hostPath, String containerPath)  
      DockerContainer withFileSystemBind​(String hostPath, String containerPath, org.testcontainers.containers.BindMode mode)  
      DockerContainer withHealthCheck​(Path healthCheckScript)  
      • Methods inherited from class org.testcontainers.containers.FixedHostPortGenericContainer

        withFixedExposedPort, withFixedExposedPort
      • Methods inherited from class org.testcontainers.containers.GenericContainer

        addEnv, addExposedPort, addExposedPorts, addFixedExposedPort, addFixedExposedPort, addLink, apply, canBeReused, configure, containerIsCreated, containerIsStarted, containerIsStarting, 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, waitingFor, waitUntilContainerStarted, withClasspathResourceMapping, withClasspathResourceMapping, withCommand, withCommand, withCopyFileToContainer, withCreateContainerCmdModifier, withEnv, withEnv, withExposedPorts, withExtraHost, withImagePullPolicy, withLabel, withLabels, withLogConsumer, withMinimumRunningDuration, withNetwork, withNetworkAliases, withNetworkMode, withPrivilegedMode, withReuse, withSharedMemorySize, withStartupAttempts, withStartupCheckStrategy, withStartupTimeout, withTmpFs, withVolumesFrom, withWorkingDirectory
      • Methods inherited from interface org.testcontainers.containers.Container

        followOutput, followOutput, self, withEnv
      • Methods inherited from interface org.testcontainers.containers.ContainerState

        copyFileFromContainer, copyFileToContainer, execInContainer, execInContainer, getBoundPortNumbers, getContainerIpAddress, getCurrentContainerInfo, getFirstMappedPort, getHost, getLogs, getLogs, getMappedPort, isCreated, isRunning
      • Methods inherited from interface org.testcontainers.lifecycle.Startable

        close
    • Constructor Detail

      • DockerContainer

        public DockerContainer​(String dockerImageName,
                               String logicalName)
    • Method Detail

      • getLogicalName

        public String getLogicalName()
      • addFileSystemBind

        public void addFileSystemBind​(String hostPath,
                                      String containerPath,
                                      org.testcontainers.containers.BindMode mode)
      • addFileSystemBind

        public void addFileSystemBind​(String hostPath,
                                      String containerPath,
                                      org.testcontainers.containers.BindMode mode,
                                      org.testcontainers.containers.SelinuxContext selinuxContext)
        Specified by:
        addFileSystemBind in interface org.testcontainers.containers.Container<DockerContainer>
        Overrides:
        addFileSystemBind in class org.testcontainers.containers.GenericContainer<DockerContainer>
      • withFileSystemBind

        public DockerContainer withFileSystemBind​(String hostPath,
                                                  String containerPath,
                                                  org.testcontainers.containers.BindMode mode)
        Specified by:
        withFileSystemBind in interface org.testcontainers.containers.Container<DockerContainer>
        Overrides:
        withFileSystemBind in class org.testcontainers.containers.GenericContainer<DockerContainer>
      • copyFileToContainer

        public void copyFileToContainer​(org.testcontainers.images.builder.Transferable transferable,
                                        String containerPath)
      • containerIsStarting

        protected void containerIsStarting​(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
        Overrides:
        containerIsStarting in class org.testcontainers.containers.GenericContainer<DockerContainer>
      • containerIsStarted

        protected void containerIsStarted​(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
        Overrides:
        containerIsStarted in class org.testcontainers.containers.GenericContainer<DockerContainer>
      • containerIsStopping

        protected void containerIsStopping​(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
        Overrides:
        containerIsStopping in class org.testcontainers.containers.GenericContainer<DockerContainer>
      • containerIsStopped

        protected void containerIsStopped​(com.github.dockerjava.api.command.InspectContainerResponse containerInfo)
        Overrides:
        containerIsStopped in class org.testcontainers.containers.GenericContainer<DockerContainer>
      • execCommand

        public String execCommand​(String... command)
      • copyLogsToHostPath

        public void copyLogsToHostPath​(Path hostPath)
      • waitingForAll

        public DockerContainer waitingForAll​(org.testcontainers.containers.wait.strategy.WaitStrategy... strategies)
      • isHealthy

        public boolean isHealthy()
      • reset

        public void reset()
      • toString

        public String toString()
        Overrides:
        toString in class org.testcontainers.containers.GenericContainer<DockerContainer>
      • cleanOrCreateHostPath

        public static void cleanOrCreateHostPath​(Path path)
      • ensurePathExists

        public static void ensurePathExists​(Path path)
      • tryStop

        public void tryStop()