docker-Java stop timeout

440 views Asked by At

i'm using the java-docker client from here: https://github.com/docker-java/docker-java. I trying to figure out how to set the stop timeout for the docker stop command.

So i'm using in java the method dockerClient.stopContainerCmd(containerId)).exec(); but there is no option for the stop timeout, like the docker cli provides. Maybe someone has already solved the problem or has an idea ? :-)

1

There are 1 answers

1
David Maze On

dockerClient.stopContainerCmd() returns a StopContainerCmd object, and that has a .withTimeout() method. You should be able to add this into your call chain:

dockerClient
  .stopContainerCmd(containerId)
  .withTimeout(new Integer(60)) // appears to be seconds
  .exec();