Commit Graph

54223 Commits

Author SHA1 Message Date
Paweł Gronowski
689decba9a Merge pull request #50981 from thaJeztah/rm_magic_vals
API: /info: remove magic `<unknown>` values for API < 1.39
2025-09-15 17:42:15 +02:00
Sebastiaan van Stijn
79450fa3ec Merge pull request #50980 from thaJeztah/sync_swagger_docs
api/docs: sync swagger and update changelog
2025-09-15 17:42:07 +02: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
Paweł Gronowski
cb62838fe7 Merge pull request #50979 from thaJeztah/mod_tidy
client: tidy go.mod
2025-09-15 17:36:31 +02:00
Sebastiaan van Stijn
30a43b877c Merge pull request #50977 from thaJeztah/rm_cors_option
daemon/config: remove deprecated CommonConfig.CorsHeaders
2025-09-15 14:58:39 +02:00
Sebastiaan van Stijn
c8c13fe058 API: /info: remove magic <unknown> values for API < 1.39
daemon versions before v18.09 (API v1.39) returned a magic `<unknown>` value
for the `KernelVersion` and `OperatingSystem` if these values were not set.
Commit e6e8ab50fa removed this magic values,
but kept a fallback for old versions of the CLI that expected this value to
be pre-formatted this way. Given that this change was over 7 Years ago, and
never was a strict contract of the API, we can remove this fallback. Current
versions of the CLI properly handle presentation, so this would only impact
EOL versions of the CLI.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-15 14:32:34 +02:00
Sebastiaan van Stijn
c600f62c25 api/docs: sync swagger and update changelog
- Update changelog to include mention of the new fields added
  in 3f86797d3f.
- Update changelog to mention removal of the deprecated fields
  in b092c8ca64
- Sync v1.52 swagger docs with the current version.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-15 13:27:40 +02:00
Sebastiaan van Stijn
6084882b98 client: tidy go.mod
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-15 12:02:21 +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
252659278e Configure addresses before adding them to DNS or /etc/hosts
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-15 10:39:08 +01:00
Rob Murray
18b8e369ae Split OS-specific code out of Sandbox.populateNetworkResources
And move the Endpoint.populateNetworkResources code into the
all-platforms part of the Sandbox method.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-15 10:39:08 +01:00
Rob Murray
a8b9eff902 Don't set up DNS in Network.createEndpoint
DNS is set up when the endpoint is joined to a network.

It was added in commit 4850c5f (Avoid duplicate entries in
/etc/hosts) then simplified in bcca214 (libnetwork: open-code
updating svc records) and seems to be related to setting up a
name on a swarm node that isn't running the container with the
endpoint.

But, all callers of Network.createEndpoint follow up with an
Endpoint.Join, which also sets up the DNS entry. Those callers are:
  Network.createLoadBalancerSandbox
  Network.CreateEndpoint
    - called by Daemon.connectToNetwork
    - called by Sandbox.setupDefaultGateway
    - called by builder-net/executor.go: iface.init

None of them bail out before the Join for a Swarm case.

So, it looks like enough has changed that the createEndpoint code is
no longer needed (it predates the internal DNS server) ... remove it.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-15 10:39:08 +01:00
Rob Murray
ddf10ee1cd Delay Endpoint config until the osSbox exists
When the SetKey hook is used (by a build container) it's called after
Endpoint.sbJoin, which will have called Sandbox.populateNetworkResources
to set up address, routes, sysctls and so on - but it's not able to do
any config until the osSbox exists. So, Sandbox.populateNetworkResources
is called again by SetKey to finish that config.

But, that means the rest of Endpoint.sbJoin has already happened before
the osSbox existed - it will have configured DNS, /etc/hosts, gateways
and so on before anything was set up for the OS.

So, if the osSbox configuration isn't applied as expected (for example,
a sysctl disables IPv6 on the endpoint), that sbJoin configuration is
incorrect.

