use of com.github.dockerjava.api.command.CreateContainerResponse in project dockerunit by qzagarese.
the class DefaultServiceBuilder method startContainer.
private String startContainer(CreateContainerCmd cmd, DockerClient client) {
CreateContainerResponse createResp = cmd.exec();
StartContainerCmd startCmd = client.startContainerCmd(createResp.getId());
try {
startCmd.exec();
} catch (Throwable t) {
throw new ContainerException(createResp.getId(), t);
}
return startCmd.getContainerId();
}
use of com.github.dockerjava.api.command.CreateContainerResponse in project tutorials by eugenp.
the class ContainerLiveTest method whenRunningContainer_thenStopContainer.
@Test
public void whenRunningContainer_thenStopContainer() throws InterruptedException {
// when
CreateContainerResponse container = dockerClient.createContainerCmd("alpine:3.6").withCmd("sleep", "10000").exec();
Thread.sleep(3000);
dockerClient.startContainerCmd(container.getId()).exec();
// then
dockerClient.stopContainerCmd(container.getId()).exec();
}
use of com.github.dockerjava.api.command.CreateContainerResponse in project tutorials by eugenp.
the class ContainerLiveTest method whenCreatingContainer_thenMustReturnContainerId.
@Test
public void whenCreatingContainer_thenMustReturnContainerId() {
// when
CreateContainerResponse container = dockerClient.createContainerCmd("mongo:3.6").withCmd("--bind_ip_all").withName("mongo").withHostName("baeldung").withEnv("MONGO_LATEST_VERSION=3.6").withPortBindings(PortBinding.parse("9999:27017")).exec();
// then
assertThat(container.getId(), is(not(null)));
}
use of com.github.dockerjava.api.command.CreateContainerResponse in project tutorials by eugenp.
the class ContainerLiveTest method whenRunningContainer_thenKillContainer.
@Test
public void whenRunningContainer_thenKillContainer() throws InterruptedException {
// when
CreateContainerResponse container = dockerClient.createContainerCmd("alpine:3.6").withCmd("sleep", "10000").exec();
dockerClient.startContainerCmd(container.getId()).exec();
Thread.sleep(3000);
dockerClient.stopContainerCmd(container.getId()).exec();
// then
dockerClient.killContainerCmd(container.getId()).exec();
}
use of com.github.dockerjava.api.command.CreateContainerResponse in project tutorials by eugenp.
the class ContainerLiveTest method whenHavingContainer_thenInspectContainer.
@Test
public void whenHavingContainer_thenInspectContainer() {
// when
CreateContainerResponse container = dockerClient.createContainerCmd("alpine:3.6").withCmd("sleep", "10000").exec();
// then
InspectContainerResponse containerResponse = dockerClient.inspectContainerCmd(container.getId()).exec();
assertThat(containerResponse.getId(), is(container.getId()));
}
Aggregations