Commit Graph

609 Commits

Author SHA1 Message Date
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
Paweł Gronowski
b5d26e5883 Merge pull request #50078 from vvoland/cdi-default-cache
daemon: Configure default CDI cache
2025-06-12 11:36:32 +00:00
Matthieu MOREL
a62de57aa1 fix sprintfQuotedString from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Sebastiaan van Stijn
d469079338 cmd: 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
Jonathan A. Sternberg
7994426e61 Revert "containerd: images overridden by a build are kept dangling"
This reverts commit 50a856157c.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-05-29 13:23:45 -05:00
Paweł Gronowski
027588eba0 builder: Pass cdi cache instead of CDISpecDirs
Instead of passing the dirs for buildkit to configure the same cache
instance, just pass the shared CDI cache instance.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-28 13:31:45 +02:00
Sebastiaan van Stijn
c6b9bb00f9 api/server/router/build: BuilderVersion: allow buildkit on Windows
Commit 7b153b9e28 changed the daemon to
advertise the recommended builder to use to V2 (BuildKit) for Linux
daemons, and V1 (Legacy Builder) for Windows daemons. For Linux daemons
we allowed the default to be overridden through the "features" field
in the daemon config (daemon.json), but for Windows we hard-coded it
to be V1, and no option to override.

With work in progress on implementing support for Windows in BuildKit,
we should remove this hardcoded assumption, and allow the default to
be overridden to advertise that BuildKit is supported.

Note that BuildKit on Windows is still very much a "work in progress",
and enabling it in the daemon may not even work, so users should not
try to enable this feature; a warning-level log is added to make it
visible that the feature is enabled.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-22 12:36:47 +02:00
Paweł Gronowski
4cecce03f6 daemon: Enable CDI by default
CDI will now be enabled by default unless opted-out by setting `cdi`
feature to `false`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-15 22:13:19 +02:00
Rafael Fernández López
8e57a019dc fix: load the CDI driver before the dockerd daemon starts
Signed-off-by: Rafael Fernández López <ereslibre@ereslibre.es>
2025-05-15 12:00:28 +02:00
Paweł Gronowski
2e25c2b14f Merge pull request #49702 from jsternberg/containerd-dangling-build-image
containerd: images overridden by a build are kept dangling
2025-05-14 17:35:32 +00:00
Sebastiaan van Stijn
4b6a9d23af cmd/dockerd/trap: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 12:14:35 +02:00
Derek McGowan
aef409dfb2 Remove unused reference store in image api
The image api already defines the backend used and does
not directly use the reference store backend. It also should not
directly use the reference store backend.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-05-03 21:59:55 -07: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
Jonathan A. Sternberg
50a856157c containerd: images overridden by a build are kept dangling
The build exporter now clears the image tags and always exported to a
dangling image. It then uses the image tagger to perform the tagging
which causes the dangling image to be removed and the naming message to
be sent correctly.

An additional progress message is sent to indicate the renaming.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-04-25 09:29:45 -05:00
Sebastiaan van Stijn
eede75c9d4 testing: remove some defer cleanup in favor of test.Cleanup()
gotest.tools v3.0.1 and up support Go's native test.Cleanup(), which
means that manually calling the cleanup functions in a defer is no
longer needed.

Some of these could probably be replaced by Go's native `t.TempDir()`,
but keeping that for a follow-up exercise.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-19 16:35:24 +02:00
Sebastiaan van Stijn
7435e4a1be registry: remove deprecated ServiceConfig.AllowNondistributableArtifacts
This option was deprecated in 1932091e21, and
is no longer used. It was only kept to allow priniting a deprecation warning
if the config would happen to have the field set.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 15:26:50 +02:00
Albin Kerouanton
4276f330fc cmd/docker-proxy: do not eagerly GC one-sided UDP conns
The UDP proxy is setting a deadline of 90 seconds when reading from the
backend. If no data is received within this interval, it reclaims the
connection.

