9916 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
20870f13c2 daemon: remove intermediate vars when collecting diskUsage
Set values directly on the DiskUsage objects instead of using some
intermediate vars, some of which were named slightly confusing due
to them being used both for "totalSize" and "reclaimableSize".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-07 19:57:36 +01:00
Sebastiaan van Stijn
0dcb1fe344 daemon: align build.DiskUsage() with other disk-usages
Move calculation of the data to the builder backend, to align with
the other type of objects. This also allows us to skip the verbose
data if it's not used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-07 19:57:30 +01:00
Sebastiaan van Stijn
f1a3387633 daemon/server/backend: align DiskUsage types with api
Make the "per-object" types aliases for the API type, and remove
the BuildCacheDiskUsage type, as it's not currently used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-07 19:57:13 +01:00
Sebastiaan van Stijn
04de584531 daemon/server/router/system: use shorter names and comments
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-07 19:56:55 +01:00
Sebastiaan van Stijn
32319028e5 daemon/server/router/system: slightly rewrite logic for legacy
Rewrite the logic to have a better separation between producing legacy
fields, and verbose. We need to preserve / include all items in the
response _either_ if a API >= v1.52 client requested "verbose" _or_
if we're about to produce legacy fields.

Also switch to using the `httputils.BoolValue` utility; while we lose
the error for invalid values (which we probably should have as a utility
in `httputils`), it aligns with values accepted for other boolean values.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-07 19:56:37 +01:00
Sebastiaan van Stijn
243e19e1f2 Merge pull request #51421 from thaJeztah/dockerd_cleanups
cmd/dockerd: minor cleanups / changes
2025-11-07 00:53:35 +01:00
Austin Vazquez
931c347b36 api/types: rename disk usage fields
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-11-06 16:21:32 -06:00
Paweł Gronowski
217fd78905 Merge pull request #51412 from austinvazquez/use-regular-slice-for-disk-usage
api/types: use regular slices for disk usage types
2025-11-06 23:13:47 +01:00
Paweł Gronowski
10f6eeb56d daemon: Refactor image store choice logic
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-06 20:09:27 +01:00
Sebastiaan van Stijn
4a3e139e3c daemon/command: NewDaemonRunner: set both stdout and stderr
Make sure Cobra is configured with the streams we use, and use
Cobra's utilities to print the validation messsage.

While updating, also add a short comment outlining why we're using
STDERR, not STDOUT for this message.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-06 15:53:11 +01:00
Sebastiaan van Stijn
0029924181 api/types/system: change legacyDiskUsage to a non-pointer slice
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-06 12:31:05 +01:00
Sebastiaan van Stijn
e509a7cefe daemon/command: remove __dummy_command workaround for completion
This workaround was added in 3bb40af036 to
work around a limitation of Cobra, which didn't support completion if there
are no subcommands, because [Command.InitDefaultCompletionCmd] disabled
completion, as implicitly adding the hidden `completion` and `__complete`
subcommands would break binaries without subcommands that accepted positional
args.

This problem was fixed in Cobra v1.9.0 through [cobra@24ada7f], which now
dynamically adds the `completion` subcommand when invoked.

This patch removes the hidden `__dummy_command`, which was used to work around
the logic in Cobra < v1.9.0, and to make it enable completion regardless.

Completion should still work as usual:

    dockerd completion --help

    Usage:	dockerd completion [flags]
    ...

    source <(dockerd completion bash)
    dockerd --default-<tab>
    --default-address-pool   (Default address pools for node specific local networks)
    --default-cgroupns-mode  (Default mode for containers cgroup namespace ("host" | "private"))
    --default-gateway        (Default gateway IPv4 address for the default bridge network)
    --default-gateway-v6     (Default gateway IPv6 address for the default bridge network)
    --default-ipc-mode       (Default mode for containers ipc ("shareable" | "private"))
    --default-network-opt    (Default network options)
    --default-runtime        (Default OCI runtime for containers)
    --default-shm-size       (Default shm size for containers)
    --default-ulimit         (Default ulimits for containers)

