552 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
4b4223a8d4 vendor: github.com/opencontainers/runtime-spec v1.3.0
This includes a breaking change in pids.Limit changing to a pointer.

full diff: https://github.com/opencontainers/runtime-spec/compare/v1.2.1...v1.3.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-12-18 19:55:56 +01:00
Rob Murray
18d2a08fcf Merge pull request #51587 from robmry/unmap_ipv6_addr
Unmap() more netip.Addr vars created from slices
2025-11-25 19:30:27 +00:00
Rob Murray
a2de9bb334 Unmap more netip.Addr vars created using AddrFromSlice
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-11-24 16:51:14 +00:00
Rob Murray
e757bbb4ea Move call to Daemon.registerLinks out of Daemon.setHostConfig
The call from Daemon.create -> Daemon.setHostConfig acquired
container.Lock, but didn't need to because the container is
newly created and solely owned by the caller. The call from
Daemon.restore did not acquire the lock.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-11-16 18:20:12 +00:00
Austin Vazquez
a7edbe8e5f api: remove support for KernelMemoryTCP
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-09-30 10:13:51 +02:00
Austin Vazquez
fb2f8115c8 api: deprecate KernelMemoryTCP support
Starting with kernel v6.12, kernel memory TCP accounting is deprecated for cgroups v1.
Note: kernel memory TCP accounting is not supported by cgroups v2.

See d046ff46ee

Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-30 10:13:30 +02:00
Sebastiaan van Stijn
c5991341eb remove support for deprecated kernel memory limit
kernel-memory limits are not supported in cgroups v2, and were obsoleted in
[kernel v5.4], producing a `ENOTSUP` in kernel v5.16. Support for this option
was removed in runc and other runtimes, as various LTS kernels contained a
broken implementation, resulting in unpredictable behavior.

We deprecated this option in [moby@b8ca7de], producing a warning when used,
and actively ignore the option since [moby@0798f5f].

Given that setting this option had no effect in most situations, we should
just remove this option instead of continuing to handle it with the expectation
that a runtime may still support it.

Note that we still support RHEL 8 (kernel 4.18) and RHEL 9 (kernel 5.14). We
no longer build packages for Ubuntu 20.04 (kernel 5.4) and Debian Bullseye 11
(kernel 5.10), which still have an LTS / ESM programme, but for those it would
only impact situations where a runtime is used that still supports it, and
an old API version was used.

[kernel v5.4]: https://github.com/torvalds/linux/commit/0158115f702b0ba208ab0
[moby@b8ca7de]: b8ca7de823
[moby@0798f5f]: 0798f5f5cf

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-09-16 13:08:36 +02:00
Albin Kerouanton
2436458227 libnet/d/bridge: Register: pass a Configuration struct
Libnetwork passes a map[string]any to the bridge driver's Register
function. This forces the daemon to convert its configuration into a
map, and the driver to convert that map back into a struct.

This is unnecessary complexity, and makes it harder to track down where
and how bridge driver configuration fields are set.

Refactor libnetwork to let the daemon register the bridge.Configuration
directly through a new option `OptionBridgeConfig`.

The bridge driver now takes a `Configuration` param that needs no
special treatment.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-09-03 12:10:10 +02:00
Albin Kerouanton
9d9b05446c libnet/pm/nat: move back fw / proxy steps into the bridge driver
Since commit 4e246efcd, individual portmappers are responsible for
setting up firewall rules and proxying according to their needs.

This change moves the responsibility back to the bridge driver, removing
unnecessary code duplication across portmappers. For now, only the nat
portmapper takes advantage of this.

This partially reverts commit 4e246efcd.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-08-28 11:47:24 +02:00
Marat Radchenko
0ded8645b6 Fix custom runtimes handling on Windows
This commit partially reverts 7ccf750daa and 84965c0752

Closes #50542

