Commit Graph

2098 Commits

Author SHA1 Message Date
Austin Vazquez
ea76dbefeb api/types/swarm: deprecate PortConfigProtocol
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-03 17:34:00 -05: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
Cory Snider
2da472b1a5 api/types/system: use netip types where appropriate
Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-10-03 21:39:13 +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
Austin Vazquez
4279e522e1 Merge pull request #50710 from austinvazquez/define-network-port-types
api: add container network port types
2025-10-02 17:43:58 -07: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
9b0c78e7d8 Merge pull request #50857 from austinvazquez/add-container-inspect-storage-driver
Add container inspect storage field
2025-09-27 00:49:07 +02:00
Austin Vazquez
efa077848f api/types/storage: define generic Storage type for container inspect
This change defines the generic `Storage` type for use in container inspect responses when using containerd snapshotter backend.

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-09-26 14:21:43 -05:00
Paweł Gronowski
b48fcf6cdb client/checkpoint_list: Wrap result in a struct
The CheckpointList method previously returned a raw slice of
checkpoint.Summary, which made it difficult to extend the API response
with additional metadata or fields in the future without breaking
backward compatibility.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-09-26 17:03:07 +02:00
Sebastiaan van Stijn
3912ffacd6 integration/nw: TestEmptyPortBindingsBC use context
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-25 22:53:49 +02:00
Sebastiaan van Stijn
0498c54577 Merge pull request #51023 from thaJeztah/integration_rename_client
integration/service: rename var to prevent shadowing
2025-09-23 10:50:56 +02:00
Sebastiaan van Stijn
69d5112c72 Merge pull request #50529 from mdaffad/50159-migrate-test-api-network-defaults-and-filter
test: migrate test api network get defaults and filter
2025-09-22 18:46:02 +02:00
Sebastiaan van Stijn
5d22d9bec9 integration/service: rename var to prevent shadowing
Use "apiClient" for the client (most places use either `apiClient`
or `c`) to prevent shadowing the `client` import.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-22 14:34:39 +02:00
Muhammad Daffa Dinaya
87d1da50f0 test: migrate test api network get defaults and filter
Signed-off-by: Muhammad Daffa Dinaya <muhammaddaffadinaya@gmail.com>
2025-09-20 05:58:35 +00:00
Sebastiaan van Stijn
0df791cb72 explicitly access Container.State instead of through embedded struct
The Container.State struct holds the container's state, and most of
its fields are expected to change dynamically. Some o these state-changes
are explicit, for example, setting the container to be "stopped". Other
state changes can be more explicit, for example due to the containers'
process exiting or being "OOM" killed by the kernel.

The distinction between explicit ("desired") state changes and "state"
("actual state") is sometimes vague; for some properties, we clearly
separated them, for example if a user requested the container to be
stopped or restarted, we store state in the Container object itself;

    HasBeenManuallyStopped   bool // used for unless-stopped restart policy
    HasBeenManuallyRestarted bool `json:"-"` // used to distinguish restart caused by restart policy from the manual one

Other properties are more ambiguous. such as "HasBeenStartedBefore" and
"RestartCount", which are stored on the Container (and persisted to
disk), but may be more related to "actual" state, and likely should
not be persisted;

    RestartCount             int
    HasBeenStartedBefore     bool

Given that (per the above) concurrency must be taken into account, most
changes to the `container.State` struct should be protected; here's where
things get blurry. While the `State` type provides various accessor methods,
only some of them take concurrency into account; for example, [State.IsRunning]
and [State.GetPID] acquire a lock, whereas [State.ExitCodeValue] does not.
Even the (commonly used) [State.StateString] has no locking at all.

The way to handle this is error-prone; [container.State] contains a mutex,
and it's exported. Given that its embedded in the [container.Container]
struct, it's also exposed as an exported mutex for the container. The
assumption here is that by "merging" the two, the caller to acquire a lock
when either the container _or_ its state must be mutated. However, because
some methods on `container.State` handle their own locking, consumers must
be deeply familiar with the internals; if both changes to the `Container`
AND `Container.State` must be made. This gets amplified more as some
(exported!) methods, such as [container.SetRunning] mutate multiple fields,
but don't acquire a lock (so expect the caller to hold one), but their
(also exported) counterpart (e.g. [State.IsRunning]) do.

