344 Commits
Author SHA1 Message Date
Paweł Gronowski 08addf04d2 Merge pull request #53172 from vvoland/kill-ctx
daemon: Pass context through container kill operations
2026-07-30 20:42:12 +02:00
Sebastiaan van Stijn ad6880bdcc Merge pull request #53233 from thaJeztah/executor_events
daemon/cluster: close container event stream on shutdown
2026-07-29 19:21:14 +02:00
Sebastiaan van Stijn df72635b87 Merge pull request #53232 from thaJeztah/executor_no_shadow
daemon/cluster/executor/container: rename var that shadowed
2026-07-29 19:16:25 +02:00
Sebastiaan van Stijn efc2fa7c61 *: don't manually call Events.Evict() in tests
Events.Subscribe() returns a cancel func that can handle this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-29 15:45:40 +02:00
Sebastiaan van Stijn f138a5bba9 daemon/cluster: close container event stream on shutdown
Close the returned event channel when the forwarding goroutine exits, allowing
consumers to detect that the event stream has stopped.

Also handle the backend subscription channel being closed. Previously, reads
from a closed channel returned nil repeatedly, causing the goroutine to log
unexpected messages and continue looping.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-29 15:35:26 +02:00
Sebastiaan van Stijn 3b823672b6 daemon/cluster: remove unused event-buffer
backend.SubscribeToEvents is always called without since/until filters,
which means that we never receive historic events, only live events.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-29 15:35:26 +02:00
Sebastiaan van Stijn 89a3b918d8 daemon/cluster/executor/container: rename var that shadowed
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-29 15:27:41 +02:00
Sopho Merkviladze 898a7d799e daemon/cluster: only fail a task on a pull error if the image is missing
A task whose image cannot be pulled is rejected outright when the registry
answers with an "unauthorized" error, even when the image is already present
on the node. A service created without registry credentials carries no auth in
its spec and cannot have its digest resolved, so its tasks always attempt an
unauthenticated pull; on nodes that already hold the image those tasks are
rejected instead of started.