Signed-off-by: Marat Radchenko <marat@slonopotamus.org>
2025-08-08 21:41:17 +02:00
Sebastiaan van Stijn
cf15d5bbc6 remove obsolete //go:build tags
These are no longer needed as these are now part of a module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-01 00:49:22 +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
26fda349b8 runconfig: remove exported errors
These errors were not used as sentinel error, and used as any other
"invalid parameter" / "invalid argument" error, so remove them, and
just produce errors where used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-28 11:46:19 +02:00
Derek McGowan
c3b0e0130a Move internal/otelutil to daemon/internal/otelutil
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-24 12:14:30 -07:00
Derek McGowan
713d7f5ed1 Move internal/nlwrap to daemon/libnetwork/nlwrap
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-24 12:13:58 -07:00
Rob Murray
cf1695bef1 Add option --bridge-accept-fwmark
Packets with the given firewall mark are accepted by the bridge
driver's filter-FORWARD rules.

The value can either be an integer mark, or it can include a
mask in the format "<mark>/<mask>".

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-07-22 19:15:02 +01:00
Albin Kerouanton
f996384932 Merge pull request #50382 from akerouanton/split-nat-routed-portmappers
libnet/d/bridge: mv portmapper to libnet/pms/{nat,routed}
2025-07-22 15:45:52 +02:00
Albin Kerouanton
4e246efcd1 libnet/d/bridge: mv portmapper to libnet/pms/{nat,routed}
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-07-22 12:37:01 +02:00
Albin Kerouanton
afb231d027 libnet/d/bridge: add a new Hairpin config flag
The bridge driver currently determines if hairpin mode is enabled by
checking whether the userland proxy is enabled, and if the binary path
is set to a non-empty string. It's used (amongst other things) by the
driver to decide whether 6-to-4 portmappings are supported, while it
normalizes port bindings.

As the userland proxy is going to be handled by the nat portmapper,
proxy-related params will be removed from the bridge driver, but the
port binding normalization will stay in the bridge driver.