This means, the backend would see a different connection every 90
seconds if the backend never sends back any reply to a client.

This change prevents the proxy from eagerly GC'ing such connections by
taking into account the last time a datagram was proxyed to the backend.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-03-17 17:51:50 +01:00
Albin Kerouanton
0356854327 cmd/docker-proxy: make the conntrack timeout a property of UDPProxy
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-03-17 17:50:38 +01:00
Albin Kerouanton
d70fd32a18 cmd/docker-proxy: UDP: thread-safe Write and Close
The UDP proxy used by cmd/docker-proxy is executing Write and Close in
two separate goroutines, such that a Close could interrupt an in-flight
Write.

Introduce a `connTrackEntry` that wraps a `net.Conn` and a `sync.Mutex`
to ensure that Write and Close are serialized.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-03-17 17:50:38 +01:00
Sebastiaan van Stijn
b633c4cc33 registry: deprecate SetCertsDir
This function had to be called both in the daemon startup, as well as
the CLI startup. Which, in case of the cli, meant that the registry
package became a required dependency for all CLI-plugins.

Make the package itself aware of situations where it's running with
rootlessKit enabled. Altogether we should get rid of this package-level
variable, and instead store this in our configuration, and pass through
where it's used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-10 19:11:09 +01:00
Sebastiaan van Stijn
556633ca47 cmd/dockerd: daemonCLI.start: scope local errors
Scope errors locally and don't use special names if there's no reason
for it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-07 00:27:12 +01:00
Sebastiaan van Stijn
8b59e1a398 cmd/dockerd: daemonCLI.start: return error instead of log.Fatal
We return errors in this function, except for this one, which was logged
as Fatal. If we want errors to be logged, we should probably do so in
the function calling daemonCLI.start.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-07 00:15:16 +01:00
Sebastiaan van Stijn
8a8cdaaa11 cmd/dockerd: daemonCLI.start: don't log warnings before failing
This function could produce various logs ("Running in rootless mode") at
the start, but further steps could still fail (such as running with
RootlessKit, but not being configured as rootless).

This patch moves the informational / warning logs further down, so that
we don't produce logs before failing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-07 00:08:45 +01:00
Sebastiaan van Stijn
6e30a4cc0c cmd/dockerd: explicitly access Config fields
Explicitly access config field through the Config field, instead
of the top-level "cli". This allows spotting locations where we don't
depend on the CLI, but really just the Config.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:50:26 +01:00
Sebastiaan van Stijn
dfecaaf908 cmd/dockerd: rewrite getContainerdDaemonOpts to a func
This method only depended on the CLI config; rewrite it to a
regular function, returning the opts to use for the containerd
daemon.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:50:26 +01:00
Sebastiaan van Stijn
b95fdcd084 cmd/dockerd: createAndStartCluster: change to accept Config
This function took the whole daemon CLI as argument, but only needed
the config; change the signature to accept that.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:50:26 +01:00
Sebastiaan van Stijn
29aa7e15bd cmd/dockerd: rewrite getSwarmRunRoot to a regular func
This method only required the config to be passed; rewrite it to a
regular func that accepts the config.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:50:26 +01:00
Sebastiaan van Stijn
29c296e1dd cmd/dockerd: rename vars that shadowed imports
Also use a consistent name for "config" arguments.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:50:26 +01:00
Sebastiaan van Stijn
4d3d4bbeeb daemon/cluster: remove Config.WatchStream and move to constructor
The WatchStream field was set as configuration option in cmd/dockerd,
but not configurable. Move creating the stream to the constructor,
and remove the configuration option. This field was introduced in
59d45c384a, at which time the cmd/dockerd
code needed direct access to the stream, but a later refactor in
05346355db introduced an accessor
(GetWatchStream) for this.

The cluster.Config struct is only used internally, it's unlikely
for any external project to use this, so skipping deprecation.

