Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 52848fb

Browse filesBrowse files
authored
Merge pull request #5248 from vvoland/v27.0-5246
[27.0 backport] push: Don't default to `DOCKER_DEFAULT_PLATFORM`, improve message
2 parents d41cb08 + bd43ca7 commit 52848fb
Copy full SHA for 52848fb

3 files changed

+39-21Lines changed: 39 additions & 21 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎cli/command/image/push.go‎

Copy file name to clipboardExpand all lines: cli/command/image/push.go
+27-9Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"encoding/json"
99
"fmt"
1010
"io"
11-
"os"
11+
"strings"
1212

1313
"github.com/containerd/platforms"
1414
"github.com/distribution/reference"
@@ -58,8 +58,13 @@ func NewPushCommand(dockerCli command.Cli) *cobra.Command {
5858
flags.BoolVarP(&opts.all, "all-tags", "a", false, "Push all tags of an image to the repository")
5959
flags.BoolVarP(&opts.quiet, "quiet", "q", false, "Suppress verbose output")
6060
command.AddTrustSigningFlags(flags, &opts.untrusted, dockerCli.ContentTrustEnabled())
61-
flags.StringVar(&opts.platform, "platform", os.Getenv("DOCKER_DEFAULT_PLATFORM"),
61+
62+
// Don't default to DOCKER_DEFAULT_PLATFORM env variable, always default to
63+
// pushing the image as-is. This also avoids forcing the platform selection
64+
// on older APIs which don't support it.
65+
flags.StringVar(&opts.platform, "platform", "",
6266
`Push a platform-specific manifest as a single-platform image to the registry.
67+
Image index won't be pushed, meaning that other manifests, including attestations won't be preserved.
6368
'os[/arch[/variant]]': Explicit platform (eg. linux/amd64)`)
6469
flags.SetAnnotation("platform", "version", []string{"1.46"})
6570

@@ -79,9 +84,9 @@ func RunPush(ctx context.Context, dockerCli command.Cli, opts pushOptions) error
7984
}
8085
platform = &p
8186

82-
printNote(dockerCli, `Selecting a single platform will only push one matching image manifest from a multi-platform image index.
83-
This means that any other components attached to the multi-platform image index (like Buildkit attestations) won't be pushed.
84-
If you want to only push a single platform image while preserving the attestations, please use 'docker convert\n'
87+
printNote(dockerCli, `Using --platform pushes only the specified platform manifest of a multi-platform image index.
88+
Other components, like attestations, will not be included.
89+
To push the complete multi-platform image, remove the --platform flag.
8590
`)
8691
}
8792

@@ -179,9 +184,22 @@ func handleAux(dockerCli command.Cli) func(jm jsonmessage.JSONMessage) {
179184

180185
func printNote(dockerCli command.Cli, format string, args ...any) {
181186
if dockerCli.Err().IsTerminal() {
182-
_, _ = fmt.Fprint(dockerCli.Err(), aec.WhiteF.Apply(aec.CyanB.Apply("[ NOTE ]"))+" ")
183-
} else {
184-
_, _ = fmt.Fprint(dockerCli.Err(), "[ NOTE ] ")
187+
format = strings.ReplaceAll(format, "--platform", aec.Bold.Apply("--platform"))
188+
}
189+
190+
header := " Info -> "
191+
padding := len(header)
192+
if dockerCli.Err().IsTerminal() {
193+
padding = len("i Info > ")
194+
header = aec.Bold.Apply(aec.LightCyanB.Apply(aec.BlackF.Apply("i")) + " " + aec.LightCyanF.Apply("Info → "))
195+
}
196+
197+
_, _ = fmt.Fprint(dockerCli.Err(), header)
198+
s := fmt.Sprintf(format, args...)
199+
for idx, line := range strings.Split(s, "\n") {
200+
if idx > 0 {
201+
_, _ = fmt.Fprint(dockerCli.Err(), strings.Repeat(" ", padding))
202+
}
203+
_, _ = fmt.Fprintln(dockerCli.Err(), aec.Italic.Apply(line))
185204
}
186-
_, _ = fmt.Fprintf(dockerCli.Err(), aec.Bold.Apply(format)+"\n", args...)
187205
}
Collapse file

‎docs/reference/commandline/image_push.md‎

Copy file name to clipboardExpand all lines: docs/reference/commandline/image_push.md
+6-6Lines changed: 6 additions & 6 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ Upload an image to a registry
99

1010
### Options
1111

12-
| Name | Type | Default | Description |
13-
|:---------------------------------------------|:---------|:--------|:--------------------------------------------------------------------------------------------------------------------------------------------|
14-
| [`-a`](#all-tags), [`--all-tags`](#all-tags) | `bool` | | Push all tags of an image to the repository |
15-
| `--disable-content-trust` | `bool` | `true` | Skip image signing |
16-
| `--platform` | `string` | | Push a platform-specific manifest as a single-platform image to the registry.<br>'os[/arch[/variant]]': Explicit platform (eg. linux/amd64) |
17-
| `-q`, `--quiet` | `bool` | | Suppress verbose output |
12+
| Name | Type | Default | Description |
13+
|:---------------------------------------------|:---------|:--------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
14+
| [`-a`](#all-tags), [`--all-tags`](#all-tags) | `bool` | | Push all tags of an image to the repository |
15+
| `--disable-content-trust` | `bool` | `true` | Skip image signing |
16+
| `--platform` | `string` | | Push a platform-specific manifest as a single-platform image to the registry.<br>Image index won't be pushed, meaning that other manifests, including attestations won't be preserved.<br>'os[/arch[/variant]]': Explicit platform (eg. linux/amd64) |
17+
| `-q`, `--quiet` | `bool` | | Suppress verbose output |
1818

1919

2020
<!---MARKER_GEN_END-->
Collapse file

‎docs/reference/commandline/push.md‎

Copy file name to clipboardExpand all lines: docs/reference/commandline/push.md
+6-6Lines changed: 6 additions & 6 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,12 @@ Upload an image to a registry
99

1010
### Options
1111

12-
| Name | Type | Default | Description |
13-
|:--------------------------|:---------|:--------|:--------------------------------------------------------------------------------------------------------------------------------------------|
14-
| `-a`, `--all-tags` | `bool` | | Push all tags of an image to the repository |
15-
| `--disable-content-trust` | `bool` | `true` | Skip image signing |
16-
| `--platform` | `string` | | Push a platform-specific manifest as a single-platform image to the registry.<br>'os[/arch[/variant]]': Explicit platform (eg. linux/amd64) |
17-
| `-q`, `--quiet` | `bool` | | Suppress verbose output |
12+
| Name | Type | Default | Description |
13+
|:--------------------------|:---------|:--------|:-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
14+
| `-a`, `--all-tags` | `bool` | | Push all tags of an image to the repository |
15+
| `--disable-content-trust` | `bool` | `true` | Skip image signing |
16+
| `--platform` | `string` | | Push a platform-specific manifest as a single-platform image to the registry.<br>Image index won't be pushed, meaning that other manifests, including attestations won't be preserved.<br>'os[/arch[/variant]]': Explicit platform (eg. linux/amd64) |
17+
| `-q`, `--quiet` | `bool` | | Suppress verbose output |
1818

1919

2020
<!---MARKER_GEN_END-->

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.