So, introduce a new Hairpin config flag, and reimplement the original
logic in the daemon, when creating the bridge config.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-07-22 12:37:01 +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
f05652867d Move opts to daemon/pkg/opts
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-07-14 09:25:05 -07:00
Sebastiaan van Stijn
3f8630cb84 internal/usergroup: move to daemon/internal
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-07-01 15:22:39 +02:00
Derek McGowan
4e8bd050bf Move libcontainerd/remote to daemon/internal/libcontainerd/remote
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-06-27 14:28:08 -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
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
Sebastiaan van Stijn
5318877858 daemon: 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:13 +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
Matthieu MOREL
9e9b6cc42e fix(ST1019): Importing the same package multiple times
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-01 14:17:59 +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
Sebastiaan van Stijn
76adb8f5c3 Merge pull request #49894 from thaJeztah/daemon_less_output_vars
daemon/*: reduce named (error)-returns, naked returns, and some minor linting-fixes
2025-05-01 10:19:50 +02:00
Rob Murray
44a3453d73 Add daemon option --allow-direct-routing
Per-network option com.docker.network.bridge.trusted-host-interfaces
accepts a list of interfaces that are allowed to route
directly to a container's published ports in a bridge
network with nat enabled.

This daemon level option disables direct access filtering,
enabling direct access to published ports on container
addresses in all bridge networks, via all host interfaces.

It overlaps with short-term env-var workaround:
  DOCKER_INSECURE_NO_IPTABLES_RAW=1
- it does not allow packets sent from outside the host to reach
  ports published only to 127.0.0.1
- it will outlive iptables (the workaround was initially intended
  for hosts that do not have kernel support for the "raw" iptables
  table).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-30 20:59:28 +01:00
Sebastiaan van Stijn
19ccb75c62 daemon: remove/rename err-returns and remove naked returns
Prevent accidentally shadowing these errors, which are used in defers, and
remove naked returns.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:50:03 +02:00
Sebastiaan van Stijn
7c52c4d92e update go:build tags to go1.23 to align with vendor.mod
Go maintainers started to unconditionally update the minimum go version
for golang.org/x/ dependencies to go1.23, which means that we'll no longer
be able to support any version below that when updating those dependencies;

> all: upgrade go directive to at least 1.23.0 [generated]
>
> By now Go 1.24.0 has been released, and Go 1.22 is no longer supported
> per the Go Release Policy (https://go.dev/doc/devel/release#policy).
>
> For golang/go#69095.

This updates our minimum version to go1.23, as we won't be able to maintain
compatibility with older versions because of the above.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 15:43:19 +02:00
Sebastiaan van Stijn
a38ca9a548 daemon/initlayer: Setup: remove uses of idtools.Identity
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-16 09:58:24 +02:00
Albin Kerouanton
489cd7edfc api, daemon, libnet: add a 'trigger' baggage member
Add an OTel span processor copying the 'trigger' baggage member
propagated through contexts to all children spans. It's used to identify
what triggered a trace / span (API call, libnet init, etc...)

All code paths that call libnet's `NewNetwork` set this baggage member
with a unique value.

For instance, this can be used to distinguish bridge's `createNetwork`
spans triggered by daemon / libnet initialization from custom network
creation triggerd by an API call.

Two util functions are added to wrap `baggage.New` and
`baggage.NewMemberRaw` to make it easier to deal with baggage and
members by panicking on error. These should not be used with dynamic
values.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-09 08:45:33 +02:00
Albin Kerouanton
31ac5cb6d9 libnet: New: plumb context
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-09 08:45:33 +02:00
Albin Kerouanton
78be7ebad7 libnet/d/bridge: trace createNetwork
Plumb context from the API down to libnet driver method `CreateNetwork`,
and add an OTel span to the bridge driver's `createNetwork` method.
Include a few attributes describing the network configuration (e.g.
IPv4/IPv6, ICC, internal and MTU).

A new util function, `RecordStatus`, is added to the `otelutil` package
to easily record any error, and update the span status accordingly.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-09 08:45:33 +02:00
Derek McGowan
3fc36bcac4 Update daemon to use moby sys/user identity mapping
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-04 08:24:09 -07:00
Paweł Gronowski
82ec984d10 daemon: Update to any from interface{}
Only files that have go build version enforcing tag

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-25 13:38:28 +01:00
Sebastiaan van Stijn
9c7112d118 daemon: configureMaxThreads: remove unused arg
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-07 02:24:31 +01:00
Sebastiaan van Stijn
433e9a50ce Merge pull request #48828 from vbatts/cgroups-rw
daemon/&container/: enable `--security-opt writable-cgroups=true|false` as an option
2025-01-23 20:41:08 +01:00
Rob Murray
bc130f367d bridge/macvlan endpoints always use a random MAC address
Now a gratuitous/unsolicted ARP is sent, there's no need to
use an IPv4-based MAC address to preserve arp-cache mappings
between an endpoint's IP addresses and its MAC addresses.

Because a random MAC address is used for the default bridge,
it no longer makes sense to derive container IPv6 addresses
from the MAC address. This "postIPv6" behaviour was needed
before IPv6 addresses could be configured, but not now. So,
IPv6 addresses will now be IPAM-allocated on the default
bridge network, just as they are for user-defined bridges.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-22 16:59:27 +00:00
Tianon Gravi
ce3e34816a Add support for bare writable-cgroups security-opt
This requires changes in the CLI to support fully, but matches our other boolean option handling (`no-new-privileges`).

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2025-01-16 16:00:44 -08:00
Tianon Gravi
f8187c0214 Error on invalid requests for writable-cgroups
This makes `WritableCgroups` a pointer so we can error when it's specified in invalid configurations (both rootless and user namespaces).

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2025-01-16 15:59:06 -08:00
Vincent Batts
e3cdd59a82 daemon/&container/: enable --security-opt writable-cgroups=true as an option
Fixes #42040
Closes #42043

Rather than making cgroups read-write by default, instead have a flag
for making it possible.

Since these security options are passed through the cli to daemon API,
no changes are needed to docker-cli.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2025-01-16 12:58:17 -08:00
Sebastiaan van Stijn
033f97519c Merge pull request #49184 from thaJeztah/drop_kernel_4.10_check
daemon: remove kernel-version check for kernel < 4.0.0
2025-01-16 18:53:34 +01:00
Sebastiaan van Stijn
45fe68629b Merge pull request #49241 from vvoland/runtime-numcpu
pkg/sysinfo: Deprecate NumCPU
2025-01-09 15:15:41 +01:00
Paweł Gronowski
3db72b255d pkg/sysinfo: Deprecate NumCPU
Deprecate in favor of `runtime.NumCPU` as the behavior is the same now.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-09 13:39:49 +01:00