Commit Graph

9907 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
7239c72eca remove uses of deprecated go-archive consts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-12-19 17:51:03 +01:00
Paweł Gronowski
1175dd348e daemon/volume/mounts: Fix tests on Windows
The test was failing on Windows because it used Unix-style paths and
relied on platform-specific filesystem behavior.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-19 12:42:43 +01:00
Shane St Savage
beeacde4b2 Remove restriction on anonymous read-only volumes
Restriction on anonymouse read-only volumes is currently preventing
the use of pre-populated volumes that should be accessed in a read-only manner in a container
(e.g. an NFS volume containing data to be processed or served).

According to @neersighted the restriction may have originally been put
in place with the assumption that pre-populated volumes would be
exposed as a named volume by the volume driver.

In practice, NFS volumes are mounted using the docker `local` driver
by supplying driver opts. Example that fails when `readonly` is specified but works without:

```
docker run --rm -it \
 --mount 'readonly,type=volume,dst=/data/dest,volume-driver=local,volume-opt=type=nfs,volume-opt=device=:/export/some-share,"volume-opt=o=nfsvers=4,addr=some.server"' \
  debian
```

Fixes #45297

Signed-off-by: Shane St Savage <shane@axds.co>
2025-12-18 16:08:31 -08:00
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
Sebastiaan van Stijn
32190e99a3 Merge pull request #51624 from AkihiroSuda/fix-51601
cdi: read XDG_CONFIG_HOME/cdi and XDG_RUNTIME_DIR/cdi for rootless
2025-12-17 16:27:13 +01:00
Sebastiaan van Stijn
614d9b966f daemon/libnetwork/options: GenerateFromModel: remove redundant check
This check was added in 14c5cd377d to prevent
passing `nil` as type (`GenerateFromModel[nil](....)`), however, `nil` is not
a type, so trying to do so won't compile. Even if it would, it would be
theoretical at best, so let's just remove it.

