362 Commits

Author SHA1 Message Date
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
Sebastiaan van Stijn
0af2962fdd daemon: reduce use of pointer-slices in backend
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-13 20:52:15 +01: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
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
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
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`]: 19e79906cb/container/state.go (L15-L23)
[moby@2998945]: 2998945a54

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
f24455c90b Move image to daemon/internal/image
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-24 12:11:02 -07: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
3581b982f7 Move plugin to daemon/pkg/plugin
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-06-27 14:26:33 -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
Matthieu MOREL
e2e7f9964f fix(QF1003): Convert if/else-if chain to tagged switch
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-01 14:16:45 +02:00
Matthieu MOREL
b0711d5fe9 fix(QF1001): Apply De Morgan’s law
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-01 14:16:44 +02:00
Derek McGowan
100102108b Use container status values from api
Alias and deprecate the status types and constants from the root
container package. The root container package is intended for use
within the daemon and no the api package.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-26 07:58:09 -07:00
Sebastiaan van Stijn
d9cf097402 daemon/cluster/executor/container: make switches exhaustive (exhaustive)
Adding a `default` statement so that disabling the "default-signifies-exhaustive"
linter option will  make it show up.

    daemon/cluster/executor/container/adapter.go:351:3: missing cases in switch of type api.Mount_MountType: api.MountTypeVolume, api.MountTypeTmpfs, api.MountTypeNamedPipe, api.MountTypeCluster (exhaustive)
            switch mount.Type {
            ^
    daemon/cluster/executor/container/adapter.go:540:4: missing cases in switch of type api.LogStream: api.LogStreamUnknown (exhaustive)
                switch stream {
                ^
    daemon/cluster/executor/container/container.go:715:3: missing cases in switch of type api.Privileges_SeccompOpts_SeccompMode: api.Privileges_SeccompOpts_DEFAULT (exhaustive)
            switch seccomp.Mode {
            ^
    daemon/cluster/executor/container/controller.go:257:4: missing cases in switch of type events.Action: events.ActionCreate, events.ActionStart, events.ActionRestart, events.ActionStop, events.ActionCheckpoint, events.ActionPause, events.ActionUnPause, events.ActionAttach, events.ActionDetach, events.ActionResize, events.ActionUpdate, events.ActionRename, events.ActionKill, events.ActionOOM, events.ActionRemove, events.ActionCommit, events.ActionTop, events.ActionCopy, events.ActionArchivePath, events.ActionExtractToDir, events.ActionExport, events.ActionImport, events.ActionSave, events.ActionLoad, events.ActionTag, events.ActionUnTag, events.ActionPush, events.ActionPull, events.ActionPrune, events.ActionDelete, events.ActionEnable, events.ActionDisable, events.ActionConnect, events.ActionDisconnect, events.ActionReload, events.ActionMount, events.ActionUnmount, events.ActionExecCreate, events.ActionExecStart, events.ActionExecDie, events.ActionExecDetach, events.ActionHealthStatus, events.ActionHealthStatusRunning (exhaustive)
                switch event.Action {
                ^
    daemon/cluster/executor/container/controller.go:480:4: missing cases in switch of type events.Action: events.ActionCreate, events.ActionStart, events.ActionRestart, events.ActionStop, events.ActionCheckpoint, events.ActionPause, events.ActionUnPause, events.ActionAttach, events.ActionDetach, events.ActionResize, events.ActionUpdate, events.ActionRename, events.ActionKill, events.ActionDie, events.ActionOOM, events.ActionDestroy, events.ActionRemove, events.ActionCommit, events.ActionTop, events.ActionCopy, events.ActionArchivePath, events.ActionExtractToDir, events.ActionExport, events.ActionImport, events.ActionSave, events.ActionLoad, events.ActionTag, events.ActionUnTag, events.ActionPush, events.ActionPull, events.ActionPrune, events.ActionDelete, events.ActionEnable, events.ActionDisable, events.ActionConnect, events.ActionDisconnect, events.ActionReload, events.ActionMount, events.ActionUnmount, events.ActionExecCreate, events.ActionExecStart, events.ActionExecDie, events.ActionExecDetach, events.ActionHealthStatus, events.ActionHealthStatusRunning, events.ActionHealthStatusHealthy, events.ActionHealthStatusUnhealthy (exhaustive)
                switch event.Action {
                ^
    daemon/cluster/executor/container/controller.go:723:4: missing cases in switch of type events.Action: events.ActionCreate, events.ActionStart, events.ActionRestart, events.ActionStop, events.ActionCheckpoint, events.ActionPause, events.ActionUnPause, events.ActionAttach, events.ActionDetach, events.ActionResize, events.ActionUpdate, events.ActionRename, events.ActionKill, events.ActionDie, events.ActionOOM, events.ActionDestroy, events.ActionRemove, events.ActionCommit, events.ActionTop, events.ActionCopy, events.ActionArchivePath, events.ActionExtractToDir, events.ActionExport, events.ActionImport, events.ActionSave, events.ActionLoad, events.ActionTag, events.ActionUnTag, events.ActionPush, events.ActionPull, events.ActionPrune, events.ActionDelete, events.ActionEnable, events.ActionDisable, events.ActionConnect, events.ActionDisconnect, events.ActionReload, events.ActionMount, events.ActionUnmount, events.ActionExecCreate, events.ActionExecStart, events.ActionExecDie, events.ActionExecDetach, events.ActionHealthStatus, events.ActionHealthStatusRunning, events.ActionHealthStatusHealthy (exhaustive)
                switch event.Action {
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:52 +01:00
Sebastiaan van Stijn
b96b14d078 cluster/executor/container: exitError: implement go1.13 unwrapper
This error implemented the Causer interface, but did not implement
the go1.13 unwrapper, which could prevent errors from being matched.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 17:47:10 +01:00
Sebastiaan van Stijn
8705018705 daemon/cluster/executor: containerConfig: store Network instead of envelope
The Network field is the only field used from the NetworkAttachment within
this code. Remove the NetworkAttachment envelope, and store the Network
field directly instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 12:30:32 +01:00
Sebastiaan van Stijn
90323ae123 daemon/cluster/executor: networkCreateRequest: not a method
This method was called in a loop, iterating over the container config's
network-attachments. It was defined as a method, but only to lookup
the same attachment we just iterated over existed, and to obtain a copy.
As there were no goroutines involved, dereferencing should not be an issue
and with Go 1.22+, dereferencing loop vars is no longer needed at all,
so we can change this method to a regular constructor; also removing the
redundant error-return in the process.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 12:30:32 +01:00
Sebastiaan van Stijn
f5f4a062a5 daemon/cluster/executor: networkCreateRequest: slight DRY cleanup
All of this function only referenced the Network field in the attachment;
use an intermediate variable to make the code less repetitive.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 12:30:32 +01:00
Sebastiaan van Stijn
16770340ea daemon/cluster/executor: networkCreateRequest don't shadow config
c is used as name for the containerConfig receiver; remove the intermediate
variable so that we don't shadow it. There's no bug here, because a new
variable is created; just to prevent confusion and to make linters happier.

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