It should be clear from the above, that this needs some architectural
changes; a clearer separation between "desired" and "actual" state (opening
the potential to update the container's config without manually touching
its `State`), possibly a method to obtain a read-only copy of the current
state (for those querying state), and reviewing which fields belong where
(and should be persisted to disk, or only remain in memory).

This PR preserves the status quo; it makes no structural changes, other
than exposing where we access the container's state. Where previously the
State fields and methods were referred to as "part of the container"
(e.g. `ctr.IsRunning()` or `ctr.Running`), we now explicitly reference
the embedded `State` (`ctr.State.IsRunning`, `ctr.State.Running`).

The exception (for now) is the mutex, which is still referenced through
the embedded struct (`ctr.Lock()` instead of `ctr.State.Lock()`), as this
is (mostly) by design to protect the container, and what's in it (including
its `State`).

[State.IsRunning]: c4afa77157/daemon/container/state.go (L205-L209)
[State.GetPID]: c4afa77157/daemon/container/state.go (L211-L216)
[State.ExitCodeValue]: c4afa77157/daemon/container/state.go (L218-L228)
[State.StateString]: c4afa77157/daemon/container/state.go (L102-L131)
[container.State]: c4afa77157/daemon/container/state.go (L15-L23)
[container.Container]: c4afa77157/daemon/container/container.go (L67-L75)
[container.SetRunning]: c4afa77157/daemon/container/state.go (L230-L277)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-19 16:02:14 +02:00
Rob Murray
07453abab3 Merge pull request #50929 from robmry/mac_ip_vlan_gateway_config
macvlan, ipvlan-l2: only configure a default route when a gateway address is supplied
2025-09-16 18:09:30 +01:00
Rob Murray
b0226d5074 Merge pull request #48971 from robmry/ipv6_disabled_on_interface
Release IPv6 address if IPv6 is disabled on an interface
2025-09-16 17:53:06 +01:00
Sebastiaan van Stijn
da5ca1b746 Merge pull request #50978 from thaJeztah/mv_exec_options
client: move ExecStartOptions, ExecAttachOptions, ExecOptions to client
2025-09-16 15:58:30 +02:00
Cory Snider
1b9ef486c7 Merge pull request #50946 from corhere/ipam-allocation-info
daemon: report IPAM status for Swarm networks
2025-09-15 13:00:32 -04:00
Sebastiaan van Stijn
082b4e8d77 client: move ExecOptions to client
- move api/types/container.ExecOptions to the client
- rename api/types/container.ExecOptions to ExecCreateRequest

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-15 17:37:47 +02:00
Sebastiaan van Stijn
6a642300f0 client: move ExecStartOptions, ExecAttachOptions to client
- move api/types/container.ExecStartOptions to the client
- move api/types/container.ExecAttachOptions to the client
- rename api/types/container.ExecStartOptions to ExecStartRequest

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-15 17:37:43 +02:00
Rob Murray
2bb0443ae9 Release IPv6 address if unused due to sysctl setting
When running:
  docker network create --ipv6 b46
  docker run --rm -ti \
    --network name=b46,driver-opt=com.docker.network.endpoint.sysctls=net.ipv6.conf.IFNAME.disable_ipv6=1 \
     busybox

IPv6 is enabled in the container and the network, so an IPv6 address
will be allocated for the endpoint.

But, when the sysctl is applied, the IPv6 address will be removed
from the interface ... so, no unsolicited neighbour advertisement
should be (or can be) sent and, the endpoint should not be treated
as dual-stack when selecting a gateway endpoint and, if it is
selected as the gateway endpoint, setting up an IPv6 route via the
network will fail.

So, if the IPv6 address disappears after sysctls have been applied,
release the address and remove it from the endpoint's config.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-15 10:39:08 +01:00
Rob Murray
aa78f19066 ipvlan-l2: do not allocate a gateway address from IPAM
When ipvlan in "l2" mode is given no '--gateway' option, an
address is allocated from IPAM and a default route is set up
via that gateway. But, the gateway address is not assigned to
anything in the Docker ipvlan network - it must be external,
and IPAM shouldn't try to guess it.

