use of com.spotify.docker.client.messages.ContainerInfo in project shinyproxy by openanalytics.
the class DockerEngineBackend method doStartProxy.
@Override
protected void doStartProxy(DockerContainerProxy proxy) throws Exception {
if (proxy.getApp().getDockerNetworkConnections() != null) {
for (String networkConnection : proxy.getApp().getDockerNetworkConnections()) {
dockerClient.connectToNetwork(proxy.getContainerId(), networkConnection);
}
}
dockerClient.startContainer(proxy.getContainerId());
ContainerInfo info = dockerClient.inspectContainer(proxy.getContainerId());
proxy.setName(info.name().substring(1));
}
use of com.spotify.docker.client.messages.ContainerInfo in project docker-client by spotify.
the class DefaultDockerClientTest method testTopProcessesOfContainer.
@Test
public void testTopProcessesOfContainer() throws Exception {
sut.pull(BUSYBOX_LATEST);
final ContainerConfig containerConfig = ContainerConfig.builder().image(BUSYBOX_LATEST).cmd("sh", "-c", "while :; do sleep 1; done").build();
final String containerName = randomName();
final ContainerCreation containerCreation = sut.createContainer(containerConfig, containerName);
final String containerId = containerCreation.id();
sut.startContainer(containerId);
// Ensure that it's running so we can check the active processes
{
final ContainerInfo containerInfo = sut.inspectContainer(containerId);
assertThat(containerInfo.state().running(), equalTo(true));
}
final TopResults topResults = sut.topContainer(containerId, null);
assertThat(topResults.titles(), not(Matchers.empty()));
// there could be one or two processes running, depending on if we happen to catch it in
// between sleeps
assertThat(topResults.processes(), hasSize(greaterThanOrEqualTo(1)));
assertThat(topResults.titles(), either(hasItem("CMD")).or(hasItem("COMMAND")));
final List<String> firstProcessStatus = topResults.processes().get(0);
assertThat("All processes will run as 'root'", firstProcessStatus, hasItem("root"));
}
use of com.spotify.docker.client.messages.ContainerInfo in project docker-client by spotify.
the class DefaultDockerClientTest method testShmSize.
@Test
public void testShmSize() throws Exception {
requireDockerApiVersionAtLeast("1.22", "ShmSize");
// Pull image
sut.pull(BUSYBOX_LATEST);
final ContainerConfig config = ContainerConfig.builder().image(BUSYBOX_LATEST).hostConfig(HostConfig.builder().shmSize(10000000L).build()).build();
final ContainerCreation container = sut.createContainer(config, randomName());
final ContainerInfo info = sut.inspectContainer(container.id());
assertThat(info.hostConfig().shmSize(), is(10000000L));
}
use of com.spotify.docker.client.messages.ContainerInfo in project docker-client by spotify.
the class DefaultDockerClientTest method testOomScoreAdj.
@Test
public void testOomScoreAdj() throws Exception {
requireDockerApiVersionAtLeast("1.22", "OomScoreAdj");
// Pull image
sut.pull(BUSYBOX_LATEST);
final ContainerConfig config = ContainerConfig.builder().image(BUSYBOX_LATEST).hostConfig(HostConfig.builder().oomScoreAdj(// Defaults to 0
500).build()).build();
final ContainerCreation container = sut.createContainer(config, randomName());
final ContainerInfo info = sut.inspectContainer(container.id());
assertThat(info.hostConfig().oomScoreAdj(), is(500));
}
use of com.spotify.docker.client.messages.ContainerInfo in project docker-client by spotify.
the class DefaultDockerClientTest method verifyNoTimeoutContainer.
private void verifyNoTimeoutContainer(final String volumeContainer, final StringBuffer result) throws Exception {
log.info("Reading has finished, waiting for program to end.");
sut.waitContainer(volumeContainer);
final ContainerInfo info = sut.inspectContainer(volumeContainer);
assertThat(result.toString().contains("Finished"), is(true));
assertThat(info.state().running(), is(false));
assertThat(info.state().exitCode(), is(0));
}
Aggregations