Class DockerContainer

java.lang.Object
org.jenkinsci.test.acceptance.docker.DockerContainer
All Implemented Interfaces:
Closeable, AutoCloseable
Direct Known Subclasses:
DynamicDockerContainer, SshdContainer

public class DockerContainer extends Object implements Closeable
Running container, a virtual machine.
Author:
Kohsuke Kawaguchi
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    void
    Stops and remove any trace of the container
    boolean
    cp(String from, String toPath)
    Deprecated.
    do not call inside container.
     
    IP address of this container reachable through the bridge.
     
    long
     
    com.fasterxml.jackson.databind.JsonNode
    Provides details of this container.
    ipBound(int n)
    Finds the ephemeral ip that the given container TCP port is bind to.
    ipUdpBound(int n)
    Finds the ephemeral ip that the given container UDP port is bind to.
    static boolean
     
    int
    port(int n)
    Finds the ephemeral port that the given container port is mapped to.
    resource(String relativePath)
    By convention, docker fixtures put their resources into a sub-directory that has the same name as the class name.
    boolean
    Support the case when ATHs are running in a docker container and using the host docker service to spin "sibling" containers, as described in http://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/
     
    int
    udpPort(int n)
    Finds the ephemeral UDP port that the given container port is mapped to.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • DockerContainer

      public DockerContainer()
  • Method Details

    • assertRunning

      public void assertRunning()
    • resource

      public Resource resource(String relativePath)
      By convention, docker fixtures put their resources into a sub-directory that has the same name as the class name.
    • getCid

      public String getCid()
    • getLogfile

      public File getLogfile()
    • getPid

      public long getPid()
    • ipBound

      public String ipBound(int n)
      Finds the ephemeral ip that the given container TCP port is bind to.
    • ipUdpBound

      public String ipUdpBound(int n)
      Finds the ephemeral ip that the given container UDP port is bind to.
    • port

      public int port(int n)
      Finds the ephemeral port that the given container port is mapped to.
    • udpPort

      public int udpPort(int n)
      Finds the ephemeral UDP port that the given container port is mapped to.
    • close

      public void close()
      Stops and remove any trace of the container
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
    • cp

      @Deprecated public boolean cp(String from, String toPath)
      Deprecated.
      do not call inside container. File ownership does not work the same way for copying from one docker container to another, see https://forums.docker.com/t/can-docker-cp-set-user-id-and-group/21562
      Copies a file or folder from inside the container to the outside. Silently overwrites an existing file.
      Parameters:
      from - the absolute path of the resource to copy
      toPath - the absolute path of the destination directory
      Returns:
      true if the copy was a success otherwise false
    • inspect

      public com.fasterxml.jackson.databind.JsonNode inspect() throws IOException
      Provides details of this container.
      Throws:
      IOException
    • getIpAddress

      public String getIpAddress() throws IOException
      IP address of this container reachable through the bridge.
      Throws:
      IOException
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • sharingHostDockerService

      public boolean sharingHostDockerService()
      Support the case when ATHs are running in a docker container and using the host docker service to spin "sibling" containers, as described in http://jpetazzo.github.io/2015/09/03/do-not-use-docker-in-docker-for-ci/
    • ipv6Enabled

      public static boolean ipv6Enabled()