Skip to content

Commit

Permalink
Avoid using the image name filter. Fixes testcontainers#3574 (testcon…
Browse files Browse the repository at this point in the history
…tainers#3575)

* filter images by reference. Fixes testcontainers#3574

* Use `inspectImageCmd`
  • Loading branch information
bsideup authored Dec 9, 2020
1 parent 602343a commit b0cc476
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.github.dockerjava.api.DockerClient;
import com.github.dockerjava.api.async.ResultCallback;
import com.github.dockerjava.api.command.CreateContainerCmd;
import com.github.dockerjava.api.command.ListImagesCmd;
import com.github.dockerjava.api.exception.InternalServerErrorException;
import com.github.dockerjava.api.exception.NotFoundException;
import com.github.dockerjava.api.model.AccessMode;
Expand Down Expand Up @@ -36,6 +37,7 @@
import java.io.InputStream;
import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.Optional;
Expand Down Expand Up @@ -326,8 +328,9 @@ private boolean checkMountableFile() {
*/
@SneakyThrows
public void checkAndPullImage(DockerClient client, String image) {
List<Image> images = client.listImagesCmd().withImageNameFilter(image).exec();
if (images.isEmpty()) {
try {
client.inspectImageCmd(image).exec();
} catch (NotFoundException e) {
client.pullImageCmd(image).exec(new TimeLimitedLoggedPullImageResultCallback(log)).awaitCompletion();
}
}
Expand Down

0 comments on commit b0cc476

Please sign in to comment.