fix linting:

    daemon/libnetwork/options/options.go:57:13: SA4023(related information): the lhs of the comparison is the 1st return value of this function call (staticcheck)
        modType := reflect.TypeFor[T]()
                   ^
    daemon/libnetwork/options/options.go:58:5: SA4023: this comparison is never true (staticcheck)
        if modType == nil {
           ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-12-17 14:19:53 +01:00
Sebastiaan van Stijn
e9dec9893f Merge pull request #51715 from jschfflr/45939-init-layer-cleanup
layer: Clean up init layer if initialization fails
2025-12-17 13:05:50 +01:00
Nicolas De Loof
aef5d996ce use mime-type application/jsonl to align with openapi 3.2
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-12-17 11:37:48 +01:00
Paweł Gronowski
26bb1af7e6 daemon/layer_store: Use named return error for defer
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-17 11:31:08 +01:00
Sebastiaan van Stijn
1f498c5ff0 fix linting issues
Some false positives from gosec (G602: slice index out of range)

    integration-cli/daemon/daemon.go:109:1: deprecatedComment: `Deprecated: ` notices should be in a dedicated paragraph, separated from the rest (gocritic)
    // Deprecated: use cli.WaitCmd instead
    ^
    integration-cli/docker_cli_build_test.go:562:3: dupOption: function argument `build.WithFile("test_file3", "test3")` is duplicated (gocritic)
            build.WithFile("test_file3", "test3"),
            ^
    integration-cli/docker_utils_test.go:250:1: deprecatedComment: `Deprecated: ` notices should be in a dedicated paragraph, separated from the rest (gocritic)
    // Deprecated: use cli.WaitFor
    ^
    daemon/libnetwork/ipams/defaultipam/address_space.go:45:39: G602: slice index out of range (gosec)
            if predefined[j].Overlaps(predefined[i].Base) {
                                                ^
    daemon/libnetwork/ipams/defaultipam/address_space.go:49:29: G602: slice index out of range (gosec)
            predefined[j] = predefined[i]
                                      ^
    daemon/libnetwork/libnetwork_linux_test.go:1492:9: G602: slice index out of range (gosec)
            sboxes[thd-1], err = controller.NewSandbox(context.Background(), fmt.Sprintf("%drace", thd))
                  ^
    daemon/libnetwork/networkdb/cluster_test.go:111:21: G602: slice index out of range (gosec)
                mean, stdev := nf[0], nf[1]
                                 ^
    daemon/libnetwork/osl/interface_linux.go:586:54: G602: slice index out of range (gosec)
                log.G(ctx).WithField("portState", stateFileContent[0]).Debug("waiting for bridge port to be forwarding")
                                                                  ^
    daemon/libnetwork/osl/interface_linux.go:594:32: G602: slice index out of range (gosec)
            "portState": stateFileContent[0],
                                         ^
    daemon/libnetwork/portallocator/osallocator_linux_test.go:358:13: G602: slice index out of range (gosec)
            if payload[0] != 0x1 {
                      ^
    daemon/libnetwork/portallocator/osallocator_linux_test.go:359:68: G602: slice index out of range (gosec)
                readCh <- fmt.Errorf("expected payload 0x1, but got %x", payload[0])
                                                                                ^
    daemon/logger/gelf/gelf_test.go:197:9: nilness: impossible condition: nil != nil (govet)
        if err != nil {
               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-12-16 16:55:20 +01:00
Sebastiaan van Stijn
1cce55d3a4 Merge pull request #51714 from jschfflr/45939-rw-layer-cleanup
layer: Clean up RW layer if mount metadata save fails
2025-12-16 15:01:54 +01:00
Paweł Gronowski
1489cb3ae0 Merge pull request #51722 from vvoland/modernize
Modernize Go code
2025-12-16 12:38:36 +00:00
Paweł Gronowski
5d716f20a3 Merge pull request #51721 from vvoland/deprecate-grpc
api: deprecate /grpc and /session endpoints
2025-12-16 12:34:55 +00: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
Rob Murray
25fbe6cd43 Merge pull request #51725 from robmry/max-api-1.53
Update client MaxAPIVersion to 1.53
2025-12-16 11:14:41 +00:00
Rob Murray
1e209e788b Continue to backfill empty PortBindings in API 1.53
- introduced by commit 0ca7ac3 ("daemon: backfill empty PBs
  slices for backward compat")

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-12-16 11:03:58 +00:00
Paweł Gronowski
51d1974500 daemon/cluster/test: Use t.Context()
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:56:34 +01:00
Paweł Gronowski
6c5233e109 modernize: Use strings.CutSuffix
Added in Go 1.20

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:56:34 +01:00
Paweł Gronowski
71fd582aa2 modernize: Use strings.Builder instead of string concatenation
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:56:34 +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
bce14ac5bc reflect: Use TypeFor instead of TypeOf
Added in Go 1.22

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:56:34 +01:00
Paweł Gronowski
3df05205f4 modernize: Use range int
Added in Go 1.22

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:56:34 +01:00
Paweł Gronowski
e548a31d28 modernize: Use min built-in
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:56:34 +01:00
Paweł Gronowski
39c19d9161 modernize: Use fmt.Appendf
Added in Go 1.19

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:56:33 +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
Paweł Gronowski
ff33808a79 modernize: Use strings.Cut instead of strings.Index where possible
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:56:33 +01:00
Paweł Gronowski
a25907b485 modernize: Prefer strings.SplitSeq instead of Split
Avoids extra allocations. Added in Go 1.24.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:56:33 +01:00
Paweł Gronowski
c9b0a21bb1 modernize: Use b.Loop (introduced in Go 1.24)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:56:33 +01:00
Rob Murray
239a49d403 Merge pull request #51711 from robmry/nri-config-reload
NRI: config reload
2025-12-15 17:51:27 +00:00
Paweł Gronowski
f44b5abf0e api: deprecate /grpc and /session endpoints
The /grpc and /session endpoints are now deprecated as the Engine has
been upgraded to properly support HTTP/2 and h2c requests, making these
specialized endpoints unnecessary.

These endpoints will be removed in the next major API version to
complete the cleanup.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 18:44:22 +01:00
Rob Murray
425f23995d Merge pull request #51712 from robmry/nri-error-on-unsupported-adjustment
NRI: error on unsupported adjustment
2025-12-15 16:21:31 +00:00
Paweł Gronowski
82c35087d0 Merge pull request #51717 from vvoland/c8d-errs-log
daemon/c8d: Log correct error extractOCIErrors
2025-12-15 16:12:37 +00:00
Paweł Gronowski
53c67be034 daemon/c8d: Log correct error extractOCIErrors
When logging an unmarshal failure in the registry error handling code,
the function was incorrectly logging the uninitialized `derrs` variable
instead of the actual JSON unmarshal error `jerr`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-15 15:56:44 +01:00
Rob Murray
98d196b714 NRI: error on unsupported adjustment
Also error on eviction requests.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-12-15 14:08:02 +00:00
Rob Murray
ff553c5069 NRI: make config reloadable
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-12-15 13:59:09 +00:00
Jan Scheffler
3fdde529e7 layer: Clean up init layer if initialization fails
Add cleanup for the init layer directory if any operation fails after
driver.CreateReadWrite() succeeds in initMount(). Previously, failures
in driver.Get(), initFunc(), or driver.Put() would leave an orphaned
overlay2 directory.

Related to moby/moby#45939

Signed-off-by: Jan Scheffler <jan.scheffler@qodev.ai>
2025-12-15 11:06:56 +00:00
Rob Murray
7c7a626e5d NRI: include in API Info response
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-12-15 10:36:05 +00:00
Rob Murray
f6b1488468 Bump API to v1.53
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-12-15 09:45:21 +00:00
Jan Scheffler
d7a6250b91 layer: Clean up RW layer if mount metadata save fails
Add cleanup for the RW layer directory if saveMount() fails after
driver.CreateReadWrite() succeeds. Previously, this failure path would
leave an orphaned overlay2 directory with no corresponding metadata.

Related to moby/moby#45939

Signed-off-by: Jan Scheffler <jan.scheffler@qodev.ai>
2025-12-12 23:03:08 +00:00
Rob Murray
0c01da8ccc Merge pull request #51675 from robmry/nri-mounts
NRI: allow plugins to add mounts
2025-12-12 18:37:29 +00:00
Rob Murray
a30301b28d NRI: allow plugins to add mounts
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-12-12 14:28:49 +00:00
Paweł Gronowski
0a0245a31a Merge pull request #51700 from jschfflr/45939-nil-check-tx-cleanup
layer: Fix orphan creation in registerWithDescriptor
2025-12-12 11:44:46 +00:00
Jan Scheffler
70004549fb layer: Fix orphan creation in registerWithDescriptor
Start the metadata transaction before creating the overlay2 directory.
This ensures that if driver.Create() fails, we can properly cancel the
transaction. Previously, if StartTransaction() failed after driver.Create()
succeeded, the defer cleanup would not run (not registered yet), leaving
an orphaned overlay2 directory.

The fix reorders operations so that:
1. Transaction is started first (no filesystem changes yet)
2. Overlay2 directory is created second (transaction ready for cleanup)
3. Defer is registered after both succeed (tx is guaranteed non-nil)

If driver.Create() fails, the transaction is explicitly cancelled before
returning. The nil check for tx in the defer is no longer needed since
tx is guaranteed to exist when the defer runs.

Related to moby/moby#45939

Signed-off-by: Jan Scheffler <jan.scheffler@qodev.ai>
2025-12-12 09:44:04 +00:00
Albin Kerouanton
3cba626582 Merge pull request #50744 from dmcgowan/add-grpc-support
Natively support gRPC on the docker socket
2025-12-12 10:25:15 +01:00
Paweł Gronowski
31184e608e Merge pull request #51692 from akerouanton/remove-dead-ctrs-on-startup
daemon: clean up dead containers on start
2025-12-11 20:45:23 +00:00
Albin Kerouanton
ec9315cd4f daemon: clean up dead containers on start
Stopping the Engine while a container with autoremove set is running may
leave behind dead containers on disk. These containers aren't reclaimed
on next start, appear as "dead" in `docker ps -a` and can't be
inspected or removed by the user.

This bug has existed since a long time but became user visible with
9f5f4f5a42. Prior to that commit,
containers with no rwlayer weren't added to the in-memory viewdb, so
they weren't visible in `docker ps -a`. However, some dangling files
would still live on disk (e.g. folder in /var/lib/docker/containers,
mount points, etc).

The underlying issue is that when the daemon stops, it tries to stop all
running containers and then closes the containerd client. This leaves a
small window of time where the Engine might receive 'task stop' events
from containerd, and trigger autoremove. If the containerd client is
closed in parallel, the Engine is unable to complete the removal,
leaving the container in 'dead' state. In such case, the Engine logs the
following error:

    cannot remove container "bcbc98b4f5c2b072eb3c4ca673fa1c222d2a8af00bf58eae0f37085b9724ea46": Canceled: grpc: the client connection is closing: context canceled

Solving the underlying issue would require complex changes to the
shutdown sequence. Moreover, the same issue could also happen if the
daemon crashes while it deletes a container. Thus, add a cleanup step
on daemon startup to remove these dead containers.

Signed-off-by: Albin Kerouanton <albin.kerouanton@docker.com>
2025-12-11 13:40:23 -06:00
Paweł Gronowski
849afcc5be daemon: use WithExtraDialOpts for containerd client connection
Replace WithDialOpts with WithExtraDialOpts when creating containerd
clients to preserve the containerd client's default dial options while
adding our custom options.

Previously, using WithDialOpts would overwrite all of containerd's
default dial options, requiring us to sync them.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-12-11 20:26:08 +01:00
Paweł Gronowski
5ce3964834 Merge pull request #51683 from thaJeztah/fix_nil_map
daemon: buildCreateEndpointOptions: fix panic with "publish all"
2025-12-11 14:19:34 +00:00
Sebastiaan van Stijn
2a191665b8 daemon/container: Container.BackfillEmptyPBs: prevent nil map
Make sure PortBindings is not a nil-map to match the behavior
we have when creating a container;
c64b781df2/daemon/internal/runconfig/config.go (L30-L47)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-12-11 12:09:32 +01:00
Albin Kerouanton
43780fe40c daemon: disallow container port 0
Signed-off-by: Albin Kerouanton <albin.kerouanton@docker.com>
2025-12-11 11:07:42 +01:00