diff --git a/pkg/api/handlers/compat/images.go b/pkg/api/handlers/compat/images.go index 3734959cf9..189bcb7989 100644 --- a/pkg/api/handlers/compat/images.go +++ b/pkg/api/handlers/compat/images.go @@ -416,9 +416,10 @@ func GetImages(w http.ResponseWriter, r *http.Request) { decoder := utils.GetDecoder(r) runtime := r.Context().Value(api.RuntimeKey).(*libpod.Runtime) query := struct { - All bool - Digests bool - Filter string // Docker 1.24 compatibility + All bool + Digests bool + Filter string // Docker 1.24 compatibility + SharedSize bool `schema:"shared-size"` // Docker 1.42 compatibility }{ // This is where you can override the golang default value for one of fields } @@ -477,6 +478,10 @@ func GetImages(w http.ResponseWriter, r *http.Request) { if s.RepoDigests == nil { s.RepoDigests = []string{} } + // Docker 1.42 sets SharedSize to -1 if ont passed explicitly + if !query.SharedSize { + s.SharedSize = -1 + } } } utils.WriteResponse(w, http.StatusOK, summaries) diff --git a/test/apiv2/10-images.at b/test/apiv2/10-images.at index ff9fee17d2..65648e2dc7 100644 --- a/test/apiv2/10-images.at +++ b/test/apiv2/10-images.at @@ -455,4 +455,11 @@ t GET images/json 200 \ podman rmi -f $(< $IIDFILE) rm -f $IIDFILE +# check that SharedSize returns -1 for compat api if not set +# and 0 (or the correct shared size) if set +t GET images/json 200 \ + .[0].SharedSize=-1 +t GET images/json?shared-size=true 200 \ + .[0].SharedSize=0 + # vim: filetype=sh