Source:
private int run0() throws InterruptedException, DockerException { Thread.sleep(delayMillis); final ContainerInfo info = getContainerInfo(existingContainerId); final String containerId; if (info != null && info.state().running()) { containerId = existingContainerId; this.containerId = Optional.of(existingContainerId); } else { containerId = createAndStartContainer(); this.containerId = Optional.of(containerId); if (healthChecker.isPresent()) { listener.healthChecking(); final RetryScheduler retryScheduler = BoundedRandomExponentialBackoff.newBuilder() .setMinIntervalMillis(SECONDS.toMillis(1)) .setMaxIntervalMillis(SECONDS.toMillis(30)) .build().newScheduler(); while (!healthChecker.get().check(containerId)) { final ContainerState state = getContainerState(containerId); if (state == null) { log.warn("container state was null during health checking: {}: {}", config, containerId); throw new RuntimeException("container state was null during health checking"); } if (!state.running()) { log.warn("container exited during health checking: {}: {}: {}", config, containerId, state.exitCode()); throw new RuntimeException("container exited during health checking"); } final long retryMillis = retryScheduler.nextMillis(); log.warn("container failed healthcheck, will retry in {}ms: {}: {}", retryMillis, config, containerId); Thread.sleep(retryMillis); } } } listener.running(); serviceRegistrationHandle = Optional.fromNullable(registrar.register(config.registration())); final ContainerExit exit; try { exit = docker.waitContainer(containerId); } finally { unregister(); this.containerId = Optional.absent(); } log.info("container exited: {}: {}: {}", config, containerId, exit.statusCode()); listener.exited(exit.statusCode()); return exit.statusCode(); }

Target:
private int run0() throws InterruptedException, DockerException { Thread.sleep(delayMillis); final ContainerInfo info = getContainerInfo(existingContainerId); final String containerId; if (info != null && info.state().running()) { containerId = existingContainerId; this.containerId = Optional.of(existingContainerId); } else { containerId = createAndStartContainer(); this.containerId = Optional.of(containerId); if (healthChecker.isPresent()) { listener.healthChecking(); final RetryScheduler retryScheduler = BoundedRandomExponentialBackoff.newBuilder() .setMinIntervalMillis(SECONDS.toMillis(1)) .setMaxIntervalMillis(SECONDS.toMillis(30)) .build().newScheduler(); while (!healthChecker.get().check(containerId)) { final ContainerState state = getContainerState(containerId); if (state == null) { final String err = "container " + containerId + " was not found during health " + "checking, or has no State object"; log.warn(err); throw new RuntimeException(err); } if (!state.running()) { final String err = "container " + containerId + " exited during health checking. " + "Exit code: " + state.exitCode() + ", Config: " + config; log.warn(err); throw new RuntimeException(err); } final long retryMillis = retryScheduler.nextMillis(); log.warn("container failed healthcheck, will retry in {}ms: {}: {}", retryMillis, config, containerId); Thread.sleep(retryMillis); } } } listener.running(); serviceRegistrationHandle = Optional.fromNullable(registrar.register(config.registration())); final ContainerExit exit; try { exit = docker.waitContainer(containerId); } finally { unregister(); this.containerId = Optional.absent(); } log.info("container exited: {}: {}: {}", config, containerId, exit.statusCode()); listener.exited(exit.statusCode()); return exit.statusCode(); }