@@ -2851,6 +2851,42 @@ async def compose_stats(compose, args):
2851
2851
pass
2852
2852
2853
2853
2854
+ @cmd_run (podman_compose , "images" , "List images used by the created containers" )
2855
+ async def compose_images (compose , args ):
2856
+ img_containers = [cnt for cnt in compose .containers if "image" in cnt ]
2857
+ data = []
2858
+ if args .quiet is True :
2859
+ for img in img_containers :
2860
+ name = img ["name" ]
2861
+ output = await compose .podman .output ([], "images" , ["--quiet" , img ["image" ]])
2862
+ data .append (output .decode ("utf-8" ).split ())
2863
+ else :
2864
+ data .append (["CONTAINER" , "REPOSITORY" , "TAG" , "IMAGE ID" , "SIZE" , "" ])
2865
+ for img in img_containers :
2866
+ name = img ["name" ]
2867
+ output = await compose .podman .output (
2868
+ [],
2869
+ "images" ,
2870
+ [
2871
+ "--format" ,
2872
+ "table " + name + " {{.Repository}} {{.Tag}} {{.ID}} {{.Size}}" ,
2873
+ "-n" ,
2874
+ img ["image" ],
2875
+ ],
2876
+ )
2877
+ data .append (output .decode ("utf-8" ).split ())
2878
+
2879
+ # Determine the maximum length of each column
2880
+ column_widths = [max (map (len , column )) for column in zip (* data )]
2881
+
2882
+ # Print each row
2883
+ for row in data :
2884
+ # Format each cell using the maximum column width
2885
+ formatted_row = [cell .ljust (width ) for cell , width in zip (row , column_widths )]
2886
+ formatted_row [- 2 :] = ["" .join (formatted_row [- 2 :]).strip ()]
2887
+ print ("\t " .join (formatted_row ))
2888
+
2889
+
2854
2890
###################
2855
2891
# command arguments parsing
2856
2892
###################
@@ -3285,6 +3321,11 @@ def compose_kill_parse(parser):
3285
3321
)
3286
3322
3287
3323
3324
+ @cmd_parse (podman_compose , "images" )
3325
+ def compose_images_parse (parser ):
3326
+ parser .add_argument ("-q" , "--quiet" , help = "Only display images IDs" , action = "store_true" )
3327
+
3328
+
3288
3329
@cmd_parse (podman_compose , ["stats" ])
3289
3330
def compose_stats_parse (parser ):
3290
3331
parser .add_argument (
0 commit comments