With this change, the cmd/dockerd package no longer has a direct
import of swarmkit.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 15:24:55 +01:00
Rob Murray
013c43fb56 Mark default-bridge-only opts in --help and manpage
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-22 20:21:23 +00:00
Sebastiaan van Stijn
d1c6550f71 daemon: use structured logs for printing reloaded config, move to cli
- Move logging out of config.Reload and daemon.Reload itself, as it was not
  the right place to know whether it was a "signal" that triggered the reload.
- Use Daemon.Config() to get the new config after reloading. This returns an
  immutable copy of the daemon's config, so we can redact fields without having
  to use an ad-hoc struct to shadow the underlying fields.
- Use structured logs for logging config reload events.

Before this (plain text):

    INFO[2025-02-08T12:13:53.389649297Z] Got signal to reload configuration, reloading from: /etc/docker/daemon.json
    INFO[2025-02-08T12:30:34.857691260Z] Reloaded configuration: {"pidfile":"/var/run/docker.pid","data-root":"/var/lib/docker","exec-root":"/var/run/docker","group":"docker","max-concurrent-downloads":3,"max-concurrent-uploads":5,"max-download-attempts":5,"shutdown-timeout":15,"hosts":["unix:///var/run/docker.sock"],"log-level":"info","log-format":"text","swarm-default-advertise-addr":"","swarm-raft-heartbeat-tick":0,"swarm-raft-election-tick":0,"metrics-addr":"","host-gateway-ips":[""],"log-driver":"json-file","mtu":1500,"ip":"0.0.0.0","icc":true,"iptables":true,"ip6tables":true,"ip-forward":true,"ip-masq":true,"userland-proxy":true,"userland-proxy-path":"/usr/local/bin/docker-proxy","default-address-pools":{"Values":null},"network-control-plane-mtu":1500,"experimental":false,"containerd":"/var/run/docker/containerd/containerd.sock","features":{"containerd-snapshotter":false},"builder":{"GC":{},"Entitlements":{}},"containerd-namespace":"moby","containerd-plugin-namespace":"plugins.moby","default-runtime":"runc","runtimes":{"crun":{"path":"/usr/local/bin/crun"}},"seccomp-profile":"builtin","default-shm-size":67108864,"default-ipc-mode":"private","default-cgroupns-mode":"private","resolv-conf":"/etc/resolv.conf","proxies":{}}

Before this (JSON logs):

    {"level":"info","msg":"Reloaded configuration: {\"pidfile\":\"/var/run/docker.pid\",\"data-root\":\"/var/lib/docker\",\"exec-root\":\"/var/run/docker\",\"group\":\"docker\",\"max-concurrent-downloads\":3,\"max-concurrent-uploads\":5,\"max-download-attempts\":5,\"shutdown-timeout\":15,\"hosts\":[\"unix:///var/run/docker.sock\"],\"log-level\":\"info\",\"log-format\":\"json\",\"swarm-default-advertise-addr\":\"\",\"swarm-raft-heartbeat-tick\":0,\"swarm-raft-election-tick\":0,\"metrics-addr\":\"\",\"host-gateway-ips\":[\"\"],\"log-driver\":\"json-file\",\"mtu\":1500,\"ip\":\"0.0.0.0\",\"icc\":true,\"iptables\":true,\"ip6tables\":true,\"ip-forward\":true,\"ip-masq\":true,\"userland-proxy\":true,\"userland-proxy-path\":\"/usr/local/bin/docker-proxy\",\"default-address-pools\":{\"Values\":null},\"network-control-plane-mtu\":1500,\"experimental\":false,\"containerd\":\"/var/run/docker/containerd/containerd.sock\",\"features\":{\"containerd-snapshotter\":false},\"builder\":{\"GC\":{},\"Entitlements\":{}},\"containerd-namespace\":\"moby\",\"containerd-plugin-namespace\":\"plugins.moby\",\"default-runtime\":\"runc\",\"runtimes\":{\"crun\":{\"path\":\"/usr/local/bin/crun\"}},\"seccomp-profile\":\"builtin\",\"default-shm-size\":67108864,\"default-ipc-mode\":\"private\",\"default-cgroupns-mode\":\"private\",\"resolv-conf\":\"/etc/resolv.conf\",\"proxies\":{}}","time":"2025-02-08T12:24:38.600761054Z"}