So ...

- always disable IPAM gateway address allocation for ipvlan-l2
  - tell libnet to assume the endpoint has a gateway instead
- update the Join code to allow for no configured gateway
- always disable 'docker_gwbridge' connection for ipvlan
  networks, so it's not hooked up when there is no gateway
  address.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-12 14:29:15 +01:00
Rob Murray
468e3521b0 macvlan: do not allocate a gateway address from IPAM
When macvlan is given no '--gateway' option, an address is
allocated from IPAM and a default route is set up via that
gateway. But, the gateway address is not assigned to anything
in the Docker macvlan network - it must be external, and
IPAM shouldn't try to guess it.

When IPv6 auto-configuration is enabled in the network the
macvlan is connected to, the macvlan driver races against it
to set up the gateway. When autoconfig wins, container creation
fails because the default route already exists.

So ...

- disable IPAM gateway address allocation for macvlan
- update the Join code to allow for no configured gateway
- always disable 'docker_gwbridge' connection for macvlan
  networks, so it's not hooked up when there is no gateway
  address.

Libnet assumes an endpoint with no statically configured default
gateway or route does not provide external connectivity. So, it
disables external DNS access, and will not select the endpoint
as gateway for containers. So, where an IPAM allocated gateway
address would have been assigned before, tell libnet to assume
there will be an auto-configured gateway.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-12 14:29:15 +01:00
Cory Snider
c2c2b80e90 daemon: report IPAM status for Swarm networks
As the Engine API requests may be directed at a non-leader Swarm
manager, the information needs to be tunneled through the Swarm API.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-09-11 15:25:14 -04:00
Rob Murray
8efe6b0183 Add TestJoinError
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-11 14:19:21 +01:00
Rob Murray
73413ea693 bridge_linux_test.go: gofumpt
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-11 14:18:18 +01:00
Cory Snider
3f86797d3f api,daemon: report IPAM status for network
On API v1.52 and newer, the GET /networks/{id} endpoint returns
statistics about the IPAM state for the subnets assigned to the network.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-09-10 11:06:05 -04: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
d3e45f8743 testutil: move back to internal
This package was originally internal, but was moved out when BuildKit
used it for its integration tests. That's no longer the case, so we
can make it internal again.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-08 10:08:30 +02:00
Sebastiaan van Stijn
2d1af4e4e4 api/types/build: move build options to client and backend
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-05 15:57:05 +02:00
Sebastiaan van Stijn
a8afc2c6fb api/types/checkpoint: move checkpoint 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.

The CreateOptions type was used both as options-struct for the client,
and as struct to marshal/unmarshal the request. For this type, a copy
is created in the Client and a new `checkpoint.CreateRequest` is added
in the API.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-05 10:20:06 +02:00
Sebastiaan van Stijn
a45639af26 Merge pull request #50897 from thaJeztah/move_container_options
api/types/container: move container options to client
2025-09-05 09:29:56 +02:00
Sebastiaan van Stijn
6da8589ebe Merge pull request #50878 from corhere/network-inspect-concrete-type
api/types/network: separate Summary from Inspect
2025-09-04 21:36:00 +02:00
Austin Vazquez
749ec81706 Merge pull request #50799 from thaJeztah/touchup_delete
image delete: inline some variables, and touch-up TODOs
2025-09-04 12:27:30 -07: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
c441b2ef19 api/types/image: make InspectResponse.GraphDriver optional
This change makes the `GraphDriver` field in `image.InspectResponse` optional. This field will only be returned when using moby engine graph drivers as a backend storage implementation. It will be omitted when using the containerd image backend.

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-09-04 13:04:10 -05:00
Cory Snider
1a86389419 api/types/network: separate Summary from Inspect
While the network Summary and Inspect types have been aliases in Go's
type system, in practice there is a difference: the Containers and
Services fields are only populated when inspecting a network. Split out
the common fields into a base network.Network struct which is embedded
in the network.Summary and network.Inspect types.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-09-04 13:51:28 -04:00
Sebastiaan van Stijn
e46a991dc5 api: remove unused DefaultVersion, MinSupportedAPIVersion consts
These consts are no longer used, and separate consts were added in both
the client and daemon packages;

