@@ -95,28 +95,27 @@ func runImages(ctx context.Context, dockerCli command.Cli, backendOptions *Backe
9595 if opts .Format == "json" {
9696
9797 type img struct {
98- ID string `json:"ID"`
99- ContainerName string `json:"ContainerName"`
100- Repository string `json:"Repository"`
101- Tag string `json:"Tag"`
102- Platform string `json:"Platform"`
103- Size int64 `json:"Size"`
104- LastTagTime time.Time `json:"LastTagTime"`
98+ ID string `json:"ID"`
99+ ContainerName string `json:"ContainerName"`
100+ Repository string `json:"Repository"`
101+ Tag string `json:"Tag"`
102+ Platform string `json:"Platform"`
103+ Size int64 `json:"Size"`
104+ Created * time.Time `json:"Created,omitempty"`
105+ LastTagTime time.Time `json:"LastTagTime,omitzero"`
105106 }
106107 // Convert map to slice
107108 var imageList []img
108109 for ctr , i := range images {
109110 lastTagTime := i .LastTagTime
110- if lastTagTime .IsZero () {
111- lastTagTime = i .Created
112- }
113111 imageList = append (imageList , img {
114112 ContainerName : ctr ,
115113 ID : i .ID ,
116114 Repository : i .Repository ,
117115 Tag : i .Tag ,
118116 Platform : platforms .Format (i .Platform ),
119117 Size : i .Size ,
118+ Created : i .Created ,
120119 LastTagTime : lastTagTime ,
121120 })
122121 }
@@ -142,7 +141,10 @@ func runImages(ctx context.Context, dockerCli command.Cli, backendOptions *Backe
142141 if tag == "" {
143142 tag = "<none>"
144143 }
145- created := units .HumanDuration (time .Now ().UTC ().Sub (img .LastTagTime )) + " ago"
144+ created := "N/A"
145+ if img .Created != nil {
146+ created = units .HumanDuration (time .Now ().UTC ().Sub (* img .Created )) + " ago"
147+ }
146148 _ , _ = fmt .Fprintf (w , "%s\t %s\t %s\t %s\t %s\t %s\t %s\n " ,
147149 container , repo , tag , platforms .Format (img .Platform ), id , size , created )
148150 }
0 commit comments