Skip to content

Commit

Permalink
filter images by reference. Fixes #3574
Browse files Browse the repository at this point in the history
  • Loading branch information
bsideup committed Dec 9, 2020
1 parent 602343a commit dc548d8
Showing 1 changed file with 5 additions and 1 deletion.
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,7 +328,9 @@ private boolean checkMountableFile() {
*/
@SneakyThrows
public void checkAndPullImage(DockerClient client, String image) {
List<Image> images = client.listImagesCmd().withImageNameFilter(image).exec();
ListImagesCmd listImagesCmd = client.listImagesCmd();
listImagesCmd.getFilters().put("reference", Arrays.asList(image));
List<Image> images = listImagesCmd.exec();
if (images.isEmpty()) {
client.pullImageCmd(image).exec(new TimeLimitedLoggedPullImageResultCallback(log)).awaitCompletion();
}
Expand Down

0 comments on commit dc548d8

Please sign in to comment.