Commit Graph

140 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
515dbc8c71 Merge pull request #51826 from thaJeztah/29.x_backport_45939-init-layer-cleanup
[docker-29.x backport] layer: Clean up init layer if initialization fails
2026-01-08 17:24:06 +01:00
Sebastiaan van Stijn
adf3073cb6 Merge pull request #51825 from thaJeztah/29.x_backport_archive_rm_deprecated
[docker-29.x backport] remove uses of deprecated go-archive consts
2026-01-08 17:23:43 +01:00
Paweł Gronowski
a1f7fff7a9 daemon/layer_store: Use named return error for defer
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit 26bb1af7e6)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-01-08 11:00:00 +01:00
Jan Scheffler
0e600c7fc4 layer: Clean up init layer if initialization fails
Add cleanup for the init layer directory if any operation fails after
driver.CreateReadWrite() succeeds in initMount(). Previously, failures
in driver.Get(), initFunc(), or driver.Put() would leave an orphaned
overlay2 directory.

Related to moby/moby#45939

Signed-off-by: Jan Scheffler <jan.scheffler@qodev.ai>
(cherry picked from commit 3fdde529e7)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-01-08 11:00:00 +01:00
Sebastiaan van Stijn
734bb626e4 remove uses of deprecated go-archive consts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 7239c72eca)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-01-08 10:54:50 +01:00
Jan Scheffler
5eaae6db52 layer: Clean up RW layer if mount metadata save fails
Add cleanup for the RW layer directory if saveMount() fails after
driver.CreateReadWrite() succeeds. Previously, this failure path would
leave an orphaned overlay2 directory with no corresponding metadata.

Related to moby/moby#45939

Signed-off-by: Jan Scheffler <jan.scheffler@qodev.ai>
(cherry picked from commit d7a6250b91)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-01-08 10:49:11 +01:00
Jan Scheffler
518779c90b layer: Fix orphan creation in registerWithDescriptor
Start the metadata transaction before creating the overlay2 directory.
This ensures that if driver.Create() fails, we can properly cancel the
transaction. Previously, if StartTransaction() failed after driver.Create()
succeeded, the defer cleanup would not run (not registered yet), leaving
an orphaned overlay2 directory.

The fix reorders operations so that:
1. Transaction is started first (no filesystem changes yet)
2. Overlay2 directory is created second (transaction ready for cleanup)
3. Defer is registered after both succeed (tx is guaranteed non-nil)

If driver.Create() fails, the transaction is explicitly cancelled before
returning. The nil check for tx in the defer is no longer needed since
tx is guaranteed to exist when the defer runs.

Related to moby/moby#45939

