@@ -274,6 +274,11 @@ var listContainersCommand = cli.Command{
274
274
Value : "" ,
275
275
Usage : "Filter by pod id" ,
276
276
},
277
+ cli.StringFlag {
278
+ Name : "image" ,
279
+ Value : "" ,
280
+ Usage : "Filter by container image" ,
281
+ },
277
282
cli.StringFlag {
278
283
Name : "state" ,
279
284
Value : "" ,
@@ -313,6 +318,9 @@ var listContainersCommand = cli.Command{
313
318
if err = getRuntimeClient (context ); err != nil {
314
319
return err
315
320
}
321
+ if err = getImageClient (context ); err != nil {
322
+ return err
323
+ }
316
324
317
325
opts := listOptions {
318
326
id : context .String ("id" ),
@@ -326,6 +334,7 @@ var listContainersCommand = cli.Command{
326
334
latest : context .Bool ("latest" ),
327
335
last : context .Int ("last" ),
328
336
noTrunc : context .Bool ("no-trunc" ),
337
+ image : context .String ("image" ),
329
338
}
330
339
opts .labels , err = parseLabelStringSlice (context .StringSlice ("label" ))
331
340
if err != nil {
@@ -639,6 +648,11 @@ func ListContainers(client pb.RuntimeServiceClient, opts listOptions) error {
639
648
if ! matchesRegex (opts .nameRegexp , c .Metadata .Name ) {
640
649
continue
641
650
}
651
+ if match , err := matchesImage (opts .image , c .GetImage ().GetImage ()); err != nil {
652
+ return fmt .Errorf ("failed to check image match %v" , err )
653
+ } else if ! match {
654
+ continue
655
+ }
642
656
if opts .quiet {
643
657
fmt .Printf ("%s\n " , c .Id )
644
658
continue
0 commit comments