1
0
mirror of https://github.com/docker/cli.git synced 2026-01-06 05:41:44 +03:00
Commit Graph

11851 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
daa15c3bfa e2e: use registry v3
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-24 10:28:42 +02:00
Sebastiaan van Stijn
e241f53ebc Merge pull request #6460 from thaJeztah/no_pause
deprecate "--pause" flag on docker commit in favor of "--no-pause"
2025-09-23 12:54:15 +02:00
Sebastiaan van Stijn
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
Sebastiaan van Stijn
233322637a Merge pull request #6452 from doringeman/image-list-completions
Enable completion for `docker images`
2025-09-19 10:57:16 +02:00
Sebastiaan van Stijn
5d8fb335d4 Merge pull request #6455 from thaJeztah/rm_kmem
cli/command/container: fully deprecate --kernel-memory options
2025-09-16 19:40:56 +02:00
Sebastiaan van Stijn
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
Sebastiaan van Stijn
a02902eb78 docs: deprecated: complete deprecation of kernel-memory limit
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-16 13:50:16 +02:00
Dorin Geman
437f1260fd Enable completion for docker images
Signed-off-by: Dorin Geman <dorin.geman@docker.com>
2025-09-15 11:30:40 +03:00
Sebastiaan van Stijn
4373ce5f8b Merge pull request #6451 from thaJeztah/fix_stats_bounds
cli/command/container: prevent panic during stats on empty event Actor.ID
2025-09-11 17:27:50 +02:00
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
c3ceba2548 Merge pull request #6447 from thaJeztah/default_completion
cli: disable file-completion by default
2025-09-10 15:07:03 +02:00
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
2f6abcf3c2 Merge pull request #6446 from thaJeztah/fix_completions
Improve shell completion for `docker secret` and `docker config` subcommands
2025-09-10 14:30:05 +02:00
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
47b1715d6f cli-plugins: 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).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-10 11:52:32 +02:00
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
c5467b5556 Merge pull request #6246 from mmorel-35/revive/use-errors-new
ci: enable use-errors-new from revive
2025-09-10 11:38:14 +02:00
Sebastiaan van Stijn
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
Matthieu MOREL
22dda0fc2b ci: enable use-errors-new from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-09-10 11:31:26 +02:00
Sebastiaan van Stijn
69972b682b Merge pull request #6441 from thaJeztah/stderrs
cli/command: replace remaining uses of pkg/errors for stdlib
2025-09-10 10:20:21 +02:00
Sebastiaan van Stijn
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
Sebastiaan van Stijn
5245e20866 update vendor
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:08 +02:00
Sebastiaan van Stijn
c0e37dda14 cli/command/container: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:08 +02:00
Sebastiaan van Stijn
b774e75931 cli/command/system: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
Sebastiaan van Stijn
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
Sebastiaan van Stijn
c5150177bf cli/command/secret: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
Sebastiaan van Stijn
573e0bddef cli/command/service: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
Sebastiaan van Stijn
b057ab6d98 cli/command/stack: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:07 +02:00
Sebastiaan van Stijn
0e4934d36c cli/command/swarm: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:06 +02:00
Sebastiaan van Stijn
cd583313ee cli/command/plugin: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:06 +02:00
Sebastiaan van Stijn
5c8817b1b2 cli/command/node: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 19:58:06 +02:00
Sebastiaan van Stijn
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
Sebastiaan van Stijn
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
Sebastiaan van Stijn
179dc0228c cli/command/image: use stdlib errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-09 17:23:58 +02:00
Sebastiaan van Stijn
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
Sebastiaan van Stijn
62d25205e9 Merge pull request #6440 from thaJeztah/use_multierror
use native errors.Join for multi-errors on "docker ps", "docker node ls"
2025-09-09 10:47:23 +02:00
Sebastiaan van Stijn
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