File tree Expand file tree Collapse file tree 1 file changed +5
-2
lines changed
core/src/main/java/org/testcontainers Expand file tree Collapse file tree 1 file changed +5
-2
lines changed Original file line number Diff line number Diff line change 3
3
import com .github .dockerjava .api .DockerClient ;
4
4
import com .github .dockerjava .api .async .ResultCallback ;
5
5
import com .github .dockerjava .api .command .CreateContainerCmd ;
6
+ import com .github .dockerjava .api .command .ListImagesCmd ;
6
7
import com .github .dockerjava .api .exception .InternalServerErrorException ;
7
8
import com .github .dockerjava .api .exception .NotFoundException ;
8
9
import com .github .dockerjava .api .model .AccessMode ;
36
37
import java .io .InputStream ;
37
38
import java .net .URI ;
38
39
import java .util .ArrayList ;
40
+ import java .util .Arrays ;
39
41
import java .util .List ;
40
42
import java .util .Map ;
41
43
import java .util .Optional ;
@@ -326,8 +328,9 @@ private boolean checkMountableFile() {
326
328
*/
327
329
@ SneakyThrows
328
330
public void checkAndPullImage (DockerClient client , String image ) {
329
- List <Image > images = client .listImagesCmd ().withImageNameFilter (image ).exec ();
330
- if (images .isEmpty ()) {
331
+ try {
332
+ client .inspectImageCmd (image ).exec ();
333
+ } catch (NotFoundException e ) {
331
334
client .pullImageCmd (image ).exec (new TimeLimitedLoggedPullImageResultCallback (log )).awaitCompletion ();
332
335
}
333
336
}
You can’t perform that action at this time.
0 commit comments