Signed-off-by: Jan Scheffler <jan.scheffler@qodev.ai>
(cherry picked from commit 70004549fb)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-12 12:45:16 +01:00
Rob Murray
7517464283 PublishAllPorts: don't crash with nil PortBindings
Introduced by commit 85b260f ("PublishAllPorts: create
port mappings for exposed ports").

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-11-29 19:43:30 +00:00
Paweł Gronowski
b4f9bd1cb3 c8d/builder-next: Don't force unpack
The image exporter wrapper was unconditionally setting `unpack=true` for
all build exports, preventing users from controlling this behavior
through buildkit's output image exporter option.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-11-12 14:34:12 +01:00
Paweł Gronowski
e7d7771bce Merge pull request #51483 from thaJeztah/rm_MinConnectTimeout
daemon: remove workaround for c8d client connection timeout
2025-11-12 11:01:16 +01:00
Tonis Tiigi
3874ca5984 vendor: update buildkit to v0.26.0-rc2
Currently requires replace rule for swarmkit etcd.

BuildKit itself doesn't use etcd but version gets bumped
via unused dependency.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-11 23:15:07 +01:00
Sebastiaan van Stijn
7e78088f8f daemon: remove workaround for c8d client connection timeout
This workaround was added in df519e9e1a, pending
a fix in containerd;

> daemon: Fix giving up too early while connecting to containerd socket
>
> Explicitly set the gRPC connection params to take the timeout into
> account to workaround the containerd v2 client not passing down the
> stack.
>
> containerd v2 replaced usages of deprecated gRPC functions but didn't
> pass the timeout to the actual dial connection options.

A fix for this was merged in [containerd@ee574e7], which is part of containerd
v2.1.0-beta.0, and backported to containerd v2.0.4 through [containerd@6b5efba].

[containerd@ee574e7]: ee574e76e7
[containerd@6b5efba]: 6b5efba83b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-11 17:55:44 +01:00
Sebastiaan van Stijn
bb56c4d7e7 daemon: remove some deprecated and unused code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-11 09:05:41 +01:00
Vigilans
d192a63467 daemon: Ensure buildkit created container's isolation mode consistent with daemon's config
- Introduced DefaultIsolation method in the Daemon to return the daemon configured isolation mode for Windows.

Signed-off-by: Vigilans <vigilans@foxmail.com>
2025-11-10 16:33:14 +01:00
Sebastiaan van Stijn
1fd87e9fdf api/types/container: make ContainerState a concrete type
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-10 16:08:12 +01:00
Sebastiaan van Stijn
46090e88e4 daemon/internal/builder-next: Builder.DiskUsage(): use singleflight
Use a singleflight for collecting the build-cache usage; collecting this
information is potentially heavy-weight, and we already do this for the
other disk-usage methods.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-07 21:32:23 +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
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
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
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
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
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
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
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
687c3d7f42 api/types/jsonstream: define Message type
The schema of a JSON-stream message is very pertinent to the api module.
Provide a canonical definition in the api module and refactor the daemon
code to use it. Drop the long-deprecated ErrorMessage field from the API
definition, but have the daemon continue to emit it for compatibility
with docker-py v7.1.0.

Co-authored-by: Cory Snider <csnider@mirantis.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-24 07:56:58 -05:00
Cory Snider
ae28867804 api/pkg/progress: move to client and daemon/internal
Move the progress package up into the client as a temporary shared location for
common clients like CLI and compose.

The progress package is used by the daemon to write progress updates to
some sink, typically a streamformatter. This package is of little use to
API clients as this package does not provide any facilities to consume
the progress updates.

Co-authored-by: Cory Snider <csnider@mirantis.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-24 07:56:57 -05:00
Cory Snider
6baf274fa3 api/pkg/streamformatter: move to client and daemon/internal
Move the streamformatter package up into the client for a temporary
shared location between common clients like CLI and compose.

The streamformatter package is used by the daemon to write streams of
status and progress messages to API clients. It is completely out of
scope of the api module and not used outside the daemon. Remove the
unused rawSteamFormatter, whose purpose is to render the progress as a
TUI.

Co-authored-by: Cory Snider <csnider@mirantis.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-24 07:56:51 -05:00
Austin Vazquez
f40e1a7582 api: move types/versions to client/pkg and daemon/internal
This change moves the api/types/versions package out into client and daemon versions.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-23 19:22:31 -05:00
Austin Vazquez
d62a521c7d daemon: initialize volumes if nil on decode
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-15 09:40:37 -05:00
Sebastiaan van Stijn
47fe719b33 api/types/build: remove deprecated BuildCache.Parent field
The BuildCache.Parent field was removed in API v1.42 in [moby@e0db820].
While we had to keep the Go struct field around to backfill the field for
older API versions, it's no longer part of API v1.42 and up (using the
"omitempty" is just an implementation detail).

Older clients unconditionally use the `Parents` field if set, and usage
of this field is very limited, so let's remove the field without back-
filling, and have clients use the replacement field;
https://github.com/docker/cli/blob/v28.5.1/cli/command/formatter/buildcache.go

[moby@e0db820]: e0db8207f3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-14 14:51:31 +02:00
David Warnquist
3848b16bca Removed all occurrences of wrapError in libcontainerd/remote
Signed-off-by: David Warnquist <voffffla@gmail.com>
2025-10-12 18:22:45 +02:00
Sebastiaan van Stijn
0769fe7087 Merge pull request #51157 from corhere/split-stdcopy
api/pkg/stdcopy: move stdWriter to daemon/internal
2025-10-10 17:33:43 +02:00
Sebastiaan van Stijn
4210e4ad16 daemon/internal/netiputil: make "MaybeXXX" functions a function, not var
This make it ever so slightly more clear (also when viewing docs).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-10 10:23:03 +02:00
Cory Snider
4c6e571d38 api/pkg/stdcopy: move stdWriter to daemon/internal
Clients have no need for muxing streams using our StdCopy wire format.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-10-09 20:13:26 -04:00
Cory Snider
778e5bfad3 api/types/filters: move to daemon/internal
Most of the code in the filters package relates to the unmarshaling,
validation and application of filters from client requests. None of this
is necessary or particularly useful for Go SDK users. Move the full-fat
filters package into daemon/internal and switch all the daemon code to
import that package so we are free to iterate upon the code without
worrying about source-code interface compatibility.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-10-08 12:06:26 -04:00
Jonathan A. Sternberg
1a7d7cc015 builder: use proper percentage calculations for default gc policy
The default gc policy calculations based on percentage were calculated
improperly. These were calculated correctly in buildkit, but the
calculation method was not copied over correctly when updating the
values.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-10-07 10:18:17 -05:00
Sebastiaan van Stijn
a99b7947e1 daemon: stop propagating Image.DockerVersion field
The DockerVersion field was used by the legacy builder, and set when
importing an image; when importing an image, this would potentially
result in less reproducible images, as the docker version used to import
the image would be encoded in the image's "v1" fields.

