Commit Graph

2463 Commits

Author SHA1 Message Date
c8600e1cea Merge pull request #6463 from thaJeztah/remove_oauth_escape_hatch
remove DOCKER_CLI_DISABLE_OAUTH_LOGIN escape hatch
2025-09-24 13:43:42 +02:00
7cc801d93d Merge pull request #6467 from thaJeztah/no_apply
cli/command: NewDockerCli: don't depend on DockerCli.Apply
2025-09-24 13:17:51 +02:00
133279fb0d cli/command: NewDockerCli: don't depend on DockerCli.Apply
The Apply method was added when CLI options for constructing the CLI were
rewritten into functional options in [cli@7f207f3]. There was no mention
in the pull request of this method specifically, and this may have been
related to work being done elsewhere on compose-on-kubernetes or the
compose-cli plugin that may have needed options to modify the CLI config
after it was already initialized.

We should try to remove functions that mutate the CLI configuration after
initialization if possible (and likely remove the `Apply` method); currently
this function is used in docker compose, but as part of a hack that can
probably be avoided.

[cli@7f207f3]: 7f207f3f95

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-24 12:10:57 +02:00
71f46056c9 remove DOCKER_CLI_DISABLE_OAUTH_LOGIN escape hatch
This code was added in 846ecf59ff as an
escape hatch in case the new OAuth login flow would cause problems.
We have not received reports where the new flow caused problems, and
searching the internet shows no mentions of the env-var.

This env-var was not documented, so we can remove it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-23 21:47:30 +02:00
083e5ce872 cli/command/registry: remove deprecated OauthLoginEscapeHatchEnvVar
This const was added in 846ecf59ff, but
only used internally; commit 18cdc25bb4
deprecated the const, which was included in the 28.4 release.

This patch removes the exported const, as it's unused.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-23 21:31:43 +02:00
c5cbb3e648 vendor: github.com/moby/moby/api, github.com/moby/moby/client master
full diffs:

- https://github.com/moby/moby/compare/api/v1.52.0-beta.1...e98849831fc4e35bdc09ed31b85f91caa87a0103
- https://github.com/moby/moby/compare/client/v0.1.0-beta.0...e98849831fc4e35bdc09ed31b85f91caa87a0103

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-23 21:11:17 +02:00
3c244d1099 deprecate "--pause" flag on docker commit in favor of "--no-pause"
Commit [moby@17d870b] (API v1.13, docker v1.1.0) changed the default to pause
containers during commit, keeping the behavior opt-in for older API versions.
This version-gate was removed in [moby@1b1147e] because API versions lower
than v1.23 were no longer supported.

This patch deprecates the `--pause` flag in favor of a `--no-pause` flag to
be more explicit on the default. The old `--pause` flag is marked deprecated
but still functional. Using the deprecated flag will print a warning, and an
error is produced when trying to use both the old and new flag;

    docker commit --pause mycontainer
    Flag --pause has been deprecated, and enabled by default. Use --no-pause to disable pausing during commit.

    docker commit --pause=false mycontainer
    Flag --pause has been deprecated, and enabled by default. Use --no-pause to disable pausing during commit.

    docker commit --pause --no-pause mycontainer
    Flag --pause has been deprecated, use --no-pause instead
    conflicting options: --no-pause and --pause cannot be used together

[moby@17d870b]: 17d870bed5
[moby@1b1147e]: 1b1147e46b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-22 15:41:22 +02:00
233322637a Merge pull request #6452 from doringeman/image-list-completions
Enable completion for `docker images`
2025-09-19 10:57:16 +02:00
f4a433f841 cli/command/container: fully deprecate --kernel-memory options
The `--kernel-memory` flag was still included to allow it to be used with
old API versions, but it's no longer supported by the kernel, and no longer
handled by OCI runtimes, so deprecating the flags.

With this patch, a deprecation warning is now produced when trying to use
the option;

    docker run --kernel-memory 123b busybox
    Flag --kernel-memory has been deprecated, this option is deprecated in the kernel and no longer supported

    docker container create --kernel-memory 123b busybox
    Flag --kernel-memory has been deprecated, and no longer supported by the kernel
    31fb57e2c6434490a2892031602be20d0206d3cf0fc281ea25654c46dcb62bac

Note that cobra does not _fail_ the command when using deprecated options;
we could make this a hard failure instead, but may not be worth the effort.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-16 15:36:45 +02:00
437f1260fd Enable completion for docker images
Signed-off-by: Dorin Geman <dorin.geman@docker.com>
2025-09-15 11:30:40 +03:00
9b79e48646 cli/command/container: prevent panic during stats on empty event Actor.ID
This code was missing a check for the ID field before truncating it to a
shorter length for presentation. This would result in a panic if an event
would either have an empty ID field or a shorter length ID;

    panic: runtime error: slice bounds out of range [:12] with length 0

    goroutine 82 [running]:
    github.com/docker/cli/cli/command/container.RunStats.func2({{0x0, 0x0}, {0x0, 0x0}, {0x0, 0x0}, {0x40001fcba0, 0x9}, {0x40001fcba9, 0x5}, ...})
        /go/src/github.com/docker/cli/cli/command/container/stats.go:146 +0x1d0
    created by github.com/docker/cli/cli/command/container.(*eventHandler).watch in goroutine 6
        /go/src/github.com/docker/cli/cli/command/container/stats.go:363 +0x1c8