Tolerating a failed pull when the image is available locally is long-standing
behaviour, described in the comment above the check, and what the executor did
for every pull error before a7cf7eac0a ("fix: propagate registry auth error in
swarm image pull").

Keep reporting the pull failure, as it is far more useful than the "No such
image" the container create would otherwise produce, but only when the image
really is unavailable. Whether a task can run should not depend on how the
registry error happened to be classified, and that classification is not
consistent: the same registry 401 surfaces as ErrUnauthenticated from the
graphdriver pull path, as ErrNotFound from the containerd image store (via
docker.ErrInvalidAuthorization), and as ErrUnknown when the failure happens
while fetching a token, since the error is then a *url.Error that
translatePullError does not classify. The check therefore only fires for some
combinations of image store and registry.

The test needs DOCKER_SERVICE_PREFER_OFFLINE_IMAGE=0 on the daemon under test:
internal/testutil/daemon sets it to 1, which makes the executor skip the pull
altogether.

Signed-off-by: Sopho Merkviladze <smerkviladze@mirantis.com>
2026-07-28 00:52:25 +02:00
Paweł Gronowski 98d4cd6551 daemon: Pass context through container kill operations
Drop cancellation at the kill boundary because killing starts
irreversible task and cleanup work that must finish after request
cancellation.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-07-27 19:11:36 +02:00
Sebastiaan van Stijn 67e0132b6c daemon/cluster: fix perfsprint linting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-06 15:36:18 +02:00
Md_Mushfiqur Rahim a7cf7eac0a fix: propagate registry auth error in swarm image pull
When a worker pull fails with unauthorized, the error was being
swallowed and replaced with misleading 'No such image' message.
Fix error propagation so the actual cause is reported.

Signed-off-by: Md_Mushfiqur Rahim <20mahin20201@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-12 15:37:21 +02:00
Sahana Narasipura Vasudevarao 07a5e924ce Fix typos and misspellings in comments, tests, and docs
Signed-off-by: Sahana Narasipura Vasudevarao <nvsahanarao@gmail.com>
2026-04-02 14:20:22 -07:00
Sebastiaan van Stijn f401a9678b daemon/server/backend: ContainerLogsOptions: use time.Time for since, until
Move parsing the wire format to the router instead of in the daemon, so
that a strong type can be used internally.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-03 21:53:23 +01:00
Sebastiaan van Stijn 8a01dc2f90 daemon/cluster/executor/container: rename vars that shadowed
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-01-05 12:42:49 +01:00
Paweł Gronowski 51d1974500 daemon/cluster/test: Use t.Context()
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:56:34 +01:00
Paweł Gronowski cdce8f4f92 modernize: Use maps.Copy instead of for loops
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:56:33 +01:00
Paweł Gronowski ea59a8d74e Merge pull request #51114 from dperny/memory_flags_for_swarm
Add support for memory swap settings for services
2025-10-24 10:04:17 +02:00
Sebastiaan van Stijn 79912d4c7f daemon: Daemon.getInspectData: move migration code to router
There also appeared to be duplication between daemon.getInspectData,
and the containerRouter.postContainersCreate methods, as both were
back-filling the field.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-21 09:15:18 +02:00
Austin Vazquez 42ba5466c7 api: rename volumes.CreateOptions to volumes.CreateRequest
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-20 13:23:41 -05:00
Jean Rouge 3a90dd8b8f Adding support for memory swap settings for services
With integration tests

Relevant Swarmkit PR: https://github.com/docker/swarmkit/pull/2816
(updated the vendored version of Swarkit to that)

Signed-off-by: Jean Rouge <rougej+github@gmail.com>

Updated for latest master, fixed bitrot.

Signed-off-by: Drew Erny <derny@mirantis.com>
2025-10-20 10:34:05 -05: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
Sebastiaan van Stijn 4302ae9d1a Merge pull request #51102 from thaJeztah/move_more_imagebackendopts
daemon/server: move GetImageOpts, ImageInspectOpts to imagebackend
2025-10-06 14:17:32 +02:00
Sebastiaan van Stijn 15bef6ff1a daemon/server: move GetImageOpts, ImageInspectOpts to imagebackend
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-05 13:41: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 fd4329a620 api/types/container: use netip types as appropriate
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
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
Sebastiaan van Stijn 9d53093db6 daemon/server/imagebackend: add PullOptions struct
The PullImage method for the ImageService used positional arguments for its
options, which made it more difficult to introduce new options. This patch
introduces a `PullOptions` struct to specify the options. As part of these
changes, the `platform` option was already adjusted to accept a slice of
platforms, which currently is not supported, but may be in the near future.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-23 09:43:03 +02:00
Sebastiaan van Stijn 4d20b6fe56 api/types/container: move container options to client
Move the option-types to the client and in some cases create a
copy for the backend. These types are used to construct query-
args, and not marshaled to JSON, and can be replaced with functional
options in the client.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-04 20:09:55 +02:00
Austin Vazquez 1b4fcb8da7 api/types/network: move CreateOptions type to client module
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-08-27 08:10:20 -05:00
Austin Vazquez 812aa46d81 Move the api/types/time package to internal daemon package
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-08-14 07:56:59 -05:00
Matthieu MOREL 96f8c6395e chore: enable use-any rule from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-08-08 17:07:07 +02:00
Sebastiaan van Stijn 78ccee32b3 update various "doc" links in code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-05 20:49:57 +02:00
Derek McGowan f74e5d48b3 Create github.com/moby/moby/v2 module
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-31 10:13:29 -07:00
Sebastiaan van Stijn d58dc493fe replace direct uses of nat types for api/types/container aliases
Follow-up to 494677f93f, which added
the aliases, but did not yet replace our own use of the nat types.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-31 02:57:39 +02:00
Sebastiaan van Stijn ec3e83a7b5 api/types/container: move StateStatus, NewStateStatus internal again
These types used to be internal to the container package, but were
moved to the API in 100102108b.

However, the `StateStatus` type is only used internally; it's used
as an intermediate type because [`container.State`] contains a sync.Mutex
field which would make copying it unsafe (see [moby@2998945]).

This moves the type and re-introduces an internal type
in the original location, effectively reverting
100102108b

[`container.State`]: https://github.com/moby/moby/blob/19e79906cb347ab12deaade16bf9d82c41d777c4/container/state.go#L15-L23
[moby@2998945]: https://github.com/moby/moby/commit/2998945a54577e24a6414d576bc861e58fa87359

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-28 13:57:10 +02:00
Sebastiaan van Stijn 83510a26b3 api/types: move backend types to daemon/server
The "backend" types in API were designed to decouple the API server
implementation from the daemon, or other parts of the code that
back the API server. This would allow the daemon to evolve (e.g.
functionality moved to different subsystems) without that impacting
the API server's implementation.

Now that the API server is no longer part of the API package (module),
there is no benefit to having it in the API module. The API server
may evolve (and require changes in the backend), which has no direct
relation with the API module (types, responses); the backend definition
is, however, coupled to the API server implementation.

It's worth noting that, while "technically" possible to use the API
server package, and implement an alternative backend implementation,
this has never been a prime objective. The backend definition was
never considered "stable", and we don't expect external users to
(attempt) to use it as such.

This patch moves the backend types to the daemon/server package,
so that they can evolve with the daemon and API server implementation
without that impacting the API module (which we intend to be stable,
following SemVer).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-28 00:03:04 +02:00
Sebastiaan van Stijn ca1c5ee08f pkg/stringid: move to daemon, and provide copy in client
The stringid package is used in many places; while it's trivial
to implement a similar utility, let's just provide it as a utility
package in the client, removing the daemon-specific logic.

For integration tests, I opted to use the implementation in the
client, as those should not ideally not make assumptions about
the daemon implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-25 13:39:32 +02:00
Derek McGowan afd6487b2e Create github.com/moby/moby/api module
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-21 09:30:05 -07:00
Derek McGowan 04f5276267 Move volume to daemon/volume
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-15 10:44:44 -07:00
Derek McGowan 7a720df61f Move libnetwork to daemon/libnetwork
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-14 09:25:23 -07:00
Derek McGowan 5419eb1efc Move container to daemon/container
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-06-27 14:27:21 -07:00
Derek McGowan 31b6886eb1 Move api/server/router/build to daemon/server/router/build
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-06-27 09:13:40 -07:00
Matthieu MOREL 381d9d0723 fix use-errors-new from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-26 12:07:38 +00:00
Matthieu MOREL 6d737371b8 fix comparison rule from errorlint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-13 08:26:56 +00:00
Matthieu MOREL b8a4f6534f fix stringsCompare and stringConcatSimplify from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Sebastiaan van Stijn 986ec3f877 daemon/cluster: remove // import comments
These comments were added to enforce using the correct import path for
our packages ("github.com/docker/docker", not "github.com/moby/moby").
However, when working in go module mode (not GOPATH / vendor), they have
no effect, so their impact is limited.

Remove these imports in preparation of migrating our code to become an
actual go module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-30 15:59:11 +02:00
Matthieu MOREL 55da8ea276 daemon: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:38:39 +00:00
Sebastiaan van Stijn e477df3b31 daemon/cluster/executor: use container.ContainerState consts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-13 15:03:41 +02:00
Cory Snider 56ad941564 Fix possible overlapping IPs when ingressNA == nil
Logic was added to the Swarm executor in commit 0d9b0ed678
to clean up managed networks whenever the node's load-balancer IP
address is removed or changed in order to free up the address in the
case where the container fails to start entirely. Unfortunately, due to
an oversight the function returns early if the Swarm is lacking
an ingress network. Remove the early return so that load-balancer IP
addresses for all the other networks are freed as appropriate,
irrespective of whether an ingress network exists in the Swarm.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-09 12:51:08 -04:00