- client: 41da5700a4
- daemon: a632b8495b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-04 07:30:35 -05:00
Albin Kerouanton
7b75f355e5 daemon/srv/r/ctr: handlePortBindingsBC: fix warning
Commit 0ca7ac325 was merged before a review comment was addressed.

Update the warning message returned by handlePortBindingsBC to handle
the case where multiple empty port bindings slices are sent to the API.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-03 11:16:51 +02:00
Sebastiaan van Stijn
abfe332072 Merge pull request #50874 from akerouanton/bc-empty-pbs-slices
daemon: backfill empty PBs slices for backward compat
2025-09-02 23:49:34 +02:00
Albin Kerouanton
0ca7ac3258 daemon: backfill empty PBs slices for backward compat
So far, on ContainerStart, the daemon was silently backfilling empty
PortBindings slices with a PortBinding with unspecified HostIP and
HostPort. This was done by github.com/docker/go-connections/nat.SortPortMap.

This backfilling doesn't make much sense, and we're trying to remove
that package. So, move the backfilling to the API server, keep it for
older API versions, deprecate it for API 1.52, and drop it for API 1.53
and above.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-02 22:45:04 +02:00
Paweł Gronowski
ce338dec81 integration/internal: Print Buildkit logs
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-09-02 11:14:57 +02:00
Paweł Gronowski
27fca93b65 c8d/history: Fix non-native platforms
When building a non-native platform, it's not unpacked by default.
History tries to read the disk usage of all the layer and it doesn't
handle missing snapshots gracefully.

This patch fixes this.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-09-02 11:12:00 +02:00
Paweł Gronowski
ad830a47af integration/internal: Handle Buildkit in GetImageIDFromBody
BuildKit emits some additional events during build and they are not
`build.Result` so don't fail if we encounter one.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-09-02 11:11:46 +02:00
Albin Kerouanton
b7c597ec35 api/t/ctr: deprecate DefaultNetworkSettings
This struct is only used to report the networking state for the default
bridge network when the container is connected to it.

It was deprecated in v1.09 (API v1.21), and scheduled for removal in
v1.11. Unfortunately, the deprecation warning was wrongly formatted in
the Go code. However, deprecation warnings are already present in
swagger.yaml, so don't touch it.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-08-29 15:40:45 +02:00
Albin Kerouanton
fbde2bcb9a nftabler,nftablesdoc: stringify numerical dstnat prio
When nftablesdoc tests dump the state of nftables, the argument '-y' /
'--numeric-priority' isn't used, so all priorities should be
stringified. However, there's a bug in older versions of nftables that
prevents the stringification of the 'dstnat' priority — it's currently
dumped as '-100'.

New versions fix that, and thus running these tests on Debian 13 fails
because of this discrepancy with golden files.

So, look for 'type nat hook output priority -100' and stringify the
priority to ensure compatibility across versions of nft.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-08-28 14:38:21 +02:00
Albin Kerouanton
a4949b669e iptablesdoc: remove -n from iptables -L invocations
The output of `iptables -nvL` has changed in Debian 13 — the proto
column now shows protocol names instead of numbers, even when `-n` is
specified. This breaks the iptablesdoc golden files, which expect
protocols to be represented numerically.

This change comes from 34f085b1607364f4eaded1140060dcaf965a2649 in repo
git.netfilter.org/iptables (see [1]), which is a revert of
da8ecc62dd765b15df84c3aa6b83dcb7a81d4ffa (see [2]), and was made to
address a bug report (see [3]).

Unfortunately, this means there's a drift between iptables versions. So,
remove the `-n` flag altogether to ensure that the iptablesdoc tests
pass everywhere.

[1]: https://git.netfilter.org/iptables/commit/?id=da8ecc62dd765b15df84c3aa6b83dcb7a81d4ffa
[2]: https://git.netfilter.org/iptables/commit/?id=34f085b1607364f4eaded1140060dcaf965a2649
[3]: https://bugzilla.netfilter.org/show_bug.cgi?id=1729

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-08-28 14:38:20 +02:00