To avoid unnecessary config+cleanup in thoses cases - delay the config
currently done by sbJoin until the osSbox exists.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-15 10:39:08 +01:00
Sebastiaan van Stijn
b043980e6f daemon/config: remove deprecated CommonConfig.CorsHeaders
This option was deprecated in Docker 27.0 through 7ea9acc97f,
and removed in 28.0 through ae96ce866f.
The field was kept to provide a user-friendly error when used; this
patch removes the field altogether.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-15 11:11:20 +02:00
Sebastiaan van Stijn
9c14afd97c Merge pull request #50959 from thaJeztah/rm_execoptions_detach
api/types/container: remove deprecated ExecOptions.Detach
2025-09-15 09:50:27 +02:00
Sebastiaan van Stijn
84ddfa140c Merge pull request #50958 from thaJeztah/cleanup_deprecated
daemon: remove some deprecated functions
2025-09-15 09:49:43 +02:00
Rob Murray
4c7deaf832 Windows containers: restore network name after reboot
When Windows reboots, it removes HNS networks. They're restored
from Docker's store (unlike after a daemon restart, where Docker
networks are restored from HNS networks).

When that happens, preserve the driver-opt that reports the HNS
network name when that happens.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-12 21:05:16 +01:00
Rob Murray
9129094b98 Windows containers: report HNS network name in inspect
After creating a new network, inspect shows that there's no value
for option "com.docker.network.windowsshim.networkname". After
restarting the daemon, it shows up with the docker network name
(not the HNS network name, which defaults to the docker network's
id).

Creating the network with "-o com.docker.network.windowsshim.networkname"
sets the HNS network name, and it shows up in inspect. Until the
daemon is restarted, then it shows the docker network name.

So - set the option value to the HNS network name on creation (the id
if no name is given), and on restore after restart use the name
reported by HNS.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-12 16:03:36 +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
Rob Murray
af6d59ea48 Merge pull request #50945 from robmry/cleanup_network_settings_on_join_err
Tidy up when endpoint join fails
2025-09-12 13:05:10 +01:00
Sebastiaan van Stijn
caae209d25 api/types/container: remove deprecated ExecOptions.Detach
This field was deprecated in 0c182d4d57,
which should be included in a 28.x release, but we don't need to carry
it in the new module.

We should also considering duplicating the `ExecOptions` type as a client
option, and renaming it to `ExecCreateRequest`, so that we can decouple
client options from the shape of the request.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-12 10:18:24 +02:00
Sebastiaan van Stijn
19edf44896 daemon/config: remove deprecated Config.
This function was deprecated in 83f8f4efd7,
and the package is internal to the daemon, so we can remove it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-12 09:59:12 +02:00
Sebastiaan van Stijn
fabe66322f builder/remotecontext: remove deprecated "Rel()" utility
This function was deprecated in 54a556a5ef,
and the package is now internal to the daemon, so we can remove it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-12 09:59:09 +02:00
Sebastiaan van Stijn
a1d05215f0 Merge pull request #50957 from corhere/fixup-after-dropping-deprecated-network-structs
daemon: fix build after revendoring api module
2025-09-12 01:50:18 +02:00
Cory Snider
cf243b64aa daemon: fix build after revendoring api module
Complete the removal of the deprecated network structs by dropping the
remaining references in daemon code.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-09-11 17:47:27 -04:00
Sebastiaan van Stijn
1e6e2ceb22 Merge pull request #50846 from akerouanton/drop-deprecated-network-structs
api/t/ctr: drop NetworkSettingsBase, DefaultNetworkSettings
2025-09-11 22:00:06 +02: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
Sebastiaan van Stijn
1c006f247d Merge pull request #50832 from thaJeztah/events_remove_deprecated
api/types/events: Message: remove deprecated Status, ID, and From fields
2025-09-11 21:22:57 +02:00
Sebastiaan van Stijn
183f1517a9 Merge pull request #50915 from thaJeztah/omit_empty_config
api: image inspect: remove temporary backfill for Config fields
2025-09-11 21:21:30 +02:00
Albin Kerouanton
b092c8ca64 api/t/container: drop NetworkSettingsBase
Except Bridge, all fields of NetworkSettingsBase were deprecated in
v1.44, and are actually never set at all.

The Bridge field was deprecated in v1.51 but it's only set when the
container is connected to the default bridge, and when the daemon is
started with the --bridge option set.

