Skip to content

Instantly share code, notes, and snippets.

@shs96c
Created February 21, 2019 14:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shs96c/2cfd75d195f11f0392c9a51c44ea97cd to your computer and use it in GitHub Desktop.
Save shs96c/2cfd75d195f11f0392c9a51c44ea97cd to your computer and use it in GitHub Desktop.
public class DockerTest {
@Test
public void bootstrap() throws IOException {
HttpClient client = HttpClient.Factory.createDefault()
.createClient(new URL("http://localhost:2375"));
Docker docker = new Docker(client);
Image image = docker.findImage(
img -> "selenium/standalone-firefox:3.141.59".equals(img.getName()));
int port = PortProber.findFreePort();
Container container = docker.create(ContainerInfo.image(image).map(tcp(4444), tcp(port)));
container.start();
assertTrue(PortProber.pollPort(port, 10, SECONDS));
container.stop(Duration.ofSeconds(30));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment