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 DockerContainer()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
assertRunning()
void
close()
Stops and remove any trace of the containerboolean
cp(String from, String toPath)
Deprecated.do not call inside container.String
getCid()
String
getIpAddress()
IP address of this container reachable through the bridge.File
getLogfile()
long
getPid()
com.fasterxml.jackson.databind.JsonNode
inspect()
Provides details of this container.String
ipBound(int n)
Finds the ephemeral ip that the given container TCP port is bind to.String
ipUdpBound(int n)
Finds the ephemeral ip that the given container UDP port is bind to.static boolean
ipv6Enabled()
int
port(int n)
Finds the ephemeral port that the given container port is mapped to.Resource
resource(String relativePath)
By convention, docker fixtures put their resources into a sub-directory that has the same name as the class name.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/String
toString()
int
udpPort(int n)
Finds the ephemeral UDP port that the given container port is mapped to.
-
-
-
Method Detail
-
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 interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
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/21562Copies 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 copytoPath
- the absolute path of the destination directory- Returns:
true
if the copy was a success otherwisefalse
-
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
-
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()
-
-