We need to look at this code in general; the truncated ID is passed to
NewStats, which uses the ID to propagate the `Container` field in the
`StatsEntry` struct. which is not used in the default format used by
`docker stats` and, having the same content as the `ID` field on the
same struct, doesn't make it very useful, other than being able to
present it under a `CONTAINER` column (instead of `CONTAINER ID`);
we should consider deprecating it; there may be some subtle things
to look into here; the `Container` field originally held the container
name. This was changed in [moby@ef915fd], which introduced separate
`ID` and `Name` fields, renaming the old `Name` field to container.

Looking at [`Stats.SetStatistics()`] and related code in [stats_helpers.go],
the `Container` field is used as the "canonical" reference for the stats
record; this allows the stats _data_ to be refreshed when a new stats
sample arrives for the same container (also see [moby@929a77b], which
moved locking to the `Stats` wrapper struct). This construct allows to
account for intermediate states, where a stats sample was incomplete
or could produce an error; in that case, the reference to the container
for which the stats were sampled is kept to allow removing a container
from the list once the container was removed. We should consider removing
`Container` as a formatting option, and moving the `Container` field to
the outer struct; this makes the outer struct responsible for keeping a
reference to the container, allowing the `StatsEntry` as a whole to be
replaced atomically.

This patch only addresses the panic;

- It changes the logic to preserve the container ID verbatim instead
  of truncating. This allows stats samples to be matched against the
  `Actor.ID` as-is.
- Truncating the `Container` is moved to the presentation logic;
  currently this does not take `--no-trunc` into account to keep
  the existing behavior, but we can (should) consider adding this.
- Logging is improved to use structured logs, and an extra check is
  added to prevent empty IDs from being added as watcher.

[`Stats.SetStatistics()`]: 82281087e3/cli/command/container/formatter_stats.go (L88-L94)
[moby@ef915fd]: ef915fd036
[moby@929a77b]: 929a77b814
[stats_helpers.go]: 82281087e3/cli/command/container/stats_helpers.go (L26-L51)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-11 14:28:25 +02:00
b9314938b7 cli/command/container: improve TestContainerStatsContext
- Use sub-tests
- Don't use un-named keys
- Add test-cases for 'Name', 'ID' and custom container names

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-11 14:10:54 +02:00
b8cda96d11 cli/command/container: improve TestContainerStatsContext
- Don't use unnamed keys
- Use sub-tests
- Add test-cases for Name and ID fields

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-11 13:58:50 +02:00
82281087e3 Merge pull request #6448 from thaJeztah/cleanup_completion
cli/command/completion: change signatures to return a cobra.CompletionFunc
2025-09-10 15:08:18 +02:00
c3ceba2548 Merge pull request #6447 from thaJeztah/default_completion
cli: disable file-completion by default
2025-09-10 15:07:03 +02:00
e78f16961d Merge pull request #6449 from thaJeztah/context_name_positional
cli/command/context: split name from options struct
2025-09-10 15:05:43 +02:00
d391d0fa4a Merge pull request #6445 from thaJeztah/add_plugin_completions
cli/command/plugin: add completion for plugin subcommands
2025-09-10 15:04:43 +02:00
ea8212ab55 cli/command/context: split name from options struct
Name is a required argument for both "create" and "update", so better
to split it from the options struct.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 12:15:50 +02:00
3785198c6e cli/command/completion: change FileNames to return a cobra.CompletionFunc
It's adding a slight indirection by constructing a function when called,
but makes the completion functions more consistent, the signature easier
to read, and making the return type a [cobra.CompletionFunc] makes it
more transparent what it's intended for, and helps discovery of functions
that provide completion.

[cobra.CompletionFunc]: https://pkg.go.dev/github.com/spf13/cobra#CompletionFunc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 12:06:43 +02:00
531f7e121d cli/command/completion: change Platforms to return a cobra.CompletionFunc
It's adding a slight indirection by constructing a function when called,
but makes the completion functions more consistent, the signature easier
to read, and making the return type a [cobra.CompletionFunc] makes it
more transparent what it's intended for, and helps discovery of functions
that provide completion.

[cobra.CompletionFunc]: https://pkg.go.dev/github.com/spf13/cobra#CompletionFunc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 12:06:42 +02:00
810be9fbe9 cli/command/completion: change Platforms to return a cobra.CompletionFunc
It's adding a slight indirection by constructing a function when called,
but makes the completion functions more consistent, the signature easier
to read, and making the return type a [cobra.CompletionFunc] makes it
more transparent what it's intended for, and helps discovery of functions
that provide completion.

