use of org.testcontainers.dockerclient.LogToStringContainerCallback in project testcontainers-java by testcontainers.
the class DockerClientFactoryTest method runCommandInsideDockerShouldNotFailIfImageDoesNotExistsLocally.
@Test
public void runCommandInsideDockerShouldNotFailIfImageDoesNotExistsLocally() {
final DockerClientFactory dockFactory = DockerClientFactory.instance();
try {
// remove tiny image, so it will be pulled during next command run
dockFactory.client().removeImageCmd(TestcontainersConfiguration.getInstance().getTinyImage()).withForce(true).exec();
} catch (NotFoundException ignored) {
// Do not fail if it's not pulled yet
}
dockFactory.runInsideDocker(cmd -> cmd.withCmd("sh", "-c", "echo 'SUCCESS'"), (client, id) -> client.logContainerCmd(id).withStdOut(true).exec(new LogToStringContainerCallback()).toString());
}
Aggregations