Skip to content

Commit b362f1c

Browse files
author
Marcus Linke
committed
Catch NotFoundException
Conflicts: src/test/java/com/github/dockerjava/client/AbstractDockerClientTest.java
1 parent dad57f9 commit b362f1c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/test/java/com/github/dockerjava/client/AbstractDockerClientTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.github.dockerjava.api.DockerClient;
2424
import com.github.dockerjava.api.DockerException;
2525
import com.github.dockerjava.api.command.InspectContainerResponse;
26+
import com.github.dockerjava.api.NotFoundException;
2627
import com.github.dockerjava.api.model.Frame;
2728
import com.github.dockerjava.api.model.Volume;
2829
import com.github.dockerjava.api.model.VolumeBind;
@@ -51,10 +52,13 @@ public void beforeTest() throws Exception {
5152
LOG.info("Connecting to Docker server");
5253
dockerClient = DockerClientBuilder.getInstance(config()).withDockerCmdExecFactory(dockerCmdExecFactory).build();
5354

54-
LOG.info("Pulling image 'busybox'");
55-
56-
// need to block until image is pulled completely
57-
dockerClient.pullImageCmd("busybox").withTag("latest").exec(new PullImageResultCallback()).awaitSuccess();
55+
try {
56+
dockerClient.inspectImageCmd("busybox").exec();
57+
} catch (NotFoundException e) {
58+
LOG.info("Pulling image 'busybox'");
59+
// need to block until image is pulled completely
60+
dockerClient.pullImageCmd("busybox").withTag("latest").exec(new PullImageResultCallback()).awaitSuccess();
61+
}
5862

5963
assertNotNull(dockerClient);
6064
LOG.info("======================= END OF BEFORETEST =======================\n\n");

0 commit comments

Comments
 (0)