77 Commits
Author SHA1 Message Date
Shane Jonas eb999c9ac4 Propagate plugin privilege fetch errors
Signed-off-by: Shane Jonas <jonas.shane@gmail.com>
2026-10-13 15:48:03 -04:00
Sebastiaan van Stijn db9f143dae daemon/pkg/registry: require all resolved addresses to be insecure
Only consider a registry insecure through CIDR matching when all of its
resolved IP addresses match a configured insecure subnet.

This prevents a registry that resolves to both loopback and non-loopback
addresses from falling back to insecure requests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-09-30 21:07:56 +02:00
Sebastiaan van Stijn a76f0e990f daemon/pkg/registry: use documentation IP addresses in tests
Replace routable test addresses with addresses reserved for documentation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-09-30 21:07:56 +02:00
Sebastiaan van Stijn 84e59b6c21 daemon/pkg/registry: TestIsSecureIndex use subtests
Add descriptive names and run the isSecureIndex test cases as subtests.

This makes failures easier to identify and prepares the table for adding
coverage of registries that resolve to multiple addresses.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-09-30 21:07:56 +02:00
Sebastiaan van Stijn 98f273a2fb daemon/pkg/registry: loadInsecureRegistries: make order deterministic
Make the order of insecure registries deterministic, and update TestNewServiceConfig
to also test the config that was produced, not just errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-09-30 21:07:52 +02:00
Sebastiaan van Stijn 5d8f006176 Merge pull request #53720 from thaJeztah/lint_usetesting
golangci-lint: enable usetesting linter
2026-09-28 10:15:13 +02:00
Sebastiaan van Stijn b1bf272a8c replace uses of docker/distribution consts for plugin-mediatype
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-09-24 15:15:23 +02:00
Sebastiaan van Stijn 27e3a5d518 replace uses of docker/distribution MediaType consts for c8d consts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-09-24 13:41:45 +02:00
Sebastiaan van Stijn af03216ce5 daemon/pkg/registry: fix G119 (gosec)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-09-18 22:59:39 +02:00
Sebastiaan van Stijn fa34dbd305 daemon/pkg/registry: use t.Context
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-09-18 18:28:44 +02:00
Sebastiaan van Stijn 00d7a3d0fa daemon/pkg/registry: replace cloneRequest for request.Clone
This utility was originally added in 73823e5e56,
and looks to be a hand-crafted equivalent for request.Clone (which may not have
been available yet at the time).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-08-31 16:54:25 +02:00
Sebastiaan van Stijn 39f073cf9b daemon/pkg/oci/caps: clean up NormalizeLegacyCapabilities
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-08-29 12:58:54 +02:00
Paweł Gronowski a8181e8020 daemon/plugins: Confine plugin mount paths to scoped roots
A managed volume plugin could return a path containing dot-dot
elements that passed the propagated-mount string prefix check, then
escaped the host mount root when filepath.Join cleaned it. Sibling
paths sharing the same string prefix were also treated as propagated
paths.

Normalize returned paths in the plugin's rooted namespace. Use
filepath.Rel and filepath.IsLocal so only path-component descendants
are mapped through the propagated mount. Other paths remain confined
beneath the plugin rootfs.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-08-26 22:55:46 +02:00
Sebastiaan van Stijn 7067ffff11 daemon/pkg/opts: fix recursive NRI JSON decoding on go1.27 (JSON v2)
Define the recursion-prevention type from NRIOpts instead of *NRIOpts.

The named pointer type was handled correctly by the legacy JSON decoder,
but Go 1.27's new JSON implementation resolves NRIOpts.UnmarshalJSON
through it, causing infinite recursion and eventually a stack overflow.