[cobra.CompletionFunc]: https://pkg.go.dev/github.com/spf13/cobra#CompletionFunc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 12:06:42 +02:00
d18af47d0f cli/command/completion: change EnvVarNames to return a cobra.CompletionFunc
It's adding a slight indirection by constructing a function when called,
but makes the completion functions more consistent, the signature easier
to read, and making the return type a [cobra.CompletionFunc] makes it
more transparent what it's intended for, and helps discovery of functions
that provide completion.

[cobra.CompletionFunc]: https://pkg.go.dev/github.com/spf13/cobra#CompletionFunc

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 12:06:39 +02:00
78c54646c3 cli: disable file-completion by default
This uses the DefaultShellCompDirective feature which was added
in cobra to override the default (which would complete to use
files for commands and flags).

Note that we set "cobra.NoFileCompletions" for many commands, which
is redundant with this change, so we could remove as well.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:52:32 +02:00
467fcfe4bd cli/command/plugin: add completion for plugin subcommands
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:49:16 +02:00
8325214ccc cli/command: fix completion for secret create, config create
These commands accept two arguments; the first is a custom name,
the second is either a filename or "-" to create from STDIN.

With this patch:

    # does not provide completion
    docker secret create <tab>

    # starts providing completion once a non-empty name is provided
    docker secret create somename<tab>
    file.txt other-file.txt

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:45:21 +02:00
924dd4710b cli/command/secret: fix completion to complete names, not IDs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:45:21 +02:00
d67dad3fb4 cli/command/secret: remove completion for "ls"
This command takes no arguments, so should not provide completion.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:40:42 +02:00
1336f51e6a remove redundant closures around completion functions
These were remnants from some earlier implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:40:42 +02:00
8b23c2bcb5 Merge pull request #6444 from thaJeztah/inspect_completion
cli/command/system: add shell completion for "docker inspect"
2025-09-10 11:36:23 +02:00
8bb5595f28 cli/command/system: add shell completion for "docker inspect"
The "docker inspect" command can inspect any type of object, which would
require all possible endpoints to be contacted. By default, we don't
provide completion, but if a `--type` is passed, we provide completion
for the given type.

For example, `docker inspect --type container` will complete container
names, `docker inspect --type volume` will complete volume names and
so on.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 00:28:08 +02:00
c0e37dda14 cli/command/container: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:08 +02:00
b774e75931 cli/command/system: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
9ba1314d3a cli/command/system: fix error formatting (errlint)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
c5150177bf cli/command/secret: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
573e0bddef cli/command/service: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
b057ab6d98 cli/command/stack: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
0e4934d36c cli/command/swarm: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:06 +02:00
cd583313ee cli/command/plugin: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:06 +02:00
5c8817b1b2 cli/command/node: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:06 +02:00
bf78331f0c cli/command/container: runUpdate: use struct-literal
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:06 +02:00
0c3bb6c0a4 cli/command/container: rename: remove renameOptions
Also remove redundant validation that's already performed by the client
or daemon.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:57:42 +02:00
179dc0228c cli/command/image: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 17:23:58 +02:00
f10041c724 Merge pull request #6439 from thaJeztah/plugin_rm_special_handling
cli/command/plugin: remove special error handling on install, upgrade
2025-09-09 11:59:51 +02:00
fb3f2da50e cli/command/plugin: remove special error handling on install, upgrade
Similar to 323fbc485e - this code was added
in [moby@c127d96], but used string-matching to detect cases where a user
tried to install an image as plugin. However, this handling no longer matched
any error-strings, so no longer worked:

    docker plugin install busybox
    Error response from daemon: did not find plugin config for specified reference docker.io/library/busybox:latest

[moby@c127d96]: c127d9614f

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 20:37:03 +02:00
5df02441ca cli/command/containers: runUpdate: use native errors.Join
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 20:30:41 +02:00
935df8a78f cli/command/node: runPs: use native errors.Join
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 20:30:41 +02:00
26bb688ed0 cli/command/stack: internalize RunDeploy, RunRemove
These were deprecated in ad6ab189a6 and
were only used internally. Move them back inside the stack package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 16:03:38 +02:00
73677146f4 cli/command/stack: internalize GetConfigDetails, LoadComposefile
These were deprecated in ad6ab189a6 and
were only used internally. Move them back inside the stack package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 15:24:35 +02:00
b55fed5ef6 vendor: github.com/moby/moby/api v1.52.0-beta.1, client v0.1.0-beta.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Co-authored-by: Austin Vazquez <austin.vazquez@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-05 22:41:03 +02:00
589f56c345 Merge pull request #6432 from thaJeztah/rm_windows_warning
cli/command/image: build: remove permissions warning on Windows
2025-09-05 09:51:00 -07:00