use of com.spotify.docker.client.messages.ContainerInfo in project docker-client by spotify.
the class DefaultDockerClientTest method testLogsSince.
@Test
public void testLogsSince() throws Exception {
requireDockerApiVersionAtLeast("1.19", "/logs?since=timestamp");
sut.pull(BUSYBOX_LATEST);
final String container = randomName();
final ContainerConfig volumeConfig = ContainerConfig.builder().image(BUSYBOX_LATEST).cmd("echo", "This was printed too late").build();
sut.createContainer(volumeConfig, container);
sut.startContainer(container);
sut.waitContainer(container);
final ContainerInfo info = sut.inspectContainer(container);
assertThat(info.state().running(), is(false));
assertThat(info.state().exitCode(), is(0));
final String logs;
// Get logs since the current timestamp. This should return nothing.
try (LogStream stream = sut.logs(info.id(), stdout(), stderr(), since((int) (System.currentTimeMillis() / 1000L)))) {
logs = stream.readFully();
}
assertThat(logs, not(containsString("This message was printed too late")));
}
use of com.spotify.docker.client.messages.ContainerInfo in project docker-client by spotify.
the class DefaultDockerClientTest method testIpcMode.
@Test
public void testIpcMode() throws Exception {
requireDockerApiVersionAtLeast("1.18", "IpcMode");
final HostConfig hostConfig = HostConfig.builder().ipcMode("host").build();
final ContainerConfig config = ContainerConfig.builder().image(BUSYBOX_LATEST).cmd("sh", "-c", "while :; do sleep 1; done").hostConfig(hostConfig).build();
final ContainerCreation container = sut.createContainer(config, randomName());
final String containerId = container.id();
sut.startContainer(containerId);
final ContainerInfo info = sut.inspectContainer(containerId);
assertThat(info.hostConfig().ipcMode(), is("host"));
}
use of com.spotify.docker.client.messages.ContainerInfo in project zalenium by zalando.
the class DockerContainerClient method loadMountedFolders.
private void loadMountedFolders(String zaleniumContainerName) {
if (!this.mntFoldersAndHttpEnvVarsChecked.get()) {
String containerId = getContainerId(zaleniumContainerName);
if (containerId == null) {
return;
}
ContainerInfo containerInfo = null;
try {
containerInfo = dockerClient.inspectContainer(containerId);
} catch (DockerException | InterruptedException e) {
logger.warn(nodeId + " Error while getting mounted folders and env vars.", e);
ga.trackException(e);
}
loadMountedFolders(containerInfo);
}
}
use of com.spotify.docker.client.messages.ContainerInfo in project zalenium by zalando.
the class DockerContainerClient method getContainerExtraHosts.
private synchronized List<String> getContainerExtraHosts(String zaleniumContainerName) {
if (zaleniumExtraHosts != null) {
return zaleniumExtraHosts;
}
String containerId = getContainerId(zaleniumContainerName);
ContainerInfo containerInfo;
try {
containerInfo = dockerClient.inspectContainer(containerId);
zaleniumExtraHosts = containerInfo.hostConfig().extraHosts();
} catch (DockerException | InterruptedException e) {
logger.warn(nodeId + " Error while getting Zalenium extra hosts.", e);
ga.trackException(e);
}
return Optional.ofNullable(zaleniumExtraHosts).orElse(DEFAULT_DOCKER_EXTRA_HOSTS);
}
use of com.spotify.docker.client.messages.ContainerInfo in project zalenium by zalando.
the class DockerContainerClient method loadIsZaleniumPrivileged.
private void loadIsZaleniumPrivileged(String zaleniumContainerName) {
if (!this.isZaleniumPrivilegedChecked.getAndSet(true)) {
String containerId = getContainerId(zaleniumContainerName);
if (containerId == null) {
return;
}
ContainerInfo containerInfo;
try {
containerInfo = dockerClient.inspectContainer(containerId);
isZaleniumPrivileged = containerInfo.hostConfig().privileged();
} catch (DockerException | InterruptedException e) {
logger.warn(nodeId + " Error while getting value to check if Zalenium is running in privileged mode.", e);
ga.trackException(e);
}
}
}
Aggregations