After this (plain text):

    INFO[2025-02-08T12:30:34.835953594Z] Got signal to reload configuration            config-file=/etc/docker/daemon.json
    INFO[2025-02-08T12:30:34.857614135Z] Reloaded configuration                        config="{\"pidfile\":\"/var/run/docker.pid\",\"data-root\":\"/var/lib/docker\",\"exec-root\":\"/var/run/docker\",\"group\":\"docker\",\"max-concurrent-downloads\":3,\"max-concurrent-uploads\":5,\"max-download-attempts\":5,\"shutdown-timeout\":15,\"hosts\":[\"unix:///var/run/docker.sock\"],\"log-level\":\"info\",\"log-format\":\"text\",\"swarm-default-advertise-addr\":\"\",\"swarm-raft-heartbeat-tick\":0,\"swarm-raft-election-tick\":0,\"metrics-addr\":\"\",\"host-gateway-ips\":[\"\"],\"log-driver\":\"json-file\",\"mtu\":1500,\"ip\":\"0.0.0.0\",\"icc\":true,\"iptables\":true,\"ip6tables\":true,\"ip-forward\":true,\"ip-masq\":true,\"userland-proxy\":true,\"userland-proxy-path\":\"/usr/local/bin/docker-proxy\",\"default-address-pools\":{\"Values\":null},\"network-control-plane-mtu\":1500,\"experimental\":false,\"containerd\":\"/var/run/docker/containerd/containerd.sock\",\"features\":{\"containerd-snapshotter\":false},\"builder\":{\"GC\":{},\"Entitlements\":{}},\"containerd-namespace\":\"moby\",\"containerd-plugin-namespace\":\"plugins.moby\",\"default-runtime\":\"runc\",\"runtimes\":{\"crun\":{\"path\":\"/usr/local/bin/crun\"}},\"seccomp-profile\":\"builtin\",\"default-shm-size\":67108864,\"default-ipc-mode\":\"private\",\"default-cgroupns-mode\":\"private\",\"resolv-conf\":\"/etc/resolv.conf\",\"proxies\":{}}"

After this (JSON logs):

    {"config-file":"/etc/docker/daemon.json","level":"info","msg":"Got signal to reload configuration","time":"2025-02-08T12:24:38.589955637Z"}
    {"config":"{\"pidfile\":\"/var/run/docker.pid\",\"data-root\":\"/var/lib/docker\",\"exec-root\":\"/var/run/docker\",\"group\":\"docker\",\"max-concurrent-downloads\":3,\"max-concurrent-uploads\":5,\"max-download-attempts\":5,\"shutdown-timeout\":15,\"hosts\":[\"unix:///var/run/docker.sock\"],\"log-level\":\"info\",\"log-format\":\"json\",\"swarm-default-advertise-addr\":\"\",\"swarm-raft-heartbeat-tick\":0,\"swarm-raft-election-tick\":0,\"metrics-addr\":\"\",\"host-gateway-ips\":[\"\"],\"log-driver\":\"json-file\",\"mtu\":1500,\"ip\":\"0.0.0.0\",\"icc\":true,\"iptables\":true,\"ip6tables\":true,\"ip-forward\":true,\"ip-masq\":true,\"userland-proxy\":true,\"userland-proxy-path\":\"/usr/local/bin/docker-proxy\",\"default-address-pools\":{\"Values\":null},\"network-control-plane-mtu\":1500,\"experimental\":false,\"containerd\":\"/var/run/docker/containerd/containerd.sock\",\"features\":{\"containerd-snapshotter\":false},\"builder\":{\"GC\":{},\"Entitlements\":{}},\"containerd-namespace\":\"moby\",\"containerd-plugin-namespace\":\"plugins.moby\",\"default-runtime\":\"runc\",\"runtimes\":{\"crun\":{\"path\":\"/usr/local/bin/crun\"}},\"seccomp-profile\":\"builtin\",\"default-shm-size\":67108864,\"default-ipc-mode\":\"private\",\"default-cgroupns-mode\":\"private\",\"resolv-conf\":\"/etc/resolv.conf\",\"proxies\":{}}","level":"info","msg":"Reloaded configuration","time":"2025-02-08T12:24:38.600736179Z"}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-14 12:22:10 +01:00