So, remove all those fields and do not backfill them for older API
versions.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-11 17:57:42 +02:00
Albin Kerouanton
fc1ff44bc2 api/t/container: drop DefaultNetworkSettings
All the fields in DefaultNetworkSettings were deprecated in Engine v1.9
and scheduled for removal in v17.12. However, they're still return in
all supported API versions.

As we still need to keep backward compatibility for older API versions,
this change leverages the newly added 'compat' package to return these
fields despite being removed from the Go struct.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-11 17:57:42 +02:00
Sebastiaan van Stijn
a11005b40a Merge pull request #50954 from akerouanton/fix-compat-html-encoding
daemon/i/compat: disable HTML encoding
2025-09-11 17:24:54 +02: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
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
Rob Murray
52c9cfd016 Use sbLeave to roll back on error from sbJoin
The old deferred error handling cleared ep.sandboxID, but only
in a copy of the Endpoint loaded from the store, not stored or
returned - so the modification was immediately lost.

It also tried to remove the endpoint from the Sandbox's 'endpoints',
but the remove function compared pointers rather than ids, so
nothing was removed. Removing it would have broken rollback anyway.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-11 13:02:41 +01:00
Rob Murray
53390f85dd Put clearNetworkResources() inline in its only caller
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-11 13:02:41 +01:00
Rob Murray
916fa31ab5 Acquire Sandbox.joinLeaveMu for Endpoint force-Delete
If an endpoint is still attached to a Sandbox when
Endpoint.Delete is called with force=true, sbLeave is
called. It may change the Sandbox's gateway, which may
conflict with a concurrent Join.

So, acquire the Sandbox's joinLeaveMu to do that, and
clarify the purpose of that mutex in struct Sandbox
comments.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-11 13:02:41 +01:00
Rob Murray
a9db1e9a26 Endpoint.sbLeave: don't load ep from store
Because it loaded the Endpoint object from store and operated
on that copy rather than its own receiver, sbJoin couldn't
successfully roll back on error if the Endpoint was not included
in the Sandbox's list of endpoints, or its current state had
not been written to store after the error occurred.

So, for example, releaseOSSboxResources() would not be called
to delete interfaces created in the container's netns.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-11 13:02:41 +01:00
Rob Murray
b192d06ec7 Remove network info from container when endpoint join fails
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-09-11 13:02:41 +01:00
Sebastiaan van Stijn
1b74b3e1ce api/types/events: Message: remove deprecated Status, ID, and From fields
These fields were deprecated in [moby@72f188] (docker v1.10, API v1.22),
with the deprecation message updated to be in the correct format in
[moby@247f47] (docker v23.0).

[moby@72f188]: 72f1881df1
[moby@247f47]: 247f4796d2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-11 10:01:17 +02:00
Sebastiaan van Stijn
5815eb82ee daemon/events: omit deprecated event fields on API >= v1.52
Don't include the deprecated `status`, `id`, and `from` fields in event
responses.

These fields were deprecated in [moby@72f188] (docker v1.10, API v1.22),
but the daemon still included them in the response.

Unfortunately, the Docker CLI (and compose indirectly), continued using
these fields up until v25.0.0, and panic if the fields are omitted, or
left empty (due to a bug), see: https://github.com/moby/moby/pull/50832#issuecomment-3276600925
so we need to continue producing these fields on API < v1.52.

[moby@72f188]: 72f1881df1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-11 10:01:17 +02:00
Sebastiaan van Stijn
c4eb791dba daemon/events: remove tests for deprecated API fields
These fields were deprecated in [moby@72f188] (docker v1.10, API v1.22),
and we shouldn't test for them.

[moby@72f188]: 72f1881df1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-11 10:01:17 +02:00
Sebastiaan van Stijn
3278393cf2 Merge pull request #50949 from thaJeztah/api_update_docs
api/docs: fix events example response
2025-09-11 10:00:37 +02:00
Sebastiaan van Stijn
e4c9d289c6 Merge pull request #50852 from thaJeztah/add_compat_wrapper
daemon/internal: add "compat" package for legacy responses
2025-09-11 09:29:57 +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
Cory Snider
c46332737c Merge pull request #50917 from corhere/ipam-allocation-info-localscope
api, daemon: report IPAM status for local-scope networks
2025-09-10 13:05:33 -04: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