Using a distinct type with NRIOpts as its underlying type removes the
method set while preserving the same fields and JSON representation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-08-02 15:41:08 +02:00
Sebastiaan van Stijn 38a3b4f4e2 daemon/pkg/oci: use native Go fuzzing
Replace go-fuzz-headers with native fuzz parameters and construct Record
values directly from the fuzz input.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-13 11:19:48 +02:00
Akihiro SudaandClaude Opus 4.7 4ca129225d rootless: fix plugin install by running ToRootless on plugin spec
Plugin specs built by (*v2.Plugin).InitSpec never went through
daemon/internal/rootless/specconv.ToRootless, so the /sys fix-up
for network=host under detach-netns (added in 84aedb805 "rootless:
support detach-netns mode") was skipped for plugins. This made
`docker plugin install` fail in rootless mode.

Apply the same rootless conversion that container specs receive in
daemon/oci_linux.go, gated on rootless.RunningWithRootlessKit().

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2026-06-02 04:01:13 +09:00
Sebastiaan van Stijn d5370d34d3 use private time-namespace for containers on supported kernels
Time namespaces were introduced in [Linux Kernel 5.6], and are supported by
[OCI runtime spec v1.1.0] and up. This patch updates the default OCI spec for
containers to use a private time-namespace if the host support it. We do not
yet provide options to customize this option (e.g. to allow switching between
"private", "host", or to join another container's time-namespace), which can be
added in a future update (but requires API changes).

With this patch applied:

    docker run -dq nginx:alpine
    54220be49a47d09f74ee918e65233365e94ecb306e4104a4468ab50221262bf7

    ctr -n moby c info 54220be49a47d09f74ee918e65233365e94ecb306e4104a4468ab50221262bf7 | jq .Spec.linux.namespaces
    [
      {"type": "mount"},
      {"type": "network"},
      {"type": "uts"},
      {"type": "pid"},
      {"type": "ipc"},
      {"type": "time"},
      {"type": "cgroup"}
    ]

[Linux Kernel 5.6]: https://lwn.net/Articles/779104/
[OCI runtime spec v1.1.0]: https://github.com/opencontainers/runtime-spec/releases/tag/v1.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-04-27 14:33:45 +02:00
Paweł Gronowski a713363783 Merge pull request #52339 from thaJeztah/search_cleans
daemon/pkg/registry: minor cleanups
2026-04-16 13:05:48 +02:00
Sebastiaan van Stijn 97cb71d7ed pkg/registry: use stdlib's x509.SystemCertPool on Windows
The `tlsconfig.SystemCertPool` utility in go-connections was added in
[docker/go-connections@55aadc3], at which time Go stdlib didn't support
system-pools ([x509.SystemCertPool]) on Windows, so an empty pool was
constructed.

Support for system pools on Windows originally added in Go 1.8 (through
[golang/go@05471e9]), but reverted, and re-implemented in Go 1.18 (through
[golang/go@3544082]).

Go 1.18 and up now implement this, but, unlike Linux, which uses a pure-Go
implementation, certificate validation is handled by the system:

> On macOS and Windows, certificate verification is handled by system APIs,
> but the package aims to apply consistent validation rules across operating
> systems.

On macOS and Windows, x509.SystemCertPool returns an empty Pool, with the
`systemPool` set to `true` (see [loadSystemRoots]). This must be considered
an implementation detail; custom CAs can be appended to this pool, and handled
as usual.

This patch removes the special handling on Windows, removing the dependency
on go-connections for this part.

[docker/go-connections@55aadc3]: https://github.com/docker/go-connections/commit/55aadc3cc561684699edcdd0921b9293c3ee6b49
[golang/go@05471e9]: https://github.com/golang/go/commit/05471e9ee64a300bd2dcc4582ee1043c055893bb
[golang/go@3544082]: https://github.com/golang/go/commit/3544082f75fd3d2df7af237ed9aef3ddd499ab9c
[x509.SystemCertPool]: https://pkg.go.dev/crypto/x509#SystemCertPool
[loadSystemRoots]: https://cs.opensource.google/go/go/+/refs/tags/go1.26.1:src/crypto/x509/root_windows.go;l=15-17

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-04-15 12:24:24 +02:00
Sebastiaan van Stijn b3bd13ad10 daemon/pkg/registry: minor cleanups
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-04-10 10:51:05 +02:00
Sebastiaan van Stijn c25bd0a255 Merge pull request #52198 from htoyoda18/transport/enable-keepalive-registry
transport: enable HTTP keep-alive for registry connections
2026-04-02 16:06:15 +02:00
Paweł Gronowski 06b31dcd12 daemon/pkg/opts: fix ValidateIPAddress docstring
Update the docstring to accurately reflect the behavior of netip.ParseAddr,
which does not allow leading/trailing whitespace and does not support IPv6
addresses in square brackets.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-04-01 15:21:47 +02:00
Sebastiaan van Stijn dd11127524 daemon/pkg/opts: ValidateIPAddress: use netip.Parse
Make sure we use the same function to validate as we use to parse
the IP-address.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-31 19:39:35 +02:00
Paweł Gronowski 99a095ecf0 plugin: Fix off-by-one in privilege validation
Fix an off-by-one error in isEqual() where the comparison loop started
at index 1 instead of 0, causing the first privilege (after sorting
alphabetically by name) to never be validated.

This allowed a malicious plugin to request different values for
whichever privilege sorts first — most notably "allow-all-devices",
which grants unrestricted rwm access to all host devices.

The bug also meant that plugins requesting exactly one privilege had
zero iterations of the comparison loop, bypassing validation entirely.

Also fix an existing test case ("diff-order-but-same-value") that only
passed due to the off-by-one bug, and add test cases for single-element
and first-sorted-element mismatches.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-03-25 12:39:24 +01:00
hiroto.toyoda 619ecc9b53 transport: enable HTTP keep-alive for registry connections
Signed-off-by: hiroto.toyoda <hiroto.toyoda@dena.com>
2026-03-23 02:30:42 +09:00
Sebastiaan van Stijn 8f45db8414 daemon/pkg/registry: use lazyregexp again
This was removed in f651a5d5e9, because
at the time docker/cli was importing this package. It's now moved
internal to the daemon, and should no longer be used externally,
so we can revert that change.

This reverts commit f651a5d5e9.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-02-02 17:22:31 +01:00
Sebastiaan van Stijn d7218ec6c1 daemon/pkg/plugin/v2: use namespace consts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-01-28 12:18:46 +01:00
Sebastiaan van Stijn 59abc76746 daemon/pkg/opts: remove unused ParseHost
Merge some of the test-cases into TestParseDockerDaemonHost.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-01-26 16:51:48 +01:00
Sebastiaan van Stijn 20c801f9e1 daemon/pkg/opts: export ParseDaemonHost
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-01-24 13:22:45 +01:00
Paweł Gronowski 0ae3f972ad daemon: Simplify slices.Contains usage
Remove unnecessary intermediate variables and helper functions when
using slices.Contains.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-16 13:31:33 +01:00
Paweł Gronowski 62ed24a87c modernize: Use slices.Contains
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
Rob Murray a230544000 NRI: add daemon.json/command line options
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-12-05 15:19:33 +00:00
Tonis Tiigi 47e852f061 image: pull/load/save attestation manifest and signatures with image
Updates docker pull to pull related attestation manifest and
any signatures for that manifest in cosign referrer objects.

These objects are transferred with the image when running
docker save and docker load and can be used to identify
the image in future updates.

Push is not updated atm as the currect push semantics
in containerd mode do not have correct immutability
guaranteed and don't work with image indexes.

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-11-12 07:53:46 -08:00
Sebastiaan van Stijn bb56c4d7e7 daemon: remove some deprecated and unused code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-11-11 09:05:41 +01:00
Sebastiaan van Stijn ebe464ea45 api/types: remove PushResult type, and move internal
This type was used as Aux message for docker push, was not documented,
and only present for Docker Content Trust (which is deprecated).

This patch removes it from the API module, and moves the type internal.
We can stop sending this Aux message once DCT is fully phased out.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-31 00:47:23 +01:00
Cory Snider ae28867804 api/pkg/progress: move to client and daemon/internal
Move the progress package up into the client as a temporary shared location for
common clients like CLI and compose.

The progress package is used by the daemon to write progress updates to
some sink, typically a streamformatter. This package is of little use to
API clients as this package does not provide any facilities to consume
the progress updates.

Co-authored-by: Cory Snider <csnider@mirantis.com>
Signed-off-by: Austin Vazquez <austin.vazquez@docker.com>
2025-10-24 07:56:57 -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 a8dd9c5025 daemon/pkg/plugin: stop propagating Plugin.Config.DockerVersion field
The DockerVersion field was present for informational purposes, but was
not used anywhere. This patch stops propagating the field, which also
reduces the number of places where the `dockerversion` package is used,
which still needs a new home.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-07 11:46:52 +02:00
Sebastiaan van Stijn c4fda95bea api/types/plugin: deprecate Config.DockerVersion field
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-06 14:19:53 +02:00
Cory Snider d6899ca5a5 api/types/registry: use netip types as appropriate
Signed-off-by: Cory Snider <csnider@mirantis.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-10-03 21:41:21 +02:00
Cory Snider d5c838dc5e internal: move sliceutil from daemon/internal
These utilities are very handy to use in integration tests, too. Move
the package so it can be imported by them.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-10-03 21:39:14 +02: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 57256a9b62 fix error-capitalization
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-05 15:42:59 +02:00
Sebastiaan van Stijn c13266d2c0 api/types: move plugin types to api/types/plugin
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-05 15:42:57 +02:00
Sebastiaan van Stijn 485b11a6f7 Merge pull request #50599 from thaJeztah/cleanup_registry
daemon/pkg/registry: some cleanups to start separating "search"
2025-08-05 13:51:17 +02:00
Cory Snider ee560a3b23 api/types: fix Plugin.Config.Interface.Types def'n
The wire type of Plugin.Config.Interface.Types is an array of strings,
not of objects with three properties. We just so happen to have a Go
struct type to represent a plugin-interface-type value in memory with
all the fields parsed out for convenience, but that is not part of the
REST API contract documented by the Swager spec.U pdate the Swagger spec
to correctly document that the Types property is an array of strings in
the API, while still generating Go definitions that unmarshal into the
convenient struct type.

Move the definition and marshal/unmarshal methods for
PluginInterfaceType into a more appropriate location than api/types.
Rename the type to one that does not stutter or overload already
heavily overloaded terminology.

Modernize the parser and use property-based testing to assert that it
behaves the same as the old parser for all well-formed inputs.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-08-01 13:37:20 -04:00
Sebastiaan van Stijn a43198845b daemon/pkg/registry: un-export ResolveAuthConfig
It's now only used to back the `Service.ResolveAuthConfig` method, and
not used outside of the package currently.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-01 16:47:47 +02:00
Sebastiaan van Stijn 5fbf680f5d daemon/pkg/registry: move newIndexInfo to search
It's the only user of it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-01 16:42:31 +02:00
Sebastiaan van Stijn 6a7f0008a3 daemon/pkg/registry: move searchRepositories to where it's used
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-08-01 16:42:31 +02:00