Tonis Tiigi
e364e28ec8 vendor: update buildkit to v0.20.0-rc1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-02-12 11:00:04 -08:00
Sebastiaan van Stijn
2e9e7989f8 cmd/dockerd: initBuildkit: return close-func
Make it more explicit that callers must call close

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-06 13:56:04 +01:00
Brian Goff
2dc03f934f cmd/dockerd: refactor buildkit init in daemon startup
- Move the "Daemon has completed initialization" log to where it has
  actually completed initialization.
- Move buildkit init to its own function.
- Move the builder options to a separate struct, and change initBuildkit
  to return it instead of passing the router-options and manipulate it.

Co-authored-by: Brian Goff <cpuguy83@gmail.com>
Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-06 13:53:29 +01:00
Sebastiaan van Stijn
3bb40af036 dockerd: enable shell-completion; add (hidden) completion subcommand
This required a minor hack to accommodate Cobra's logic (and a TODO was
added to see if we can improve that logic in upstream). Some changes also
had to be made to our "Usage" template, as our custom template did not
take into account subcommands and long descriptions for commands. We
should review these templates, as some additional features were added
in upstream Cobra that we currently may not be using.

With this patch:

instructions for the (hidden) completion subcommand:

    docker completion --help

    Usage:  docker completion COMMAND

    Generate the autocompletion script for docker for the specified shell.
    See each sub-command's help for details on how to use the generated script.

    Commands:
      bash        Generate the autocompletion script for bash
      fish        Generate the autocompletion script for fish
      powershell  Generate the autocompletion script for powershell
      zsh         Generate the autocompletion script for zsh

    Run 'docker completion COMMAND --help' for more information on a command.

and instructions for installing:

    dockerd completion bash --help

    Usage:	dockerd completion bash

    Generate the autocompletion script for the bash shell.

    This script depends on the 'bash-completion' package.
    If it is not installed already, you can install it via your OS's package manager.

    To load completions in your current shell session:

        source <(dockerd completion bash)

    To load completions for every new session, execute once:

    #### Linux:

        dockerd completion bash > /etc/bash_completion.d/dockerd

    #### macOS:

        dockerd completion bash > $(brew --prefix)/etc/bash_completion.d/dockerd

    You will need to start a new shell for this setup to take effect.

    Options:
          --help              Print usage
          --no-descriptions   disable completion descriptions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 17:12:26 +01:00
Derek McGowan
0aa8fe0bf9 Update to containerd v2.0.2, buildkit v0.19.0-rc2
Update buildkit version to commit which uses 2.0

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-01-15 14:09:30 +01:00
Sebastiaan van Stijn
48e6b4e8f7 vendor: otel v0.56.0 / v1.31.0
Reverts otel workaround, added in cca7085464,
as it's no longer needed:

    === Failed
    === FAIL: cmd/dockerd TestOtelMeterLeak (0.64s)
        daemon_test.go:303: Allocations: 3
        daemon_test.go:307: Allocations count decreased. OTEL leak workaround is no longer needed!

We're keeping the test for now, so that we can check for possible
regressions in the OTel dependencies.

