Skip to content

Instantly share code, notes, and snippets.

@max-weis
Last active May 18, 2020 16:51
Show Gist options
  • Save max-weis/8cfa32cc98ef1ed412a0e6b8df1339ed to your computer and use it in GitHub Desktop.
Save max-weis/8cfa32cc98ef1ed412a0e6b8df1339ed to your computer and use it in GitHub Desktop.
4 ways to wait for a container
// Status Code
GenericContainer container = new GenericContainer("your/image:1.0.0")
.waitingFor(Wait.forHttp("/"));
// Docker Healthcheck
GenericContainer container = new GenericContainer("your/image:1.0.0")
.waitingFor(Wait.forHealthcheck());
// Log
GenericContainer container = new GenericContainer("your/image:1.0.0")
.waitingFor(new WaitAllStrategy()
.withStrategy(Wait.forLogMessage(".*Started web server*.", 1))
.withStartupTimeout(Duration.ofMinutes(1)));
// Health Probe
GenericContainer container = new GenericContainer("your/image:1.0.0")
.waitingFor(new WaitAllStrategy()
.withStrategy(Wait.forHttp("/health/live"))
.withStartupTimeout(Duration.ofMinutes(1)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment