From 4ce6e50e2e1b4c761235916a6d1b9f186127cc0c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Mon, 8 Jul 2024 14:40:51 +0200 Subject: [PATCH] push: Don't default to DOCKER_DEFAULT_PLATFORM MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Paweł Gronowski --- cli/command/image/push.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/cli/command/image/push.go b/cli/command/image/push.go index 6abacbf71d..4460dda70f 100644 --- a/cli/command/image/push.go +++ b/cli/command/image/push.go @@ -8,7 +8,6 @@ import ( "encoding/json" "fmt" "io" - "os" "github.com/containerd/platforms" "github.com/distribution/reference" @@ -58,7 +57,11 @@ func NewPushCommand(dockerCli command.Cli) *cobra.Command { flags.BoolVarP(&opts.all, "all-tags", "a", false, "Push all tags of an image to the repository") flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress verbose output") command.AddTrustSigningFlags(flags, &opts.untrusted, dockerCli.ContentTrustEnabled()) - flags.StringVar(&opts.platform, "platform", os.Getenv("DOCKER_DEFAULT_PLATFORM"), + + // Don't default to DOCKER_DEFAULT_PLATFORM env variable, always default to + // pushing the image as-is. This also avoids forcing the platform selection + // on older APIs which don't support it. + flags.StringVar(&opts.platform, "platform", "", `Push a platform-specific manifest as a single-platform image to the registry. 'os[/arch[/variant]]': Explicit platform (eg. linux/amd64)`) flags.SetAnnotation("platform", "version", []string{"1.46"})