Co-authored-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 15:01:34 +01:00
Paweł Gronowski
048fece105 Alias github.com/docker/go-metrics imports
Next commits will introduce a new internal `metrics` package, so alias
the "external" import to avoid confusion.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-07 14:13:05 +01:00
Sebastiaan van Stijn
c02c2a3a79 cmd/dockerd: remove uses of deprecated system.MkdirAll
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-21 14:30:56 +01:00
Paweł Gronowski
ce9c1635cd Merge pull request #49138 from vvoland/api-remove-unused-gd-fields
api: Remove unused imageStore and layerStore
2024-12-19 14:52:07 +00:00
Paweł Gronowski
7e9a5064dc api: Remove unused imageStore and layerStore
Commit 8fb71ce208 moved access to these to
the image service directly, so they are no longer used in the router.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-19 14:50:50 +01:00
Sebastiaan van Stijn
4f5ec9994c pkg/reexec: deprecate and migrate to github.com/moby/sys/reexec
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-19 10:12:58 +01:00
Sebastiaan van Stijn
1e0477f6ec Merge pull request #49065 from thaJeztah/deprecate_nondistributable_artifacts
remove support for configuring pushing non-distributable artifacts and deprecate API fields and config
2024-12-12 21:39:34 +01:00
Paweł Gronowski
d8358ebc87 otel: Use non-noop tracer provider for grpc
Needed for Buildkit history

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-12 19:31:00 +01:00
Paweł Gronowski
4847557d1b otel: Avoid excessive memory allocations if not configured
Use noop tracer provider if the OTEL exporter is not configured.
This makes the OTEL tracing avoid doing unneeded memory allocations for
spans which aren't going to be exported anywhere anyway.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-12 18:31:03 +01:00
Sebastiaan van Stijn
1932091e21 remove support for non-distributable artifacts and deprecate API fields and config
Non-distributable artifacts (foreign layers) were introduced in commit
05bd04350b to accommodate Windows images,
for which the EULA did not allow layers to be distributed through registries
other than those hosted by Microsoft. The concept of foreign / non-distributable
layers was adopted by the OCI distribution spec in [oci#233].

These restrictions were relaxed later to allow distributing these images
through non-public registries, for which a configuration was added in the
daemon in 67fdf574d5. In 2022, Microsoft updated
the EULA and [removed these restrictions altogether][1], and the OCI distribution
spec deprecated the  functionality in [oci#965].

In 2023, Microsoft [removed the use of foreign data layers][2] for their images,
making this functionality obsolete.

This patch:

- Deprecates the `--allow-nondistributable-artifacts` daemon flag and corresponding
  `allow-nondistributable-artifacts` field in `daemon.json`. Setting either
  option will no longer take an effect, but a deprecation warning log is added
  to raise awareness about the deprecation. This warning is planned to become
  an error in the next release.
- Deprecates the `RegistryConfig.AllowNondistributableArtifactsCIDRs` and
  `RegistryConfig.AllowNondistributableArtifactsHostnames` fields in the
  `GET /info` API response. For API version v1.48 and lower, the fields are
  still included in the response, but always `null`. In API version v1.49 and
  higher, the field will be omitted entirely.
- Deprecates the `api/types/registry/ServiceConfig.AllowNondistributableArtifactsCIDRs`
  field.
- Deprecates the `api/types/registry/ServiceConfig.AllowNondistributableArtifactsHostnames`
  field.
- Deprecates the `registry.ServiceOptions.AllowNondistributableArtifacts` field.

[oci#233]: https://github.com/opencontainers/image-spec/pull/233
[oci#965]: https://github.com/opencontainers/image-spec/pull/965
[1]: https://techcommunity.microsoft.com/blog/containers/announcing-windows-container-base-image-redistribution-rights-change/3645201
[2]: https://techcommunity.microsoft.com/blog/containers/announcing-removal-of-foreign-layers-from-windows-container-images/3846833

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 20:29:46 +01:00
Sebastiaan van Stijn
9da0e69608 api/server: Server.CreateMux: pass context and use structured logs
Pass the context that's used for logging, and add minimal handling of
context-cancellation. Also update logs to use structured fields.

Before this  patch:

    DEBU[2024-12-08T15:24:47.324420709Z] Registering POST, /networks/{id:.*}/disconnect
    DEBU[2024-12-08T15:24:47.324447251Z] Registering POST, /networks/prune
    DEBU[2024-12-08T15:24:47.324460626Z] Registering DELETE, /networks/{id:.*}

With this patch:

    DEBU[2024-12-08T15:33:50.408445543Z] Registering route                              method=POST path="/networks/{id:.*}/disconnect"
    DEBU[2024-12-08T15:33:50.408484335Z] Registering route                              method=POST path=/networks/prune
    DEBU[2024-12-08T15:33:50.408505251Z] Registering route                              method=DELETE path="/networks/{id:.*}"

Or in JSON format:

    {"level":"debug","method":"POST","msg":"Registering route","path":"/networks/{id:.*}/connect","time":"2024-12-08T15:37:19.235209667Z"}
    {"level":"debug","method":"POST","msg":"Registering route","path":"/networks/{id:.*}/disconnect","time":"2024-12-08T15:37:19.235243001Z"}
    {"level":"debug","method":"POST","msg":"Registering route","path":"/networks/prune","time":"2024-12-08T15:37:19.235290876Z"}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-09 15:58:46 +01:00
Sebastiaan van Stijn
9c1ff095e8 cmd/dockerd: pass debug-router instead of constructing in CreateMux
Now that debug-routes are identical to regular routers, we can pass them
the same as those routers. With this, the daemon also logs those routes
as part of its startup (when in debug mode).

Before this patch, only non-debug endpoints would be logged:

    DEBU[2024-12-08T15:24:47.320933959Z] Registering routers
    ...
    DEBU[2024-12-08T15:24:47.324420709Z] Registering POST, /networks/{id:.*}/disconnect
    DEBU[2024-12-08T15:24:47.324447251Z] Registering POST, /networks/prune
    DEBU[2024-12-08T15:24:47.324460626Z] Registering DELETE, /networks/{id:.*}
    INFO[2024-12-08T15:24:47.324828334Z] API listen on /var/run/docker.sock

With this patch, debug endpoints are also logged:

    DEBU[2024-12-08T15:24:47.320933959Z] Registering routers
    ...
    DEBU[2024-12-08T15:24:47.324420709Z] Registering POST, /networks/{id:.*}/disconnect
    DEBU[2024-12-08T15:24:47.324447251Z] Registering POST, /networks/prune
    DEBU[2024-12-08T15:24:47.324460626Z] Registering DELETE, /networks/{id:.*}
    DEBU[2024-12-08T15:24:47.324486834Z] Registering GET, /debug/vars
    DEBU[2024-12-08T15:24:47.324506751Z] Registering GET, /debug/pprof/
    DEBU[2024-12-08T15:24:47.324532126Z] Registering GET, /debug/pprof/cmdline
    DEBU[2024-12-08T15:24:47.324549293Z] Registering GET, /debug/pprof/profile
    DEBU[2024-12-08T15:24:47.324564501Z] Registering GET, /debug/pprof/symbol
    DEBU[2024-12-08T15:24:47.324582043Z] Registering GET, /debug/pprof/trace
    DEBU[2024-12-08T15:24:47.324604751Z] Registering GET, /debug/pprof/{name}
    INFO[2024-12-08T15:24:47.324828334Z] API listen on /var/run/docker.sock

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-09 15:55:26 +01:00
Albin Kerouanton
f1bb2bc446 Merge pull request #49052 from thaJeztah/remove_daemon_NetworkControllerEnabled
daemon: remove Daemon.NetworkControllerEnabled
2024-12-09 11:50:16 +01:00
Sebastiaan van Stijn
5fc32c12c7 cmd/dockerd: ignore some unhandled errors
These are unlikely to fail ever, so should be fine to ignore.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-08 17:18:33 +01:00