[Command.InitDefaultCompletionCmd]: https://github.com/spf13/cobra/blob/v1.8.1/completions.go#L685-L698
[cobra@24ada7f]: 24ada7fe71

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-06 09:42:49 +01:00
Austin Vazquez
6881ae72c7 api/types: use regular slices for disk usage types
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-11-05 22:05:47 -06:00
Austin Vazquez
5e985ccd90 Merge pull request #51406 from austinvazquez/move-disk-system-usage-types
api/types: move disk usage structs to per type packages
2025-11-05 14:36:03 -06:00
Austin Vazquez
b90e059dd9 Merge pull request #51386 from thaJeztah/adjust_build_tags
daemon/internal: adjust some build-tags
2025-11-05 11:34:12 -06:00
Austin Vazquez
cc25d0ebd4 Merge pull request #51403 from thaJeztah/singularize_prune
client: singularize prune methods
2025-11-05 11:33:14 -06:00
Austin Vazquez
fabdccbe10 api/types: move disk usage structs to per type packages
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-11-05 11:20:15 -06:00
Sebastiaan van Stijn
cdede16ce7 Merge pull request #51399 from thaJeztah/swarm_enums
api/types/swarm: create types for enum-consts
2025-11-05 16:33:20 +01:00
Sebastiaan van Stijn
ebc1dfbb64 client: singularize prune methods
All methods are singular; while pruning will impact multiple items,
it's more consistent to use singular for all operations.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-05 15:48:02 +01:00
Paweł Gronowski
25f880c923 Merge pull request #51365 from SamStudio8/51364-dockersave
docker/save: stable timestamp for blobs/digest dir
2025-11-05 14:04:40 +01:00
Sebastiaan van Stijn
b075a393b1 Merge pull request #51235 from austinvazquez/refactor-client-system
api/types/system: deprecate `DiskUsage.*` fields and add type specific fields
2025-11-05 14:02:50 +01:00
Sebastiaan van Stijn
39ccd04ca8 api/types/swarm: define type for RegistryAuthSource
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-05 13:48:38 +01:00
Sebastiaan van Stijn
3a105f4e0c daemon/internal: adjust some build-tags
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-04 10:52:52 +01:00
Austin Vazquez
a69abdd90d api/types/system: add type specific usage fields to DiskUsage
This change adds type specific fields to `GET /system/df` endpoint with high level information of disk usage. This change also introduces `verbose` query to the endpoint so that detailed information is by default excluded unless queried to reduce memory consumption. The previous top level `DiskUsage` fields (`Images`, `Containers`, `Volumes` and `BuildCache`) are now deprecated and kept for backwards compatibility.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-11-03 16:34:26 -06:00
Rob Murray
2af22d3512 Fix TestHandleMACAddressBC
- expCtrWideMAC was unused
- missing test for API 1.52

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-11-03 18:33:13 +00:00
Sam Nicholls
668b546d2c docker/save: stable timestamp for blobs/digest dir
Writing the OCI manifest file to the blobs/digest dir will update the
directory mtime, producing a tar file containing a member with a
contemporary mtime. Exported tars for the same image will therefore have
different checksums.

Although this was previously addressed by overriding the mtime manually
to 0, this was done before the OCI manifest file was written. This
change simply moves the call to system.Chtimes to set the mtime of the
blobs/digest directory to 0 after writing the OCI manifest file.

This commit also updates the TestSaveCheckTimes integration test to
check the mtime of all members in the exported tar to ensure that all
mtime are not newer than img.Created or 0 (depending on whether the
containerd-snapshotter is disabled or enabled, respectively).

Signed-off-by: Sam Nicholls <sam.nicholls@nanoporetech.com>
2025-11-03 13:15:19 +00:00
Sebastiaan van Stijn
9b8419f6ed daemon/config: export "min-api-version" through daemon.json
Allows the minimum API version to be set through the daemon.json,
e.g. "min-api-version": "1.24"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-31 19:15:18 +01:00
Sebastiaan van Stijn
42eb0aa973 Merge pull request #51360 from AkihiroSuda/deprecate-cgroup1
Deprecate cgroup v1
2025-10-31 17:41:23 +01:00
Paweł Gronowski
fd1593c067 api/container_inspect: Ensure Config is not nil in inspect response
Ensure that the JSON response for the `GET /containers/{name}/json`
outputs an empty object instead of a nil config.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-10-31 12:41:39 +01:00
Sebastiaan van Stijn
6aea8c2591 Dockerfile: update integration-cli CLI to v25.0.5
Now that we're raising the minimum API version, we can also update
the CLI used in our integration-cli tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-31 09:22:40 +01:00
Akihiro Suda
4bcd446f03 Deprecate cgroup v1
Fix issue 51111

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-10-31 17:00:33 +09:00
Sebastiaan van Stijn
12c9de37e9 api/types: move Version to api/types/system
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-31 02:09:38 +01:00
Sebastiaan van Stijn
f6ee11fe60 Merge pull request #51357 from thaJeztah/internalize_pushresult
api/types: remove PushResult type, and move internal
2025-10-31 02:02:06 +01:00
Sebastiaan van Stijn
d7bd5092d9 Merge pull request #51356 from robmry/compat-replace-nil-pointer
API compat: replace nil values when adding fields
2025-10-31 01:13:20 +01:00
Sebastiaan van Stijn
ebe464ea45 api/types: remove PushResult type, and move internal
This type was used as Aux message for docker push, was not documented,
and only present for Docker Content Trust (which is deprecated).