For the legacy builder, including the version of docker used to build
the image could still be useful information (but could be set as comment,
similar to what BuildKit does), however, many code paths were also shared
with other parts of the code; e.g., when listing images or inspecting images,
the `DockerVersion` field would always be set to the current version of
the docker daemon, and not taken from the information available in the
image (if any).

This patch removes locations where the `DockerVersion` field was set to
the current version of the daemon binary. When inspecting an image, the
field is still set with the information in the image itself (which may
be empty in most cases).

This also reduces the number of places where the `dockerversion` package
is used, which still needs a new home.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-07 09:00:09 +02:00
Sebastiaan van Stijn
8ddcbbd612 Merge pull request #51094 from austinvazquez/consolidate-api-port-types
Consolidate api port types
2025-10-06 12:35:15 +02:00
Sebastiaan van Stijn
e204ba1dca daemon/internal/compat: add extra fields recursively, and don't replace
This was a bit of an oversight; when setting additional fields to add,
the compat package currently replaces fields unconditionally. This may
have sounded like an OK idea, but it makes it more complicated to augment
responses where current versions use an "omitempty", but older API versions
should return default / zero-values.

This patch:

- Changes the meaning of "extra fields"; extra fields are only used if
  the field is not present in the response.
- Makes the merging of "extra fields" recursive; this makes it easier
  to patch responses where extra fields must be added to nested structs.
  Previously, this would require the nested struct to be wrapped with a
  `compat.Wrap` and replaced as a whole; lacking a "replace" option made
  that more complicated, so making the extra fields recursive.
- Comment-out a test that tested the old behavior of replacing fields;
  we currently have no cases where we must _replace_ fields or structs,
  so I did not yet implement such an option, but we can implement a
  `WithReplaceFields` (e.g.) once there's a need.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-04 15:09:22 +02:00
Austin Vazquez
c646091d57 api: move container port type to network package
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-03 17:30:42 -05:00
Cory Snider
d5c838dc5e internal: move sliceutil from daemon/internal
These utilities are very handy to use in integration tests, too. Move
the package so it can be imported by them.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-10-03 21:39:14 +02:00
Cory Snider
a90adb6dc1 api/types/network: use netip types as appropriate
And generate the ServiceInfo struct from the Swagger spec.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-10-03 21:39:14 +02:00
Cory Snider
cc082add87 api/types/swarm: use netip types as appropriate
Change the types for IP address and prefix struct fields to netip.Addr
and netip.Prefix for convenience. Fields such as
swarm.InitRequest.ListenAddr which may encode non-numeric values such as
a network interface name have not been modified.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-10-03 21:39:13 +02:00
Cory Snider
46ab36ae46 daemon/internal: move netiputil from libnetwork
These utilities are going to be needed elsewhere in the daemon to handle
netip values from API requests.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-10-03 21:39:13 +02:00
Cory Snider
470f5b50a5 internal/sliceutil: map nil to nil
As there is a meaningful distinction between a nil slice and an empty
but non-nil slice in some contexts, having sliceutil.Map return an empty
slice when passed a nil slice can introduce subtle bugs. Modify Map to
return a nil slice when passed a nil slice.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-10-03 21:39:10 +02:00
Austin Vazquez
cb3abacc52 api/types/container: add network port and port range types
Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Co-authored-by: Cory Snider <csnider@mirantis.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-02 13:59:34 -05:00
Albin Kerouanton
d5d3716705 daemon/i/compat: disable HTML encoding
The compat package marshals the base value into JSON to convert it into
a map[string]any, then applies the compat options, and finally
re-encodes the map into JSON.

`json.Marshal` is used for both marshalling operations. However, this
function encodes special HTML characters by default. The API responses
aren't meant to be embedded into HTML, so this behavior is not desired.

Replace `json.Marshal` with a `json.Encoder` with HTML escaping
disabled. Extra care is taken to drop the trailing LF added by
`(*json.Encoder).Encode()` (see [1]).

[1]: https://pkg.go.dev/encoding/json#Encoder.Encode

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-11 15:43:36 +02:00
Sebastiaan van Stijn
33a05ac344 daemon/internal: add "compat" package for legacy responses
Add a package to help augmenting API responses with additional fields,
replacing fields, or to remove fields from the response to allow for
legacy API responses to be produced without having to keep deprecated
fields in the API type definitions.

Co-authored-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-11 00:13:05 +02:00
Sebastiaan van Stijn
4b230a4909 internal/testutils: merge with internal/testutil
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 10:08:35 +02:00
Sebastiaan van Stijn
5232d82c1b daemon/server/backend: move build options to buildbackend
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-05 15:56:56 +02:00