This patch removes it from the API module, and moves the type internal.
We can stop sending this Aux message once DCT is fully phased out.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-31 00:47:23 +01:00
Rob Murray
43b48f1929 Merge pull request #51355 from corhere/api-macaddr-marshaltext
api/t/network: represent MAC addrs as byte slices
2025-10-30 23:43:12 +00:00
Sebastiaan van Stijn
466f2d2e5d Merge pull request #51354 from vvoland/bye-namegen
Move namesgenerator to internal
2025-10-31 00:25:03 +01:00
Rob Murray
22c037982c API compat: replace nil values when adding fields
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-10-30 22:48:32 +00:00
Cory Snider
19f4c27d81 api/t/network: represent MAC addrs as byte slices
Make invalid states unrepresentable by moving away from stringly-typed
MAC address values in API structs. As go.dev/issue/29678 has not yet
been implemented, provide our own HardwareAddr byte-slice type which
implements TextMarshaler and TextUnmarshaler to retain compatibility
with the API wire format.

When stdlib's net.HardwareAddr type implements TextMarshaler and
TextUnmarshaler and GODEBUG=netmarshal becomes the default, we should be
able to make the type a straight alias for stdlib net.HardwareAddr as a
non-breaking change.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-10-30 17:11:38 -04:00
Paweł Gronowski
433023a03d Move namesgenerator to internal
It's frozen and only kept for historical/legacy purposes.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-10-30 19:41:58 +01:00
Paweł Gronowski
7a97e1cb40 Merge pull request #51334 from thaJeztah/rename_auth
api/types/registry: rename AuthenticateOKBody to AuthResponse
2025-10-29 23:51:39 +01:00
Sebastiaan van Stijn
a5c0f152a7 daemon: improve validation for container rename
Improve validation for empty name; while the daemon already handled empty
strings, it didn't account for the "canonical" name with "/" prefix, for
which it would produce an obscure error:

    Error response from daemon: Error when allocating new name: Invalid container name (/ ), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed

Before this change:

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/old/rename?name='
    {"message":"Neither old nor new names may be empty"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/old/rename?name=/'
    {"message":"Error when allocating new name: Invalid container name (/), only [a-zA-Z0-9][a-zA-Z0-9_.-] are allowed"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.51/containers/old/rename?name=/hello'
    # OK

A check was added in the client as well for situations where an older daemon
is used; the same code currently was implemented in the CLI.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-29 18:42:36 +01:00
Sebastiaan van Stijn
0eba2989e0 api/types/registry: rename AuthenticateOKBody to AuthResponse
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-29 18:06:29 +01:00
Austin Vazquez
e9f28e2a41 client: refactor NetworkConnect, NetworkDisconnect, NetworkRemove
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-29 13:02:01 +01:00
Austin Vazquez
aa380c26fc Merge pull request #51304 from thaJeztah/faulty_defers
fix some faulty defers in tests
2025-10-28 18:11:19 -05:00
Sebastiaan van Stijn
90109a373d Merge pull request #51308 from thaJeztah/client_container_types
client: add option and output structs for various container methods
2025-10-28 15:42:25 +01:00
Sebastiaan van Stijn
9e7e01ef16 Merge pull request #51153 from corhere/excise-json-streams-from-api
api: move `pkg/streamformatter`, `pkg/progress` to `daemon/internal`
2025-10-28 13:36:16 +01:00
Sebastiaan van Stijn
1f5c82b9fa client: add option and output structs for various container methods
Add option- and output structs for;

- Client.ContainerKill
- Client.ContainerPause
- Client.ContainerRemove
- Client.ContainerResize
- Client.ContainerRestart
- Client.ContainerStart
- Client.ContainerStop
- Client.ContainerUnpause

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 23:46:28 +01:00
Sebastiaan van Stijn
6a2a1dd6cf api/types/container: StatsResponse: add OSType field
Adds a per-stats OSType field to allow handle the platform-specific fields.
Before this change, the client had to get the OSType field from the server's
API response header and copy it to each record.

Older daemon versions don't have this field, so the client still needs to
handle fallbacks.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 16:39:32 +01:00
Sebastiaan van Stijn
5df881f3a7 daemon: Daemon.ContainerStats: don't escape HTML in responses
We have no need for it, and keeps the response more readable in case
it would ever contain any values that need escaping; it also would save
some cycles to check for such characters.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-27 12:46:03 +01:00