Compare commits

...

978 Commits

Author SHA1 Message Date
Paweł Gronowski
265f709647 Merge pull request #50247 from vvoland/50245-28.x
[28.x backport] docs: cut api docs for v1.51
2025-06-20 16:22:35 +00:00
Paweł Gronowski
b2a9318a1e docs: cut api docs for v1.51
Used by the upcoming 28.3.0 release

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
(cherry picked from commit ef50844a0b)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-20 18:16:33 +02:00
Sebastiaan van Stijn
b3e2e22b2a Merge pull request #50244 from vvoland/50177-28.x
[28.x backport] gha: lower timeouts on "build" and "merge" steps
2025-06-20 17:37:41 +02:00
Sebastiaan van Stijn
c571cd8513 Merge pull request #50243 from vvoland/50238-28.x
[28.x backport] vendor: update buildkit to v0.23.1
2025-06-20 17:36:18 +02:00
Sebastiaan van Stijn
8c713c1af4 gha: lower timeouts on "build" and "merge" steps
We had some runs timeout after 120 minutes; expected duration is much
lower than that, so let's lower the timeout to make actions fail faster.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 0a30b98447)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-20 16:29:08 +02:00
Paweł Gronowski
539c115023 Merge pull request #50240 from thaJeztah/28.x_backport_validate_mirrors
[28.x backport] daemon/config: Validate: add missing validation for registry mirrors and improve errors
2025-06-20 14:16:09 +00:00
CrazyMax
8e7ea470cf vendor: update buildkit to v0.23.1
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
(cherry picked from commit 5a02e7f4e3)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-20 16:05:04 +02:00
Jonathan A. Sternberg
222baf4ccb vendor: github.com/moby/buildkit v0.23.0
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
(cherry picked from commit e43968d7ed)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-20 16:04:30 +02:00
Paweł Gronowski
1627e828d7 Merge pull request #50241 from thaJeztah/28.x_backport_update_cgroups
[28.x backport] vendor: github.com/opencontainers/cgroups v0.0.3
2025-06-20 14:00:46 +00:00
Paweł Gronowski
4070ebda88 Merge pull request #50242 from thaJeztah/28.x_backport_fix_event_ordering
[28.x backport] daemon: containerStop: fix ordering of "stop" and "die" events
2025-06-20 13:38:31 +00:00
Paweł Gronowski
b613ac489e Merge pull request #50239 from vvoland/50237-28.x
[28.x backport] Update containerd to v2.1.3
2025-06-20 11:36:57 +00:00
Sebastiaan van Stijn
0e0ca09ddc daemon: containerStop: fix ordering of "stop" and "die" events
Commit 8e6cd44ce4 added synchronisation to
wait for the container's status to be updated in memory. However, since
952902efbc, a defer was used to produce
the container's "stop" event.

As a result of the sychronisation that was added, the "die" event would
now be produced before the "stop" event.

This patch moves the locking inside the defer to restore the previous
behavior.

Unfortunately the order of events is still not guaranteed, because events
are emited from multiple goroutines that don't have synchronisation between
them; this is something to look at for follow ups. This patch keeps the status
quo and should preserve the old behavior, which was "more" correct in most
cases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 062082ec9b)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-20 13:29:19 +02:00
Sebastiaan van Stijn
e62b0e2234 vendor: github.com/opencontainers/cgroups v0.0.3
- ConvertCPUSharesToCgroupV2Value: improve
- Add .github/dependabot.yml
- Remove annotations from Resources (fixes a regression introduced in v0.0.2)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit a90da2edc3)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-20 13:26:46 +02:00
Sebastiaan van Stijn
06ab9cd1ed daemon/config: Validate: add missing validation for registry mirrors
Validation of registry mirrors was performed during daemon startup,
but after the config-file was validated. As a result, the `--validate`
option would incorrectly print that the configuration was valid, but
the daemon would fail to start;

    echo '{"registry-mirrors":["example.com"]}' > my-config.json
    dockerd --config-file ./my-config.json --validate
    configuration OK

    dockerd --config-file ./my-config.json
    # ...
    failed to start daemon: invalid mirror: no scheme specified for "example.com": must use either 'https://' or 'http://'

With this patch applied, validation is also performed as part of the
daemon config validation;

    echo '{"registry-mirrors":["example.com"]}' > my-config.json
    dockerd --config-file ./my-config.json --validate
    unable to configure the Docker daemon with file ./my-config.json: merged configuration validation from file and command line flags failed: invalid mirror: no scheme specified for "example.com": must use either 'https://' or 'http://'

    # fix the invalid config
    echo '{"registry-mirrors":["https://example.com"]}' > my-config.json
    dockerd --config-file ./my-config.json --validate
    configuration OK

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 1d8545d60c)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-20 13:20:27 +02:00
Sebastiaan van Stijn
97aa4e8550 registry: ValidateMirror: improve validation for missing schemes
Before this patch, a missing scheme would sometimes produce a confusing
error message. If no scheme was specified at all, an empty "" would be
included in the message;

    echo '{"registry-mirrors":["example.com"]}' > my-config.json
    dockerd --config-file ./my-config.json
    # ...
    failed to start daemon: invalid mirror: unsupported scheme "" in "example.com"

If a scheme was missing, but a port was included, the hostname would be
printed as the scheme;

    echo '{"registry-mirrors":["example.com:8080"]}' > my-config.json
    dockerd --config-file ./my-config.json
    # ...
    failed to start daemon: invalid mirror: unsupported scheme "example.com" in "example.com:8080"

With this patch applied, the error messages are slightly more user-friendly;

    echo '{"registry-mirrors":["example.com"]}' > my-config.json
    dockerd --config-file ./my-config.json
    # ...
    failed to start daemon: invalid mirror: no scheme specified for "example.com": must use either 'https://' or 'http://'

    echo '{"registry-mirrors":["example.com:8080"]}' > my-config.json
    dockerd --config-file ./my-config.json
    # ...
    failed to start daemon: invalid mirror: no scheme specified for "example.com:8080": must use either 'https://' or 'http://'

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 307c18598d)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-20 13:20:26 +02:00
Derek McGowan
e18a9c95b8 Update containerd to v2.1.3
Fixes various issues with pulling from registries

Signed-off-by: Derek McGowan <derek@mcg.dev>
(cherry picked from commit b466c35da1)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-20 11:28:31 +02:00
Sebastiaan van Stijn
b959bebdfc Merge pull request #50219 from thaJeztah/28.x_backport_deprecate_execconfig_detach
[28.x backport] api/types/container: deprecate ExecOptions.Detach
2025-06-18 23:03:00 +02:00
Sebastiaan van Stijn
02ade1a34c Merge pull request #50210 from thaJeztah/28.x_backport_pkg_idtools_deprecate
[28.x backport] pkg/idtools: deprecate IdentityMapping, Identity.Chown
2025-06-18 23:02:12 +02:00
Paweł Gronowski
106c4b0af6 Merge pull request #50211 from thaJeztah/28.x_backport_bump_swarmkit
[28.x backport] vendor: github.com/moby/swarmkit/v2 v2.0.0
2025-06-17 16:18:54 +00:00
Sebastiaan van Stijn
54d2eee6d6 Merge pull request #50217 from thaJeztah/28.x_backport_update-buildkit-v0.23.0-rc2
[28.x backport] vendor: update buildkit to v0.13.0-rc2
2025-06-17 15:10:47 +02:00
Sebastiaan van Stijn
09fef2b26e api/types/container: deprecate ExecOptions.Detach
This field was added in 5130fe5d38, which
added it for use as intermediate struct when parsing CLI flags (through
`runconfig.ParseExec`) in c786a8ee5e.

Commit 9d9dff3d0d rewrote the CLI to use
Cobra, and as part of this introduced a separate `execOptions` type in
`api/client/container`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit 0c182d4d57)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-17 13:10:50 +02:00
Tonis Tiigi
44c8cd2e8f vendor: update buildkit to v0.13.0-rc2
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
(cherry picked from commit 1289519b03)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-17 11:36:27 +02:00
Cory Snider
78b6204f9e vendor: github.com/moby/swarmkit/v2 v2.0.0
Use the tagged version instead of the v2.0.0-20250613170222-a45be3cac15c
pseudo-version. The referenced commit has not changed.

Signed-off-by: Cory Snider <csnider@mirantis.com>
(cherry picked from commit c3ac979ecf)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-17 11:23:57 +02:00
Cory Snider
cf98237186 vendor: github.com/moby/swarmkit/v2 v2.0.0-20250613170222-a45be3cac15c
- fix task scheduler infinite loop

full diff: 8c19597365...a45be3cac1

Signed-off-by: Cory Snider <csnider@mirantis.com>
(cherry picked from commit 2d60b8eacd)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-16 17:53:26 +02:00
Sebastiaan van Stijn
fd96b01b0e pkg/idtools: deprecate IdentityMapping, Identity.Chown
The IdentityMapping and Identity types are still used internally, but
should be considered transitional.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
(cherry picked from commit b7ef527bdc)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-16 17:40:11 +02:00
Paweł Gronowski
6a1fb46d48 Merge pull request #50169 from robmry/revert_overlay_refactoring
[28.x]: Revert overlay bug fixes / refactoring
2025-06-13 15:49:07 +00:00
Paweł Gronowski
9a9cade0df Merge pull request #50199 from vvoland/c8d-push-fixtag
c8d/push: Fix fallback single-manifest push not creating a tag
2025-06-13 13:42:50 +00:00
Paweł Gronowski
987b8a88a6 c8d/push: Extract shared push logic
Just a refactor of the previous commit to reduce duplication.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-13 14:51:18 +02:00
Sebastiaan van Stijn
e921abf618 Merge pull request #50198 from thaJeztah/bump_containerd
vendor: github.com/containerd/containerd/v2 v2.1.2
2025-06-13 14:39:07 +02:00
Paweł Gronowski
d9e7b86de4 c8d/push: Fix fallback single-manifest push not creating a tag
After pushing the multi-platform index fails due to missing content, we
retry with the single-platform manifest. While the target descriptor was
changed for the second push, the actual target digested reference still
pointed to the original multi-platform index. Obviously, with the
fallback that didn't really work correctly, because the multi-platform
index is not pushed.

This commit fixes the issue by updating the target reference to point to
the single-platform manifest.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-13 14:31:34 +02:00
Sebastiaan van Stijn
5dc1ccdfc8 Merge pull request #50136 from mabrarov/50133-container_stop_state_sync
fix: daemon: state of stopped container visible to other queries when container is stopped
2025-06-13 14:16:37 +02:00
Sebastiaan van Stijn
53d12c96f8 vendor: github.com/containerd/containerd/v2 v2.1.2
no significant changes other than error messages that now contain more
information

full diff: https://github.com/containerd/containerd/compare/v2.1.1...v2.1.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-13 13:50:48 +02:00
Paweł Gronowski
72145a8ad2 Merge pull request #50146 from vvoland/image-list-containers
api/image/list: Return `Containers` count
2025-06-13 11:34:38 +00:00
Rob Murray
f9e6f25677 Merge pull request #50196 from robmry/fix_TestDaemonRestartRestoreBridgeNetwork
Fix flaky test TestDaemonRestartRestoreBridgeNetwork
2025-06-13 12:21:19 +01:00
Sebastiaan van Stijn
9e985bd96f Merge pull request #50158 from mmorel-35/errorlint
fix errorlint linter
2025-06-13 12:38:38 +02:00
Rob Murray
aac0260d21 Fix flaky test TestDaemonRestartRestoreBridgeNetwork
It checked for "Bind for 0.0.0.0:80 failed: port is already
allocated". But, since commit d662091 ("portallocator: always
check for ports allocated for 0.0.0.0/::"), the message is
sometimes about ":::80".

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-13 10:53:22 +01:00
Paweł Gronowski
cfcbfabb0f api/image/list: Return Containers count
This parameter was already supported for some time in the backend (for
purposes related to docker system prune). It was also already present in
the imagetypes.ListOptions but was never actually handled by the client.

Make it available by default in the response.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-13 11:46:09 +02:00
Sebastiaan van Stijn
52a54d9ef6 Merge pull request #50176 from dmcgowan/handle-token-server-error-messages
Handle error message from token server with containerd backend
2025-06-13 10:40:33 +02:00
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
b65c31427c Merge pull request #50174 from jsternberg/buildkit-update
vendor: github.com/moby/buildkit v0.23.0-rc1
2025-06-12 18:55:04 +00:00
Rob Murray
5de6c1f6f3 Merge pull request #50189 from thaJeztah/fix_TestCopyFromContainerPathIsNotDir
integration-cli: TestCopyFromContainerPathIsNotDir: adjust for win 2025
2025-06-12 19:54:41 +01:00
Sebastiaan van Stijn
84f5e5351c Merge pull request #50145 from vvoland/api-151
api: bump to 1.51
2025-06-12 20:18:50 +02:00
Derek McGowan
941d09e265 Handle error message from token server with containerd backend
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-06-12 11:13:34 -07:00
Jonathan A. Sternberg
e4e7fcf668 vendor: github.com/moby/buildkit v0.23.0-rc1
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 19:08:16 +02:00
Sebastiaan van Stijn
a057f98a30 Merge pull request #50187 from thaJeztah/bump_buildkit_deps
vendor: update buildkit and containerd dependencies
2025-06-12 19:08:04 +02:00
Sebastiaan van Stijn
d3d20b9195 integration-cli: TestCopyFromContainerPathIsNotDir: adjust for win 2025
It looks like the error returned by Windows changed in Windows 2025; before
Windows 2025, this produced a `ERROR_INVALID_NAME`;

    The filename, directory name, or volume label syntax is incorrect.

But Windows 2025 produces a `ERROR_DIRECTORY` ("The directory name is invalid."):

    CreateFile \\\\?\\Volume{d9f06b05-0405-418b-b3e5-4fede64f3cdc}\\windows\\system32\\drivers\\etc\\hosts\\: The directory name is invalid.

Docs; https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 15:18:17 +02:00
Sebastiaan van Stijn
a3d2e72958 Merge pull request #50183 from thaJeztah/remove_v1_code
daemon/containerd remove leftover schema1 compatibility code
2025-06-12 14:50:38 +02:00
Sebastiaan van Stijn
cf86f3a082 vendor: github.com/containerd/nydus-snapshotter v0.15.2
full diff: https://github.com/containerd/nydus-snapshotter/compare/v0.15.0...v0.15.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 14:07:03 +02:00
Sebastiaan van Stijn
9a85f50aaa vendor: github.com/pelletier/go-toml/v2 v2.2.4
full diff: https://github.com/pelletier/go-toml/compare/v2.2.3...v2.2.4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 14:07:03 +02:00
Sebastiaan van Stijn
1764909076 vendor: github.com/fsnotify/fsnotify v1.9.0
full diff: https://github.com/fsnotify/fsnotify/compare/v1.7.0...v1.9.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 14:07:02 +02:00
Sebastiaan van Stijn
102adcab57 vendor: github.com/containerd/console v1.0.5
full diff: https://github.com/containerd/console/compare/v1.0.4...v1.0.5

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 14:07:02 +02:00
Sebastiaan van Stijn
5230692cad vendor: cloud.google.com/go/longrunning v0.5.5
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 14:05:28 +02:00
Sebastiaan van Stijn
5fb6604642 vendor: google.golang.org/api v0.160.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 14:03:05 +02:00
Paweł Gronowski
f2faca7de3 Merge pull request #50178 from thaJeztah/pull_clean
daemon/containerd: fix minor linting issue, and update link to error message
2025-06-12 11:49:37 +00:00
Paweł Gronowski
c430c9c7f2 Merge pull request #50115 from corhere/libn/fix-47859-networkdb-clusterleave-leak
libnetwork/networkdb: always shut down memberlist
2025-06-12 11:49:00 +00:00
Sebastiaan van Stijn
d2954c4e05 vendor: otel v1.35.0, otel/contrib v0.60.0, grpc v1.72.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 13:43:25 +02:00
Sebastiaan van Stijn
05f892190c vendor: github.com/prometheus/client_golang v1.22.0
full diff: https://github.com/prometheus/client_golang/compare/v1.20.5...v1.22.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 13:43:24 +02:00
Sebastiaan van Stijn
952cddd05b vendor: google.golang.org/protobuf v1.36.6
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 13:43:24 +02:00
Sebastiaan van Stijn
ccf5f8036c vendor: golang.org/x/sys v0.33.0
full diff: https:/github.com/golang/sys/compare/v0.32.0...v0.33.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 13:43:24 +02:00
Sebastiaan van Stijn
c81e03bc0b vendor: golang.org/x/sync v0.14.0
full diff: https://github.com/golang/sync/compare/v0.13.0...v0.14.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 13:43:24 +02: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
Sebastiaan van Stijn
05e8b1701c daemon/containerd remove leftover schema1 compatibility code
commit 7c09fa25fd and
e8c269843c removed support for schema1, but
we still enabled the schema1 conversion in containerd, causing the error
produced by dockerd to be shadowed by the error from containerd;

Before this patch, we would get an error from containerd;

    docker pull docker:1.0
    Error response from daemon: failed to get converter for "docker.io/library/docker:1.0": Pulling Schema 1 images have been deprecated and disabled by default since containerd v2.0. As a workaround you may set an environment variable `CONTAINERD_ENABLE_DEPRECATED_PULL_SCHEMA_1_IMAGE=1`, but this will be completely removed in containerd v2.1.

After enabling that env-var, it would return the error from dockerd;

    CONTAINERD_ENABLE_DEPRECATED_PULL_SCHEMA_1_IMAGE=1 dockerd --feature containerd-snapshotter

    docker pull docker:1.0
    Error response from daemon: Docker Image Format v1 and Docker Image manifest version 2, schema 1 support has been removed. Suggest the author of docker.io/library/docker:1.0 to upgrade the image to the OCI Format or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/

With this patch, we immediately return the error from dockerd;

    docker pull docker:1.0
    Error response from daemon: Docker Image Format v1 and Docker Image manifest version 2, schema 1 support has been removed. Suggest the author of docker.io/library/docker:1.0 to upgrade the image to the OCI Format or Docker Image manifest v2, schema 2. More information at https://docs.docker.com/go/deprecated-image-specs/

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 12:34:26 +02:00
Paweł Gronowski
5bbdb066d8 Merge pull request #50031 from vvoland/bbolt-1.4
vendor: go.etcd.io/bbolt v1.4.0
2025-06-12 10:09:09 +00:00
Sebastiaan van Stijn
2ff281e33a daemon/containerd: update link to containerd code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 11:36:08 +02:00
Sebastiaan van Stijn
d54f713d95 daemon/containerd: rename var that shadowed type
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 11:32:02 +02:00
Marat Abrarov
8e6cd44ce4 daemon: ensuring state of stopped container is visible to other queries when container is stopped and before API response is sent (fix for https://github.com/moby/moby/issues/50133).
Signed-off-by: Marat Abrarov <abrarov@gmail.com>
2025-06-11 18:08:33 +03:00
Sebastiaan van Stijn
3b1d2f746d Merge pull request #49952 from sgopinath1/49824-amd-gpu
Added support for AMD GPUs in "docker run --gpus".
2025-06-11 14:48:58 +02:00
Sebastiaan van Stijn
349a2d0050 Merge pull request #50143 from marie/validate-bind-dir
Validate BIND_DIR variable in Makefile
2025-06-11 14:11:45 +02:00
Rob Murray
7acb079403 Revert "libn/networkdb: don't exceed broadcast size limit"
This reverts commit dacf445614.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:49 +01:00
Rob Murray
0df31cf585 Revert "libn/networkdb: fix data race in GetTableByNetwork"
This reverts commit ec65f2d21b.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:48 +01:00
Rob Murray
83b2fc245d Revert "Fix possible overlapping IPs when ingressNA == nil"
This reverts commit 56ad941564.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:46 +01:00
Rob Murray
e079583ab4 Revert "libnetwork/networkdb: use correct index in GetTableByNetwork"
This reverts commit d5c370dee6.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:45 +01:00
Rob Murray
cfd5e5e4d4 Revert "libn/networkdb: b'cast watch events from local POV"
This reverts commit c68671d908.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:44 +01:00
Rob Murray
576cf73add Revert "libn/networkdb: record tombstones for all deletes"
This reverts commit ada8bc3695.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:43 +01:00
Rob Murray
2297ae3e64 Revert "libn/networkdb: Watch() without race conditions"
This reverts commit a3aea15257.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:41 +01:00
Rob Murray
cc60ec8d3c Revert "libn/networkdb: stop table events from racing network leaves"
This reverts commit 270a4d41dc.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:40 +01:00
Rob Murray
b5b349dbd6 Revert "libn/osl: drop unused AddNeighbor force parameter"
This reverts commit 3bdf99d127.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:39 +01:00
Rob Murray
35916f0869 Revert "libn/osl: refactor func (*Namespace) AddNeighbor"
This reverts commit b6d76eb572.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:38 +01:00
Rob Murray
3eb59ba5a2 Revert "libnetwork/osl: remove superfluous locks in Namespace"
This reverts commit 9866738736.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:37 +01:00
Rob Murray
5d6ae34753 Revert "libnetwork/osl: stop tracking neighbor entries"
This reverts commit 0d6e7cd983.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:36 +01:00
Rob Murray
ea818a7f6f Revert "libnetwork/internal/setmatrix: make keys generic"
This reverts commit 0317f773a6.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:33 +01:00
Rob Murray
78ccc20545 Revert "libn/d/overlay: use netip types more"
This reverts commit d188df0039.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-11 12:05:26 +01:00
Paweł Gronowski
86091394e9 Merge pull request #50164 from thaJeztah/fix_linting_nits
fix some linting issues
2025-06-11 10:46:15 +00:00
Rob Murray
6b9bd0a800 Merge pull request #50144 from thaJeztah/rm_import_aliases
all: remove redundant import-aliases for "go-winio"
2025-06-11 11:25:05 +01:00
Paweł Gronowski
d371ea117b Merge pull request #50156 from gagara/openrc-containerd-customization
openrc: allow customizing containerd service name
2025-06-11 09:24:11 +00:00
Paweł Gronowski
e84353ebbd Merge pull request #50135 from thaJeztah/inspect_no_omitempty
api: image inspect: add back fields that did not omitempty
2025-06-11 08:58:14 +00:00
Sebastiaan van Stijn
23c56099ee daemon/logger/loggerutils: use defer to fix gocritic "badlock" linter
daemon/logger/loggerutils/logfile.go:374:2: badLock: defer is missing, mutex is unlocked immediately (gocritic)
        w.rotateMu.Unlock()
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-10 13:54:56 +02:00
Sebastiaan van Stijn
0069360e3b volume/mounts: windowsDetectMountType: rewrite using switch
Mostly for readability, and to avoid linters suggesting to move the
default condition outside of the if/else.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-10 13:19:25 +02:00
Sebastiaan van Stijn
027355d7b3 container/stream: TestRaceUnbuffered: put unused testing.T to use
Some linters were complaining about the testing.T not being used; put
it to use to silence the linter.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-10 13:15:05 +02:00
Sebastiaan van Stijn
2bbf5f5a39 daemon/containerd: ImageService.resolveImage: cleanup resolve by name:tag
- scope variables locally to the if/else if
- use if/else if to try to make it more clear it's a "best effort" before
  falling through to other ways of resolving the image reference
- remove outdated TODO, now that containerd errdefs can be used for either
  moby, or containerd error definitions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-10 13:13:44 +02:00
Sebastiaan van Stijn
13879e7b49 Merge pull request #50082 from mmorel-35/go-critic
fix go-critic linter
2025-06-10 13:09:05 +02:00
Paweł Gronowski
729cbbd5c0 Merge pull request #49950 from dmcgowan/contributing-package-location
Add contributor guidelines for where to put source code in packages
2025-06-10 10:56:43 +00:00
Paweł Gronowski
52a8109a6b Merge pull request #50155 from robmry/windows_no_mirrored_plugin
Windows: don't try to load "mirrored" network plugin
2025-06-10 09:36:22 +00:00
Tianon Gravi
b2d4925e4a Merge pull request #50154 from robmry/dont_prune_windows_host_networks
Only "prune" Windows networks created by Docker
2025-06-09 15:28:51 -07:00
Paweł Gronowski
2e25775c83 libnetwork: Replace deprecated usages
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-09 19:30:00 +02:00
Paweł Gronowski
3dd8f03f25 vendor: go.etcd.io/bbolt v1.4.0
full diff: https://github.com/etcd-io/bbolt/compare/v1.3.11...v1.4.0

Changelog: https://github.com/etcd-io/bbolt/blob/main/CHANGELOG/CHANGELOG-1.4.md

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-09 19:29:58 +02:00
Rob Murray
55f47f9e34 Windows: don't try to load "mirrored" network plugin
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-09 11:38:13 +01:00
Matthieu MOREL
20b6075380 fix badCall from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-08 09:02:11 +02:00
Viacheslav Gagara
10c4715a62 openrc: allow customizing containerd service name
Signed-off-by: Viacheslav Gagara <viacheslavg@gmail.com>
2025-06-08 09:10:59 +03:00
Matthieu MOREL
c466ae0f71 fix badLock from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
19f5ac3c81 fix initClause from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
aa632664b6 fix mapKey from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
5ad4e4edf7 fix deprecatedComment from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
b8a4f6534f fix stringsCompare and stringConcatSimplify from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02: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
Matthieu MOREL
bc9ec5fc02 fix emptyStringTest from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
469afa5f8f fix httpNoBody from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:58 +02:00
Matthieu MOREL
8f7faa01d1 fix boolExprSimplify from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:58 +02:00
Matthieu MOREL
e5be7b54b1 fix yodaStyleExpr from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:58 +02:00
Matthieu MOREL
64075850fc fix go-critic linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:58 +02:00
Sebastiaan van Stijn
145834f278 Merge pull request #50153 from vvoland/update-go
update to go1.24.4
2025-06-07 07:37:53 +02:00
Rob Murray
793dd8385a Only "prune" Windows networks created by Docker
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-06 20:24:04 +01:00
Derek McGowan
071d27cd3d Add contributor guidelines for where to put source code in packages
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-06-06 11:31:04 -07:00
Paweł Gronowski
1603ad636e update to go1.24.4
- https://github.com/golang/go/issues?q=milestone%3AGo1.24.4+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.24.3...go1.24.4

This release includes 3 security fixes following the security policy:

- net/http: sensitive headers not cleared on cross-origin redirect

    Proxy-Authorization and Proxy-Authenticate headers persisted on cross-origin redirects potentially leaking sensitive information.

    Thanks to Takeshi Kaneko (GMO Cybersecurity by Ierae, Inc.) for reporting this issue.

    This is CVE-2025-4673 and Go issue https://go.dev/issue/73816.

- os: inconsistent handling of O_CREATE|O_EXCL on Unix and Windows

    os.OpenFile(path, os.O_CREATE|O_EXCL) behaved differently on Unix and Windows systems when the target path was a dangling symlink. On Unix systems, OpenFile with O_CREATE and O_EXCL flags never follows symlinks. On Windows, when the target path was a symlink to a nonexistent location, OpenFile would create a file in that location.

    OpenFile now always returns an error when the O_CREATE and O_EXCL flags are both set and the target path is a symlink.

    Thanks to Junyoung Park and Dong-uk Kim of KAIST Hacking Lab for discovering this issue.

    This is CVE-2025-0913 and Go issue https://go.dev/issue/73702.

- crypto/x509: usage of ExtKeyUsageAny disables policy validation

    Calling Verify with a VerifyOptions.KeyUsages that contains ExtKeyUsageAny unintentionally disabledpolicy validation. This only affected certificate chains which contain policy graphs, which are rather uncommon.

    Thanks to Krzysztof Skrzętnicki (@Tener) of Teleport for reporting this issue.

    This is CVE-2025-22874 and Go issue https://go.dev/issue/73612.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-06 19:35:32 +02:00
Sebastiaan van Stijn
2da78d4fcc Merge pull request #50022 from mmorel-35/thelper
fix thelper linter
2025-06-06 09:53:29 +02:00
Matthieu MOREL
9b5d8cd186 fix thelper linter
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-05 21:42:05 +00:00
Maria Glushenok
ea581c96b9 Validate BIND_DIR variable in Makefile
Signed-off-by: Maria Glushenok <glushenokm@gmail.com>
2025-06-05 20:43:41 +03:00
Sebastiaan van Stijn
59bdc72463 Merge pull request #50147 from robmry/inspect_overlay_enableipv4
Set EnableIPv4=true in overlay network inspect response
2025-06-05 19:08:48 +02:00
Sudheendra Gopinath
e32715ec03 Added support for AMD GPUs in "docker run --gpus".
Added backend code to support the exact same interface
used today for Nvidia GPUs, allowing customers to use
the same docker commands for both Nvidia and AMD GPUs.

Signed-off-by: Sudheendra Gopinath <sudheendra.gopinath@amd.com>

Reused common functions from nvidia_linux.go.

Removed duplicate code in amd_linux.go by reusing
the init() and countToDevices() functions in
nvidia_linux.go. AMD driver is registered in init().

Signed-off-by: Sudheendra Gopinath <sudheendra.gopinath@amd.com>

Renamed amd-container-runtime constant

Signed-off-by: Sudheendra Gopinath <sudheendra.gopinath@amd.com>

Removed empty branch to keep linter happy.

Also renamed amd_linux.go to gpu_amd_linux.go.

Signed-off-by: Sudheendra Gopinath <sudheendra.gopinath@amd.com>

Renamed nvidia_linux.go and gpu_amd_linux.go.

Signed-off-by: Sudheendra Gopinath <sudheendra.gopinath@amd.com>
2025-06-05 14:44:18 +00:00
Rob Murray
6bac5ca833 Set EnableIPv4=true in overlay network inspect response
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-05 15:27:32 +01:00
Paweł Gronowski
27f2e0ecc5 api: bump to 1.51
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-06-05 12:32:48 +02:00
Sebastiaan van Stijn
bd20bfdc41 all: remove redundant import-aliases for "go-winio"
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-05 12:11:30 +02:00
Sebastiaan van Stijn
acac1d84ce Merge pull request #50127 from thaJeztah/swagger_uint
api/swagger: quote maxUint64 example value
2025-06-05 11:59:20 +02:00
Akihiro Suda
c29de525b8 Merge pull request #50087 from vvoland/vendor-miekgdns
vendor: github.com/miekg/dns v1.1.66
2025-06-05 15:24:33 +09:00
Sebastiaan van Stijn
f85394dd5d api: image inspect: add back fields that did not omitempty
commit 4dc961d0e9 removed deprecated
fields from the image inspect response for API v1.50 and up. As
part of that change, it changed the type used for the Config field
to use the docker image spect structs, which embeds the OCI image
spec structs.

While the OCI image spect struct contains the same fields as we
used before, those fields also have "omitempty" set, which means
they are now omitted when empty.

We should probably consider deprecating that behavior in the API,
and call out that these fields are omitted if not set, but in the
meantime, we can add them back with their default (zero) value.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-04 18:01:19 +02:00
Rob Murray
9663b36b6d Merge pull request #50054 from robmry/fix_port_mapping
Avoid selecting duplicate host ports for mappings to 0.0.0.0 and specific addresses
2025-06-04 16:46:29 +01:00
Sebastiaan van Stijn
ee69d8ac95 Merge pull request #50051 from robmry/nftables_no_docker_user
nftables: don't create DOCKER-USER iptables chains
2025-06-03 13:19:12 +02:00
Sebastiaan van Stijn
e2b9f3d844 Merge pull request #50059 from shangmu/master
dockerd-rootless-setuptool.sh: Fix silent stop on error due to using output redirection together wit…
2025-06-03 12:05:03 +02:00
Paweł Gronowski
a8d3645957 Merge pull request #50128 from thaJeztah/bump_cli
Dockerfile: update cli to v28.2.2
2025-06-02 14:14:39 +00:00
Sebastiaan van Stijn
a9fabe7f0e Merge pull request #50124 from thaJeztah/resolvconf_table_test
libnetwork/resolvconf: Build: decorate error for invalid nameservers and use table-tests
2025-06-02 15:51:41 +02:00
Sebastiaan van Stijn
284904119a Dockerfile: update cli to v28.2.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-02 14:54:44 +02:00
Sebastiaan van Stijn
8ba832cc8f docs/api: swagger: quote maxUint64 example value
More recent versions of go-swagger failed on this, because the value
is interpolated as JSON numberic value, which assumes int64 (signed).

Quote the value to prevent it being handled before validated against
uint64.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-02 14:47:48 +02:00
Sebastiaan van Stijn
affe1d6335 api/swagger: quote maxUint64 example value
More recent versions of go-swagger failed on this, because the value
is interpolated as JSON numberic value, which assumes int64 (signed).

Quote the value to prevent it being handled before validated against
uint64.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-02 14:45:11 +02:00
Sebastiaan van Stijn
b6fa565cba libnetwork/resolvconf: Build: decorate error for invalid nameservers
Using the same prefix as is used in `Sandbox.loadResolvConf`, but omiting
the value, as it's already part of the error message;
829b695375/libnetwork/sandbox_dns_unix.go (L258-L261)

Unfortunately, `netip.ParseAddr` returns a non-exported (`parseAddrError`)
error-type; https://cs.opensource.google/go/go/+/refs/tags/go1.24.3:src/net/netip/netip.go;l=115

So we don't have the option to omit the `` from the error-message, and to
take the underlying `msg` field;
https://cs.opensource.google/go/go/+/refs/tags/go1.24.3:src/net/netip/netip.go;l=141-153

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-02 12:33:28 +02:00
Sebastiaan van Stijn
35e062dde1 libnetwork/resolvconf: rewrite TestBuild tests to a table-test
Also adding test-cases for;

- empty options for all fields
- invalid nameServer (domain instead of IP).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-02 12:20:19 +02:00
Akihiro Suda
829b695375 Merge pull request #50109 from vvoland/binimage-nosha
gha/bin-image: Don't push sha tags
2025-05-31 15:52:08 +09:00
Sebastiaan van Stijn
9649dc8134 Merge pull request #50110 from thaJeztah/remove_import_comments
all: remove // import comments
2025-05-30 20:35:54 +02:00
Cory Snider
16ed51d864 libnetwork/networkdb: always shut down memberlist
Gracefully leaving the memberlist cluster is a best-effort operation.
Failing to successfully broadcast the leave message to a peer should not
prevent NetworkDB from cleaning up the memberlist instance on close. But
that was not the case in practice. Log the error returned from
(*memberlist.Memberlist).Leave instead of returning it and proceed with
shutting down irrespective of whether Leave() returns an error.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-30 13:56:47 -04:00
Sebastiaan van Stijn
c1a27ea5af pkg/stack: 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:22 +02:00
Sebastiaan van Stijn
dd382769bd pkg/rootless: 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:22 +02:00
Sebastiaan van Stijn
ce191648c7 pkg/useragent: 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:21 +02:00
Sebastiaan van Stijn
ad1a388895 pkg/tailfile: 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:21 +02:00
Sebastiaan van Stijn
b6f99f6d7f pkg/stringid: 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:21 +02:00
Sebastiaan van Stijn
ca2cca1286 pkg/stdcopy: 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:21 +02:00
Sebastiaan van Stijn
225b7ca6b7 pkg/progress: 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:21 +02:00
Sebastiaan van Stijn
0f9818ad03 pkg/pools: 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:20 +02:00
Sebastiaan van Stijn
f0f4fa0038 pkg/plugingetter: 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:20 +02:00
Sebastiaan van Stijn
5f4da92972 pkg/platform: 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:20 +02:00
Sebastiaan van Stijn
7a703f3772 pkg/pidfile: 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:20 +02:00
Sebastiaan van Stijn
511cf09e75 pkg/namesgenerator: 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:19 +02:00
Sebastiaan van Stijn
864e3f9348 pkg/longpath: 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:19 +02:00
Sebastiaan van Stijn
cc329af619 pkg/jsonmessage: 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:19 +02:00
Sebastiaan van Stijn
0c70c762b2 pkg/streamformatter: 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:19 +02:00
Sebastiaan van Stijn
fd8b6a24ab pkg/tarsum: 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:19 +02:00
Sebastiaan van Stijn
17845556f2 pkg/system: 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:19 +02:00
Sebastiaan van Stijn
18a1b61b49 pkg/sysinfo: 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:18 +02:00
Sebastiaan van Stijn
126246ae39 pkg/plugins: 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:18 +02:00
Sebastiaan van Stijn
0380c952a6 pkg/parsers: 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:18 +02:00
Sebastiaan van Stijn
4800a9b50d pkg/ioutils: 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:18 +02:00
Sebastiaan van Stijn
ca3982adea pkg/homedir: 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:17 +02:00
Sebastiaan van Stijn
c93f18e0b8 pkg/fileutils: 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:17 +02:00
Sebastiaan van Stijn
6a9f7c543c pkg/authorization: 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:17 +02:00
Sebastiaan van Stijn
a4411f497f errdefs: 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:17 +02:00
Sebastiaan van Stijn
0ea03c4add opts: 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:16 +02:00
Sebastiaan van Stijn
7ce4e9685a oci: 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:16 +02:00
Sebastiaan van Stijn
23009a700a testutil: 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:16 +02:00
Sebastiaan van Stijn
fe1bc3e7fd runconfig: 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:16 +02:00
Sebastiaan van Stijn
4656712b82 restartmanager: 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:15 +02:00
Sebastiaan van Stijn
134f20c828 reference: 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:15 +02:00
Sebastiaan van Stijn
97b20f6b79 registry: 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:15 +02:00
Sebastiaan van Stijn
2548254317 quota: 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:15 +02:00
Sebastiaan van Stijn
66055ea07c plugin: 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:15 +02:00
Sebastiaan van Stijn
3bbb38f1d2 volume: 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:14 +02:00
Sebastiaan van Stijn
021dd75bc4 libcontainerd: 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:14 +02:00
Sebastiaan van Stijn
fe34e89992 layer: 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:14 +02:00
Sebastiaan van Stijn
9abf9f2d0d internal: 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:14 +02:00
Sebastiaan van Stijn
4970333621 integration: 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:14 +02:00
Sebastiaan van Stijn
a4b0d32fa6 integration-cli: 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
Sebastiaan van Stijn
7eecd04c7b image: 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
Sebastiaan van Stijn
c1a3c51d9e dockerversion: 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
Sebastiaan van Stijn
c7cb2d9783 distribution: 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
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
Sebastiaan van Stijn
076e98e8f3 daemon/links, daemon/network: 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:12 +02:00
Sebastiaan van Stijn
2b42088bd5 daemon/listeners: 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:12 +02:00
Sebastiaan van Stijn
241e0bca8b daemon/events: 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:12 +02:00
Sebastiaan van Stijn
27956106d5 daemon/config: 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:12 +02:00
Sebastiaan van Stijn
69c34390c0 daemon/logger: 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:12 +02:00
Sebastiaan van Stijn
7d4caf4ba8 daemon/images: 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:12 +02:00
Sebastiaan van Stijn
9876c9fbcf daemon/graphdriver: 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
Sebastiaan van Stijn
986ec3f877 daemon/cluster: 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
Sebastiaan van Stijn
89aa33001e container: 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
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
Sebastiaan van Stijn
c6bbc3bb6e builder: 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
Sebastiaan van Stijn
4856e8ffad client: 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:10 +02:00
Sebastiaan van Stijn
bf9d739561 api: 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:01 +02:00
Sebastiaan van Stijn
cee6f64ac7 Merge pull request #50112 from thaJeztah/libnet_overlayutils_overflow
libnet/d/overlay/overlayutils: prevent uint32 overflow
2025-05-30 15:56:00 +02:00
Sebastiaan van Stijn
f1f9950e4a Merge pull request #50111 from thaJeztah/fluentd_overflow
daemon/logger/fluentd: cap max-retries to MaxInt32
2025-05-30 15:55:32 +02:00
Sebastiaan van Stijn
fca97dae9d libnet/d/overlay/overlayutils: prevent uint32 overflow
CodeQL was complaining about the conversion to uint32

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-30 14:00:14 +02:00
Sebastiaan van Stijn
3d8195a20f daemon/logger/fluentd: cap max-retries to MaxInt32
CodeQL was warning about a potential overflow; the default value
was set to MaxInt32 in 13086f387b,
which documented that higher values caused problems, so cap it
to that value as maximum.

45873be4ae/daemon/logger/fluentd/fluentd.go (L45-L47)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-30 13:50:55 +02:00
Paweł Gronowski
404f29c42d gha/bin-image: Don't push sha tags
This change eliminates the automatic creation of image tags in the
format `moby/moby-bin:sha-ad132f5` for every push.

They're not too useful, produce noise and use a lot of space.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-30 11:43:05 +02:00
Paweł Gronowski
45873be4ae Merge pull request #50105 from jsternberg/revert-build-dangling
Revert "containerd: images overridden by a build are kept dangling"
2025-05-30 08:53:59 +00: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
Cory Snider
f144264bae Merge pull request #50090 from corhere/libn/overlay-netip
libnetwork/d/overlay: use netip types more
2025-05-29 14:12:28 -04:00
Rob Murray
a2652d4b81 Don't set up iptables chain DOCKER-USER when using nftables
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-29 19:12:23 +01:00
Rob Murray
768cfaeb62 Merge pull request #50050 from robmry/nftables_internal_dns
nftables: rules for the internal DNS resolver
2025-05-29 19:11:27 +01:00
Rob Murray
d3289dda4b Add nftables NAT rules for internal DNS resolver
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-29 17:20:25 +01:00
Sebastiaan van Stijn
7a0bf747f5 Merge pull request #50038 from ctalledo/fix-for-50037
Update worker.Platforms() in builder-next worker.
2025-05-29 16:09:38 +02:00
Rob Murray
b43afbf898 Merge pull request #50098 from robmry/remove_docker-user_return_rule
iptables: Drop explicit RETURN rule from DOCKER-USER
2025-05-29 11:27:54 +01:00
Cesar Talledo
c299ba3b38 Update worker.Platforms() in builder-next worker.
Use platform MatchComparer when checking for matching platforms.

Also, add unit test to ensure the merging of defined and host-supported
platforms works correctly.

Signed-off-by: Cesar Talledo <cesar.talledo@docker.com>
2025-05-28 14:47:59 -07:00
Shang Mu
6889039d76 Fix silent stop on error due to using output redirection together with set -eu.
Signed-off-by: Shang Mu <smu@princeton.edu>
2025-05-28 13:23:52 -04:00
Rob Murray
d6620915db portallocator: always check for ports allocated for 0.0.0.0/::
We set SO_REUSEADDR on sockets used for host port mappings by
docker-proxy - which means it's possible to bind the same port
on a specific address as well as 0.0.0.0/::.

For TCP sockets, an error is raised when listen() is called on
both sockets - and the port allocator will be called again to
avoid the clash (if the port was allocated from a range, otherwise
the container will just fail to start).

But, for UDP sockets, there's no listen() - so take more care
to avoid the clash in the portallocator.

The port allocator keeps a set of allocated ports for each of
the host IP addresses it's seen, including 0.0.0.0/::. So, if a
mapping to 0.0.0.0/:: is requested, find a port that's free in
the range for each of the known IP addresses (but still only
mark it as allocated against 0.0.0.0/::). And, if a port is
requested for specific host addresses, make sure it's also
free in the corresponding 0.0.0.0/:: set (but only mark it as
allocated against the specific addresses - because the same
port can be allocated against a different specific address).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-28 14:00:33 +01:00
Paweł Gronowski
0e2cc22d36 Merge pull request #50049 from robmry/nftables_env_var_enable
nftables: enable using env var
2025-05-28 12:58:21 +00:00
Paweł Gronowski
e37efd4c2d Merge pull request #50068 from mmorel-35/github.com/containerd/errdefs
refactor: replace uses of errdefs package
2025-05-28 12:57:15 +00:00
Rob Murray
1d6b471ce2 Merge pull request #50092 from thaJeztah/bump_dev_cli
Dockerfile: update cli to v28.2.0-rc.2
2025-05-28 13:42:07 +01:00
Paweł Gronowski
5cc94a552d Merge pull request #50094 from thaJeztah/rm_non_compliant_registry_fallback
remove fallback for non-OCI-compliant docker.pkg.github.com registry
2025-05-28 12:10:12 +00:00
Paweł Gronowski
8330a083d5 Merge pull request #50097 from vvoland/seccomp-lsm
seccomp: Require CAP_SYS_ADMIN for lsm_* syscalls
2025-05-28 12:05:57 +00: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
Paweł Gronowski
bc6bc7aafa daemon/cdi: Log not found dirs as INFO
Avoid logging warnings when default CDI directory does not exist:
```
WARN[2025-05-26T14:27:54.008196418Z] CDI setup error /var/run/cdi: failed to monitor for changes: no such file or directory
WARN[2025-05-26T14:27:54.008209168Z] CDI setup error /etc/cdi: failed to monitor for changes: no such file or directory
```

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-28 13:31:42 +02:00
Paweł Gronowski
9856bf52a2 daemon: Configure default CDI cache
And share it with BuildKit

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-28 13:31:40 +02:00
Rob Murray
ae2fc2ddd1 PortAllocator: Use netip.Addr instead of string as map key
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-28 11:38:59 +01:00
Rob Murray
19dc38f79b Listen on mapped host ports before mapping more ports
Because we set SO_REUSEADDR on sockets for host ports, if there
are port mappings for INADDR_ANY (the default) as well as for
specific host ports - bind() cannot be used to detect clashes.

That means, for example, on daemon startup, if the port allocator
returns the first port in its ephemeral range for a specific host
adddress, and the next port mapping is for 0.0.0.0 - the same port
is returned and both bind() calls succeed. Then, the container
fails to start later when listen() spots the problem and it's too
late to find another port.

So, bind and listen to each set of ports as they're allocated
instead of just binding.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-28 11:38:59 +01:00
Rob Murray
dc519a0f18 iptables: Drop explicit RETURN rule from DOCKER-USER
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-28 11:11:56 +01:00
Paweł Gronowski
148a19b6d6 seccomp: Require CAP_SYS_ADMIN for lsm_* syscalls
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-28 11:47:08 +02:00
Paweł Gronowski
0ab8108b57 seccomp: Fix typo in lsm_set_self_attr
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-28 11:23:56 +02:00
Rob Murray
21a165de23 Use env-var DOCKER_FIREWALL_BACKEND=nftables to enable nftables
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-28 09:57:26 +01:00
Matthieu MOREL
637e8142ce clean up golangci-lint config for deprectated errdefs.*
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:42:45 +00:00
Matthieu MOREL
37caf3881a volume: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:41:53 +00:00
Matthieu MOREL
08768e4d9d testutil: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:41:39 +00:00
Matthieu MOREL
416dc8c1bf runconfig: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:41:24 +00:00
Matthieu MOREL
8803b58259 refernce: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:41:10 +00:00
Matthieu MOREL
dcf253ffe2 plugin: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:40:55 +00:00
Matthieu MOREL
8561016335 libnetwork: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:40:38 +00:00
Matthieu MOREL
f06c450a8e libcontainerd: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:40:24 +00:00
Matthieu MOREL
528f2284ee integration-cli: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:40:06 +00:00
Matthieu MOREL
14852fcd82 integration: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:39:50 +00:00
Matthieu MOREL
a1a789dbd0 image: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:39:34 +00:00
Matthieu MOREL
6ee53a6831 errdefs: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:39:19 +00:00
Matthieu MOREL
083ccfa486 distribution: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:39:02 +00: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
364d8d8b31 container: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:38:15 +00:00
Matthieu MOREL
415fc7b41e builder: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:37:58 +00:00
Matthieu MOREL
f0eaf228c1 api: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:37:31 +00:00
Sebastiaan van Stijn
f98b7005d2 remove fallback for non-OCI-compliant docker.pkg.github.com registry
The legacy `docker.pkg.github.com` registry provided by GitHub was not
OCI compliant, and did not suport pull by digest (among others). Commit
495d623ae5 added fallback code to detect
"not found" errors when pulling by digest, in which case we would fall
back to pulling by `name:tag`.

GitHub deprecated the legacy registry, and it was [sunset on Feb 24th, 2025][1]
in favor of GitHub Container Registry (GHCR) (ghcr.io).

This reverts commit 495d623ae5, removing the
fallback logic.

[1]: https://github.blog/changelog/2025-01-23-legacy-docker-registry-closing-down/

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-27 23:34:37 +02:00
Sebastiaan van Stijn
048199f191 Dockerfile: update cli to v28.2.0-rc.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-27 22:54:09 +02:00
Sebastiaan van Stijn
5d7550e9ef Merge pull request #50048 from robmry/nftables_integ_tests
nftables: integration test updates
2025-05-27 21:49:59 +02:00
Cory Snider
d188df0039 libn/d/overlay: use netip types more
The netip types are really useful for tracking state in the overlay
driver as they are hashable, unlike net.IP and friends, making them
directly useable as map keys. Converting between netip and net types is
fairly trivial, but fewer conversions is more ergonomic.

The NetworkDB entries for the overlay peer table encode the IP addresses
as strings. We need to parse them to some representation before
processing them further. Parse directly into netip types and pass those
values around to cut down on the number of conversions needed.

The peerDB needs to marshal the keys and entries to structs of hashable
values to be able to insert them into the SetMatrix. Use netip.Addr in
peerEntry so that peerEntry values can be directly inserted into the
SetMatrix without conversions. Use a hashable struct type as the
SetMatrix key to avoid having to marshal the whole struct to a string
and parse it back out.

Use netip.Addr as the map key for the driver's encryption map so the
values do not need to be converted to and from strings. Change the
encryption configuration methods to take netip types so the peerDB code
can pass netip values directly.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-27 13:47:11 -04:00
Cory Snider
0317f773a6 libnetwork/internal/setmatrix: make keys generic
Make the SetMatrix key's type generic so that e.g. netip.Addr values can
be used as matrix keys.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-27 13:29:41 -04:00
Rob Murray
7ea613d780 Merge pull request #50088 from corhere/libn/stateless-neighbor
libnetwork/osl: stop tracking neighbor entries
2025-05-27 18:01:22 +01:00
Rob Murray
e48ea1c6e0 Make integration tests ready for nftables
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-27 17:50:03 +01:00
Rob Murray
f9f0db0789 Add nftables support to testutil SetFilterForwardPolicies
Because nftables tables/chain aren't fixed, like they are
in iptables - this change makes an assumption about the
bridge driver's naming.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-27 17:50:03 +01:00
Rob Murray
7ea0e60dde Skip test TestBridgeINCRouted in rootless mode
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-27 17:50:03 +01:00
Cory Snider
0d6e7cd983 libnetwork/osl: stop tracking neighbor entries
The Namespace keeps some state for each inserted neighbor-table entry
which is used to delete the entry (and any related entries) given only
the IP and MAC address of the entry to delete. This state is not
strictly required as the retained data is a pure function of the
parameters passed to AddNeighbor(), and the kernel can inform us whether
an attempt to add a neighbor entry would conflict with an existing
entry. Get rid of the neighbor state in Namespace. It's just one more
piece of state that can cause lots of grief if it falls out of sync with
ground truth. Require callers to call DeleteNeighbor() with the same
aguments as they had passed to AddNeighbor(). Push the responsibility
for detecting attempts to insert conflicting entries into the neighbor
table onto the kernel by using (*netlink.Handle).NeighAdd() instead of
NeighSet().

Modernize the error messages and logging in DeleteNeighbor() and
AddNeighbor().

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-27 11:46:21 -04:00
Cory Snider
9866738736 libnetwork/osl: remove superfluous locks in Namespace
The isDefault and nlHandle fields are immutable once the Namespace is
constructed.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-27 11:46:13 -04:00
Cory Snider
b6d76eb572 libn/osl: refactor func (*Namespace) AddNeighbor
Scope local variables as narrowly as possible.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-27 11:30:30 -04:00
Cory Snider
3bdf99d127 libn/osl: drop unused AddNeighbor force parameter
func (*Namespace) AddNeighbor is only ever called with the force
parameter set to false. Remove the parameter and eliminate dead code.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-27 11:30:30 -04:00
Paweł Gronowski
f834a0bd82 vendor: github.com/miekg/dns v1.1.66
full diff: https://github.com/miekg/dns/compare/v1.1.61...v1.1.66

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-27 15:09:09 +02:00
Paweł Gronowski
458e69fc2e Merge pull request #49896 from vvoland/ai-models-pull
run/pull: Warn/reject AI model images
2025-05-27 12:18:59 +00:00
Paweł Gronowski
67535a4454 Merge pull request #50084 from thaJeztah/q_ctr_c_let_me_out_of_here_wq_wq_wq
Dockerfile: install nano as alternative to vim
2025-05-27 11:11:17 +00:00
Paweł Gronowski
034298520b Merge pull request #50080 from corhere/libn/joinleavestartmu
libnetwork: don't reinvent mutexes
2025-05-27 10:11:28 +00:00
Paweł Gronowski
4da3b4bf2d run/pull: Warn/reject AI model images
Add checks in both containerd-based and distribution-based image pull
code paths to detect and AI model images early in the pull process.

These are not yet supported directly by the Engine and need to be
handled by the `docker model` CLI plugin.

For distribution-based pull, reject the AI models pulls.

For containerd image service only emit a warning.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-27 12:02:21 +02:00
Paweł Gronowski
f5f3be4f9a Merge pull request #49957 from thaJeztah/bind_dir_auto
Makefile: set BIND_DIR to "." by default
2025-05-27 09:04:51 +00:00
Paweł Gronowski
da92a28a53 Merge pull request #50079 from thaJeztah/bump_dockerfile_tools
Dockerfile: bump buildx v0.24.0, compose v2.36.2
2025-05-27 08:59:44 +00:00
Sebastiaan van Stijn
339be4e2ae Dockerfile: install nano as alternative to vim
I'm horrible at vim, and use nano as my go-to editor for quick changes.
Let's install nano in the dev-container as alternative to vim for those
like me, who are not so vim-savvy ^O^C^C:wq:

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-27 10:29:19 +02:00
Sebastiaan van Stijn
26db31fdab Merge pull request #50069 from vvoland/cut-api
docs/api: Cut docs for API v1.50
2025-05-26 21:57:45 +02:00
Paweł Gronowski
588a05a1ce docs/api: Cut docs for API v1.50
Used by the upcoming v28.2.0 release.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-26 19:37:21 +02:00
Cory Snider
94daa36f03 libnetwork: don't reinvent mutexes
The (*Sandbox).joinLeaveStart() and .joinLeaveEnd() methods implement an
exclusive lock which is almost functionally identical to
(*sync.Mutex).Lock() and .Unlock(), respectively. The only notable
differences are that joinLeaveStart allocates, and calling
joinLeaveEnd() more times than joinLeaveStart() is a silent no-op
instead of a fatal error.

The construction of the joinLeaveStart/End methods is shaped like a
condition variable which uses channels for waiting and broadcasting.
The condition being waited for is that the joinLeaveDone struct field is
nil, i.e. that the lock has not been acquired by another goroutine.
As the condition is being checked and set while in a critical section,
it is a mutex implemented in terms of mutexes and channels. Replace the
home-grown mutex with a plain sync.Mutex.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-26 13:21:20 -04:00
Sebastiaan van Stijn
a9649e7a5d Merge pull request #49982 from vvoland/c8d-image-remove-platform
c8d/delete: Add support for deleting specific platforms
2025-05-26 18:47:34 +02:00
Sebastiaan van Stijn
cd2702e04e Dockerfile: update compose to v2.36.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-26 18:37:39 +02:00
Sebastiaan van Stijn
01fec904e4 Dockerfile: update buildx to v0.24.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-26 18:35:26 +02:00
Paweł Gronowski
d0ad1357a1 Merge pull request #48457 from thaJeztah/api_remove_deprecated_fields
image-inspect: remove Config fields that are not part of the image
2025-05-26 16:04:57 +00:00
Paweł Gronowski
072483f9d7 c8d/delete: Require --force when deleting platforms
When deleting specific platforms from a multi-platform image, there's
potential risk as platform-specific content might be shared across
images/containers.

For now, require `force` parameter to make the user aware.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-26 17:43:10 +02:00
Paweł Gronowski
30da69d694 c8d/delete: Support deleting specific platforms
This change adds the ability to delete a specific platform from a
multi-platform image.

Previously, image deletion was an all-or-nothing operation - when
deleting a multi-platform image, all platforms would be removed
together. This change allows users to selectively remove individual
platforms from a multi-architecture image while keeping other platforms
intact.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-26 17:43:10 +02:00
Paweł Gronowski
acf6b6542e daemon/images: Make ImageDelete take opts struct
Pass whole `RemoveOptions` struct instead of individual `force` and
`prune` parameters.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-26 17:43:09 +02:00
Paweł Gronowski
871675be9b c8d/delete: Extract untagReferences
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-26 17:43:08 +02:00
Paweł Gronowski
153b16ad27 c8d: Extract memoryLabelStore
Move to an internal testutils package

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-26 17:43:07 +02:00
Paweł Gronowski
536b35299b Merge pull request #50077 from vvoland/update-syscalls
profile/seccomp: Update to kernel v6.13 (libseccomp v2.6.0, containerd)
2025-05-26 15:17:58 +00:00
Paweł Gronowski
d15f59243a Merge pull request #50074 from thaJeztah/update_systemd_units
contrib: systemd: update deprecated StartLimit options
2025-05-26 15:15:54 +00:00
Sebastiaan van Stijn
d7cca3f997 docs/api: update deprecation version for erroneous fields
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-26 17:14:44 +02:00
Sebastiaan van Stijn
4dc961d0e9 image-inspect: remove Config fields that are not part of the image
commit af0cdc36c7 marked these fields as
deprecated and to be removed in API v1.47 (which was targeted for v28.0).
We shipped v1.47 with the v27.2 release, but did not yet remove the erroneous
fields, so the version to deprecate was updated to v1.48 through
3df03d8e66

This patch removes fields that are not part of the image by replacing the
type with the Config struct from the docker image-spec.

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.50/images/alpine/json | jq .Config
    {
      "Env": [
        "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
      ],
      "Cmd": [
        "/bin/sh"
      ]
    }

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.49/images/alpine/json | jq .Config
    {
      "Hostname": "",
      "Domainname": "",
      "User": "",
      "AttachStdin": false,
      "AttachStdout": false,
      "AttachStderr": false,
      "Tty": false,
      "OpenStdin": false,
      "StdinOnce": false,
      "Env": [
        "PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
      ],
      "Cmd": [
        "/bin/sh"
      ],
      "Image": "",
      "Volumes": null,
      "WorkingDir": "",
      "Entrypoint": null,
      "OnBuild": null,
      "Labels": null
    }

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-26 17:14:37 +02:00
Paweł Gronowski
0ec3278d48 profiles/seccomp: kernel v6.13
reference: seccomp/libseccomp@42b5968 (libseccomp v2.6.0)
           containerd/containerd@1a4c3210

- v6.13:
  * getxattrat, listxattrat, removexattrat, setxattrat (torvalds/linux@6140be9)

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-26 15:45:09 +02:00
Paweł Gronowski
6aa8288cfb profiles/seccomp: kernel v6.12
reference: seccomp/libseccomp@f01e675 (libseccomp v2.6.0)
           containerd/containerd@6180d62

- v6.8:
  * listmount (torvalds/linux@b4c2bea)
  * lsm_get_self_attr, lsm_set_self_attrs (torvalds/linux@a04a119)
  * lsm_list_modules (torvalds/linux@ad4aff9)
  * statmount (torvalds/linux@46eae99)

- v6.9:
  * mseal (torvalds/linux@8be7258)

- v6.11:
  * uretprobe (torvalds/linux@190fec7)

- v6.12:
  * riscv_hwprobe (torvalds/linux@3db80c9)

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-26 15:45:03 +02:00
Sebastiaan van Stijn
b1c0bfa225 Merge pull request #50076 from thaJeztah/createCDICache_fix_err_capitalization
daemon: createCDICache: fix error-capitalization
2025-05-26 15:28:59 +02:00
Sebastiaan van Stijn
e03ac1fad9 daemon: createCDICache: fix error-capitalization
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-26 14:44:15 +02:00
Sebastiaan van Stijn
a5a3a74a79 Merge pull request #50064 from thaJeztah/registry_errdefs
registry: replace uses of errdefs package
2025-05-26 14:40:09 +02:00
Sebastiaan van Stijn
7263ae74cd contrib: systemd: update deprecated StartLimit options
These were originally added in 7b9ecb9700.

The `StartLimitBurst` and `StartLimitInterval` options used to be
options for `[Service]`, but were moved to the `[Unit]` in systemd 229,
and systemd 230 respectively. The `StartLimitInterval` was renamed to
`StartLimitIntervalSec`, which either takes a number (using "seconds" as
default unit) or an optional unit;

- 6bf0f408e4
- f0367da7d1

We kept these deprecated options to provide compatibility with older distros
that not yet had systemd 230, but all distros we support are now on versions
of systemd that support the new options;

    docker run --rm registry.access.redhat.com/ubi8/ubi systemctl --version
    systemd 239 (239-82.el8_10.5)
    +PAM +AUDIT +SELINUX +IMA -APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=legacy

    docker run -it --rm debian:
    apt-get update && apt-get install -y systemd
    ...
    systemctl --version
    systemd 247 (247.3-7+deb11u6)
    +PAM +AUDIT +SELINUX +IMA +APPARMOR +SMACK +SYSVINIT +UTMP +LIBCRYPTSETUP +GCRYPT +GNUTLS +ACL +XZ +LZ4 +ZSTD +SECCOMP +BLKID +ELFUTILS +KMOD +IDN2 -IDN +PCRE2 default-hierarchy=unified

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-26 13:49:57 +02:00
Akihiro Suda
158c04fac8 Merge pull request #50070 from thaJeztah/bump_cgroups
vendor: github.com/opencontainers/cgroups v0.0.2
2025-05-26 19:52:30 +09:00
Sebastiaan van Stijn
6021139a9f Merge pull request #50055 from thaJeztah/fix_fluent_migration
daemon: restore: fix fluentd-async-connect migration for downgrades
2025-05-26 12:14:07 +02:00
Sebastiaan van Stijn
888cbfddf2 vendor: github.com/opencontainers/cgroups v0.0.2
- Mark some fields with `omitempty` JSON attribute.
- Modernize code by using new Go features.
- systemd: write rounded CPU quota to cgroupfs.

full diff: https://github.com/opencontainers/cgroups/compare/v0.0.1...v0.0.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-26 11:30:39 +02:00
Sebastiaan van Stijn
42970fc461 registry: replace uses of errdefs package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-24 13:14:08 +02:00
Akihiro Suda
926a4dd23c Merge pull request #50041 from thaJeztah/bump_containerd_api_1.9
vendor: github.com/containerd/containerd/api v1.9.0
2025-05-24 17:55:24 +09:00
Sebastiaan van Stijn
979f18691a daemon: restore: fix fluentd-async-connect migration for downgrades
The "fluentd-async-connect" option was deprecated in 20.10 through
cc1f3c750e, and removed in 28.0 trough
49ec488036, which added migration code
on daemon startup.

However, the migration code _copied_ the deprecated option to the new
("fluentd-async") option, preserving the old field. Doing so could cause
an issue if a user would downgrade the daemon to a previous release, as
the changes in cc1f3c750e invalidate a config
that has both fields set (see [daemon/logger/fluentd/fluentd.go#L198-L200]);

    if cfg[asyncKey] != "" && cfg[asyncConnectKey] != "" {
        return config, errors.Errorf("conflicting options: cannot specify both '%s' and '%s", asyncKey, asyncConnectKey)
    }

This patch updates the migration code to remove the deprecated option.

[daemon/logger/fluentd/fluentd.go#L198-L200]: cc1f3c750e/daemon/logger/fluentd/fluentd.go (L198-L200)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-23 14:47:50 +02:00
Sebastiaan van Stijn
32c5774524 Merge pull request #48038 from thaJeztah/builder_allow_buildkit
api/server/router/build: BuilderVersion: allow buildkit on Windows
2025-05-22 14:13:50 +02:00
Sebastiaan van Stijn
56d5a46c0f Merge pull request #49740 from profnandaa/wcow-builder-next
builder-next: add buildkit executor for wcow
2025-05-22 13:42:28 +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
f4ffeb8c38 Merge pull request #50047 from thaJeztah/re_enable_integrationcli_check
validation: re-enable check for changes in integration-cli"
2025-05-22 08:41:22 +00:00
Sebastiaan van Stijn
dddc943a6a Merge pull request #49977 from robmry/nftables_util_updates
nftables: util updates, including table reload
2025-05-22 02:15:34 +02:00
Sebastiaan van Stijn
560299a16f validation: re-enable check for changes in integration-cli"
This reverts commit a891e4e3e1.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-22 01:13:16 +02:00
Sebastiaan van Stijn
b3160e88bf Merge pull request #50036 from thaJeztah/buildkit_rm_schema1
builder-next: remove support for deprecated schema1 images
2025-05-21 23:44:12 +02:00
Sebastiaan van Stijn
7148c6a5f5 Merge pull request #42300 from thaJeztah/carry_39384_remove_v2_schema1_push
Remove support for pulling v2 schema1
2025-05-21 23:43:41 +02:00
Paweł Gronowski
b590eff717 Merge pull request #50046 from crazy-max/buildkit-0.22.0
vendor: update buildkit to v0.22.0
2025-05-21 17:24:27 +00:00
CrazyMax
e354e42e14 vendor: update buildkit to v0.22.0
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-05-21 18:31:50 +02:00
Rob Murray
0facb0cd63 Merge pull request #49969 from robmry/firewaller_wsl2_param
Make WSL2Mirrored into a Firewaller param
2025-05-21 15:32:04 +01:00
Sebastiaan van Stijn
61a1a297c0 Merge pull request #50042 from vvoland/daemon-create-platformnil
daemon/create: Simplify `GetImage` args
2025-05-21 16:01:08 +02:00
Paweł Gronowski
94b5e85c10 Merge pull request #50039 from vvoland/netlink-1.3.1
vendor: github.com/vishvananda/netlink v1.3.1
2025-05-21 11:03:11 +00:00
Paweł Gronowski
a2ada6b258 daemon/create: Simplify GetImage args
`opts.params.Platform` is always nil inside this branch so we can omit
it from the `GetImage` call to make it less confusing.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-21 12:50:27 +02:00
Paweł Gronowski
894244cc37 Merge pull request #50030 from vvoland/client-c8dhttp
client: Use containerd errdefs to convert http errors
2025-05-21 10:29:26 +00:00
Sebastiaan van Stijn
2c57455339 vendor: github.com/containerd/containerd/api v1.9.0
full diff: https://github.com/containerd/containerd/compare/api/v1.8.0...api/v1.9.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-21 12:19:52 +02:00
Paweł Gronowski
a3ce441ae0 client: Use containerd errdefs to convert http errors
Previously, we were using our own `FromStatusCode` function to map HTTP
status codes to Docker error types. Switch to the containerd code.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-21 11:41:23 +02:00
Paweł Gronowski
86187b2606 vendor: github.com/vishvananda/netlink v1.3.1
full diff: https://github.com/vishvananda/netlink/compare/655392bc778a...v1.3.1

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-21 11:26:17 +02:00
Paweł Gronowski
a3bee4156f Merge pull request #49973 from ctalledo/fix-for-48659
Replace platforms.Format with platforms.FormatAll in user-visible messages and logs.
2025-05-21 08:03:34 +00:00
Sebastiaan van Stijn
e8c269843c builder-next: remove support for deprecated schema1 images
the core/remotes/docker/schema1 package is deprecated and removed
in containerd v2.1; remove its use as we already deprecated these
images for "docker pull" and elsewhere.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-20 23:33:39 +02:00
Anthony Nandaa
a9ec07a005 builder-next: add buildkit executor for wcow
WCOW support on Buildkit is now coming to maturity. As part
of making this generally available, integrating it in
Docker Engine is critical for it's adoption.

This commit adds the buildkit execuitor for WCOW as the
next-builder (backend) for building Windows containers.

This will be an opt-in feature, with the end users setting
DOCKER_BUILDKIT=1 environment variable to use it.

The integration tests bit has also been handled.
https://github.com/moby/buildkit/pull/5956,
BUILDKIT_REF has been set to `master` for now, so
that the tests can run successfully. On the next
release, we will revert this back to using releases.

Signed-off-by: Anthony Nandaa <profnandaa@gmail.com>
2025-05-20 00:14:09 +03:00
Sebastiaan van Stijn
8601b22f5d Merge pull request #50032 from vvoland/vendor-buildkit
vendor: github.com/moby/buildkit v0.22.0-rc2
2025-05-19 22:15:20 +02:00
Sebastiaan van Stijn
dfcf95540f Merge pull request #50019 from vvoland/client-cerrdefs
client: use containerd errdefs checks
2025-05-19 22:14:15 +02:00
Paweł Gronowski
e655763837 client/volume: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:37:39 +02:00
Paweł Gronowski
6bde39b729 client/utils: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:37:39 +02:00
Paweł Gronowski
144363fea2 client/task_list_test: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:37:37 +02:00
Paweł Gronowski
6cd9eaf5ab client/task_inspect_test: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:37:05 +02:00
Paweł Gronowski
68a8a8f3c8 client/swarm: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:37:03 +02:00
Paweł Gronowski
0b4495463f client/service: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:36:36 +02:00
Paweł Gronowski
ad4a3d32c6 client/secret: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:34:08 +02:00
Paweł Gronowski
df96159df0 client/request: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:34:08 +02:00
Paweł Gronowski
7e8b26ecb9 client/plugin: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:34:08 +02:00
Paweł Gronowski
2356f435a6 client/node: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:34:04 +02:00
Paweł Gronowski
4a830df491 client/network: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:32:24 +02:00
Paweł Gronowski
8f2bf4aef5 client/info_test: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:32:24 +02:00
Paweł Gronowski
a1035ec59b client/image: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:32:23 +02:00
Paweł Gronowski
370b7e65fc client/events_test: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:32:23 +02:00
Paweł Gronowski
27e64d3bdb client/distribution_inspect_test: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:32:23 +02:00
Paweł Gronowski
f030c7bf10 client/disk_usage_test: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:32:23 +02:00
Paweł Gronowski
c75ca8ef10 client/container: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:32:23 +02:00
Paweł Gronowski
eafa2266f6 client/config: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:32:22 +02:00
Paweł Gronowski
685fa0bb91 client/checkpoint: use containerd errdefs checks
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 20:32:22 +02:00
Cesar Talledo
bb41e5a32e Replace platforms.Format with platforms.FormatAll in functional code.
Signed-off-by: Cesar Talledo <cesar.talledo@docker.com>
2025-05-19 11:07:28 -07:00
Sebastiaan van Stijn
cbeec12d12 Merge pull request #50027 from thaJeztah/move_service_types
api/types: move swarm-related types to api/types/swarm
2025-05-19 19:59:07 +02:00
Paweł Gronowski
9319fefe35 vendor: github.com/moby/buildkit v0.22.0-rc2
full diff: https://github.com/moby/buildkit/compare/v0.22.0-rc1...v0.22.0-rc2

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 18:49:10 +02:00
Cesar Talledo
cf11cd1aac Replace platforms.Format with platforms.FormatAll in user-visible messages and logs.
Use FormatAll in user-visible messages and logs, since it includes the image's
platform OS version (when set).

Fixes https://github.com/moby/moby/issues/48659.

Signed-off-by: Cesar Talledo <cesar.talledo@docker.com>
2025-05-19 08:47:44 -07:00
Sebastiaan van Stijn
0b1c7a8306 api/types: move ServiceUpdateOptions to api/types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 16:30:33 +02:00
Sebastiaan van Stijn
31d62930f7 api/types: move ServiceCreateOptions to api/types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 16:30:31 +02:00
Sebastiaan van Stijn
5ad0867236 api/types: move TaskListOptions to api/types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 16:30:03 +02:00
Sebastiaan van Stijn
7e8f630bec api/types: move SwarmUnlockKeyResponse to api/types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 13:43:19 +02:00
Sebastiaan van Stijn
f008d85edc api/types: move NodeListOptions, NodeRemoveOptions to types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 13:43:16 +02:00
Sebastiaan van Stijn
b13528522a api/types: move ServiceListOptions, ServiceInspectOptions to types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 13:41:59 +02:00
Sebastiaan van Stijn
7937f0846c Merge pull request #50025 from thaJeztah/move_builder_options
api/types: move build-related types to api/types/build
2025-05-19 13:40:40 +02:00
Sebastiaan van Stijn
7f4bf1229a Merge pull request #50024 from thaJeztah/move_secret_config_types
api/types: move config and secret options to api/types/swarm
2025-05-19 13:40:21 +02:00
Paweł Gronowski
02fe3a8dd1 Merge pull request #50018 from vvoland/client-gotesttools
client: Use gotest.tools style assertions
2025-05-19 11:38:05 +00:00
Paweł Gronowski
5e8fd897e1 client/volume: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:10 +02:00
Paweł Gronowski
9432eff6bc client/utils_test: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:09 +02:00
Paweł Gronowski
adf7ecc366 client/task_list_test: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:09 +02:00
Paweł Gronowski
b781699ee2 client/task_inspect_test: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:08 +02:00
Paweł Gronowski
d8ee5caf9a client/swarm: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:08 +02:00
Paweł Gronowski
a6cd40de6b client/service: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:08 +02:00
Paweł Gronowski
3658dae265 client/secret: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:07 +02:00
Paweł Gronowski
2e65796c86 client/request_test: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:07 +02:00
Paweł Gronowski
44f30261da client/plugin: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:07 +02:00
Paweł Gronowski
832efcd672 client/options_test: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:07 +02:00
Paweł Gronowski
88453254af client/node: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:06 +02:00
Paweł Gronowski
047343d070 client/network: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:06 +02:00
Paweł Gronowski
6402a106e7 client/image: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:06 +02:00
Paweł Gronowski
043c7fa539 client/hijack_test: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:05 +02:00
Paweł Gronowski
a8ed3bd734 client/events_test: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:05 +02:00
Paweł Gronowski
c88f921331 client/disk_usage_test: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:05 +02:00
Paweł Gronowski
051dae4fdc client/container: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:05 +02:00
Paweł Gronowski
cae3ccd34b client/config_create: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:04 +02:00
Paweł Gronowski
bfc684d3f7 client/client_test: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:04 +02:00
Paweł Gronowski
19f3259093 client/checkpoint: use gotest.tools-style asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-19 12:04:04 +02:00
Sebastiaan van Stijn
a411a39be0 api/types: move ConfigCreateResponse, ConfigListOptions to types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 09:39:23 +02:00
Sebastiaan van Stijn
23117afca8 api/types: move SecretCreateResponse, SecretListOptions to types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 09:36:48 +02:00
Sebastiaan van Stijn
3d1e4d9002 api/types: move build-related types to api/types/build
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 09:30:27 +02:00
Sebastiaan van Stijn
94e84169ec Merge pull request #49949 from henry118/pushtag
Fix multiarch image push tag for containerd snapshotter
2025-05-19 06:57:59 +02:00
Sebastiaan van Stijn
bb7dbaafcd api/types: move BuildResult to api/types/build.Result
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-17 00:39:09 +02:00
Paweł Gronowski
4b9f0707a0 Merge pull request #50017 from thaJeztah/align_go_build_versions
align //go:build versions
2025-05-16 19:00:44 +00:00
Paweł Gronowski
71862f3303 Merge pull request #49904 from thaJeztah/deprecate_bridgenfip_fields_take2
API: /info: remove BridgeNfIptables, BridgeNfIp6tables fields (take 2)
2025-05-16 18:51:00 +00:00
Sebastiaan van Stijn
6505d3877c API: /info: remove BridgeNfIptables, BridgeNfIp6tables fields
The `BridgeNfIptables` and `BridgeNfIp6tables` fields in the
`GET /info` response were deprecated in API v1.48, and are now omitted
in API v1.50.

With this patch, old API version continue to return the field:

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.48/info | jq .BridgeNfIp6tables
    false

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.48/info | jq .BridgeNfIptables
    false

Omitting the field in API v1.50 and above

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.50/info | jq .BridgeNfIp6tables
    null

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.50/info | jq .BridgeNfIptables
    null

This reverts commit eacbbdeec6, and re-applies
a variant of 5d2006256f

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 19:49:52 +02:00
Paweł Gronowski
b45aa469ca Merge pull request #49897 from scalewithlee/49768-docker-stats-follow-up
Refactor CPU stats collection
2025-05-16 16:42:34 +00:00
Sebastiaan van Stijn
ede73684c4 Merge pull request #49968 from thaJeztah/dont_persist_removal_in_progress
container: don't persist State.RemovalInProgress on disk
2025-05-16 18:31:52 +02:00
Sebastiaan van Stijn
2ff42e192f Merge pull request #50012 from thaJeztah/deprecate_client_iserrnotfound
client: deprecate IsErrNotFound
2025-05-16 18:21:17 +02:00
Sebastiaan van Stijn
48733b0751 Merge pull request #47883 from dmcgowan/errdefs-check-containerd
Update errdefs package to use containerd/errdefs
2025-05-16 18:20:41 +02:00
Paweł Gronowski
81116f75de Merge pull request #49980 from vvoland/devices-discovery
daemon: Discover devices and include in system info
2025-05-16 16:08:17 +00:00
Paweł Gronowski
e190fdf286 Merge pull request #50015 from thaJeztah/move_prune_options
api/types: move build cache types to api/types/build
2025-05-16 16:06:07 +00:00
Sebastiaan van Stijn
114b8a4fa9 Remove unused image/v1 code
This image format is only used for docker save / docker load.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 18:00:06 +02:00
Sebastiaan van Stijn
7130cd4f16 Remove DockerSchema1RegistrySuite schema 2 version 1 tests
Also remove the DOCKER_ALLOW_SCHEMA1_PUSH_DONOTUSE from Jenkins

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 18:00:06 +02:00
Tibor Vass
7c09fa25fd distribution: remove v2 schema1 push
Manifest v2 schema1 was deprecated in 4866f5139a1 and this commit
removes the push code for v2 schema1.

This reverts commit f695e98cb7,
adjusted for changes that were made since

daemon: do not mkdir trust directory

Remove push tests and move UUID tests to integration

Partial revert of f23a51a860.

Only the schema1 push tests are removed but the schema1 pull tests
are still desired.

The UUID test is moved from integration-cli to integration.

Signed-off-by: Tibor Vass <tibor@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 18:00:06 +02:00
Sebastiaan van Stijn
a891e4e3e1 validation: temporarily allows changes in integration-cli
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 18:00:06 +02:00
Sebastiaan van Stijn
2a96d2eb8d align //go:build versions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 17:52:43 +02:00
Paweł Gronowski
c1b2be0399 client/info_test: Use gotest.tools asserts
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-16 17:03:31 +02:00
Paweł Gronowski
9095698a5c daemon: Discover devices and include in system info
Add ability for the device driver to implement a device discovery
mechanism and expose discovered devices in the `docker info` output.

Currently it's only implemented for CDI devices.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-16 17:03:29 +02:00
Paweł Gronowski
f95a7c47e8 api: bump API version to 1.50
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-16 17:03:28 +02:00
Paweł Gronowski
b70b496505 testutil/daemon: Don't use devcontainers daemon.json
Prevent the daemon spawned for integration tests from sourcing the
daemon configuration intended interactive dev shell usage.

Before this change, integration tests would fail to create a daemon
with different configuration provided via cli flags (like `--feature`)
if they're already specified in the default daemon.json.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-16 17:03:26 +02:00
Paweł Gronowski
23bbfea718 daemon: Fix error log when CDI cache creation failed
Logger was created but no consumed.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-16 17:03:25 +02:00
Lee Gaines
6d7a370fe5 Refactor CPU usage stats test to use go:embed
Refactor the system CPU usage testing approach for improved maintainability:

1. Extract the core CPU usage parsing logic into a new `readSystemCPUUsage`
   function that accepts an io.Reader, making it more testable and modular.

2. Use go:embed directive to embed the test data file at compile time,
   eliminating runtime file operations and making tests more reliable.

3. Simplify the test by removing global variable mocking in favor of a more
   direct approach with the new reader-based function.

4. Maintain full test coverage for the long "intr" line edge case which was
   crucial for the original bug fix, while making the test more maintainable.

This change preserves the original test behavior while improving code quality,
testability, and making the tests self-contained.

Signed-off-by: Lee Gaines <leetgaines@gmail.com>
2025-05-16 10:23:49 -04:00
Sebastiaan van Stijn
eefe68a37c api/types: move build cache types to api/types/build
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 16:23:32 +02:00
Sebastiaan van Stijn
7aa7369f1f client: deprecate IsErrNotFound
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 15:32:04 +02:00
Paweł Gronowski
c04dec1143 Merge pull request #49998 from thaJeztah/fix_linting
daemon: startIngressWorker: fix S1000: should use for range (staticcheck)
2025-05-16 11:44:56 +00:00
Paweł Gronowski
bcc7954343 Merge pull request #49707 from jsternberg/containerd-system-df
containerd: include present content size in layer disk usage calculation
2025-05-16 10:45:14 +00:00
Akihiro Suda
242985bcfc Merge pull request #50009 from thaJeztah/update_authors
update authors and mailmap
2025-05-16 15:32:48 +09:00
Sebastiaan van Stijn
a022e916c8 update authors and mailmap
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 01:06:19 +02:00
Sebastiaan van Stijn
fd1a78e0a3 Merge pull request #49942 from thaJeztah/exec_start_cleanups
daemon: Daemon.ContainerExecStart: rename err-return, and minor refactor
2025-05-15 23:51:11 +02:00
Sebastiaan van Stijn
994d2800c1 Merge pull request #49963 from vvoland/cdi-ga
daemon: Enable CDI by default
2025-05-15 23:49:40 +02:00
Sebastiaan van Stijn
63bcfab0ed Merge pull request #49932 from corhere/libn/networkdb-fixes
libnetwork/networkdb: fix logical race conditions
2025-05-15 23:05:55 +02:00
Cory Snider
66dab7ac65 Merge pull request #50007 from corhere/libn/fix-49402-harder
libnetwork/networkdb: use correct index in GetTableByNetwork
2025-05-15 16:23:53 -04: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
Sebastiaan van Stijn
07466d2e9b daemon: Daemon.ContainerExecStart: rename err-return, and minor refactor
- rename the error-return to prevent accidental shadowing
- remove some intermediate variables
- usee a struct-literal for specs.Process
- optimize logging-code to not use chained "WithField"
- remove punctuation from error-message

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-15 22:09:56 +02:00
Sebastiaan van Stijn
5919ab26f0 Merge pull request #49992 from thaJeztah/snapshot_health
container: Snapshot.Health: change type to container.HealthStatus
2025-05-15 22:07:27 +02:00
Sebastiaan van Stijn
e7ccfae846 Merge pull request #49991 from thaJeztah/container_summary_state
api/types/container: Summary.State change type to ContainerState
2025-05-15 21:53:17 +02:00
Sebastiaan van Stijn
702d19e2c2 Merge pull request #49961 from corhere/addrplugin-adapter
d/cluster/convert: expose Addr() on plugins
2025-05-15 21:26:15 +02:00
Cory Snider
d5c370dee6 libnetwork/networkdb: use correct index in GetTableByNetwork
Commit ec65f2d21b has a typo: it switches
indexes[byTable] with indexes[byNetwork]. The indexes are not
equivalent. Switch it back.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-15 15:19:06 -04:00
Sebastiaan van Stijn
9d1b069a4b Merge pull request #50002 from mmorel-35/usestdlibvars
fix usestdlibvars
2025-05-15 20:14:29 +02:00
Cory Snider
270a4d41dc libn/networkdb: stop table events from racing network leaves
When a node leaves a network or the cluster, or memberlist considers the
node as failed, NetworkDB atomically deletes all table entries (for the
left network) owned by the node. This maintains the invariant that table
entries owned by a node are present in the local database indices iff
that node is an active cluster member which is participating in the
network the entries pertain to.

(*NetworkDB).handleTableEvent() is written in a way which attempts to
minimize the amount of time it is in a critical section with the mutex
locked for writing. It first checks under a read-lock whether both the
local node and the node where the event originated are participating in
the network which the event pertains to. If the check passes, the mutex
is unlocked for reading and locked for writing so the local database
state is mutated in a critical section. That leaves a window of time
between the participation check the write-lock being acquired for a
network or node event to arrive and be processed. If a table event for a
node+network races a node or network event which triggers the purge of
all table entries for the same node+network, the invariant could be
violated. The table entry described by the table event may be reinserted
into the local database state after being purged by the node's leaving,
resulting in an orphaned table entry which the local node will bulk-sync
to other nodes indefinitely.

It's not completely wrong to perform a pre-flight check outside of the
critical section. It allows for an early return in the no-op case
without having to bear the cost of synchronization. But such optimistic
concurrency control is only sound if the condition is double-checked
inside the critical section. It is tricky to get right, and this
instance of optimistic concurrency control smells like a case of
premature optimization. Move the pre-flight check into the critical
section to ensure that the invariant is maintained.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-15 12:57:37 -04:00
Matthieu MOREL
205ba05feb fix usestdlibvars
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-15 18:24:58 +02:00
Akihiro Suda
49e43afb47 Merge pull request #49997 from thaJeztah/bump_crun
Dockerfile: update crun to 1.21
2025-05-16 00:57:02 +09:00
Derek McGowan
23fa0ae74a Cleanup http status error checks
Use the errdefs resolver to ensure the status code is chosen from the
first outermost error. Remove duplicate containerd errdefs checks.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-05-15 08:05:53 -07:00
Derek McGowan
fadb571106 Update api status checks to use containerd/errdefs
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-05-15 08:05:53 -07:00
Derek McGowan
5c16f2d091 Use standard library interface to unwrap errors
The `Cause()` function is not part of the standard library and should
not be used or relied on. `pkg/errors` already has compatibility with
the standard library.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-05-15 08:05:52 -07:00
Derek McGowan
a90a9d899b Ignore deprecations for internal errdefs package
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-05-15 08:05:50 -07:00
Derek McGowan
f1bb44aeee Use containerd errdefs for error checks
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-05-15 08:00:13 -07:00
Sebastiaan van Stijn
ba2ddd75e4 Dockerfile: update crun to 1.21
full diff: https://github.com/containers/crun/compare/1.12...1.21

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-15 16:55:46 +02:00
Jonathan A. Sternberg
f07242f6d7 containerd: include present content size in disk usage calculations
The present content size is included in the image size usage and should
be included in the total size that the layer takes up on disk.

This prevents an issue where the reclaimable amount reported by the CLI
was a negative number.

This also updates the `/system/df` endpoint to use a new type that
computes information that was previously computed by the CLI. Computing
these in the server should require less work from the CLI and ensure
the calculations are more accurate because the CLI doesn't have to
reconstruct the numbers.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-05-15 09:46:51 -05:00
Akihiro Suda
2c5f8c51c5 Merge pull request #49996 from thaJeztah/bump_compose
Dockerfile: update compose to v2.36.0
2025-05-15 23:46:25 +09:00
Akihiro Suda
2438415cb8 Merge pull request #49999 from thaJeztah/vendor_accelerated_container_image
vendor: github.com/containerd/accelerated-container-image v1.3.0
2025-05-15 23:46:12 +09:00
Sebastiaan van Stijn
3ded7b97d0 vendor: github.com/containerd/accelerated-container-image v1.3.0
no changes in vendored code

full diff: https://github.com/containerd/accelerated-container-image/compare/v1.2.3...v1.3.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-15 14:53:35 +02:00
Sebastiaan van Stijn
68e025a11b daemon: startIngressWorker: fix S1000: should use for range (staticcheck)
daemon/network.go:156:3: S1000: should use for range instead of for { select {} } (staticcheck)
            for {
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-15 14:49:34 +02:00
Sebastiaan van Stijn
493662ddd3 Merge pull request #49870 from mmorel-35/golangci-lint@v2
chore: bump golangci-lint to v2
2025-05-15 14:42:44 +02:00
Sebastiaan van Stijn
7bc6fd09da Dockerfile: update compose to v2.36.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-15 14:05:20 +02:00
Sebastiaan van Stijn
a6ad2f2157 Merge pull request #49988 from thaJeztah/flaky_TestPortMappedHairpinWindows
integration/networking: mark TestPortMappedHairpinWindows as flaky
2025-05-15 13:12:00 +02:00
Sebastiaan van Stijn
8cb41620fd Merge pull request #49990 from ereslibre/fix-restore-containers-with-cdi
fix: load the CDI driver before the dockerd daemon starts
2025-05-15 13:10:47 +02:00
Sebastiaan van Stijn
76b24759f0 container: Snapshot.Health: change type to container.HealthStatus
container.HealthStatus is a pseudo-type (alias for string) that was
introduced in 1e4bb14bcd.

Changing this field to use that type as a potential stepping-stone
towards making that type a distinct type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-15 12:17:08 +02:00
Sebastiaan van Stijn
7a7d72e874 api/types/container: Summary.State change type to ContainerState
ContainerState is currently an alias for string, so this should not
be a disruptive change, but is a stepping-stone to make it a distinct
type in future.

Relates to b811829595

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-15 12:11:35 +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
Rob Murray
b87aecc50a Merge pull request #49985 from corhere/libn/set-primary-key-lock
libn/networkdb: SetPrimaryKey() under a write lock
2025-05-15 10:30:41 +01:00
Paweł Gronowski
c4dc09eac1 Merge pull request #49848 from jsternberg/remove-unlease-snapshots-from-deleted-configs
containerd: remove unleaseSnapshotsFromDeletedConfigs
2025-05-15 09:04:52 +00:00
Sebastiaan van Stijn
c2348c9fc3 Merge pull request #49986 from tonistiigi/buildkit-v0.22.0-rc1
vendor: update buildkit to v0.22.0-rc1
2025-05-15 11:01:53 +02:00
Sebastiaan van Stijn
b3ed54db81 integration/networking: mark TestPortMappedHairpinWindows as flaky
This test is failing frequently on Windows;

    === FAIL: github.com/docker/docker/integration/networking TestPortMappedHairpinWindows (12.37s)
        nat_windows_test.go:108: assertion failed: error is not nil: Post "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.49/containers/1181d6510a2f55c742b7b183aa7324eddbc213cd15797428c4062dcb031fb825/start": context deadline exceeded
        panic.go:636: assertion failed: error is not nil: Error response from daemon: error while removing network: network clientnet has active endpoints (name:"laughing_lederberg" id:"8605ebbc2c7c")

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-15 10:57:00 +02:00
Matthieu MOREL
7b5d2b4ec3 chore: bump golangci-lint to v2
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-15 10:00:16 +02:00
Tonis Tiigi
3d1cfb4de0 vendor: update buildkit to v0.22.0-rc1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-05-14 17:16:15 -07:00
Cory Snider
c9b01e0c4c libn/networkdb: SetPrimaryKey() under a write lock
(*NetworkDB).SetPrimaryKey() acquires a read lock on the NetworkDB
instance. That seems sound on the surface as it is only reading from the
NetworkDB struct, not mutating it. However, concurrent calls to
(*memberlist.Keyring).UseKey() would get flagged by Go's race detector
due to some questionable locking in its implementation. Acquire an
exclusive lock in SetPrimaryKey so concurrent calls don't race each
other.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-14 19:45:14 -04: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
Jonathan A. Sternberg
61646c8bfc containerd: remove unleaseSnapshotsFromDeletedConfigs
Removes workaround for https://github.com/moby/buildkit/issues/3797 now
that the underlying issue is fixed.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-05-14 09:20:22 -05:00
Rob Murray
2154b9c646 Merge pull request #49976 from thaJeztah/fix_godoc
integration, libnetwork: fix some godoc comments (ST1020)
2025-05-14 10:50:53 +01:00
Rob Murray
350bb5197a nftables: attempt a table-reload after an Apply error
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-14 10:38:11 +01:00
Rob Murray
06afbe9618 Check nftables is enabled before applying updates
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-14 10:38:11 +01:00
Rob Murray
976f855f68 Add OTEL span for nftables updates
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-14 10:38:11 +01:00
Paweł Gronowski
c3f484dada Merge pull request #49965 from thaJeztah/container_state_const
api/types/container: add ContainerState and const for container state
2025-05-14 08:50:49 +00:00
Rob Murray
eeba428939 Make WSL2Mirrored a Firewaller param
The bridge driver should figure out whether it's running in
a mirrored WSL2 setup, and tell the firewaller.

So, move the WSL2-deciding code back into the bridge driver
and unit test it there. Use TestIptabler to check the rules
are constructed properly.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-14 09:38:32 +01:00
Rob Murray
9f1e3ae306 Merge pull request #49861 from robmry/bridge_test_firewaller
Unit test the bridge driver in terms of its firewaller
2025-05-14 09:30:02 +01:00
Sebastiaan van Stijn
1028b123e8 integration, libnetwork: fix some godoc comments (ST1020)
integration/internal/network/ops.go:137:1: ST1020: comment on exported function WithIPAMRange should be of the form "WithIPAMRange ..." (staticcheck)
    // WithIPAM adds an IPAM with the specified Subnet, IPRange and Gateway to the network
    ^
    libnetwork/bitmap/sequence.go:50:1: ST1020: comment on exported function New should be of the form "New ..." (staticcheck)
    // NewHandle returns a new Bitmap of ordinals in the interval [0, n).
    ^
    libnetwork/diagnostic/server.go:61:1: ST1020: comment on exported method HandleFunc should be of the form "HandleFunc ..." (staticcheck)
    // Handle registers the handler function for the given pattern,
    ^
    libnetwork/endpoint.go:388:1: ST1020: comment on exported method Key should be of the form "Key ..." (staticcheck)
    // endpoint Key structure : endpoint/network-id/endpoint-id
    ^
    libnetwork/network.go:574:1: ST1020: comment on exported method MarshalJSON should be of the form "MarshalJSON ..." (staticcheck)
    // TODO : Can be made much more generic with the help of reflection (but has some golang limitations)
    ^
    libnetwork/network.go:633:1: ST1020: comment on exported method UnmarshalJSON should be of the form "UnmarshalJSON ..." (staticcheck)
    // TODO : Can be made much more generic with the help of reflection (but has some golang limitations)
    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-14 10:11:59 +02:00
Cory Snider
a3aea15257 libn/networkdb: Watch() without race conditions
NetworkDB's Watch() facility is problematic to use in practice. The
stream of events begins when the watch is started, so the watch cannot
be used to process table entries that existed beforehand. Either option
to process existing table entries is racy: walking the table before
starting the watch leaves a race window where events could be missed,
and walking the table after starting the watch leaves a race window
where created/updated entries could be processed twice.

Modify Watch() to initialize the channel with synthetic CREATE events
for all existing entries owned by remote nodes before hooking it up to
the live event stream. This way watchers observe an equivalent sequence
of events irrespective of whether the watch was started before or after
entries from remote nodes are added to the database. Remove the bespoke
and racy synthetic event replay logic for driver watches from the
libnetwork agent.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-13 14:09:51 -04:00
Cory Snider
ada8bc3695 libn/networkdb: record tombstones for all deletes
The gossip protocol which powers NetworkDB does not guarantee in-order
reception of events. This poses a problem with deleting entries: without
some mechanism to discard stale CREATE or UPDATE events received after a
DELETE, out-of-order reception of events could result in a deleted entry
being spuriously resurrected in the local NetworkDB state! NetworkDB
handles this situation by storing "tombstone" entries for a period of
time with the Lamport timestamps of the entries' respective DELETE
events. Out-of-order CREATE or UPDATE events will be ignored by virtue
of having older timestmaps than the tombstone entry, just like how it
works for entries that have not yet been deleted.

NetworkDB was only storing a tombstone if the entry was already present
in the local database at the time of the DELETE event. If the first
event received for an entry is a DELETE, no tombstone is stored. If a
stale CREATE/UPDATE event for the entry (with an older timestamp than
the DELETE) is subsequently received, NetworkDB erroneously creates a
live entry in the local state with stale data. Modify NetworkDB to store
tombstones for DELETE events irrespective of whether the entry was known
to NetworkDB beforehand so that it correctly discards out-of-order
CREATEs and UPDATEs in all cases.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-13 14:09:51 -04:00
Cory Snider
c68671d908 libn/networkdb: b'cast watch events from local POV
NetworkDB gossips changes to table entries to other nodes using distinct
CREATE, UPDATE and DELETE events. It is unfortunate that the wire
protocol distinguishes CREATEs from UPDATEs as nothing useful can be
done with this information. Newer events for an entry invalidate older
ones, so there is no guarantee that a CREATE event is broadcast to any
node before an UPDATE is broadcast. And due to the nature of gossip
protocols, even if the CREATE event is broadcast from the originating
node, there is no guarantee that any particular node will receive the
CREATE before an UPDATE. Any code which handles an UPDATE event
differently from a CREATE event is therefore going to behave in
unexpected ways in less than perfect conditions.

NetworkDB table watchers also receive CREATE, UPDATE and DELETE events.
Since the watched tables are local to the node, the events could all
have well-defined meanings that are actually useful. Unfortunately
NetworkDB is just bubbling up the wire-protocol event types to the
watchers. Redefine the table-watch events such that a CREATE event is
broadcast when an entry pops into existence in the local NetworkDB, an
UPDATE event is broadcast when an entry which was already present in the
NetworkDB state is modified, and a DELETE event is broadcast when an
entry which was already present in the NetworkDB state is marked for
deletion. DELETE events are broadcast with the same value as the most
recent CREATE or UPDATE event for the entry.

The handler for endpoint table events in the libnetwork agent assumed
incorrectly that CREATE events always correspond to adding a new active
endpoint and that UPDATE events always correspond to disabling an
endpoint. Fix up the handler to handle CREATE and UPDATE events using
the same code path, checking the table entry's ServiceDisabled flag to
determine which action to take.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-13 14:09:51 -04:00
Rob Murray
ba0ad9e80f Unit test the bridge driver in terms of its firewaller
Don't inspect iptables rules, because the driver's Firewaller won't
always be an iptabler.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-13 18:27:55 +01:00
Henry Wang
a7ef4a208d Fix multiarch image push tag for containerd snapshotter
Signed-off-by: Henry Wang <henwang@amazon.com>
2025-05-13 17:14:36 +00:00
Sebastiaan van Stijn
854f3f62db container: don't persist State.RemovalInProgress on disk
State.RemovalInProgress was originally non-exported when it was added in
[40945fc186][1], adding a comment that the
field should not be persisted to disk.

But when moved to a separate package in [6bb0d1816a][2],
it was was exported, without adding `json:"-"`. As a result, it's now persisted
to disk;

    cat /var/lib/docker/containers/e493924a99cad918cda8048f967032729105ee072d563d734125cec46e1b5885/config.v2.json | jq .State
    {
      "Running": true,
      "Paused": false,
      "Restarting": false,
      "OOMKilled": false,
      "RemovalInProgress": false,
      "Dead": false,
      "Pid": 5053,
      "ExitCode": 0,
      "Error": "",
      "StartedAt": "2025-05-13T12:12:15.115512564Z",
      "FinishedAt": "0001-01-01T00:00:00Z",
      "Health": null
    }

Note that this type is used internally, and (while similar) is not used for
API responses;

    docker inspect e493924a99cad918cda8048f967032729105ee072d563d734125cec46e1b5885 | jq .[].State
    {
      "Status": "running",
      "Running": true,
      "Paused": false,
      "Restarting": false,
      "OOMKilled": false,
      "Dead": false,
      "Pid": 5053,
      "ExitCode": 0,
      "Error": "",
      "StartedAt": "2025-05-13T12:12:15.115512564Z",
      "FinishedAt": "0001-01-01T00:00:00Z"
    }

However, interestingly, [`daemon.restore`][3] does take this field into account
while restoring containers, which seems that it depends on the field being
persisted to disk. That logic was added in [ce72473197][4].
That logic may be redundant if we no longer persist to disk, as the `State.Dead`
is already set when cleaning up a container in [`daemon.cleanupContainer`][5].

[1]: 40945fc186
[2]: 6bb0d1816a (diff-60173e67d15f3085dd09956b3ffa83566ae25fec61cfe08ddd2e1c37223e3be7R24)
[3]: d42d79dceb/daemon/daemon.go (L498-L514)
[4]: ce72473197
[5]: 294f0c36e4/daemon/delete.go (L124-L126)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-13 18:09:34 +02:00
Sebastiaan van Stijn
44b653ef99 container: deprecate IsValidStateString
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-13 15:03:42 +02:00
Sebastiaan van Stijn
e477df3b31 daemon/cluster/executor: use container.ContainerState consts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-13 15:03:41 +02:00
Sebastiaan van Stijn
3bbdda696d use container.ContainerState consts in tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-13 15:03:34 +02:00
Sebastiaan van Stijn
b811829595 api/types/container: add ContainerState and const for container state
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-13 14:49:04 +02:00
Paweł Gronowski
294f0c36e4 Merge pull request #49943 from thaJeztah/cleanupContainer_cleanup_errs
daemon: rmLink, cleanupContainer: cleanup errors
2025-05-13 12:20:28 +00:00
Paweł Gronowski
d42d79dceb Merge pull request #49924 from dmcgowan/api-system-build-backend
Create api interface to define build usage backend
2025-05-13 11:41:49 +00:00
Paweł Gronowski
10ac996d64 Merge pull request #49960 from thaJeztah/TestPruneDontDeleteUsedDangling_noshadow
TestPruneDontDeleteUsedDangling: rename var that shadowed import
2025-05-13 11:19:23 +00:00
Paweł Gronowski
0d6d4456ea Merge pull request #49958 from thaJeztah/container_state_defer
container: use defer for locks
2025-05-13 11:02:25 +00:00
Paweł Gronowski
7828a65aeb Merge pull request #49956 from thaJeztah/container_state_godoc
container: update GoDoc for State
2025-05-13 10:18:37 +00:00
Paweł Gronowski
3af89f31f6 Merge pull request #49959 from thaJeztah/testing_use_native_tempdir_step2
use Go's native t.TempDir() in tests (step 2)
2025-05-13 09:07:41 +00:00
Cory Snider
8b6d6b9ad5 d/cluster/convert: expose Addr() on plugins
The swarmPlugin type does not implement the Swarm plugin.AddrPlugin
interface because it embeds an interface value which does not include
that method in its method set. (You can type-assert an interface value
to another interface which the concrete type implements, but a struct
embedding an interface value is not itself an interface value.) Wrap the
plugin with a different adapter type which exposes the Addr() method if
the concrete plugin implements it.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-12 20:28:47 -04:00
Sebastiaan van Stijn
d89cd570f0 Merge pull request #49867 from robmry/make_integration-cli_iptablesless
Remove/replace integration-cli tests that use iptables directly
2025-05-12 20:26:04 +02:00
Sebastiaan van Stijn
17702d9dcb Merge pull request #49862 from robmry/test_iptabler_params
Test iptabler params
2025-05-12 20:09:01 +02:00
Rob Murray
37259540e9 Remove/replace integration-cli tests that use iptables directly
In preparation for testing with an nftables backend.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-12 17:51:59 +01:00
Rob Murray
daeb080ff1 Test Iptabler params
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-12 17:30:40 +01:00
Sebastiaan van Stijn
ea2e147c4c TestPruneDontDeleteUsedDangling: rename var that shadowed import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 18:03:58 +02:00
Rob Murray
cb38cc0fdd Merge pull request #49860 from robmry/firewaller_interface
Firewaller interface
2025-05-12 14:18:16 +01:00
Sebastiaan van Stijn
e824fed281 Merge pull request #49937 from corhere/libn/fix-49402
libn/networkdb: fix data race in GetTableByNetwork
2025-05-12 14:48:37 +02:00
Sebastiaan van Stijn
99368eeba2 Merge pull request #49948 from corhere/process-all-attachments
Fix possible overlapping IPs when ingressNA == nil
2025-05-12 14:46:36 +02:00
Sebastiaan van Stijn
02e800dcbb plugin: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 14:35:24 +02:00
Sebastiaan van Stijn
57b27f2e9e image: use t.TempDir and rename vars that shadowed
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 14:35:24 +02:00
Sebastiaan van Stijn
08c5ebe040 layer: use t.TempDir and minor cleanups
- Use strings.Cut
- Use strconv instead of fmt.Sprintf
- Rename vars that shadowed

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 14:35:21 +02:00
Sebastiaan van Stijn
239bf178b8 Merge pull request #49845 from thaJeztah/testing_use_native_tempdir_step1
use Go's native t.TempDir() in tests (step 1)
2025-05-12 14:34:58 +02:00
Sebastiaan van Stijn
f84694ebdc container: use defer for locks
Makes the code slightly more idiomatic. These paths avoided uses of
defer because they came with an overhead in older versions of Go,
but this overhead should now be neglectible.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 13:17:18 +02:00
Sebastiaan van Stijn
24f305b666 Makefile: set BIND_DIR to "." by default
Currently, it's needed to set `BIND_DIR=.` when starting the dev-container
in order to bind-mount the current source-code into the container. Omitting
that option only bind-mounts the "bundles" directory and copies the source
into the image before starting.

While there are some cases where (e.g.) a remote server is used for development,
and bind-mounting is not possible, those scenarios should be considered more
advanced, so let's make the common scenario easier to use.

With this patch, running `make shell` should build and run the dev-container
with the source-code mounted.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 13:15:05 +02:00
Paweł Gronowski
23825bc1fd Merge pull request #49893 from thaJeztah/move_more_container_types
container: deprecate IsValidHealthString
2025-05-12 10:51:10 +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
Paweł Gronowski
4c189b8fe8 Merge pull request #49174 from thaJeztah/bump_golang_1.24
update to go1.24.3
2025-05-12 10:10:05 +00:00
Sebastiaan van Stijn
ea37a1f040 integration/build: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 12:09:39 +02:00
Sebastiaan van Stijn
900bd88848 internal/directory: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 12:05:50 +02:00
Sebastiaan van Stijn
46baf7deb0 distribution: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 12:05:50 +02:00
Sebastiaan van Stijn
1b4ba20708 distribution/metadata: use t.TempDir, rename var that shadowed
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 12:05:50 +02:00
Sebastiaan van Stijn
735ccfbc6f pkg/stack: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 12:05:50 +02:00
Sebastiaan van Stijn
72a11b84d4 testutil/fakestorage: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 12:05:50 +02:00
Sebastiaan van Stijn
b38f73afe3 daemon: cleanupContainer: leave decorating container-id/name to caller
This function was decorating errors with the container name, but within its
own context wouldn't be aware how the delete was referenced. This could
result in a container deleted by "ID" to produce an error with the container
Name. Some errors were also decorated before storing as "removalError" on
the container object itself.

The removalError was originally added in f963500c54,
before which the error was returned. Now that it's part of the container's
state itself, adding the container's ID is probably not very useful.

This patch reduces the scope of decorating the errors to the error-condition
itself, leaving it to the caller to decorate them further with the container
ID or Name (if any).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 11:05:39 +02:00
Sebastiaan van Stijn
d44b2e4bd7 daemon: cleanupContainer: use state-fields instead of string form
This code only needed to know whether the container was paused; for other
states ("restarting", "running"), it's still used to be included in the
error string.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 11:02:57 +02:00
Sebastiaan van Stijn
4a00ce10fa daemon: rmLink, cleanupContainer: rename args that shadowed import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 10:58:50 +02:00
Sebastiaan van Stijn
1cf7d7ea4b hack/make/.binary: update link to go source for "pie" support
Keeping it up to date, in case the situation changes.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 10:31:24 +02:00
Sebastiaan van Stijn
e991c7185d update to go1.24.3
release notes: https://go.dev/doc/go1.24

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 10:31:00 +02:00
Sebastiaan van Stijn
89ee292709 container: update GoDoc for State
Better describe that various states are not mutually exclusive.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-12 10:28:20 +02:00
Sebastiaan van Stijn
7979b3d46b Merge pull request #49911 from aaithal/fluentd-write-timeout
fluentd: add write timeout log option
2025-05-10 16:12:09 +02:00
Anirudh Aithal
7dae7c54dd fluentd: add write timeout log option
Currently, there's no mechanism to specify a write timeout value for
fluentd connections. This means that writes can forever be blocked if
the downstream connections is unhealthy. This commit makes this value
configurable via a new fluentd log option called "fluentd-write-timeout".

Signed-off-by: Anirudh Aithal <aithal@amazon.com>
2025-05-09 12:32:24 -07:00
Sebastiaan van Stijn
c8db8ca6b2 Merge pull request #49946 from robmry/modprobe_rootless_test_integration
Try to load br_netfilter on the test host for rootless test-integration
2025-05-09 20:17:30 +02:00
Sebastiaan van Stijn
31e992cccd Merge pull request #49944 from thaJeztah/container_fix_waitcondition
container: State.Wait(): don't use deprecated type
2025-05-09 20:03:33 +02:00
Sebastiaan van Stijn
97be6333e6 Merge pull request #49939 from corhere/libn/networkdb-broadcast-overflow
libn/networkdb: don't exceed broadcast size limit
2025-05-09 19:20:38 +02:00
Cory Snider
56ad941564 Fix possible overlapping IPs when ingressNA == nil
Logic was added to the Swarm executor in commit 0d9b0ed678
to clean up managed networks whenever the node's load-balancer IP
address is removed or changed in order to free up the address in the
case where the container fails to start entirely. Unfortunately, due to
an oversight the function returns early if the Swarm is lacking
an ingress network. Remove the early return so that load-balancer IP
addresses for all the other networks are freed as appropriate,
irrespective of whether an ingress network exists in the Swarm.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-09 12:51:08 -04:00
Rob Murray
dc1d23c646 Revert "rootless: skip tests that need br-netfilter loaded"
Shouldn't be needed, the top level Makefile will try to modprobe.

This reverts commit 4c4810e5d2.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-09 17:31:38 +01:00
Rob Murray
4b9092aa27 Load br-netfilter for rootless test-integration
If kernel module br_netfilter isn't loaded on the test host
before rootless test-integration tests that need it, the
rootless daemon hits a permission error when trying to do
the load. So, try to load the module before going rootless.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-09 17:31:38 +01:00
Sebastiaan van Stijn
62694ab30c Merge pull request #49813 from p5/systemd-sysusers
Add systemd-sysusers contrib configuration
2025-05-09 18:25:29 +02:00
Sebastiaan van Stijn
9b19172c7f Merge pull request #49868 from thaJeztah/exec_validate_user
docker exec: fail early on exec create if specified user doesn't exist
2025-05-09 17:00:50 +02:00
Rob Murray
f848191e40 Merge pull request #49901 from robmry/active_endpoints_error_error
Active endpoints error error
2025-05-09 09:29:33 +01:00
Tianon Gravi
6f477852a1 Merge pull request #47366 from thaJeztah/less_output_vars
reduce named (error)-returns and some minor linting-fixes
2025-05-08 21:18:27 +00:00
Sebastiaan van Stijn
7957a28859 container: remove GoDoc for deprecated aliases.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 21:59:08 +02:00
Sebastiaan van Stijn
fe403362b4 container: State.Wait(): don't use deprecated type
The container.WaitCondition type was deprecated in
100102108b, but this use of the
deprecated alias was left behind.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 21:56:07 +02:00
Robert Sturla
0bd82bfac2 chore: add systemd-sysusers configuration
Part of https://github.com/docker/docker-ce-packaging/issues/1186

Adds the required systemd-sysusers configuration to the
moby/moby repo.  This will be used by downstream package
maintainers (RPM, DEB etc) as a replacement to the
`groupadd` postinstall commands.

It's generally recommended to use sysusers since it is
more of a declarative method of defining these service
accounts and groups.

This configuration file specifies a group ("g") named
"docker" should be created with an automatic GID
allocation ("-").

Signed-off-by: Robert Sturla <robertsturla@outlook.com>
2025-05-08 18:26:17 +01:00
Sebastiaan van Stijn
df662ebc59 container: deprecate IsValidHealthString
Introduce a ValidateHealthStatus utility in api/types/container to
validate if a given HealthState is valid.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 16:52:52 +02:00
Sebastiaan van Stijn
f9c4601760 volume/mounts: MountPoint.Setup: rename output-var, and simplify err-handling
Rename the ouput variable to prevent accidental shadowing, and simplify how
we check for the `syscall.ENOTDIR` error; `errors.Is()` will already unwrap
the error, so no type-casting is needed;

    package main

    import (
        "errors"
        "fmt"
        "os"
        "syscall"
    )

    func main() {
        err := &os.PathError{Op: "mkdir", Path: "/hello/world", Err: syscall.ENOTDIR}
        if errors.Is(err, syscall.ENOTDIR) {
            fmt.Println(err)
        }
    }

While at it, also improve the code-comment that outlines the intent.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:11 +02:00
Sebastiaan van Stijn
6ac3afe483 volume: remove/rename err-returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:11 +02:00
Sebastiaan van Stijn
986988a394 testutil/daemon: Daemon.StopWithError: rename output-var to prevent shadowing
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:11 +02:00
Sebastiaan van Stijn
3606712e2d testutil: remove named returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:11 +02:00
Sebastiaan van Stijn
fe2d323c82 registry: remove/rename err-returns, and minor refactor
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:10 +02:00
Sebastiaan van Stijn
79b1b561a3 registry/resumable: remove named err-return, fix minor linting issue
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:10 +02:00
Sebastiaan van Stijn
e67b6bfc69 plugin: remove/rename err-returns
Prevent accidentally shadowing these errors, which are used in defers, and
while at it, also fixed some linting warnings about unhandled errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:10 +02:00
Sebastiaan van Stijn
943dfa985d oci: remove named err-return
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:10 +02:00
Sebastiaan van Stijn
0b169d34e4 libnetwork: remove named (err)-returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:10 +02:00
Sebastiaan van Stijn
154230cdd7 libnetwork/portallocator: getDynamicPortRange: fix err-handling on freeBSD
The function used a `cmdErr` error, but it was discarded when returning an
error. Also removing the named "err" return variable.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:09 +02:00
Sebastiaan van Stijn
962fd8bc41 libnetwork/ipams/remote: inline decodeToMap
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:09 +02:00
Sebastiaan van Stijn
cfdfbfab9b libnetwork/drivers/remote: inline decodeToMap
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:09 +02:00
Sebastiaan van Stijn
152db74d96 libcontainerd: remove/rename err-returns
Prevent accidentally shadowing these errors, which are used in defers.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:09 +02:00
Sebastiaan van Stijn
f87dcbe350 layer: remove/rename err-returns and remove naked returns
- rename error-output variables to prevent shawdowing
- remove naked returns
- rename some (err) variables for clarity
- remove redundant assertNotDirectoryError utility

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:09 +02:00
Sebastiaan van Stijn
6981aad790 internal/testutils: remove named returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:09 +02:00
Sebastiaan van Stijn
d1c58bdbbe integration-cli: 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-05-08 14:33:08 +02:00
Sebastiaan van Stijn
1b317b0323 distribution: remove named err-returns and minor refactor
- remove named err-returns to prevent accidental shadowing
- fix some minor linting issues (unhandled errors)
- update code depending on "errors.Wrap" behavior. which ignores
  nil-errors, which can be easily overlooked when rewriting to
  native go error-wrapping (fmt.Errorf()).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-08 14:33:08 +02:00
Sebastiaan van Stijn
e205701266 Merge pull request #49938 from corhere/libn/fix-networkdb-loopback-tests
libnetwork/networkdb: fix most flaky loopback tests
2025-05-08 13:33:45 +02:00
Sebastiaan van Stijn
49a0770c7a Merge pull request #49925 from 17neverends/refactor_metrics
Optimization methods in internal\metrics\metrics.go
2025-05-08 01:13:40 +02:00
Sebastiaan van Stijn
69ee71225e Merge pull request #49919 from dmcgowan/api-image-unused-reference-store
Remove unused reference store in image api
2025-05-07 23:25:48 +02:00
17neverends
1244685329 Optimization methods in internal\metrics\metrics.go
Signed-off-by: 17neverends <ionianrise@gmail.com>
2025-05-07 23:56:17 +03:00
Rob Murray
1b1a5a6878 Merge pull request #49940 from robmry/flaky_tests_rootless_and_firewalld
Skip tests that recently started failing in rootless/firewalld
2025-05-07 21:48:29 +01:00
Rob Murray
84ef7e4899 Allow TestIsolated/ipv6 to unexpectedly pass
This test normally fails due to a known issue, but it
has recently started passing in CI ... not sure why, it
still fails locally - so, allow it to unexpeectedly
pass, but collect some debug info to try to undertand
why.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-07 19:57:27 +01:00
Rob Murray
4c4810e5d2 rootless: skip tests that need br-netfilter loaded
Skip tests that have recently started failing in rootless
mode with error:

failed to start daemon: Error initializing network controller:
  error creating default "bridge" network:
    cannot restrict inter-container communication or run
    without the userland proxy:
      stat /proc/sys/net/bridge/bridge-nf-call-iptables:
        no such file or directory:
          set environment variable DOCKER_IGNORE_BR_NETFILTER_ERROR=1 to ignore

(Perhaps we can ensure the module is loaded before starting
the rootless env - or work out why the failures have only
recently started, and put-back whatever changed. But, for
now, I think we need to skip.)

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-07 19:51:07 +01:00
Cory Snider
dacf445614 libn/networkdb: don't exceed broadcast size limit
NetworkDB uses a hierarchy of queues to prioritize messages for
broadcast. Unfortunately the logic to pull from multiple queues is
flawed. The length of the messages pulled from the first queue is not
taken into account when pulling messages from the second queue. A list
of messages up to tiwce as long as the limit could be returned! Messages
beyond the limit will be truncated unceremoniously by memberlist.

Memberlist broadcast queues assume that all messages returned from a
GetBroadcasts call will be broadcasted to other nodes in the cluster.
Messages are popped from the queue once they have hit their retransmit
limit. On a busy system messages may be broadcast fewer times than
intended, possibly even being dropped without ever being broadcast!

Subtract the length of messages pulled from the first queue from the
broadcast size limit so the limit is not exceeded when pulling from the
second queue.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-07 12:32:54 -04:00
Cory Snider
697c17ca95 libn/networkdb: take most tests off flaky list
The loopback-test fixes seem to be sufficient to resolve the flakiness
of all the tests aside from TestFlakyNetworkDBIslands.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-07 11:51:29 -04:00
Cory Snider
90ec2c209b libn/networkdb: listen only on loopback in tests
NetworkDB defaults to binding to the unspecified address for gossip
communications, with no advertise address set. In this configuration,
the memberlist instance listens on all network interfaces and picks one
of the host's public IP addresses as the advertise address.
The NetworkDB unit tests don't override this default, leaving them
vulnerable to flaking out as a result of rogue network traffic
perturbing the test, or the inferred advertise address not being useable
for loopback testing. And macOS prompts for permission to allow the test
executable to listen on public interfaces every time it is rebuilt.

Modify the NetworkDB tests to explicitly bind to, advertise, and join
ports on 127.0.0.1 to make the tests more robust to flakes in CI and
more convenient to run locally.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-07 11:38:12 -04:00
Cory Snider
e3f9edd348 libn/networkdb: advertise the configured bind port
The NetworkDB unit tests instantiate clusters which communicate over
loopback where every "node" listens on a distinct localhost port. The
tests make use of a NetworkDB configuration knob to set the port. When
the NetworkDB configuration's BindPort field is set to a nonzero value,
its memberlist instance is configured to bind to the specified port
number. However, the advertise port is left at the
memberlist.DefaultLANConfig() default value of 7946. Because of this,
nodes would be unable to contact any of the other nodes in the cluster
learned by gossip as the gossiped addresseses specify the wrong ports!
The flaky tests passed as often as they did thanks to the robustness of
the memberlist module: NetworkDB gossip and and memberlist node
liveness-probe pings to unreachable nodes can all be relayed through
the reachable nodes, the nodes on the bootstrap join list.

Make the NetworkDB unit tests less flaky by setting each node's
advertise port to the bind port.

The daemon is unaffected by this oversight as it unconditionally uses
the default listen port of 7946, which aligns with the advertise port.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-07 11:38:12 -04:00
Cory Snider
ec65f2d21b libn/networkdb: fix data race in GetTableByNetwork
The function was accessing the index map without holding the mutex, so
it would race any mutation to the database indexes. Fetch the reference
to the tree's root while holding a read lock. Since the radix tree is
immutable, taking a reference to the root is equivalent to starting a
read-only database transaction, providing a consistent view of the data
at a snapshot in time, even as the live state is mutated concurrently.

Also optimize the WalkTable function by leveraging the immutability of
the radix tree.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-05-07 11:28:17 -04:00
Rob Murray
d71afd73bf Merge pull request #49931 from robmry/commit_cory
Move Cory from Reviewers to Committers
2025-05-07 13:10:03 +01:00
Rob Murray
d0af7c3c08 Move Cory from Reviewers to Committers
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-06 20:49:41 +01:00
Rob Murray
b0777be89e Use firewaller.IPVersion instead of iptables.IPVersion for gwmode
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-06 10:18:22 +01:00
Rob Murray
3cbb1ae736 Move filter-FORWARD DROP setting to the firewaller
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-06 10:18:22 +01:00
Rob Murray
44843d9917 Pass context to more places
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-06 10:18:22 +01:00
Rob Murray
a9bf151260 Put Iptabler behind a Firewaller interface.
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-06 10:18:22 +01:00
Derek McGowan
92e497b9dc Create api interface to define build usage backend
Avoid importing buildkit builder into api package when only a single
backend function is needed.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-05-04 23:18:35 -07: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
Austin Vazquez
453c165be7 Merge pull request #49910 from austinvazquez/update-branches-and-tags-05-01-2025
project: update status of branches for Moby 28.x
2025-05-02 22:19:00 -07:00
Austin Vazquez
9eec936eb0 project: update status of branches for Moby 28.x
Signed-off-by: Austin Vazquez <austin.vazquez.dev@gmail.com>
2025-05-02 22:22:18 -06:00
Sebastiaan van Stijn
d3579b9582 Merge pull request #49885 from mmorel-35/fix-staticcheck
fix staticcheck linting issues for golangci-lint v2
2025-05-01 17:08:40 +02:00
Matthieu MOREL
9315b15dc6 fix(ST1006): Poorly chosen receiver name
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-01 14:30:59 +02:00
Matthieu MOREL
70139978d3 fix(ST1016): Use consistent method receiver names
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-01 14:30:52 +02: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
27bf320a72 fix(ST1017): Don’t use Yoda conditions
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-01 14:17:59 +02:00
Matthieu MOREL
98fa4bcfeb fix(exhaustive): missing cases in switch of type snapshots.Kind
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-01 14:17:58 +02:00
Matthieu MOREL
95af77d038 fix(ST1015): A switch’s default case should be the first or last case
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-01 14:17:58 +02:00
Matthieu MOREL
f770f6c5ec fix(QF1012): Use fmt.Fprintf(x, ...) instead of x.Write(fmt.Sprintf(...))
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-01 14:17:58 +02:00
Matthieu MOREL
a88c49f38e fix(QF1011): Omit redundant type from variable declaration
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-01 14:17:58 +02:00
Matthieu MOREL
4f9214c156 fix(QF1007): Merge conditional assignment into variable declaration
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-01 14:17:49 +02:00
Matthieu MOREL
be54c79d9c fix(QF1006): Lift if+break into loop condition
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-01 14:17:42 +02:00
Matthieu MOREL
2cce9a51ca fix(QF1004): Use strings.ReplaceAll instead of strings.Replace with n == -1
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-01 14:16:45 +02:00
Matthieu MOREL
e2e7f9964f fix(QF1003): Convert if/else-if chain to tagged switch
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-01 14:16:45 +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
Matthieu MOREL
7d8df25d16 fix misused error
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-01 14:16:44 +02:00
Matthieu MOREL
fef139ccc1 fix import
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-01 14:16:44 +02:00
Sebastiaan van Stijn
e547b63e1a Merge pull request #49899 from jsternberg/buildkit-gc-enabled-default
config: set buildkit gc enabled to default to true
2025-05-01 13:18:59 +02:00
Sebastiaan van Stijn
4ae3705d06 Merge pull request #49895 from thaJeztah/linting_fix_noshadow
fix various "no shadow" linting issues (govet)
2025-05-01 13:09:38 +02:00
Akihiro Suda
ef15c13611 Merge pull request #49881 from thaJeztah/bump_md2man
man: vendor github.com/cpuguy83/go-md2man/v2 v2.0.7
2025-05-01 19:22:41 +09:00
Akihiro Suda
6f3ccaf311 Merge pull request #49880 from thaJeztah/bump_cobra
vendor: github.com/spf13/cobra v1.9.1
2025-05-01 19:20:42 +09:00
Akihiro Suda
5e1171a508 Merge pull request #49882 from thaJeztah/bump_runtime_spec
vendor: github.com/opencontainers/runtime-spec v1.2.1
2025-05-01 19:20:08 +09: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
fa23123741 Merge pull request #49832 from robmry/trusted_interfaces
Allow direct routing to container ports from trusted interfaces
2025-05-01 08:50:36 +01: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
Rob Murray
c16caabe36 Add TestNetworkConfigurationMarshalling
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-30 20:59:28 +01:00
Rob Murray
a94643a1b3 bridge: add option com.docker.network.bridge.trusted_host_interfaces
trusted_host_interface have access to published ports on container
addresses - enabling direct routing to the container via those
interfaces.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-30 20:59:28 +01:00
Sebastiaan van Stijn
fb4e0bcd2a Merge pull request #49902 from jsternberg/buildkit-update
vendor: github.com/moby/buildkit v0.21.1
2025-04-30 18:59:05 +02:00
Rob Murray
33f5b9e963 Don't add stub Endpoint/Network object to cache on Sandbox restore
On Sandbox restore if an Endpoint (or Network) can't be loaded from
the store and the container is to be preserved (live-restore), stub
Network and Endpoint objects are created and added to the cache. But
then the Endpoint is just dropped - leaving the stub objects in
cache.

If not-live-restore, the Sandbox is reconstructed do that it can be
deleted by sb.delete(force=true). But, the only thing sb.delete does
with the Endpoint in this case is call ep.Delete. And, ep.Delete
doesn't do anything if the Network and Endpoint can't both be loaded
from the store. So, again, the stub objects are left in the in-memory
cache and nothing that might have needed tidying up got tidied up.

So, whether live-restoring or not, just log an error and ignore an
Endpoint if it can't be loaded from disk.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-30 15:26:14 +01:00
Rob Murray
c129c0fa9f Improve logging and readability of Controller.sandboxRestore
- Use structured logging.
  - Which means ids are logged consistently.
- Use variable 'isRestore' instead of extra map lookups.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-30 12:42:26 +01:00
Rob Murray
5d8192fcce Report endpoint id as well as name in ActiveEndpointsError
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-30 12:42:26 +01:00
Jonathan A. Sternberg
9aa66be7ec vendor: github.com/moby/buildkit v0.21.1
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-04-29 14:49:26 -05:00
Jonathan A. Sternberg
a79d081aa5 config: set buildkit gc enabled to default to true
This will use the default settings for buildkit gc unless explicitly
disabled by setting `enabled: false` in the gc configuration.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-04-29 14:05:57 -05:00
Paweł Gronowski
b0e8932009 Merge pull request #49892 from thaJeztah/bump_go_winres
Dockerfile.windows: update github.com/tc-hib/go-winres to v0.3.3
2025-04-29 08:26:01 +00: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
9ed975a247 daemon: NewDaemon: rename err-return
Prevent accidentally shadowing the error, which is used in a defer.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:50:02 +02:00
Sebastiaan van Stijn
3e586094fc daemon: parseXXVersion: rewrite to be slightly more iodiomatic
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:50:02 +02:00
Sebastiaan van Stijn
2145cf6309 daemon: Daemon.ContainerStatPath, ContainerArchivePath: minor refactor
- remove named error-returns
- make error-handling slightly more idiomatic (check for non-nil errors)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:50:02 +02:00
Sebastiaan van Stijn
6da1ff6bf9 builder/builder-next: fix vars that shadowed (govet)
builder/builder-next/adapters/containerimage/pull.go:912:3: shadow: declaration of "now" shadows declaration at line 905 (govet)
            now := time.Now()
            ^
    builder/builder-next/adapters/snapshot/layer.go:52:4: shadow: declaration of "diffIDs" shadows declaration at line 28 (govet)
                diffIDs, err := s.EnsureLayer(gctx, info.Parent)
                ^
    builder/builder-next/worker/worker.go:577:3: shadow: declaration of "now" shadows declaration at line 570 (govet)
            now := time.Now()
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:42:06 +02:00
Sebastiaan van Stijn
692610414a pkg/plugins: fix vars that shadowed (govet)
pkg/plugins/plugins.go:325:4: shadow: declaration of "pl" shadows declaration at line 315 (govet)
                pl, err := loadWithRetry(name, false)
                ^
    pkg/plugins/pluginrpc-gen/parser.go:153:4: shadow: declaration of "iface" shadows declaration at line 135 (govet)
                iface, ok := spec.Type.(*ast.InterfaceType)
                ^
    pkg/plugins/pluginrpc-gen/parser_test.go:61:2: shadow: declaration of "arg" shadows declaration at line 40 (govet)
        arg := f.Args[0]
        ^
    pkg/plugins/pluginrpc-gen/parser_test.go:165:2: shadow: declaration of "arg" shadows declaration at line 40 (govet)
        arg := f.Args[0]
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:42:06 +02:00
Sebastiaan van Stijn
0fcd23ec13 daemon/logger/loggertest: fix vars that shadowed (govet)
daemon/logger/loggertest/logreader.go:548:14: shadow: declaration of "open" shadows declaration at line 545 (govet)
                case err, open := <-lw.Err:
                          ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:41:08 +02:00
Sebastiaan van Stijn
4c57ffaca7 api/server/router/build: fix vars that shadowed (govet)
api/server/router/build/build_routes.go:212:6: shadow: declaration of "bs" shadows declaration at line 200 (govet)
            if bs, err := parseBytesFromFormValue("max-used-space"); err != nil {
               ^
    api/server/router/build/build_routes.go:218:6: shadow: declaration of "bs" shadows declaration at line 200 (govet)
            if bs, err := parseBytesFromFormValue("min-free-space"); err != nil {
               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:36:30 +02:00
Sebastiaan van Stijn
eef5c75276 api/server/router/network: fix vars that shadowed (govet)
api/server/router/network/network_routes.go:148:14: shadow: declaration of "nwv" shadows declaration at line 146 (govet)
                } else if nwv, ok := listByFullName[nwk.ID]; ok {
                          ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:23:51 +02:00
Sebastiaan van Stijn
7edd83a1b3 libnetwork: fix vars that shadowed, and slight refactor (govet)
libnetwork/network.go:637:6: shadow: declaration of "v" shadows declaration at line 634 (govet)
            if v, ok := n.generic[netlabel.GenericData]; ok {
               ^
    libnetwork/service_linux.go:125:7: shadow: declaration of "ep" shadows declaration at line 86 (govet)
                if ep := sb.getGatewayEndpoint(); ep != nil {
                   ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:23:51 +02:00
Sebastiaan van Stijn
7dbe2f1fb6 libnetwork/portallocator: fix vars that shadowed (govet)
libnetwork/portallocator/portallocator_test.go:151:7: shadow: declaration of "i" shadows declaration at line 150 (govet)
            for i := 0; i <= p.end-p.begin; i++ {
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:23:51 +02:00
Sebastiaan van Stijn
357b136ee9 libnetwork/drivers: fix vars that shadowed (govet)
libnetwork/drivers/overlay/peerdb.go:126:4: shadow: declaration of "peerEntryDB" shadows declaration at line 46 (govet)
                peerEntryDB := entryDBList[0]
                ^
    libnetwork/drivers/bridge/port_mapping_linux.go:862:3: shadow: declaration of "rule" shadows declaration at line 843 (govet)
            rule := iptRule{ipv: ipv, table: iptables.Mangle, chain: "POSTROUTING", args: args}
            ^
    libnetwork/drivers/macvlan/macvlan_network.go:116:3: shadow: declaration of "networkList" shadows declaration at line 68 (govet)
            networkList := d.getNetworks()
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:23:50 +02:00
Sebastiaan van Stijn
f831618e5b libnetwork/networkdb: fix vars that shadowed (govet)
also moved the variables closer to where they're used

    libnetwork/networkdb/cluster.go:414:4: shadow: declaration of "nid" shadows declaration at line 397 (govet)
                nid := params[0]
                ^
    libnetwork/networkdb/networkdb.go:514:4: shadow: declaration of "nid" shadows declaration at line 506 (govet)
                nid := params[0]
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:23:50 +02:00
Sebastiaan van Stijn
f633e8f03f libnetwork/cmd/diagnostic: fix vars that shadowed (govet)
libnetwork/cmd/diagnostic/main.go:198:5: shadow: declaration of "resp" shadows declaration at line 147 (govet)
                    resp, err := http.Get(fmt.Sprintf(deleteEntry, ip, port, network, tableName, k))
                    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:23:47 +02:00
Sebastiaan van Stijn
190ad0610d daemon/logger: remove/rename err-returns and linting warnings
Prevent accidentally shadowing these errors, which are used in defers, and
while at it, also fixed some linting warnings about unhandled errors, and
defers created in a loop.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:06:35 +02:00
Sebastiaan van Stijn
ba15bbc422 daemon/images: rename err-returns to prevent shadowing
Prevent accidentally shadowing the error, which is used in a defer, and
while at it, also fixed some linting warnings about unhandled errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:06:34 +02:00
Sebastiaan van Stijn
48220008d8 daemon/graphdriver: remove/rename err-returns and remove naked returns
Prevent accidentally shadowing these errors, which are used in defers, and
while at it, also fixed some linting warnings about unhandled errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:06:34 +02:00
Sebastiaan van Stijn
088c180a9e daemon/containerd: remove named err-returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:06:34 +02:00
Sebastiaan van Stijn
dc79403f7b daemon/cluster: remove/rename err-returns and remove naked returns
Prevent accidentally shadowing these errors, which are used in defers.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 15:06:31 +02:00
Rob Murray
8d5177b229 Merge pull request #49876 from thaJeztah/pseudo_type_healthstatus
api/types/container: define HealthStatus "pseudo" type
2025-04-28 13:43:50 +01:00
Sebastiaan van Stijn
533f0a0f75 Merge pull request #49877 from thaJeztah/pkg_less_output_vars
pkg/*: reduce named (error)-returns and some minor linting-fixes
2025-04-28 14:41:14 +02:00
Sebastiaan van Stijn
9b62592bfe Dockerfile.windows: update github.com/tc-hib/go-winres to v0.3.3
full diff: https://github.com/tc-hib/go-winres/compare/v0.3.1...v0.3.3
diff of github.com/tc-hib/winres v0.2.1; https://github.com/tc-hib/winres/compare/v0.1.6...v0.2.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 14:34:17 +02:00
Paweł Gronowski
9ee1716c41 Merge pull request #49874 from dmcgowan/container-types-to-api
Use container status values from api
2025-04-28 12:31:46 +00:00
Sebastiaan van Stijn
bf8673db87 Merge pull request #49889 from ChengyuZhu6/hack
hack: Update broken link from README
2025-04-28 14:20:17 +02:00
Paweł Gronowski
1437cf558e Merge pull request #49878 from thaJeztah/api_builder_client_less_output_vars
api, builder, client, container: reduce named (error)-returns, naked returns and some minor linting-fixes
2025-04-28 12:15:38 +00:00
Sebastiaan van Stijn
d6b2aec809 pkg/progress: remove named err-return
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 14:15:19 +02:00
Sebastiaan van Stijn
029f267d9b pkg/pidfile: remove named err-returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 14:15:19 +02:00
Sebastiaan van Stijn
fdbf246889 pkg/parsers: remove named err-returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 14:15:18 +02:00
Sebastiaan van Stijn
b0f93d5283 pkg/fileutils: remove named err-returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 14:15:11 +02:00
Sebastiaan van Stijn
ab8e3da82c pkg/stdcopy: remove/rename err-returns
Prevent accidentally shadowing these errors, which are used in defers, and
while at it, also fixed some linting warnings about unhandled errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 14:14:51 +02:00
Sebastiaan van Stijn
d17a62592f pkg/ioutils: remove named err-returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 14:14:37 +02:00
Sebastiaan van Stijn
f193ff1317 pkg/broadcaster: remove named err-returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-28 14:14:17 +02:00
Paweł Gronowski
e4bf3995d7 Merge pull request #49879 from thaJeztah/volume_use_tempdir
volume/*: use Go's native t.TempDir() in tests
2025-04-28 11:59:20 +00:00
ChengyuZhu6
91f6e00ffa hack: Update broken links from README
Update referencesin hack/README.md from outdated docker URLs to the correct location at /docs/contributing/test.md.

Signed-off-by: ChengyuZhu6 <hudson@cyzhu.com>
2025-04-28 18:57:05 +08:00
Paweł Gronowski
fac076ccf9 Merge pull request #49875 from thaJeztah/use_health_consts
use consts for health-status in tests
2025-04-28 09:52:12 +00:00
Sebastiaan van Stijn
7868d3ee3e vendor: github.com/opencontainers/runtime-spec v1.2.1
full diff: https://github.com/opencontainers/runtime-spec/compare/v1.2.0...v1.2.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 19:02:07 +02:00
Derek McGowan
100102108b Use container status values from api
Alias and deprecate the status types and constants from the root
container package. The root container package is intended for use
within the daemon and no the api package.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-26 07:58:09 -07:00
Sebastiaan van Stijn
878de14c8d man: vendor github.com/cpuguy83/go-md2man/v2 v2.0.7
full diff: https://github.com/cpuguy83/go-md2man/compare/v2.0.6...v2.0.7

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 16:22:46 +02:00
Sebastiaan van Stijn
11f65b566d vendor: github.com/spf13/cobra v1.9.1
full diff: https://github.com/spf13/cobra/compare/v1.8.1...v1.9.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 16:17:55 +02:00
Sebastiaan van Stijn
ea7152e493 volume/local: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 16:07:56 +02:00
Sebastiaan van Stijn
4b41198e3c volume/mounts: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 16:07:56 +02:00
Sebastiaan van Stijn
2b869baea3 volume/service: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 16:07:56 +02:00
Sebastiaan van Stijn
88f6dd72e5 volume/service: rename interface that collided with vars
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 16:07:56 +02:00
Sebastiaan van Stijn
3b4e21081f container: remove unused named-returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 15:47:11 +02:00
Sebastiaan van Stijn
35167dc616 client: Client: PluginInstall, PluginUpgrade: remove/rename err-returns
Prevent accidentally shadowing these errors, which are used in defers, and
while at it, also fixed some linting warnings about unhandled errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 15:47:11 +02:00
Sebastiaan van Stijn
bb57656932 builder/remotecontext: remove unused named and "naked" returns
Also renamed some vars for clarity, renamed a error-returns to prevent
shadowing, and fixed some linter warnings about unhandled errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 15:47:11 +02:00
Sebastiaan van Stijn
5416f2d57c builder/dockerfile: remove unused named and "naked" returns
Also renamed some vars for clarity, renamed a error-returns to prevent
shadowing, and fixed some linter warnings about unhandled errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 15:47:10 +02:00
Sebastiaan van Stijn
f38b1fa30d builder/builder-next: SanitizeRepoAndTags: remove named err return
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 15:47:10 +02:00
Sebastiaan van Stijn
c025dd74f0 builder/builder-next: wrapRC.Read: remove intermediate err-var
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 15:47:10 +02:00
Sebastiaan van Stijn
49d5b2cc8e builder/builder-next: puller.resolve: rename err-return
Prevent accidentally shadowing the error, which is used in a defers, and
while at it, also fixed some linting warnings about unhandled errors and
shadowed vars.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 15:47:10 +02:00
Sebastiaan van Stijn
3f2296cfc1 api/server/router: remove named (err) returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 15:47:05 +02:00
Sebastiaan van Stijn
1e4bb14bcd api/types/container: define HealthStatus "pseudo" type
It currently is an alias for string, but may become a distinct type in future.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 15:26:26 +02:00
Sebastiaan van Stijn
c690e0076a use consts for health-status in tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 15:05:26 +02:00
Sebastiaan van Stijn
91473ce253 api/server/backend/build: sanitizeRepoAndTags: remove named err return
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 13:18:04 +02:00
Sebastiaan van Stijn
c5031c8632 api/types/time: remove named err return
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-26 13:18:03 +02:00
Sebastiaan van Stijn
890d48de19 Merge pull request #49869 from thaJeztah/builder_use_native_tempdir
builder: use t.TempDir() in tests
2025-04-26 13:11:37 +02:00
Rob Murray
19e79906cb Merge pull request #49866 from robmry/drop_enable_ipv_opt_if_overridden
Drop "-o com.docker.network.enable_ipv[46]" if overridden
2025-04-25 15:56:22 +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
eee14cff72 builder/remotecontext: use t.TempDir
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-25 15:27:33 +02:00
Sebastiaan van Stijn
5749bc242a builder/dockerfile: use t.TempDir, rename vars that shadowed
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-25 15:27:33 +02:00
Sebastiaan van Stijn
b54a038bec docker exec: fail early on exec create if specified user doesn't exist
Before this patch, and error would be produced when starting the exec,
but the CLI would wait for the exec to complete, timing out after 10
seconds (default). With this change, an error is returned immediately
when creating the exec.

Note that "technically" this check may have some TOCTOU issues, because
'/etc/passwd' and '/etc/groups' may be mutated by the container in between
creating the exec and starting it.

This is very likely a corner-case, but something we can consider changing
in future (either allow creating an invalid exec, and checking before
starting, or checking both before create and before start).

With this patch:

    printf 'FROM alpine\nRUN rm -f /etc/group' | docker build -t nogroup -
    ID=$(docker run -dit nogroup)

    time docker exec -u 0:root $ID echo hello
    Error response from daemon: unable to find group root: no matching entries in group file

    real	0m0.014s
    user	0m0.010s
    sys	0m0.003s

    # numericc uid/gid (should not require lookup);
    time docker exec -u 0:0 $ID echo hello
    hello

    real	0m0.059s
    user	0m0.007s
    sys	0m0.008s

    # no user specified (should not require lookup);
    time docker exec $ID echo hello
    hello

    real	0m0.057s
    user	0m0.013s
    sys	0m0.008s

    docker rm -fv $ID

    # container that does have a valid /etc/groups

    ID=$(docker run -dit alpine)
    time docker exec -u 0:root $ID echo hello
    hello

    real	0m0.063s
    user	0m0.010s
    sys	0m0.009s

    # non-existing user or group
    time docker exec -u 0:blabla $ID echo hello
    Error response from daemon: unable to find group blabla: no matching entries in group file

    real	0m0.013s
    user	0m0.004s
    sys	0m0.009s

    docker rm -fv $ID

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-25 15:24:00 +02:00
Sebastiaan van Stijn
82fc83ec41 Merge pull request #49863 from robmry/test_legacy_link
Add TestLegacyLink
2025-04-25 14:50:22 +02:00
Rob Murray
37725b5eae Drop "-o com.docker.network.enable_ipv[46]" if overridden
When a network is created with "-o com.docker.network.enable_ipv4'
(including via "default-network-opts" in daemon config), and
EnableIPv4 is present in the API request (including when CLI option
"--ipv4" is used) - the top-level API value is used and the '-o'
is ignored.

But, the "-o" still shows up in Options in inspect output, which is
confusing if the values are different.

So, drop the "-o" if the top-level API option is set. Ditto IPv6.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-25 11:21:13 +01:00
Sebastiaan van Stijn
5ccaf18e8c Merge pull request #49857 from vvoland/todo-build
integration/build: Unskip TestBuildEmitsImageCreateEvent for c8d
2025-04-24 21:25:27 +02:00
Rob Murray
8d0c272e4a Add TestLegacyLink
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-24 20:03:17 +01:00
Sebastiaan van Stijn
b466483877 Merge pull request #49776 from vvoland/vpnkit-moby
Dockerfile: Fetch vpnkit from moby org
2025-04-24 16:19:06 +02:00
Rob Murray
e7599dad7e Merge pull request #49829 from robmry/block_direct_routing_per_container
iptables: Direct routing DROP rules per-container, not per-port
2025-04-24 14:59:06 +01:00
Paweł Gronowski
dfd59c0a95 Dockerfile: Fetch vpnkit from moby org
`moby/vpnkit` now officially pushes a binary image to `moby/vpnkit-bin`
repository on Docker Hub.
Use it to fetch the vpnkit binary.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-24 14:11:00 +02:00
Paweł Gronowski
af0232d52b integration/build: Unskip TestBuildEmitsImageCreateEvent for c8d
The issue is now fixed.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-24 13:38:11 +02:00
Rob Murray
a0ff0a361e iptables: Direct routing DROP rules per-container, not per-port
Commit 27adcd5 ("libnet/d/bridge: drop connections to lo mappings, and
direct remote connections") introduced an iptables rule to drop 'direct'
remote connections made to the container's IP address - for each
published port on the container.

The normal filter-FORWARD rules would then drop packets sent directly to
unpublished ports. This rule was only created along with the rest of port
publishing (when a container's endpoint was selected as its gateway). Until
then, all packets addressed directly to the container's ports were dropped
by the filter-FORWARD rules.

But, the rule doesn't need to be per-port. Just drop packets sent
directly to a container's address unless they originate on the host.

That means fewer rules, that can be created along with the endpoint (then
directly-routed get dropped at the same point whether or not the endpoint
is currently the gateway - very slightly earlier than when it's not the
gateway).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-24 12:00:44 +01:00
Rob Murray
c333c0df17 Merge pull request #49843 from thaJeztah/remotecontext_deprecate_rel
builder/remotecontext: Deprecate Rel()
2025-04-23 15:11:50 +01:00
Rob Murray
59920a733f Merge pull request #49823 from robmry/integration_test_bridge_addrs
Reset default bridge addresses after integration tests
2025-04-23 14:45:02 +01:00
Rob Murray
0451e4fa18 Merge pull request #49788 from robmry/iptabler_package
Move bridge driver iptables code into its own package
2025-04-23 12:32:22 +01:00
Paweł Gronowski
31c7a10822 Merge pull request #49846 from thaJeztah/fix_duplicate_import
fix duplicate import, and force consistent alias for bolt
2025-04-23 10:39:05 +00:00
Rob Murray
dea236e0ce Split iptabler into multiple files
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-23 10:41:15 +01:00
Rob Murray
282b3f7b97 Move bridge driver iptables code into its own package
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-23 10:41:15 +01:00
Rob Murray
8c36a22e79 Rename function insertMirroredWSL2Rule
It's now shouldInsertMirroredWSL2Rule, because it's a test and
doesn't do the insertion.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-23 10:41:15 +01:00
Rob Murray
aa4abaf820 Use firewaller (iptabler) structs in iptables unit tests
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-23 10:41:14 +01:00
Rob Murray
75c60598b7 Move clearConntrackEntries to bridge_linux.go
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-23 10:41:14 +01:00
Sebastiaan van Stijn
6997452eb5 Merge pull request #49817 from AkihiroSuda/fix-49816
CI: deduplicate execution of unit tests
2025-04-22 14:17:29 +02:00
Sebastiaan van Stijn
42d149e45d fix duplicate import, and force consistent alias for bolt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-22 11:31:10 +02:00
Sebastiaan van Stijn
972c3918c5 Merge pull request #43340 from thaJeztah/testing_remove_defers
testing: remove some defer cleanup in favor of test.Cleanup()
2025-04-22 09:43:12 +02:00
Akihiro Suda
c3a7df35e7 Merge pull request #49838 from thaJeztah/remotecontext_clean
builder/remotecontext: MakeGitContext: use "WithFields" for logs
2025-04-20 06:50:32 +09:00
Akihiro Suda
784da88b15 Merge pull request #49839 from thaJeztah/dockerfile_updates
Dockerfile: update cli to v28.1.1, buildx v0.33.0, compose v0.35.1, syntax: docker/dockerfile:1
2025-04-20 06:49:30 +09:00
Akihiro Suda
7305bf47b8 Merge pull request #49844 from thaJeztah/bump_tar_split
vendor: github.com/vbatts/tar-split v0.12.1
2025-04-20 06:48:40 +09: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
e3a0f2e690 vendor: github.com/vbatts/tar-split v0.12.1
archive/tar: fix for CVE-2022-2879

full diff: https://github.com/vbatts/tar-split/compare/v0.11.6...v0.12.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-19 12:28:51 +02:00
Sebastiaan van Stijn
bcc720abde builder/remotecontext: MakeGitContext: use "WithFields" for logs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-18 18:11:40 +02:00
Sebastiaan van Stijn
54a556a5ef builder/remotecontext: Deprecate Rel()
This function was added in 684633f734, because
Go stdlib's filepath.Rel did not support Windows UUID paths (and UNC paths).

UNC paths were fixed in https://golang.org/cl/253197 (go1.17), and I think
UUID paths were also supported now.

To verify the behavior I temporarily added a unit-test to compare between
stdlib and this implementation, and it all looks to work, so we can deprecate
and remove this function. Deprecating first, but there's no (known) external
users of this, so we can likely remove in an upcoming minor (or patch) release.

    func TestRel(t *testing.T) {
        testCases := []struct {
            doc      string
            base     string
            target   string
            expected string
        }{
            {
                doc:      "UNC path",
                base:     `\\server\share`,
                target:   `\\server\share\folder\file.txt`,
                expected: `folder\file.txt`,
            },
            {
                doc:      "UUID path",
                base:     `\\?\Volume{b75e2c83-0000-0000-0000-602f00000000}\data`,
                target:   `\\?\Volume{b75e2c83-0000-0000-0000-602f00000000}\data\file.txt`,
                expected: `file.txt`,
            },
            {
                doc:      "subdirectory",
                base:     `C:\Projects`,
                target:   `C:\Projects\Go\main.go`,
                expected: `Go\main.go`,
            },
            {
                doc:      "same directory",
                base:     `C:\Projects`,
                target:   `C:\Projects`,
                expected: `.`,
            },
            {
                doc:      "parent directory",
                base:     `C:\Projects\Go`,
                target:   `C:\Projects`,
                expected: `..`,
            },
        }

        for _, tc := range testCases {
            t.Run(tc.doc, func(t *testing.T) {
                actual, err := remotecontext.Rel(tc.base, tc.target)
                if err != nil {
                    t.Fatal(err)
                }
                if actual != tc.expected {
                    t.Errorf("expected: %q, got: %q", tc.expected, actual)
                }

                // Try with stdlib
                actual, err = filepath.Rel(tc.base, tc.target)
                if err != nil {
                    t.Fatal(err)
                }
                if actual != tc.expected {
                    t.Errorf("expected: %q, got: %q", tc.expected, actual)
                }
            })
        }
    }

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-18 18:04:43 +02:00
Sebastiaan van Stijn
2808e59f4c Dockerfile: update compose to v2.35.1
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-18 18:00:48 +02:00
Sebastiaan van Stijn
a75be33ba0 Dockerfile: update buildx to v0.23.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-18 18:00:48 +02:00
Sebastiaan van Stijn
dd36139b1a Dockerfile: update cli to v28.1.1
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-18 18:00:42 +02:00
Sebastiaan van Stijn
f1e3ed0c48 Dockerfile: don't pin syntax to 1.7
The syntax was pinned for 1.7 in f696e0d2a7
possibly because it was not yet promoted as "latest stable" at the
time.

I don't think we need to pin to an old version, and just go with
the latest, so that we can use the latest features provided.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-18 18:00:13 +02:00
Akihiro Suda
01f442b84d Merge pull request #49588 from thaJeztah/bump_go_build_tags
update go:build tags to go1.23 to align with vendor.mod
2025-04-18 13:25:23 +09:00
Akihiro Suda
e03c0f03e7 Merge pull request #49834 from thaJeztah/cleanup_ignore
cleanup ignore files
2025-04-18 13:24:33 +09:00
Akihiro Suda
8dde918e77 Merge pull request #49837 from thaJeztah/bump_containerd_2.0.5
vendor: github.com/containerd/containerd v2.0.5, golang.org/x/oauth2 v0.29.0
2025-04-18 13:04:42 +09:00
Akihiro Suda
e70ce7a35b Merge pull request #49833 from vvoland/rootless-iptables-check
contrib/rootless-setuptool: Fix iptables detection
2025-04-18 08:56:51 +09:00
Sebastiaan van Stijn
fc8361c078 vendor: github.com/containerd/containerd v2.0.5
full diff: https://github.com/containerd/containerd/compare/v2.0.4...v2.0.5

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 22:01:00 +02:00
Sebastiaan van Stijn
62f51e4367 vendor: golang.org/x/oauth2 v0.29.0
notable changes

- oauth2.go: use a more straightforward return value
- oauth2: Deep copy context client in NewClient
- jws: improve fix for CVE-2025-22868

full diff: https://github.com/golang/oauth2/compare/v0.27.0...v0.29.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 22:00:44 +02:00
Sebastiaan van Stijn
bbbb0036df cleanup ignore files
- We now only use winresources for the dockerd binary, so we can
  reduce some uses of wildcards
- Use explicit ("/") to indicate these should only be ignored
  relative to the root of the repository and build-context
- Remove remnant ignore for rpm builds

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 19:25:47 +02:00
Paweł Gronowski
ead379a464 contrib/rootless-setuptool: Fix iptables detection
Fix a logical error in the rootless setup tool where the iptables error
handling was incorrectly placed. The code was setting
`faced_iptables_error=1` even when iptables was available, causing
unnecessary error messages and setup suggestions.

This patch correctly moves the error handling into the `else` branch so
that we only report iptables errors when the command is actually
unavailable.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-17 19:23:15 +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
Rob Murray
6573a13e4a Merge pull request #49827 from robmry/warn_no_ext_nameservers
Warn when no external DNS nameservers are found
2025-04-17 14:08:01 +01:00
Rob Murray
619f1ddd05 Warn when no external DNS nameservers are found
Since commit 925b484 ("No fallback nameservers for internal
resolver"), if the host's resolv.conf has no nameservers and
no servers are supplied via config, the internal resolver will
not use Google's DNS - so the container will not be able to
resolve external DNS requests.

That can happen when container's are "restart-always" and the
docker daemon starts before the host's DNS is configured.

So, to highlight the issue (which may not be an error, but
probably is), include a warning in the container's resolv.conf
file.

Also, log a warning - logs currently say "No non-localhost DNS
nameservers are left in resolv.conf. Using default external
servers". But, that's misleading because it's from an initial
resolv.conf setup, before the internal resolver configured without
those fallbacks - we'll drop the fallbacks completely once the
default bridge has an internal resolver).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-17 10:51:06 +01:00
Rob Murray
6083fad7df Reset default bridge addresses after integration tests
CI runs a docker daemon, and some tests run their own. That tramples
the CI daemon's default bridge.

If a test leaves the bridge with only a link-local IPv6 address (for
example), subsequent tests are likely to fail - even if they also
start their own daemon because, by default the default bridge
network's config is based on an existing bridge device.

So, remember the bridge's addresses at the start of each test, and
restore them afterwards.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-16 22:50:19 +01:00
Rob Murray
c2b7abacf8 Use setupTest instead of testutil.StartSpan in tests
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-16 21:59:34 +01:00
Rob Murray
d4e0d6f2a1 Integration tests: use different docker0 addresses
So that, if they leak from a test, it's possible to work out
which test.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-16 19:59:11 +01:00
Paweł Gronowski
3f46cadf39 Merge pull request #49805 from thaJeztah/vendor_goarchive
vendor: github.com/moby/go-archive v0.1.0
2025-04-16 12:07:48 +00:00
Sebastiaan van Stijn
b57d41c4bf Merge pull request #49799 from thaJeztah/apparmor_cleanups
profiles/apparmor: add some optimisations and tests
2025-04-16 13:21:25 +02:00
Sebastiaan van Stijn
29edd17909 Merge pull request #49815 from z63d/docs-api-image-tarball-format
docs/api: update image tarball format
2025-04-16 13:05:21 +02:00
Sebastiaan van Stijn
fd550344b1 vendor: github.com/moby/go-archive v0.1.0
full diff: https://github.com/moby/go-archive/compare/21f3f3385ab7...v0.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-16 13:00:13 +02:00
Akihiro Suda
fd5e772aec CI: deduplicate execution of unit tests
Fix issue 49816

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-04-16 19:59:15 +09:00
Paweł Gronowski
2834da861b Merge pull request #49814 from thaJeztah/initlayer_rm_idtools
daemon/initlayer: Setup: remove uses of idtools.Identity
2025-04-16 09:42:35 +00:00
Paweł Gronowski
1f43ad3a16 Merge pull request #49782 from thaJeztah/container_rm_idtools
container: Container.SetupWorkingDirectory: remove use of pkg/idtools
2025-04-16 09:41:35 +00:00
Kaita Nakamura
b8067d159f docs/api: update image tarball format
Signed-off-by: Kaita Nakamura <kaita.nakamura0830@gmail.com>
2025-04-16 18:02:08 +09: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
Rob Murray
9c9a6cb941 Merge pull request #49812 from robmry/endpoint_count_for_downgrade
Store an endpoint count for networks, for downgrade
2025-04-15 21:59:50 +01:00
Rob Murray
380ded6309 Store an endpoint count for networks, for downgrade
Since commit 51d7f95 ("libnet: remove struct endpointCnt") an
endpoint count for networks has not been persisted.

But, on downgrade to a version older than that commit, the
missing field caused daemon startup to fail.

So, create the count in the store - it only needs to exist, it's
no longer maintained as a count of endpoints. On downgrade, the
count is probably zero anyway (the daemon is stopped), but the
older daemon fixes it up on startup if necessary.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-15 17:59:34 +01:00
Sebastiaan van Stijn
c58a765707 Merge pull request #49809 from crazy-max/buildkit-0.21.0
vendor: update buildkit to v0.21.0
2025-04-15 18:20:39 +02:00
CrazyMax
ae0331d8f5 vendor: update buildkit to v0.21.0
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-04-15 17:04:25 +02:00
Paweł Gronowski
b2d06baf9b Merge pull request #49806 from robmry/missing_firewaller_error_check
bridge: Add a missing error check for firewaller setup
2025-04-15 13:06:27 +00:00
Rob Murray
57bf7a8c70 bridge: Add a missing error check for firewaller setup
It got lost in commit 29e0db2 ("Factor out top-level iptables
setup into its own object").

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-15 12:05:10 +01:00
Paweł Gronowski
bb8fcf3031 Merge pull request #49802 from vvoland/TestStopContainerWithTimeout-noparallel
integration/TestStopContainerWithTimeout: Attempt to fix flakiness
2025-04-14 15:19:25 +00:00
Paweł Gronowski
c49ce64514 integration/TestStopContainerWithTimeout: Attempt to fix flakiness
Temporarily remove Parallel.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-14 12:31:52 +02:00
Akihiro Suda
aa51a79ef9 Merge pull request #49800 from thaJeztah/seccomp_stdlib
profiles/seccomp: use stdlib for asserting, remove "// import" comments
2025-04-13 00:51:57 +09:00
Sebastiaan van Stijn
ecde7b9b7c Merge pull request #49797 from jsternberg/buildkit-rc2
vendor: github.com/moby/buildkit v0.21.0-rc2
2025-04-12 14:25:17 +02:00
Sebastiaan van Stijn
7eda35fd05 profiles/apparmor: IsLoaded: optimize
- Use a bufio.Scanner to read the profiles
- Use strings.Cut

Before/After:

    BenchmarkIsLoaded-10  2258	    508049 ns/op    244266 B/op    10004 allocs/op
    BenchmarkIsLoaded-10  5680	    208703 ns/op      4264 B/op	       4 allocs/op

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-12 13:34:13 +02:00
Sebastiaan van Stijn
0462b5e318 profiles/apparmor: add BenchmarkIsLoaded
go test -bench=. ./profiles/apparmor/
    goos: linux
    goarch: arm64
    pkg: github.com/docker/docker/profiles/apparmor
    BenchmarkIsLoaded-10    	    2258	    508049 ns/op	  244266 B/op	   10004 allocs/op
    PASS
    ok  	github.com/docker/docker/profiles/apparmor	1.210s

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-12 13:34:13 +02:00
Sebastiaan van Stijn
b23d267cb5 profiles/apparmor: add basic unit-test for IsLoaded
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-12 13:34:12 +02:00
Sebastiaan van Stijn
0dd5959eeb profiles/apparmor: InstallDefault: slight cleanup and optimization
The existing code was more complicated than needed. By default, the daemon
runs "unconfined", but we try to detect the current profile that's set.
When failing to do so (error, or detected profile is empty), we assume
the default ("unconfined").

This patch simplifies the logic;

- Set the default ("unconfined")
- Only update the default when we successfully found the current profile
  (no error occurred, and the profile is not empty).

While updating, also;

- Replaced use of `strings.SplitN` for `strings.Cut`, which is more
  efficient, and doesn't allocate.
- Move constructing the profileData closer to where it's used.
- Remove intermediate var.
- Combine defers and change the order (close file first, before removing),
  and suppress errors to keep linters happy.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-12 13:34:12 +02:00
Sebastiaan van Stijn
0bb761698c profiles/apparmor: loadprofile: fix double command in error message
`exec.Cmd.Path` already contains the command that was executed, so we
were printing the command twice. However, `exec.Cmd` implements a stringer
interface, which provides a readable version of the command that was
executed, so use that instead. While updating, lso change backticks in
the error for regular quotes.

Before:

    running `/usr/sbin/apparmor_parser apparmor_parser -Kr /no/such/file` failed with output: Cache read/write disabled: interface file missing. (Kernel needs AppArmor 2.4 compatibility patch.)
    Warning: unable to find a suitable fs in /proc/mounts, is it mounted?
    Use --subdomainfs to override.

    error: exit status 1

After:

    running '/usr/sbin/apparmor_parser -Kr /no/such/file' failed with output: Cache read/write disabled: interface file missing. (Kernel needs AppArmor 2.4 compatibility patch.)
    Warning: unable to find a suitable fs in /proc/mounts, is it mounted?
    Use --subdomainfs to override.

    error: exit status 1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-12 13:34:12 +02:00
Sebastiaan van Stijn
8e1c366773 profiles/apparmor: remove "// import" comments
We are considering moving the apparmor profile to a separate module,
so removing these comments in preparation. These comments are ignored
already when building in go module mode, so have little benefits.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-12 13:34:12 +02:00
Sebastiaan van Stijn
1fa6a46c5d profiles/seccomp: remove "// import" comments
We are considering moving the seccomp profile to a separate module,
so removing these comments in preparation. These comments are ignored
already when building in go module mode, so have little benefits.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-12 10:46:03 +02:00
Sebastiaan van Stijn
89604f1df1 profiles/seccomp: use stdlib for asserting
We are considering moving the seccomp profile to a separate module,
so reducing the list of dependencies for this package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-12 10:26:10 +02:00
Jonathan A. Sternberg
14623770e1 vendor: github.com/moby/buildkit v0.21.0-rc2
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-04-11 14:02:47 -05:00
Paweł Gronowski
250792c1a5 Merge pull request #49795 from thaJeztah/revert_info_changes
Revert "API: /info: remove BridgeNfIptables, BridgeNfIp6tables fields"
2025-04-11 13:17:24 +00:00
Sebastiaan van Stijn
eacbbdeec6 Revert "API: /info: remove BridgeNfIptables, BridgeNfIp6tables fields"
This reverts commit 5d2006256f, which
caused some issues in the docker/cli formatting code that needs some
investigating.

Let's (temporarily) revert this while we look what's wrong.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-11 14:47:10 +02:00
Paweł Gronowski
73520a5ab7 Merge pull request #49793 from vvoland/cut-api
docs/api: add documentation for API v1.49
2025-04-11 11:40:21 +00:00
Paweł Gronowski
36f87754c2 Merge pull request #49794 from vvoland/update-authors
Update AUTHORS
2025-04-11 11:40:06 +00:00
Paweł Gronowski
ece7e02b86 Update AUTHORS
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-11 13:08:52 +02:00
Paweł Gronowski
adb9e9135a docs/api: add documentation for API v1.49
Copy the swagger / OpenAPI file to the documentation. This is the API
version used by the upcoming v28.1.0 release.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-11 13:01:02 +02:00
Paweł Gronowski
f3d6830d27 Merge pull request #49783 from thaJeztah/deprecate_bridgenfip_fields
API: /info: remove BridgeNfIptables, BridgeNfIp6tables fields
2025-04-11 10:46:59 +00:00
Paweł Gronowski
cdad178d02 Merge pull request #49789 from akerouanton/trace-containerCreate-labels
daemon: containerCreate, containerStart: add filtered labels to OTel span
2025-04-11 10:34:02 +00:00
Paweł Gronowski
fb2983ab0d Merge pull request #49677 from vvoland/integration-cli-bump-cli
integration-cli: Update default CLI version to v18.06.3-ce
2025-04-11 10:32:36 +00:00
Sebastiaan van Stijn
a6928fd396 Merge pull request #49787 from thaJeztah/bump_registry
Dockerfile: update registry to v3.0.0
2025-04-10 22:13:58 +02:00
Sebastiaan van Stijn
511cd1c0a7 Merge pull request #49785 from thaJeztah/fix_debug_logs
api/server/middleware: fix debug-logs missing form-data
2025-04-10 21:54:00 +02:00
Sebastiaan van Stijn
e2b95a9525 Merge pull request #49770 from dmcgowan/containerd-registry-error-handling
Add registry error handling for push and pull
2025-04-10 21:32:56 +02:00
Albin Kerouanton
099d3ee008 daemon: containerStart: add filtered labels to OTel span
Like for containerCreate, filter the list of container labels based on
`DOCKER_OTEL_INCLUDE_CONTAINER_LABEL_ATTRS` and put that list in the
OTel span.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-10 19:12:25 +02:00
Albin Kerouanton
0c5e816638 daemon: trace containerCreate
This commit adds a new OTel span to `(*Daemon).containerCreate()` and
puts filtered container labels in the span attributes.

The filter is based on a comma-separated list of labels provided through
the `DOCKER_OTEL_INCLUDE_CONTAINER_LABEL_ATTRS` environment variable.
This label might be removed at any point in time if we figure out a
better way to filter labels, or if that span becomes unecessary.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-10 19:12:25 +02:00
Rob Murray
3fc5bfd565 Merge pull request #49778 from robmry/fix_delete_legacy_link
Fix removal of legacy links
2025-04-10 15:16:00 +01:00
Sebastiaan van Stijn
f96dc9d1a5 Dockerfile: update registry to v3.0.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 15:54:11 +02:00
Rob Murray
4d35864c3d Fix removal of legacy links
It's possible to remove a legacy link from running containers.
When that happens, the Sandbox's Endpoints are removed and
re-added.

Since commit 65120d5 ("Create bridge veth in container netns")
the veth device has been created in the container's netns. When
that happens, a flag is set on the Endpoint to note that it
does not need to be moved into the netns.

But, during the Leave/Join (Sandbox.Refresh) the veth is moved
out of the netns. So, clear the flag during the Leave, to note
that it needs to be moved back in during the Join.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-10 14:22:40 +01:00
Sebastiaan van Stijn
5d2006256f API: /info: remove BridgeNfIptables, BridgeNfIp6tables fields
The `BridgeNfIptables` and `BridgeNfIp6tables` fields in the
`GET /info` response were deprecated in API v1.48, and are now omitted
in API v1.49.

With this patch, old API version continue to return the field:

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.48/info | jq .BridgeNfIp6tables
    false

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.48/info | jq .BridgeNfIptables
    false

Omitting the field in API v1.49 and above

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.49/info | jq .BridgeNfIp6tables
    null

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.49/info | jq .BridgeNfIptables
    null

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 14:26:42 +02:00
Sebastiaan van Stijn
499e15d4ab api/server/middleware: fix debug-logs missing form-data
This was introduced in c817ea2159, but overlooked
that the logs were now produced before (for POST requests) the form-data was
handled and added to the "fields" variable.

This patch changes the logic to wrap the handler and make sure logs are
created before, and after the handler is called (the "form-data" is always
added before the handler is called).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 14:22:31 +02:00
Paweł Gronowski
325076df0c Merge pull request #49765 from robmry/iptables_bridge_driver_level_rules
Put bridge driver's top-level iptables config in a separate object
2025-04-10 11:08:51 +00:00
Sebastiaan van Stijn
97688e8d06 container: Container.SetupWorkingDirectory: remove use of pkg/idtools
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-10 12:30:34 +02:00
Sebastiaan van Stijn
3e993060ee Merge pull request #48556 from thaJeztah/deprecate_info_expected_version_step2
api: info: omit deprecated "Commit.Expected" fields on API >= 1.49
2025-04-10 12:29:48 +02:00
Sebastiaan van Stijn
91ba210bc8 Merge pull request #49666 from thaJeztah/legacy_errors
api, client: produce human-readable errors for unsupported API versions (< v1.24)
2025-04-10 12:08:56 +02:00
Sebastiaan van Stijn
bfbd1004f4 Merge pull request #49762 from thaJeztah/remove_deprecated_AllowNondistributableArtifacts
registry: remove deprecated ServiceConfig.AllowNondistributableArtifacts
2025-04-10 12:08:14 +02:00
Paweł Gronowski
5f9d99b4cc integration-cli/swarm: Update to use gotest.tools
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-10 11:39:18 +02:00
Paweł Gronowski
ea6c76ee03 integration-cli/TestSwarmInit: Skip failing part on CLI after 18.06
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-10 11:39:16 +02:00
Paweł Gronowski
fab94808f5 integration-cli: Update default CLI version to v18.06.3-ce
This updates the Docker CLI version used for integration-cli tests from
v17.06.2-ce to v18.06.3-ce.

v18.06 is the first one that supports enabling BuildKit.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-10 11:39:13 +02:00
Tianon Gravi
6df89e7961 Merge pull request #49775 from dmcgowan/remove-ubuntu-20.04
Update remaining Ubuntu 20.04 GHA uses to 22.04 and 24.04
2025-04-10 00:05:30 +00:00
Sebastiaan van Stijn
466dda63dc Merge pull request #49747 from jsternberg/buildkit-vendor
vendor: github.com/moby/buildkit v0.21.0-rc1
2025-04-10 01:18:47 +02:00
Derek McGowan
6c73266a71 Add registry error handling for push and pull
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-09 14:19:27 -07:00
Jonathan A. Sternberg
ae3a1ac602 vendor: github.com/moby/buildkit v0.21.0-rc1
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-04-09 14:37:09 -05:00
Derek McGowan
cd89a35ea0 Run CLI tests with cgroups v2
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-09 11:05:14 -07:00
Sebastiaan van Stijn
da039bf8e6 Merge pull request #49777 from thaJeztah/bump_x_deps
vendor: update golang.org/x/.. dependencies
2025-04-09 18:05:11 +02:00
Sebastiaan van Stijn
58eabf4b36 Merge pull request #49759 from thaJeztah/migrate_archive_squashed_alt_step2
replace uses of idtools.MkdirAllAndChown, MkdirAllAndChownNew
2025-04-09 17:04:34 +02:00
Albin Kerouanton
888c14749d Merge pull request #47733 from krissetto/otel-test-stack
otel: simple OTEL collector/Jaeger/Aspire stack for testing purposes
2025-04-09 16:25:42 +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
Sebastiaan van Stijn
ba03cd7a63 daemon/config: add test for deprecated daemon.json fields
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 15:26:50 +02:00
Albin Kerouanton
27e7c650b8 Merge pull request #49773 from akerouanton/improve-has-active-endpoints-error
libnet: add ep name in 'has active endpoints' error
2025-04-09 15:14:37 +02:00
Sebastiaan van Stijn
d72e434d30 vendor: golang.org/x/mod v0.24.0
full diff: https://github.com/golang/mod/compare/v0.22.0...v0.24.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 14:28:37 +02:00
Sebastiaan van Stijn
224b393eb3 vendor: golang.org/x/net v0.39.0
full diff: https://github.com/golang/net/compare/v0.36.0...v0.39.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 14:26:51 +02:00
Sebastiaan van Stijn
b1ac2a53ed vendor: golang.org/x/crypto v0.37.0
full diff: https://github.com/golang/crypto/compare/v0.35.0...v0.37.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 14:25:29 +02:00
Sebastiaan van Stijn
a8af27bbae vendor: golang.org/x/text v0.24.0
no changes in vendored files

full diff: https://github.com/golang/text/compare/v0.22.0...v0.24.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 14:23:48 +02:00
Sebastiaan van Stijn
7d49b014b6 vendor: golang.org/x/sync v0.13.0
full diff: https://github.com/golang/sync/compare/v0.11.0...v0.13.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 14:20:16 +02:00
Sebastiaan van Stijn
9d04c28def vendor: golang.org/x/time v0.11.0
full diff: https://github.com/golang/time/compare/v0.6.0...v0.11.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 14:18:22 +02:00
Sebastiaan van Stijn
cdb3590e1a vendor: golang.org/x/sys v0.32.0
full diff: https://github.com/golang/sys/compare/v0.31.0...v0.32.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 14:16:30 +02:00
Christopher Petito
970fc1b6f7 Basic compose file for testing OTEL bits
Signed-off-by: Christopher Petito <chrisjpetito@gmail.com>
2025-04-09 13:48:04 +02:00
Sebastiaan van Stijn
d8a5e8928b replace uses of idtools.MkdirAllAndChown, MkdirAllAndChownNew
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 12:04:42 +02:00
Sebastiaan van Stijn
d96d20d45f update golangci-lint exceptions
These are no longer needed since d0154d3e59

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-09 12:00:50 +02:00
Rob Murray
29e0db25e7 Factor out top-level iptables setup into its own object
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-09 10:54:14 +01:00
Sebastiaan van Stijn
bcbcbb73fa Merge pull request #49743 from dmcgowan/update-archive-to-go-archive
Update archive to use github.com/moby/go-archive
2025-04-09 11:51:14 +02:00
Paweł Gronowski
5172617617 Merge pull request #49774 from akerouanton/fix-ContainerStart-trace
libnet/osl: independent OTel trace for advertiseAddrs
2025-04-09 09:29:48 +00:00
Albin Kerouanton
45daa6de06 Merge pull request #49769 from akerouanton/trace-bridge-createNetwork
libnet/d/bridge: trace createNetwork
2025-04-09 11:28:53 +02:00
Albin Kerouanton
241d685574 libnet: add ep name in 'has active endpoints' error
There have been numerous reports of the "has active endpoints" error
over the years. Historically, there were some faulty code paths that
could lead to this error, but we believe they all have been fixed by
now.

However, users are still facing this error from time to time. Either
because they forgot that some containers are still running, or because
we still have bugs lying around.

To help users figure whether this error is legitimate, and what triggers
it, add endpoint names (which are just container names) to the error
message.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-09 10:53:56 +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
667c7d70b3 libnet/d/bridge: trace network setup steps
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-09 08:45:33 +02:00
Albin Kerouanton
eaae4b5fb6 libnet/d/bridge: put span prefix in var
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
Albin Kerouanton
f8806f2b80 libnet/osl: independent OTel trace for advertiseAddrs
Since commit `eaa84bc`, when a container joins a network, we broadcast
unsolicited ARP/NAs to other containers connected to that network. The
initial advertisement is sent synchronously, and then remaining
advertisements (by default, 2) are sent asynchronously at a regular
interval (by default, 1 second).

An OTel span records the time spent sending subsequent advertisements,
but it's attached to the parent span `libnetwork.osl.AddInterface` so it
affects the overall latency reported by the trace.

The real latency (i.e. excluding the latency of that asynchronous
process), is pretty much what CLI users perceive, so it's an important
measure. It's available on the top-most span in the trace, but limiting
the trace to the real time taken by the Engine to process the HTTP
request seems better.

With this change, the initial advertisement is now tracked by a
dedicated span, and a new independent trace (containing a single span)
is created and linked to the 'initial' span / HTTP trace.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-09 08:43:34 +02:00
Derek McGowan
d0154d3e59 Update to use github.com/moby/go-archive
Update use of idtools to moby/user for archive and other deprecated uses

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-08 17:35:05 -07:00
Derek McGowan
45f9d679f8 Update remaining Ubuntu 20.04 uses to 22.04 and 24.04
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-08 12:50:52 -07:00
Derek McGowan
57a042b77c deprecate pkg/(chroot)archive for github.com/moby/go-archive
- pkg/archive: deprecate, and add aliases
  Keeping the tests in this commit; also moves various utilities
  into a _test.go file, as they were now only used in tests.
- pkg/chrootarchive: deprecate and add aliase
  deprecate pkg/archive and add aliases
  keeping the tests in this commit
- Add temporary exceptions for deprecation linting errors, because
  this commit is to verify everything works with the aliases.
- remove tests that depend on un-exported types

    === RUN   TestDisablePigz
    --- FAIL: TestDisablePigz (0.00s)
    panic: interface conversion: io.Reader is *archive.readCloserWrapper, not *archive.readCloserWrapper (types from different packages) [recovered]

- pkg/archive, pkg/chrootarchive: remove test files

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-08 10:56:58 -07:00
Sebastiaan van Stijn
564abf9157 api: info: omit deprecated "Commit.Expected" fields on API >= 1.49
These fields were deprecated in ff191c58f7,
and are now omitted.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-08 15:15:58 +02:00
Sebastiaan van Stijn
ba12b2d0bc Merge pull request #49749 from thaJeztah/omit_non_distributable
api: /info: omit non-distributable-artifacts fields for API >= 1.49
2025-04-08 15:14:02 +02:00
Paweł Gronowski
cf1001d555 Merge pull request #48563 from crazy-max/dockerfile-dind
dockerfile: dind target to build docker image for testing
2025-04-08 10:33:40 +00:00
Rob Murray
1b187e0959 Merge pull request #49728 from robmry/bridge_driver_firewalld_reload
Stop firewalld reload re-creating rules for deleted networks
2025-04-08 11:18:34 +01:00
CrazyMax
f410dbda88 dockerfile: dind target to build docker image for testing
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-04-08 11:48:33 +02:00
Rob Murray
c3fa7c1779 Test that firewalld reload doesn't re-create deleted iptables rules
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-08 10:27:35 +01:00
Rob Murray
dbea045e0d Report firewalld reload time in Info.FirewallBackend
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-08 10:26:41 +01:00
Rob Murray
a527e5a546 Restore iptables for current networks on firewalld reload
Using iptables.OnReloaded to restore individual per-network rules
on firewalld reload means rules for deleted networks pop back in
to existence (because there was no way to delete the callbacks on
network-delete).

So, on firewalld reload, walk over current networks and ask them
to restore their iptables rules.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-08 10:26:41 +01:00
Rob Murray
9ba5c5d70e Merge pull request #49732 from robmry/nftables_primitives
Add utils for manipulating nftables rules
2025-04-08 09:25:41 +01:00
Akihiro Suda
3509feb1a5 Merge pull request #49763 from thaJeztah/registry_wire_up_contexts
registry: wire up contexts in some places, and remove some intermediate vars
2025-04-08 16:14:31 +09:00
Sebastiaan van Stijn
185651d26b Merge pull request #49767 from thaJeztah/vendor_atomicwriter
vendor: github.com/moby/sys/atomicwriter v0.1.0
2025-04-07 19:17:02 +02:00
Sebastiaan van Stijn
7d9c50db2b api: /info: omit non-distributable-artifacts fields for API >= 1.49
- registry.ServiceConfig: add a "ExtraFields" for outputting deprecated
  fields.
- remove uses of AllowNondistributableArtifactsCIDRs and AllowNondistributableArtifactsHostnames

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-07 19:12:09 +02:00
Paweł Gronowski
ebc6c065d2 Merge pull request #49761 from robmry/add_info_firewallbackend
Add Info.FirewallBackend
2025-04-07 17:00:45 +00:00
Paweł Gronowski
83278485c0 Merge pull request #49734 from Shaggy84675/49709-fix_system_cpu_usage_stat
Fix docker stats parsing with large amount of interrupts
2025-04-07 16:41:25 +00:00
Rob Murray
a0a86d0982 Add Info.FirewallBackend
Report FirewallBackend in "docker info".

It's currently "iptables" or "iptables+firewalld" on Linux, and
omitted on Windows.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-07 16:56:49 +01:00
Sebastiaan van Stijn
25a80bd48e vendor: github.com/moby/sys/atomicwriter v0.1.0
no changes in vendored files

full diff: https://github.com/moby/sys/compare/6e2523cbf3a1...atomicwriter/v0.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-07 17:44:43 +02:00
Paweł Gronowski
d7d91b6bc5 Merge pull request #49764 from akerouanton/fix-TestNetworkStore-TestEndpointStore
libnet: de-flake TestEndpointStore and TestNetworkStore
2025-04-07 15:31:16 +00:00
Sebastiaan van Stijn
96601d1211 Merge pull request #49586 from vvoland/image-inspect-platform
image/inspect: Add platform selection
2025-04-07 16:29:57 +02:00
Albin Kerouanton
4eebd2c920 libnet: TestNetworkStore: replace assert.Equal with Check
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-07 16:25:00 +02:00
Patrik Leifert
e22d04e8a9 Improve CPU usage parsing and error reporting
This fix address issues where the scanner was unable to properly parse longer outputs from /proc/stat. This could happen on an ARM machine with large amount of CPU cores (and interrupts). By switching to reader we have more control over data parsing and dump unnecessary data

Signed-off-by: Patrik Leifert <patrikleifert@hotmail.com>
2025-04-07 16:19:02 +02:00
Albin Kerouanton
40650c6982 libnet: de-flake TestNetworkStore
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-07 16:03:36 +02:00
Albin Kerouanton
1c79c893b1 libnet: de-flake TestEndpointStore
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-07 16:03:03 +02:00
Paweł Gronowski
d9fd0c2db4 Merge pull request #49746 from vvoland/c8d-pull-progress-all
c8d/pull: Show progress for non-layer blobs
2025-04-07 12:40:46 +00:00
Sebastiaan van Stijn
8a5f141b0e registry: Service.lookupV2Endpoints: wire-up context
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-07 13:36:21 +02:00
Sebastiaan van Stijn
9d8c8382d3 registry: authorizeClient: wire-up context
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-07 13:35:03 +02:00
Sebastiaan van Stijn
8b920b2812 registry: loginV2: wire-up context
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-07 13:35:03 +02:00
Sebastiaan van Stijn
4642704ed7 registry: newTransport: remove intermediate var
Align closer to other code doing the same.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-07 13:35:03 +02:00
Paweł Gronowski
7acef8101e c8d/pull: Show progress for non-layer blobs
Use the same logic as push for determining whether a progress should be
shown for a blob.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-07 13:31:04 +02:00
Paweł Gronowski
da3b31fb2c Merge pull request #49736 from akerouanton/cache-endpoint-in-memory
libnet: Controller: cache networks & endpoints in-memory
2025-04-07 10:00:36 +00:00
Paweł Gronowski
4f7588f6ad Merge pull request #49724 from akerouanton/fix-duplicated-port-mappings
libnet: fix duplicated port mappings in overlay networks
2025-04-07 09:57:38 +00:00
Sebastiaan van Stijn
c95e17638f Merge pull request #49757 from thaJeztah/archive_fix_linting
pkg/archive: fix linting issues
2025-04-07 10:18:03 +02:00
Akihiro Suda
b3bafd4b78 Merge pull request #49753 from thaJeztah/idtools_replace
pkg/idtools: MkdirAllAndChownNew: improve deprecation message
2025-04-07 09:00:46 +01:00
Akihiro Suda
e7ab601ab9 Merge pull request #49750 from thaJeztah/bump_go_cmp
vendor: github.com/google/go-cmp v0.7.0
2025-04-07 08:59:43 +01:00
Sebastiaan van Stijn
b3791dea92 pkg/archive: fix linting issues
fix "struct literal uses unkeyed fields" (govet)

    pkg/archive/changes_test.go:123:18: composites: github.com/docker/docker/pkg/archive.Change struct literal uses unkeyed fields (govet)
        modifyChange := Change{"change", ChangeModify}
                        ^
    pkg/archive/changes_test.go:128:15: composites: github.com/docker/docker/pkg/archive.Change struct literal uses unkeyed fields (govet)
        addChange := Change{"change", ChangeAdd}
                     ^
    ...

fix various variables that shadowed types

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-07 08:48:53 +02:00
Akihiro Suda
27568e54ce Merge pull request #49751 from thaJeztah/bump_compress
vendor: github.com/klauspost/compress v1.18.0
2025-04-07 04:52:12 +01:00
Sebastiaan van Stijn
a427477220 pkg/idtools: MkdirAllAndChownNew: improve deprecation message
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-06 13:02:52 +02:00
Sebastiaan van Stijn
a91bcc677b vendor: github.com/klauspost/compress v1.18.0
full diff: https://github.com/klauspost/compress/compare/v1.17.11...v1.18.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-05 16:44:10 +02:00
Sebastiaan van Stijn
2c54f6f316 vendor: github.com/google/go-cmp v0.7.0
full diff: https://github.com/google/go-cmp/v0.6.0...v0.7.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-05 16:42:24 +02:00
Sebastiaan van Stijn
6cbca96bfa Merge pull request #49748 from thaJeztah/migrate_atomicwriter
deprecate pkg/atomicwriter, migrate to github.com/moby/sys/atomicwriter
2025-04-05 11:01:16 +02:00
Sebastiaan van Stijn
79b22645fc Merge pull request #49737 from thaJeztah/bump_golang_1.23.8
update to go1.23.8 (fix CVE-2025-22871)
2025-04-05 11:00:11 +02:00
Sebastiaan van Stijn
6422ff2804 deprecate pkg/atomicwriter, migrate to github.com/moby/sys/atomicwriter
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-04 23:07:00 +02:00
Sebastiaan van Stijn
872b6d5df9 Merge pull request #49738 from thaJeztah/bump_cdi
vendor: tags.cncf.io/container-device-interface v1.0.1
2025-04-04 22:43:21 +02:00
Sebastiaan van Stijn
d7b743b856 Merge pull request #49741 from thaJeztah/atomicwriter_stricter_validate
pkg/atomicwriter: disallow symlinks for now, add more tests and touch-up GoDoc
2025-04-04 20:11:23 +02:00
Sebastiaan van Stijn
43b7c78cbd Merge pull request #49566 from dmcgowan/update-moby-user-idtools
Update `github.com/moby/sys/user` and use of idtools
2025-04-04 18:31:19 +02:00
Sebastiaan van Stijn
5ea21c927c Merge pull request #49745 from thaJeztah/registry_cleanup_step3
registry: wire up context in some places
2025-04-04 17:43:49 +02:00
Sebastiaan van Stijn
f1ec5bf14f pkg/idtools: remove tests already covered in moby/sys/user
Removes all tests, except for TestGetRootUIDGID and TestToContainer, which
are the only once that have a local implementation that's not covered.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-04 08:24:09 -07: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
Derek McGowan
b5c99c0e95 Update moby/sys/user to version which includes mapping
Update idtools to use Mkdir funcs from moby sys/user package
Add deprecation exception to golanci until move off idtools is complete

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-04 08:22:05 -07:00
Sebastiaan van Stijn
0a83a476d8 registry: v1Endpoint.ping: pass through context
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-04 12:59:42 +02:00
Sebastiaan van Stijn
2a272a0c5d registry: newV1Endpoint: pass through context
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-04 12:59:42 +02:00
Sebastiaan van Stijn
f158d2e809 registry: ReadCertsDirectory: internalize, and pass context
- Split the implementation from the exported function (exported
  function is still used by the CLI for Docker Content Trust).
- Pass through context to allow handling context-cancellation
  once wired up in callers.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-04 12:59:36 +02:00
Sebastiaan van Stijn
11bf52e9e3 Merge pull request #49739 from thaJeztah/registry_cleanup_step2
registry: minor fixes and cleanups
2025-04-04 12:30:52 +02:00
Albin Kerouanton
51d7f95c4b libnet: remove struct endpointCnt
endpointCnt is a refcounter used to track how many endpoints use a
network, and how many networks references a config-only network. It's
stored separately from the network.

This is only used to determine if a network can be removed.

This commit removes the `endpointCnt` struct and all its references. The
refcounter is replaced by two lookups in the newly introduced `networks`
and `endpoints` caches added to the `Controller`.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-04 11:21:17 +02:00
Paweł Gronowski
68451d3c99 Merge pull request #49650 from jsternberg/containerd-dangling-image-on-load
containerd: ensure overwritten images from load are left dangling
2025-04-04 09:14:38 +00:00
Albin Kerouanton
d377cd3810 libnet: Controller: cache networks in-memory
The `Controller`'s store is used by:

- `deleteFromStore`
- `getNetworks`
- `getNetworksFromStore`
- `updateToStore`
- … and other methods that can't store / delete / retrieve a Network

Calls to `updateToStore` and `deleteFromStore` have been replaced with
`upsertNetwork` and `deleteNetwork`.

Both `getNetworks` and `getNetworksFromStore` call `cacheNetwork` to
ensure networks loaded from the datastore are kept in-memory.

Finally, `sandboxRestore` was instantiating `Network` itself. These are
cached too.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-04 10:03:02 +02:00
Albin Kerouanton
cc8bd2016e libnet: Controller: cache endpoints in-memory
The `Controller`'s store is used by:

- `deleteFromStore`
- `getEndpointFromStore`
- `getEndpointsFromStore`
- `updateToStore`
- … and other methods that can't store / delete / retrieve an Endpoint

Calls to `updateToStore` and `deleteFromStore` have been replaced with
`upsertEndpoint` and `deleteEndpoint`.

Both `getEndpointFromStore` and `getEndpointsFromStore` call
`cacheEndpoint` to ensure endpoints loaded from the datastore are kept
in-memory.

Finally, `sandboxRestore` was instantiating `Endpoint` itself. These are
cached too.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-04 10:03:02 +02:00
Sebastiaan van Stijn
4ad6854eb3 Merge pull request #49727 from robmry/rootlesskit_iptables_check
Rootless setup: check for module nf_tables
2025-04-04 01:06:14 +02:00
Sebastiaan van Stijn
c6cdfbf495 pkg/atomicwriter: return early if parent directory is invalid
Rewrite `validateDestination` to first check if the destination path
exists. This slightly simplifies the logic (allowing returning
early in each step of the validation) and slightly improves the
error produced.

Before this, the error confusingly would mention the full path
not being a directory. While this _does_ match what `os.Writefile`
would return, it's .. confusing:

    failed to stat output path: lstat ./not-a-dir/new-file.txt: not a directory

After this, the error would mention the directory that doesn't exist:

    invalid output path: stat ./not-a-dir: not a directory

A slight optimization is made as well, now checking for _both_ "."
and ".." as special case, as either path should exist given any current
working directory (unless the working directory has been deleted, but we'd
fail further down the line).

With this change in order, we can also merge `validateFileMode` into
`validateDestination`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-03 21:57:13 +02:00
Sebastiaan van Stijn
00c988caa4 pkg/atomicwriter: add test for parent dir not being a directory
While the target-file does not have to exist, its parent must, and must
be a directory. This adds a test-case to verify the behavior if the
parent is not a directory.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-03 21:39:33 +02:00
Sebastiaan van Stijn
ad386f64e5 pkg/atomicwriter: error on unknown file-modes
Previously, we were silently discarding this situation and hoping that
it would work; let's produce an error instead (we can add additional
filemodes when they arrive and if we need them)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-03 21:39:32 +02:00
Sebastiaan van Stijn
ec82bc35c3 pkg/atomicwriter: disallow symlinked files for now
The implementation uses "os.Rename" to move the temporary file to
the destination, which does not follow symlinks, and because of this
would replace a symlink with a file.

We can consider adding support for symlinked files in future, so that
WriteFile can be used as a drop-in replacement for `os.WriteFile()`
but in the meantime, let's produce an error so that nobody can depend
on this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-03 21:39:32 +02:00
Sebastiaan van Stijn
f3aebbf9d8 pkg/atomicwriter: add basic godoc for package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-03 21:39:21 +02:00
Rob Murray
f80feba181 Rootlesskit: check for module nf_tables
CentOS 10 uses iptables-nft by default, and doesn't have
kernel module ip_tables - so dockerd-rootless-setuptool.sh
reports that the module is missing. It suggests installing
it (which isn't needed), or using --skip-iptables (which
disables iptables in daemon config).

So, unless "iptables --version" command reports "legacy",
check for kernel module "nf_tables" instead of "ip_tables".

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-03 20:25:35 +01:00
Paweł Gronowski
26e516dff4 Merge pull request #49720 from robmry/iptablesnetwork_per_port_rules
Include per-port rules in iptablesNetwork
2025-04-03 18:59:09 +00:00
Rob Murray
7d742ebf75 Add utils for manipulating nftables rules
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-03 16:47:30 +01:00
Paweł Gronowski
59169d0f97 image/inspect: Add platform selection
`GET /image/{name}/json` now supports `platform` parameter allowing to
specify which platform variant of a multi-platform image to inspect.

For servers that do not use containerd image store integration, this
option will cause an error if the requested platform doesn't match the
image's actual platform

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-04-03 13:57:51 +02:00
Sebastiaan van Stijn
d4e70f6325 vendor: tags.cncf.io/container-device-interface v1.0.1
full diff: https://github.com/cncf-tags/container-device-interface/compare/v0.8.1...v1.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-03 13:10:29 +02:00
Sebastiaan van Stijn
74b71c41ac update to go1.23.8 (fix CVE-2025-22871)
full diff: https://github.com/golang/go/compare/go1.23.7...go1.23.8
release notes: https://go.dev/doc/devel/release#go1.24.2

go1.23.8 (released 2025-04-01) includes security fixes to the net/http package,
as well as bug fixes to the runtime and the go command. See the Go 1.23.8
milestone on our issue tracker for details;

https://github.com/golang/go/issues?q=milestone%3AGo1.23.8+label%3ACherryPickApproved

From the mailing list:

Hello gophers,

We have just released Go versions 1.24.2 and 1.23.8, minor point releases.
These minor releases include 1 security fixes following the security policy:

- net/http: request smuggling through invalid chunked data
  The net/http package accepted data in the chunked transfer encoding
  containing an invalid chunk-size line terminated by a bare LF.
  When used in conjunction with a server or proxy which incorrectly
  interprets a bare LF in a chunk extension as part of the extension,
  this could permit request smuggling.
  The net/http package now rejects chunk-size lines containing a bare LF.
  Thanks to Jeppe Bonde Weikop for reporting this issue.
  This is CVE-2025-22871 and Go issue https://go.dev/issue/71988.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-03 12:30:00 +02:00
Sebastiaan van Stijn
fc58c829e8 registry: ParseRepositoryInfo: remove some intermediate vars
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-03 12:10:17 +02:00
Sebastiaan van Stijn
44b7a42fc6 registry: ReadCertsDirectory: return early on error
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-03 12:10:16 +02:00
Sebastiaan van Stijn
4f65e35f02 registry: NewService: return nil on error
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-03 12:10:16 +02:00
Sebastiaan van Stijn
a7daab5df4 registry: authTransport: un-export AuthConfig, RoundTripper
Don't embed these interfaces/types, and keep them internal.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-03 12:10:13 +02:00
Paweł Gronowski
36295bb9ed Merge pull request #49714 from thaJeztah/distribution_cleanups
distribution: cleanup tests, and remove unused fields
2025-04-03 09:26:31 +00:00
Rob Murray
2e92272753 Merge pull request #49735 from thaJeztah/sync_swagger_docs
docs: API v1.48: Add missing platform parameter to ImageGet api docs and add it under Image tag
2025-04-03 09:47:35 +01:00
Sebastiaan van Stijn
5b8a41934b Merge pull request #49729 from robmry/no_rootless_unit_tests
Don't run unit tests with mode rootless
2025-04-02 23:51:12 +02:00
Kristian Heljas
795461eceb docs: api v1.48: Move ImageGet api docs under Image tag
Signed-off-by: Kristian Heljas <kristian@kristian.ee>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-02 23:25:57 +02:00
Kristian Heljas
e1e58409a1 docs: API v1.48 Add missing platform parameter to ImageGetAll api docs
Signed-off-by: Kristian Heljas <kristian@kristian.ee>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-02 23:25:26 +02:00
Rob Murray
b5b6e1b24c Merge pull request #49726 from kristianheljas/image-get-platform-parameter
Add missing platform parameter to ImageGet api docs and add it under Image tag
2025-04-02 19:26:01 +01:00
Albin Kerouanton
db275ddbc1 libnet: fix duplicated port mappings in overlay networks
Since commit f2a183a99, `getEndpointPortMapInfo` is called for all the
endpoints of a container to get its complete list of port mappings. This
is required as multiple endpoints might publish different ports (e.g.
IPv4-only and IPv6-only endpoints mapping an IPv4 and an IPv6 port).

`getEndpointPortMapInfo` calls `(*Endpoint).DriverInfo()` which has a
dodgy behavior: if the endpoint is part of a sandbox that also has an
endpoint for the `docker_gwbridge` network, then `(*Endpoint).DriverInfo()`
returns the DriverInfo of that `docker_gwbridge` endpoint in place of
the current Endpoint's DriverInfo.

On overlay networks, host port-mappings are made through the
`docker_gwbridge` network (which is automatically attached to all Swarm
tasks). This results in duplicated port mappings reported for all Swarm
containers.

Since `getEndpointPortMapInfo` is the only place where
`(*Endpoint).DriverInfo()` is called, just remove that dodgy behavior.

`(*Endpoint).DriverInfo()` has an OS-specific implementation. Unlike the
Linux implementation, on Windows, `DriverInfo()` returns the DriverInfo
of the gateway endpoint _in addition_ to the current Endpoint's
DriverInfo. So it shouldn't be affected by this bug -- don't touch it.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-04-02 12:30:50 +02:00
Rob Murray
a9e22ee5e7 Don't run unit tests with mode rootless
Tests will run in the host's namspace not the rootlesskit
namespace. So, just duplicating the non-rootless unit tests.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-04-02 10:43:40 +01:00
Rob Murray
25905ab6c6 Merge pull request #49718 from vvoland/api-1.49
api: bump API version to 1.49
2025-04-01 19:53:31 +01:00
Kristian Heljas
749e35cf5e Move ImageGet api docs under Image tag
Signed-off-by: Kristian Heljas <kristian@kristian.ee>
2025-04-01 16:06:17 +03:00
Kristian Heljas
094df015b1 Add missing platform parameter to ImageGetAll api docs
Signed-off-by: Kristian Heljas <kristian@kristian.ee>
2025-04-01 16:06:03 +03:00
Sebastiaan van Stijn
843e51459f Merge pull request #49609 from thaJeztah/client_more_canonical
client: keep image refs in canonical format where possible
2025-04-01 09:43:52 +02:00
Sebastiaan van Stijn
b5280352e9 Merge pull request #49608 from thaJeztah/atomicwriter_sequential
pkg/atomicwriter: use sequential file access on Windows
2025-03-31 18:11:18 +02:00
Rob Murray
7243860557 Include per-port rules in iptablesNetwork
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-31 17:04:17 +01:00
Rob Murray
f01a2eb710 Merge pull request #49710 from robmry/simplify_bridge_legacy_links
Simplify bridge legacy links
2025-03-31 16:15:00 +01:00
Paweł Gronowski
4390ab275a api: bump API version to 1.49
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-31 14:09:39 +02:00
Paweł Gronowski
67670ddc80 Merge pull request #49715 from thaJeztah/registry_touchup_ValidateMirror
registry: ValidateMirror: touch-up GoDoc and improve test-coverage
2025-03-31 11:48:46 +00:00
Paweł Gronowski
0cabd9dfba Merge pull request #49713 from thaJeztah/search_pass_context
registry: session.searchRepositories: pass through context
2025-03-31 11:46:47 +00:00
Rob Murray
0b5e1f904a Use netip.Addr instead of net.IP for legacy links
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-31 11:52:16 +01:00
Rob Murray
725e699741 Simplify iptables setup for legacy links
Include legacy link setup in IptablesNetwork, with the other
per-network rules.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-31 11:52:16 +01:00
Rob Murray
c5c9dc0376 Merge pull request #49668 from robmry/iptables_network_rules
Bridge: factor out creation of network-level iptables rules
2025-03-31 11:48:45 +01:00
Sebastiaan van Stijn
31f9ae0d19 registry: TestValidateMirror: improve coverage
Test actual error returned, and test normalized value.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-31 10:14:43 +02:00
Sebastiaan van Stijn
cb0a9d713c registry: ValidateMirror: touch-up GoDoc
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-31 10:11:29 +02:00
Sebastiaan van Stijn
6b258ce567 registry: session.searchRepositories: pass through context
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-31 10:00:23 +02:00
Sebastiaan van Stijn
83aaa3428f distribution: pusher.push(): don't use APIEndpoint.Mirror field
Unlike the equivalent for pulling images, [Service.LookupPushEndpoints]
never returns mirror endpoints, as it calls [Service.lookupV2Endpoints]
with "includeMirrors=false", so we should not use this field, and
unconditionally handle errors without the additional fallbacks that
we consider for pulling images from a mirror.

[Service.LookupPushEndpoints]: cea56c1d9c/registry/service.go (L134-L139)
[Service.lookupV2Endpoints]: cea56c1d9c/registry/service_v2.go (L10-L40)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-31 09:57:05 +02:00
Sebastiaan van Stijn
6439824449 distribution: pushDescriptor: remove unused endpoint field
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-31 09:57:05 +02:00
Sebastiaan van Stijn
09ee47de39 distribution: cleanup some tests and add missing error-checks
- use gotest.tools for assertions
- remove some debug-logs

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-31 09:57:04 +02:00
Rob Murray
37f866285a Merge pull request #49659 from robmry/firewalld_status
Run firewalld in CI
2025-03-28 18:32:18 +00:00
Rob Murray
adfed82ab8 Install and run firewalld for CI's firewalld tests
The github action running bake expected FIREWALLD to be set, but
DOCKER_FIREWALLD was set instead, so firewalld wasn't installed
in the dev image.

The dind-systemd script expected DOCKER_FIREWALLD to be set if it
needed to run firewalld, and it was. But it had no effect.

In CI, bake builds the image then make runs it - and the use the
same env. So, align on FIREWALLD (as it's not a docker feature).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-28 16:59:48 +00:00
Rob Murray
409707b633 bridge: factor out creation of network-level iptables rules
Create an iptablesNetwork containing all the info needed to
set up per-network iptables rules, give it methods to do
create the rules, and use it instead of per-rule-type calls
from driver.createNetwork().

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-28 16:57:16 +00:00
Sebastiaan van Stijn
4cc249d7e3 Merge pull request #49706 from thaJeztah/deprecate_apiendpoint_official
registry: deprecate APIEndpoint.Official field
2025-03-28 16:24:15 +01:00
Sebastiaan van Stijn
81e267c013 Merge pull request #49696 from thaJeztah/registry_cleanup_step1
refactor and simplify various code-paths related to distribution / authentication
2025-03-28 15:48:00 +01:00
Sebastiaan van Stijn
ec7fe73690 distribution: pushDescriptor: rename repoInfo to repoName
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:58 +01:00
Sebastiaan van Stijn
b1c526b4a9 daemon/containerd: remove registryResolver interface
While it's generally better to define interfaces locally, this one
now duplicated distribution.RegistryResolver, and it's passed on
to other types which expect that interface.

Remove this (un-exported) interface to make it easier to discover
what's used where.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:58 +01:00
Sebastiaan van Stijn
0d95e1680a registry: ResolveAuthConfig: inline newIndexInfo code
inline a simplified version of "newIndexInfo" without handling of
insecure registries and mirrors, as we don't need that information
to resolve the auth-config.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:57 +01:00
Sebastiaan van Stijn
6c643bc366 lookup auth-config without depending on RepositoryInfo
Simplify how we lookup auth-config, as we don't need the
additional information provided by RepositoryInfo. There's
still more layers to peel off, which will be done in follow-ups.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:57 +01:00
Sebastiaan van Stijn
a18dae049f daemon/containerd: registryResolver: remove IsInsecureRegistry
It's not called anywhere, so we can remove it from this interface.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:57 +01:00
Sebastiaan van Stijn
abcc70b9ef distribution: GetRepositories skip using Service.ResolveRepository
[Service.ResolveRepository] is a shallow wrapper around [newRepositoryInfo],
from which we only consume the `Name` field. That field is a direct result
of `reference.TrimNamed`, so we can replace this with that.

[Service.ResolveRepository]: ecb03c4cda/registry/service.go (L106-L111)
[newRepositoryInfo]: ecb03c4cda/registry/config.go (L392-L408)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:57 +01:00
Sebastiaan van Stijn
071d8b21e9 distribution: Push: skip using Service.ResolveRepository
[Service.ResolveRepository] is a shallow wrapper around [newRepositoryInfo],
from which we only consume the `Name` field. That field is a direct result
of `reference.TrimNamed`, so we can replace this with that.

[Service.ResolveRepository]: ecb03c4cda/registry/service.go (L106-L111)
[newRepositoryInfo]: ecb03c4cda/registry/config.go (L392-L408)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:57 +01:00
Sebastiaan van Stijn
8b6a045aa4 distribution; newPusher: don't require RepositoryInfo
This constructor only uses the name / reference, and doesn't
use any of the other properties provided in RepositoryInfo.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:56 +01:00
Sebastiaan van Stijn
8653af5854 distribution: pullEndpoints: skip using Service.ResolveRepository
[Service.ResolveRepository] is a shallow wrapper around [newRepositoryInfo],
from which we only consume the `Name` field. That field is a direct result
of `reference.TrimNamed`, so we can replace this with that.

[Service.ResolveRepository]: ecb03c4cda/registry/service.go (L106-L111)
[newRepositoryInfo]: ecb03c4cda/registry/config.go (L392-L408)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:56 +01:00
Sebastiaan van Stijn
20a2807caa distribution: pullEndpoints: don't return RepositoryInfo
we're only consuming the name returned.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:56 +01:00
Sebastiaan van Stijn
f1ecce6877 distribution: pullEndpoints: don't require RepositoryInfo
The callback only used the name / reference

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:56 +01:00
Sebastiaan van Stijn
d6afe88b3c distribution: newPuller: don't require RepositoryInfo
This constructor only uses the name / reference, and doesn't
use any of the other properties provided in RepositoryInfo.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:54 +01:00
Sebastiaan van Stijn
03918c5b07 distribution: layerDescriptor: don't require RepositoryInfo
This type only uses the name / reference, and doesn't use any of the
other properties provided in RepositoryInfo.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:55:04 +01:00
Sebastiaan van Stijn
c91318e6c0 distribution: newRepository: don't require RepositoryInfo
This constructor only uses the name / reference, and doesn't
use any of the other properties provided in RepositoryInfo.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:54:59 +01:00
Sebastiaan van Stijn
2e8bf8b0ab distribution: remove vars that shadowed imports or types
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-28 10:48:10 +01:00
Rob Murray
a420005d4e Merge pull request #49672 from jsternberg/containerd-prioritize-non-dangling
containerd: prioritize non-dangling images with image list
2025-03-27 17:34:25 +00:00
Sebastiaan van Stijn
d8fa2f8071 registry: deprecate APIEndpoint.Official field
This field was introduced in 19515a7ad8 when
the registry code was replaced for code vendored from docker/distribution.

It was used for v1 registries to update the "TrustStore" for signed manifests;
19515a7ad8/graph/pull.go (L89-L93)

Before that, it used the IndexInfo.Official field;
276c640be4/graph/pull.go (L94-L97)

And related to "v2" registries;
88fdcfef02

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-27 15:00:39 +01:00
Rob Murray
0ab6f07c31 Fix TestPassthrough
Doesn't look like it would ever have worked, but:
- init the dbus connection to avoid a segv
- include the chain name when creating the rule
- remove the test rule if it's created

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-27 12:15:16 +00:00
Rob Murray
2d643b6835 Firewalld: skip unit tests that run in their own netns
Firewalld runs in the host netns. So, tests running in
their own netns can't check firewalld's iptables rules.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-27 12:14:20 +00:00
Rob Murray
4fbfb618c3 Skip flaky part of TestAccessPublishedPortFromHost
With firewalld enabled in CI, TestAccessPublishedPortFromHost/userland-proxy=true/IPv6=true
consistently fails when trying to use a link-local address on
eth0 (it's ok for the ULL added by the test).

In a local moby dev container, it passes - although it sometimes
fails when making its request to the host's ::1.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-27 08:36:09 +00:00
Rob Murray
b8323abe0a TestIsolated for IPv6 is broken under firewalld
Skip the test for now.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-27 08:36:09 +00:00
Rob Murray
86eff82789 Firewalld: Skip tests that run dockerd in an L3Segment
The daemon runs in a separate netns, but when it wants to create
an iptables rule it sends a dbus message to firewalld - which is
running in the host's netns.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-27 08:36:09 +00:00
Rob Murray
dc963a00c1 Firewalld should use its nftables backend
Since commit cfc049c the dev container has been using iptables-nft,
but the Dockerfile configured firewalld to use its iptables backend
(if firewalld is enabled, which it accidentally hasn't been in CI).

The integration tests run ok for a while, then some things start
failing with the less than obvious message:

  Error: COMMAND_FAILED: UNKNOWN_ERROR: nonexistent or underflow of priority count

So, let firewalld use its default nftables backend.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-27 08:36:09 +00:00
Rob Murray
b8cacdf324 Add test util "FirewalldRunning"
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-27 08:36:09 +00:00
Rob Murray
cea56c1d9c Merge pull request #49671 from robmry/unit_test_with_firewalld
Run systemd/rootless when systemd/rootless unit testing
2025-03-27 08:34:31 +00:00
Sebastiaan van Stijn
6de8ba3bc5 Merge pull request #49688 from thaJeztah/disable_go_telemetry
Dockerfile: disable saving Golang telemetry in dev-container
2025-03-26 17:25:34 +01:00
Jonathan A. Sternberg
8f506a51e5 containerd: ensure overwritten images from load are left dangling
During a load, ensure any existing images are left as dangling images.
This affects the `docker load` command with the containerd snapshotter
backend.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-03-26 09:20:46 -05:00
Paweł Gronowski
264fc2fac8 Merge pull request #49705 from robmry/continue_if_bridge_port_down
Start containers, even when connected to a disabled bridge port
2025-03-26 13:08:03 +00:00
Paweł Gronowski
849c723078 Merge pull request #46941 from thaJeztah/govalidator
implement module compatibility check
2025-03-26 12:52:10 +00:00
Paweł Gronowski
82b25f0947 Merge pull request #49704 from thaJeztah/bump_image_spec
vendor: github.com/opencontainers/image-spec v1.1.1
2025-03-26 12:44:27 +00:00
Rob Murray
7b2e47846c Run systemd/rootless when systemd/rootless unit testing
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-26 12:13:18 +00:00
Paweł Gronowski
8d9e3502ab hack: Fix TestOverlay* test failure in pkg/archive
The pkg/archive/archive_linux_test.go tests create a test archive
content in a temporary directory. This also includes device nodes (using
mknod).
Running these tests in Docker-in-Docker (dind) with systemd was failing
with "operation not permitted" because the rootfs is remounted with
`nodev`.

This change aligns `hack/dind-systemd` with `hack/dind` by
conditionally mounting a `tmpfs` on `/tmp` (with dev enabled),
to make the mknod work.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-26 12:11:44 +00:00
Paweł Gronowski
fbe2330989 Merge pull request #49693 from vvoland/ifc-to-any
Update `interface{}` to `any`
2025-03-26 11:54:35 +00:00
Rob Murray
f5d84a45cc Start containers, even when connected to a disabled bridge port
Commit 9a6e96f ("Before sending ARPs/NAs, check the bridge is ready")
introduced a check that, if a container's veth is connected to a bridge,
the port is forwarding before sending unsolicited ARP/NA messages to
advertise the container's MAC/IP addresses.

It waited for up-to 200ms, but it seems that's not always enough.

If the port isn't forwarding, the ARP/NA messages will be silently
dropped. But, if it comes up within two seconds, one or both of the
resends will succeed.

So - keep the wait for 200ms but, if anything goes wrong with checking
the bridge port's state, or it's not forwarding after that time, just
log an info/warning level message and continue.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-26 11:46:38 +00:00
Sebastiaan van Stijn
072ea62fcc vendor: github.com/opencontainers/image-spec v1.1.1
full diff: https://github.com/opencontainers/image-spec/compare/v1.1.0...v1.1.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-26 10:01:40 +01:00
Sebastiaan van Stijn
454a7a7358 Merge pull request #49678 from vvoland/c8d-events-tag
c8d/builder: Fix missing `image tag` event with BuildKit
2025-03-25 20:36:26 +01:00
Paweł Gronowski
a60603bfa3 hack/validate: Add gocompat
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-25 16:10:42 +01:00
Sebastiaan van Stijn
2be7f48561 implement module compatibility check
This package imports all "importable" packages, i.e., packages that:

- are not applications ("main")
- are not internal
- and that have non-test go-files

We do this to verify that our code can be consumed as a dependency
in "module mode". When using a dependency that does not have a go.mod
(i.e.; is not a "module"), go implicitly generates a go.mod. Lacking
information from the dependency itself, it assumes "go1.16" language
(see [DefaultGoModVersion]). Starting with Go1.21, go downgrades the
language version used for such dependencies, which means that any
language feature used that is not supported by go1.16 results in a
compile error;

    # github.com/docker/cli/cli/context/store
    /go/pkg/mod/github.com/docker/cli@v25.0.0-beta.2+incompatible/cli/context/store/storeconfig.go:6:24: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)
    /go/pkg/mod/github.com/docker/cli@v25.0.0-beta.2+incompatible/cli/context/store/store.go:74:12: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)

These errors do NOT occur when using GOPATH mode, nor do they occur
when using "pseudo module mode" (the "-mod=mod -modfile=vendor.mod"
approach used in this repository).

As a workaround for this situation, we must include "//go:build" comments
in any file that uses newer go-language features (such as the "any" type
or the "min()", "max()" builtins).

From the go toolchain docs (https://go.dev/doc/toolchain):

> The go line for each module sets the language version the compiler enforces
> when compiling packages in that module. The language version can be changed
> on a per-file basis by using a build constraint.
>
> For example, a module containing code that uses the Go 1.21 language version
> should have a go.mod file with a go line such as go 1.21 or go 1.21.3.
> If a specific source file should be compiled only when using a newer Go
> toolchain, adding //go:build go1.22 to that source file both ensures that
> only Go 1.22 and newer toolchains will compile the file and also changes
> the language version in that file to Go 1.22.

This file is a generated module that imports all packages provided in
the repository, which replicates an external consumer using our code
as a dependency in go-module mode, and verifies all files in those
packages have the correct "//go:build <go language version>" set.

To test this package:

    make -C ./internal/gocompat/
    GO111MODULE=off go generate .
    go mod tidy
    go test -v
    # github.com/docker/docker/libnetwork/options
    ../../libnetwork/options/options.go:45:25: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)
    # github.com/docker/docker/libnetwork/internal/setmatrix
    ../../libnetwork/internal/setmatrix/setmatrix.go:13:16: type parameter requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/internal/setmatrix/setmatrix.go:13:18: predeclared comparable requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/internal/setmatrix/setmatrix.go:14:20: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/internal/setmatrix/setmatrix.go:20:10: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/internal/setmatrix/setmatrix.go:31:10: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/internal/setmatrix/setmatrix.go:43:10: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/internal/setmatrix/setmatrix.go:59:10: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/internal/setmatrix/setmatrix.go:80:10: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/internal/setmatrix/setmatrix.go:93:10: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/internal/setmatrix/setmatrix.go:104:10: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/internal/setmatrix/setmatrix.go:104:10: too many errors
    # github.com/docker/docker/libnetwork/config
    ../../libnetwork/config/config.go:35:47: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/config/config.go:47:41: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/config/config.go:63:55: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/config/config.go:95:63: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)
    # github.com/docker/docker/testutil
    ../../testutil/helpers.go:80:9: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)
    # github.com/docker/docker/builder/builder-next/adapters/containerimage
    ../../builder/builder-next/adapters/containerimage/pull.go:72:4: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../builder/builder-next/adapters/containerimage/pull.go:200:19: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    FAIL	gocompat [build failed]
    make: *** [Makefile:5: verify] Error 1

[DefaultGoModVersion]: 58c28ba286/src/cmd/go/internal/gover/version.go (L15-L24)
[2]: https://go.dev/doc/toolchain

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-25 16:10:42 +01:00
Sebastiaan van Stijn
6430e49a55 Merge pull request #49700 from vvoland/missing-buildtags
Add missing go1.22 build constraints
2025-03-25 14:53:08 +01:00
Paweł Gronowski
cc90726fb8 Add missing go1.22 build constraints
Some recent changes used a newer Go features.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-25 13:45:47 +01:00
Paweł Gronowski
19a0f886da testutil: 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:42:53 +01:00
Paweł Gronowski
f14c23a90f libnetwork: 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:42:51 +01: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
Paweł Gronowski
003bf197d7 container: 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:24 +01:00
Paweł Gronowski
444a1597ff c8d/builder: Fix missing image tag event with BuildKit
The builder `Named` callback was not called with the containerd image
store integration enabled and BuildKit due to wrong imageexporter output
key being used.

We have a test `TestBuildEmitsEvents` that should have detected the bug,
but it wasn't actually working because the CLI version used in the
`integration-cli` didn't support BuildKit yet.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-25 12:02:52 +01:00
Sebastiaan van Stijn
330857ad0f Merge pull request #49698 from jsternberg/buildkit-0.20.2
vendor: github.com/moby/buildkit v0.20.2
2025-03-25 01:30:05 +01:00
Jonathan A. Sternberg
2fce935df2 vendor: github.com/moby/buildkit v0.20.2
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-03-24 15:53:53 -05:00
Akihiro Suda
ecb03c4cda Merge pull request #49691 from thaJeztah/bump_selinux
vendor: github.com/opencontainers/selinux v1.12.0
2025-03-24 20:18:38 +09:00
Akihiro Suda
accda3119d Merge pull request #49562 from thaJeztah/switch_cgroups
switch to github.com/opencontainers/cgroups
2025-03-24 20:08:41 +09:00
Paweł Gronowski
7c09e4e607 TestBuildEmitsEvents: Skip Windows only for buildkit
The test was always skipped on Windows, regardless if buildkit is used
or not.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-24 11:55:30 +01:00
Paweł Gronowski
99356b6e17 integration-cli/TestBuildEmitsEvents: Verify event count
Make sure that the events are not sent twice

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-24 11:55:28 +01:00
Paweł Gronowski
6a0f71cac9 Merge pull request #49686 from thaJeztah/attach_nits
daemon, api/router: minor cleanups in attach and logging code
2025-03-24 10:53:47 +00:00
Paweł Gronowski
e2011affd4 Merge pull request #49692 from thaJeztah/rm_aliases
remove some redundant import-aliases
2025-03-24 10:37:55 +00:00
Sebastiaan van Stijn
3e957c6240 remove some redundant import-aliases
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-24 00:43:31 +01:00
Sebastiaan van Stijn
4db84b197d switch to github.com/opencontainers/cgroups
The runc libcontainer/cgroups package was moved to a separate
module; switch our use of the runc module to use the new
location.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-24 00:36:25 +01:00
Sebastiaan van Stijn
697956a8c7 vendor: github.com/opencontainers/selinux v1.12.0
This release removes deprecated functions from the `label` package,
and improves documentation and error reporting of `SetCreateKey`.

Relevant changes:

-label: remove deprecated stuff
-Improve SetKeyCreate error reporting

full diff: https://github.com/opencontainers/selinux/compare/v1.11.1...v1.12.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-24 00:30:46 +01:00
Akihiro Suda
c1cd4e5eb4 Merge pull request #49683 from thaJeztah/vendor_ebpf
vendor: github.com/cilium/ebpf v0.17.3
2025-03-24 08:27:46 +09:00
Akihiro Suda
f6a642f588 Merge pull request #49689 from thaJeztah/dockerfile_update_registry
Dockerfile: update registry to v3.0.0-rc.4
2025-03-24 08:27:12 +09:00
Akihiro Suda
69a307600d Merge pull request #49690 from thaJeztah/bump_jwt
vendor: github.com/golang-jwt/jwt/v5 v5.2.2
2025-03-24 08:26:49 +09:00
Sebastiaan van Stijn
34bc972519 vendor: github.com/golang-jwt/jwt/v5 v5.2.2
Fixes [GHSA-mh63-6h87-95cp] / [CVE-2025-30204]

full diff: https://github.com/golang-jwt/jwt/compare/v5.2.1...v5.2.2

[GHSA-mh63-6h87-95cp]: https://github.com/golang-jwt/jwt/security/advisories/GHSA-mh63-6h87-95cp
[CVE-2025-30204]: https://www.cve.org/CVERecord?id=CVE-2025-30204

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-23 17:34:42 +01:00
Akihiro Suda
06e319e210 Merge pull request #49687 from thaJeztah/update_delve
Dockerfile: upgrade Delve to v1.24.1
2025-03-24 00:22:41 +09:00
Akihiro Suda
108d7d1004 Merge pull request #49681 from thaJeztah/vendor_runc
vendor: github.com/opencontainers/runc v1.2.6
2025-03-24 00:21:49 +09:00
Sebastiaan van Stijn
c02ca31fbc Merge pull request #49675 from AkihiroSuda/dockerfile-simple
Dockerfile.simple: avoid `Could not find installer for "proxy"`
2025-03-23 15:01:37 +01:00
Sebastiaan van Stijn
d01ee23c15 Dockerfile: update registry to v3.0.0-rc.4
release notes: https://github.com/distribution/distribution/releases/tag/v3.0.0-rc.4
full diff: https://github.com/distribution/distribution/compare/v3.0.0-rc.1...v3.0.0-rc.4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-23 14:57:19 +01:00
Sebastiaan van Stijn
081987b647 Dockerfile: disable saving Golang telemetry in dev-container
Disable collecting local telemetry, as collected by Go and Delve;

- https://github.com/go-delve/delve/blob/v1.24.1/CHANGELOG.md#1231-2024-09-23
- https://go.dev/doc/telemetry#background

Telemetry is only collected, and not sent by default, so let's skip producing
it in the first place, as the dev-container is an ephemeral environment, and
this telemetry is not used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-23 14:46:25 +01:00
Sebastiaan van Stijn
af14f3e7d3 Dockerfile: upgrade Delve to v1.24.1
Update to the latest version:

- https://github.com/go-delve/delve/releases/tag/v1.24.1
- https://github.com/go-delve/delve/blob/v1.24.1/CHANGELOG.md#1241-2025-03-05

Also update links to supported platforms. Delve v1.21.1 and higher now supports
linux/ppc64le (added in [delve@71f1220]), but this looks to be gated behind
an experimental build-tag. We could consider enabling this tag, but skipping
that for now.

[delve@71f1220]: 71f1220717

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-23 14:29:28 +01:00
Sebastiaan van Stijn
d0b4bdbd25 api/router: postContainersAttach, wsContainersAttach: minor cleanups
- remove intermediate variables that were only used once
- move variables closer to where used

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-23 13:29:28 +01:00
Sebastiaan van Stijn
73aa7e933c daemon: daemon.containerAttach: use structured logs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-23 13:29:27 +01:00
Sebastiaan van Stijn
d494520aa0 daemon: daemon.ContainerAttach: use Println instead of Printf
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-23 13:21:23 +01:00
Sebastiaan van Stijn
183ca46099 daemon: daemon.ContainerLogs: move vars closer to where used
- remove intermediate variable that was only used once
- move "follow" variable to where it's used; keeping an intermediate
  variable for now, as the logic related to "follow" and "created"
  could use some comment / documentation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-23 13:11:39 +01:00
Sebastiaan van Stijn
c164eec7e9 daemon: daemon.ContainerAttach: move vars closer to where used
- remove intermediate err vars
- move "multiplexed" variable closer to where used

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-23 13:11:39 +01:00
Sebastiaan van Stijn
f7853799fc daemon: daemon.containerAttach: remove redundant defers
Both these defers were defined in the closure, and would be executed
at the end of the goroutine; inline them to prevent them being confused
for being executed after the function starting the goroutine.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-23 13:11:39 +01:00
Sebastiaan van Stijn
80bf93c9d7 daemon: daemon.containerAttach: rename vars for clarity and prevent shadow
- rename var that shadowed argument
- use consistent name for container arg; We use `ctr` as short name in most
  places; use the same name to make the code slightly more readable.
- rename "logs" argument to prevent it being confused with a logs import
  and to more clearly indicate its a bool

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-23 13:11:29 +01:00
Akihiro Suda
e1e6d35277 Merge pull request #49682 from thaJeztah/bump_runc_binary_1.2.6
Dockerfile: update runc binary to v1.2.6
2025-03-22 03:21:17 +09:00
Sebastiaan van Stijn
daeb6fb0b7 vendor: github.com/cilium/ebpf v0.17.3
full diff: https://github.com/cilium/ebpf/compare/v0.16.0...v0.17.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-21 17:02:01 +01:00
Sebastiaan van Stijn
eeee17eaad Dockerfile: update runc binary to v1.2.6
This is the sixth patch release in the 1.2.z series of runc.
It primarily fixes an issue with runc exec vs time namespace,
and a compatibility issue with older kernels.

* Fix a stall issue that would happen if setting `O_CLOEXEC` with
  `CloseExecFrom` failed.
* `runc` now properly handles joining time namespaces (such as with
  `runc exec`). Previously we would attempt to set the time offsets
  when joining, which would fail.
* Handle `EINTR` retries correctly for socket-related direct
  `golang.org/x/sys/unix` system calls.
* We no longer use `F_SEAL_FUTURE_WRITE` when sealing the runc binary, as it
  turns out this had some unfortunate bugs in older kernel versions and was
  never necessary in the first place.
* Remove `Fexecve` helper from `libcontainer/system`. Runc 1.2.1 removed
  runc-dmz, but we forgot to remove this helper added only for that.
* Use Go 1.23 for official builds, run CI with Go 1.24 and drop Ubuntu 20.04
  from CI. We need to drop Ubuntu 20.04 from CI because Github Actions
  announced it's already deprecated and it will be discontinued soon.

full diff: https://github.com/opencontainers/runc/compare/v1.2.5...v1.2.6

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-21 16:54:24 +01:00
Sebastiaan van Stijn
c1c5f16b8b vendor: github.com/opencontainers/runc v1.2.6
This is the sixth patch release in the 1.2.z series of runc.
It primarily fixes an issue with runc exec vs time namespace,
and a compatibility issue with older kernels.

* Fix a stall issue that would happen if setting `O_CLOEXEC` with
  `CloseExecFrom` failed.
* `runc` now properly handles joining time namespaces (such as with
  `runc exec`). Previously we would attempt to set the time offsets
  when joining, which would fail.
* Handle `EINTR` retries correctly for socket-related direct
  `golang.org/x/sys/unix` system calls.
* We no longer use `F_SEAL_FUTURE_WRITE` when sealing the runc binary, as it
  turns out this had some unfortunate bugs in older kernel versions and was
  never necessary in the first place.
* Remove `Fexecve` helper from `libcontainer/system`. Runc 1.2.1 removed
  runc-dmz, but we forgot to remove this helper added only for that.
* Use Go 1.23 for official builds, run CI with Go 1.24 and drop Ubuntu 20.04
  from CI. We need to drop Ubuntu 20.04 from CI because Github Actions
  announced it's already deprecated and it will be discontinued soon.

full diff: https://github.com/opencontainers/runc/compare/v1.2.5...v1.2.6

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-21 16:49:42 +01:00
Sebastiaan van Stijn
be6e92a57b pkg/atomicwriter: use sequential file access on Windows
Using sequential file access ([FILE_FLAG_SEQUENTIAL_SCAN]) prevents
Windows from aggressively keeping files in the cache, freeing up system
memory for other tasks. On Linux, these changes have no effect, as the
sequential package use the standard (os.CreateTemp, os.OpenFile) on
non-Windows platforms. Refer to the [Win32 API documentation] for details
on sequential file access.

[Win32 API documentation]: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#FILE_FLAG_SEQUENTIAL_SCAN
[FILE_FLAG_SEQUENTIAL_SCAN]: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea#FILE_FLAG_SEQUENTIAL_SCAN

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-21 16:39:28 +01:00
Akihiro Suda
ef56b83597 Merge pull request #49670 from thaJeztah/integration_cli_fixes
integration-cli: minor fixes
2025-03-21 23:48:45 +09:00
Akihiro Suda
452ff75159 Dockerfile.simple: avoid Could not find installer for "proxy"
`Could not find installer for "proxy"` error had been ignored
due to lack of `set -e`

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-03-21 06:35:49 +09:00
Jonathan A. Sternberg
fa21996da5 containerd: prioritize non-dangling images with image list
When listing images, prioritize the tagged version. When computing the
unique images, the last returned image would be used as a base and repo
tags would be merged into it.

This makes it so `RepoDigests` has the correct value when there is both
a dangling and non-dangling version of the same image.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-03-20 14:59:33 -05:00
Sebastiaan van Stijn
126d4cf672 client: remove version-gate for JSON response errors
JSON errors were introduced in API 1.24, and daemons running older versions of
the API would return errors as plain-text. However, such API versions would
also send the corresponding content-type header (text/plain), so we don't
really need to make the code version-dependent; there's already fallbacks
in place to handle JSON-responses that don't use the expected format, in
which case we produce a generic status-code error.

Before this patch, the client would print JSON-responses as-is when the
daemon returned an "API version too old" error;

    DOCKER_API_VERSION=v1.10 docker info --format '{{.ID}}'
    Error response from daemon: {"message":"client version 1.10 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version"}

With this patch, the client detects that the response is JSON, and prints
a friendlier error-message to help the user discover their client is too
old;

    DOCKER_API_VERSION=v1.10 docker info --format '{{.ID}}'
    Error response from daemon: client version 1.10 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-20 20:25:11 +01:00
Sebastiaan van Stijn
230f178f8b api: return plain-text errors for deprecated API versions
Docker 25.0 (08e4e88482) deprecated API versions
older than v1.24, and support was removed in Docker 26.0.

As part of this deprecation, support for plain-text errors was also removed
in commit ffd877f948.

So while we no longer support API versions older 1.24 [api.MinSupportedAPIVersion],
a client may try to connect using an older version and expect a plain-text error
instead of a JSON error. This would result in an "API version too old" error
formatted in JSON being printed as-is.

    DOCKER_API_VERSION=v1.10 docker info --format '{{.ID}}'
    Error response from daemon: {"message":"client version 1.10 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version"}

    curl --unix-socket /var/run/docker.sock http://localhost/v1.10/info
    {"message":"client version 1.10 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version"}

Note that this was only a problem for old API versions; unsupported API versions
that were higher than the maximum version were already handled as JSON;

    DOCKER_API_VERSION=v1.99 docker info --format '{{.ID}}'
    Error response from daemon: client version 1.99 is too new. Maximum supported API version is 1.48

    curl --unix-socket /var/run/docker.sock http://localhost/v1.99/info
    {"message":"client version 1.99 is too new. Maximum supported API version is 1.48"}

Let's be nice, and return errors in plain-text to provide a more readable error
to help the user understand the API version they're using is no longer supported.

With this patch applied:

    DOCKER_API_VERSION=v1.10 docker info --format '{{.ID}}'
    Error response from daemon: client version 1.10 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

    curl --unix-socket /var/run/docker.sock http://localhost/v1.10/info
    client version 1.10 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-20 20:25:05 +01:00
Sebastiaan van Stijn
c7fbe1c2ba integration-cli: fix duplicate close of body
request.ReadBody already closes the body;

    time="2025-03-20T19:08:25Z" level=error msg="subsequent attempt to close ReadCloserWrapper"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-20 20:20:22 +01:00
Sebastiaan van Stijn
1c00755826 integration-cli: fix some unhandled errors
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-20 20:20:22 +01:00
Sebastiaan van Stijn
7b964974e7 Merge pull request #49619 from thaJeztah/atomicwriter_validate
pkg/atomicwriter: fix tempfiles cleanup, improve tests, and validate destination path
2025-03-20 18:24:42 +01:00
Paweł Gronowski
e4079dbbf1 Merge pull request #49660 from thaJeztah/journald_noshadow
daemon/logger/journald: rename func that shadowed builtin
2025-03-20 15:49:03 +00:00
Paweł Gronowski
770200d154 Merge pull request #49648 from robmry/combine_bridge_firewalld_reload_calls
Combine bridge firewalld reload calls
2025-03-20 15:42:51 +00:00
Sebastiaan van Stijn
8be5696c37 daemon/logger/journald: rename func that shadowed builtin
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-19 12:02:59 +01:00
Rob Murray
485cb90b77 Remove duplicate iptables-enabled checks
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-17 10:31:11 +00:00
Rob Murray
fce915897c Combine firewalld reload callbacks for IPv4/IPv6
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-17 10:30:45 +00:00
Sebastiaan van Stijn
1daeaec333 pkg/atomicwriter: validate destination path
- Disallow empty filenames
- Don't allow writing to a directory
- Return early if parent dir doesn't exist
- TBD: do we want to allow symlinks to be followed, or disallow?

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-10 18:23:02 +01:00
Sebastiaan van Stijn
084b7cec1a pkg/atomicwriter: add additional test-cases
- test errors returned for non-existing destination
- test that files are cleaned up after
- test writing to a symlinked file (to be fixed)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-10 17:58:51 +01:00
Sebastiaan van Stijn
ff061e28c1 pkg/atomicwriter: don't overwrite destination on close without write
Creating a writer (`atomicwriter.New()`) and closing it without a write
ever happening, would replace the destination file with an empty file.

This patch adds a check whether a write was performed (either successful
or unsuccessful); if no write happened, we cleanup the tempfile without
replacing the destination file.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-10 17:58:46 +01:00
Sebastiaan van Stijn
88a5bca43c pkg/atomicwriter: add separate tests for New()
We were testing this function implicitly through `TestWriteFile`, but
not verifying the behavior of `New` in isolation. Add separate tests
for this function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-10 17:58:11 +01:00
Sebastiaan van Stijn
09e804f570 pkg/atomicwriter: refactor tests
- rename tests to match the function tested
- remove init func in favor or a test-helper
- rename some vars to prevent shadowing
- update example values to be more descriptive
- add a utility for asserting file content and mode

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-10 17:57:17 +01:00
Sebastiaan van Stijn
0823d76ec5 client: keep image refs in canonical format where possible
Using "familiarname" (e.g. "ubuntu") should be mostly done for presenting
image refernces to the user, but internally, we should use the canonical
format where possible ("docker.io/library/ubuntu").

There's still many places where we use the familiar (short) form, but
let's start with not converting references in the client.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-09 16:52:21 +01:00
3207 changed files with 120910 additions and 42836 deletions

View File

@@ -1,4 +1,6 @@
.git
bundles/
cli/winresources/**/winres.json
cli/winresources/**/*.syso
/.git
# build artifacts
/bundles/
/cli/winresources/dockerd/winres.json
/cli/winresources/dockerd/*.syso

123
.github/workflows/.test-unit.yml vendored Normal file
View File

@@ -0,0 +1,123 @@
# reusable workflow
name: .test-unit
# TODO: hide reusable workflow from the UI. Tracked in https://github.com/community/community/discussions/12025
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
on:
workflow_call:
env:
GO_VERSION: "1.24.4"
GOTESTLIST_VERSION: v0.3.1
TESTSTAT_VERSION: v0.1.25
SETUP_BUILDX_VERSION: edge
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
jobs:
unit:
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
strategy:
fail-fast: false
matrix:
mode:
- ""
- firewalld
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up runner
uses: ./.github/actions/setup-runner
-
name: Prepare
run: |
CACHE_DEV_SCOPE=dev
if [[ "${{ matrix.mode }}" == *"firewalld"* ]]; then
echo "FIREWALLD=true" >> $GITHUB_ENV
CACHE_DEV_SCOPE="${CACHE_DEV_SCOPE}firewalld"
fi
echo "CACHE_DEV_SCOPE=${CACHE_DEV_SCOPE}" >> $GITHUB_ENV
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dev image
uses: docker/bake-action@v6
with:
targets: dev
set: |
dev.cache-from=type=gha,scope=${{ env.CACHE_DEV_SCOPE }}
-
name: Test
run: |
make -o build test-unit
-
name: Prepare reports
if: always()
run: |
mkdir -p bundles /tmp/reports
find bundles -type f \( -name '*-report.json' -o -name '*.log' -o -name '*.out' -o -name '*.prof' -o -name '*-report.xml' \) -print | xargs sudo tar -czf /tmp/reports.tar.gz
tar -xzf /tmp/reports.tar.gz -C /tmp/reports
sudo chown -R $(id -u):$(id -g) /tmp/reports
tree -nh /tmp/reports
-
name: Send to Codecov
uses: codecov/codecov-action@v4
with:
directory: ./bundles
env_vars: RUNNER_OS
flags: unit
token: ${{ secrets.CODECOV_TOKEN }} # used to upload coverage reports: https://github.com/moby/buildkit/pull/4660#issue-2142122533
-
name: Upload reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-unit--${{ matrix.mode }}
path: /tmp/reports/*
retention-days: 1
unit-report:
runs-on: ubuntu-24.04
timeout-minutes: 10
continue-on-error: ${{ github.event_name != 'pull_request' }}
if: always()
needs:
- unit
steps:
-
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: Download reports
uses: actions/download-artifact@v4
with:
pattern: test-reports-unit-*
path: /tmp/reports
-
name: Install teststat
run: |
go install github.com/vearutop/teststat@${{ env.TESTSTAT_VERSION }}
-
name: Create summary
run: |
find /tmp/reports -type f -name '*-go-test-report.json' -exec teststat -markdown {} \+ >> $GITHUB_STEP_SUMMARY

View File

@@ -21,7 +21,7 @@ on:
default: "graphdriver"
env:
GO_VERSION: "1.23.7"
GO_VERSION: "1.24.4"
GOTESTLIST_VERSION: v0.3.1
TESTSTAT_VERSION: v0.1.25
ITG_CLI_MATRIX_SIZE: 6
@@ -32,135 +32,6 @@ env:
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
jobs:
unit-prepare:
runs-on: ubuntu-24.04
timeout-minutes: 10 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
outputs:
includes: ${{ steps.set.outputs.includes }}
steps:
-
name: Create matrix includes
id: set
uses: actions/github-script@v7
with:
script: |
let includes = [
{ mode: '' },
{ mode: 'rootless' },
{ mode: 'systemd' },
];
if ("${{ inputs.storage }}" == "snapshotter") {
includes.push({ mode: 'firewalld' });
}
await core.group(`Set matrix`, async () => {
core.info(`matrix: ${JSON.stringify(includes)}`);
core.setOutput('includes', JSON.stringify(includes));
});
-
name: Show matrix
run: |
echo ${{ steps.set.outputs.includes }}
unit:
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
needs:
- unit-prepare
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.unit-prepare.outputs.includes) }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up runner
uses: ./.github/actions/setup-runner
-
name: Prepare
run: |
CACHE_DEV_SCOPE=dev
if [[ "${{ matrix.mode }}" == *"firewalld"* ]]; then
echo "DOCKER_FIREWALLD=true" >> $GITHUB_ENV
CACHE_DEV_SCOPE="${CACHE_DEV_SCOPE}firewalld"
fi
echo "CACHE_DEV_SCOPE=${CACHE_DEV_SCOPE}" >> $GITHUB_ENV
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dev image
uses: docker/bake-action@v6
with:
targets: dev
set: |
dev.cache-from=type=gha,scope=dev
-
name: Test
run: |
make -o build test-unit
-
name: Prepare reports
if: always()
run: |
mkdir -p bundles /tmp/reports
find bundles -path '*/root/*overlay2' -prune -o -type f \( -name '*-report.json' -o -name '*.log' -o -name '*.out' -o -name '*.prof' -o -name '*-report.xml' \) -print | xargs sudo tar -czf /tmp/reports.tar.gz
tar -xzf /tmp/reports.tar.gz -C /tmp/reports
sudo chown -R $(id -u):$(id -g) /tmp/reports
tree -nh /tmp/reports
-
name: Send to Codecov
uses: codecov/codecov-action@v4
with:
directory: ./bundles
env_vars: RUNNER_OS
flags: unit
token: ${{ secrets.CODECOV_TOKEN }} # used to upload coverage reports: https://github.com/moby/buildkit/pull/4660#issue-2142122533
-
name: Upload reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-unit-${{ inputs.storage }}-${{ matrix.mode }}
path: /tmp/reports/*
retention-days: 1
unit-report:
runs-on: ubuntu-24.04
timeout-minutes: 10
continue-on-error: ${{ github.event_name != 'pull_request' }}
if: always()
needs:
- unit
steps:
-
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: Download reports
uses: actions/download-artifact@v4
with:
pattern: test-reports-unit-${{ inputs.storage }}-*
path: /tmp/reports
-
name: Install teststat
run: |
go install github.com/vearutop/teststat@${{ env.TESTSTAT_VERSION }}
-
name: Create summary
run: |
find /tmp/reports -type f -name '*-go-test-report.json' -exec teststat -markdown {} \+ >> $GITHUB_STEP_SUMMARY
docker-py:
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
@@ -219,7 +90,7 @@ jobs:
retention-days: 1
integration-flaky:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
steps:
@@ -264,14 +135,12 @@ jobs:
with:
script: |
let includes = [
{ os: 'ubuntu-20.04', mode: '' },
{ os: 'ubuntu-20.04', mode: 'rootless' },
{ os: 'ubuntu-20.04', mode: 'systemd' },
{ os: 'ubuntu-24.04', mode: '' },
{ os: 'ubuntu-22.04', mode: '' },
{ os: 'ubuntu-22.04', mode: 'rootless' },
{ os: 'ubuntu-22.04', mode: 'systemd' },
{ os: 'ubuntu-24.04', mode: '' },
// { os: 'ubuntu-24.04', mode: 'rootless' }, // FIXME: https://github.com/moby/moby/pull/49579#issuecomment-2698622223
{ os: 'ubuntu-24.04', mode: 'systemd' },
// { os: 'ubuntu-20.04', mode: 'rootless-systemd' }, // FIXME: https://github.com/moby/moby/issues/44084
// { os: 'ubuntu-24.04', mode: 'rootless-systemd' }, // FIXME: https://github.com/moby/moby/issues/44084
];
if ("${{ inputs.storage }}" == "snapshotter") {
@@ -318,7 +187,7 @@ jobs:
CACHE_DEV_SCOPE="${CACHE_DEV_SCOPE}systemd"
fi
if [[ "${{ matrix.mode }}" == *"firewalld"* ]]; then
echo "DOCKER_FIREWALLD=true" >> $GITHUB_ENV
echo "FIREWALLD=true" >> $GITHUB_ENV
CACHE_DEV_SCOPE="${CACHE_DEV_SCOPE}firewalld"
fi
echo "CACHE_DEV_SCOPE=${CACHE_DEV_SCOPE}" >> $GITHUB_ENV
@@ -485,7 +354,7 @@ jobs:
echo ${{ steps.set.outputs.matrix }}
integration-cli:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
needs:
@@ -508,7 +377,7 @@ jobs:
run: |
CACHE_DEV_SCOPE=dev
if [[ "${{ matrix.mode }}" == *"firewalld"* ]]; then
echo "DOCKER_FIREWALLD=true" >> $GITHUB_ENV
echo "FIREWALLD=true" >> $GITHUB_ENV
CACHE_DEV_SCOPE="${CACHE_DEV_SCOPE}firewalld"
fi
echo "CACHE_DEV_SCOPE=${CACHE_DEV_SCOPE}" >> $GITHUB_ENV

View File

@@ -28,7 +28,7 @@ on:
default: false
env:
GO_VERSION: "1.23.7"
GO_VERSION: "1.24.4"
GOTESTLIST_VERSION: v0.3.1
TESTSTAT_VERSION: v0.1.25
WINDOWS_BASE_IMAGE: mcr.microsoft.com/windows/servercore

View File

@@ -23,7 +23,7 @@ on:
pull_request:
env:
GO_VERSION: "1.23.7"
GO_VERSION: "1.24.4"
TESTSTAT_VERSION: v0.1.25
DESTDIR: ./build
SETUP_BUILDX_VERSION: edge

View File

@@ -65,13 +65,10 @@ jobs:
# moby/moby-bin:master
## push on 23.0 branch
# moby/moby-bin:23.0
## any push
# moby/moby-bin:sha-ad132f5
tags: |
type=semver,pattern={{version}}
type=ref,event=branch
type=ref,event=pr
type=sha
-
name: Rename meta bake definition file
# see https://github.com/docker/metadata-action/issues/381#issuecomment-1918607161
@@ -94,7 +91,7 @@ jobs:
build:
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
timeout-minutes: 20 # guardrails timeout for the whole job
needs:
- validate-dco
- prepare
@@ -170,7 +167,7 @@ jobs:
merge:
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
timeout-minutes: 40 # guardrails timeout for the whole job
needs:
- build
if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && github.event_name != 'pull_request' && github.repository == 'moby/moby'

View File

@@ -23,7 +23,7 @@ on:
pull_request:
env:
GO_VERSION: "1.23.7"
GO_VERSION: "1.24.4"
DESTDIR: ./build
SETUP_BUILDX_VERSION: edge
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
@@ -32,7 +32,7 @@ jobs:
validate-dco:
uses: ./.github/workflows/.dco.yml
build:
build-linux:
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
needs:
@@ -59,11 +59,11 @@ jobs:
if-no-files-found: error
retention-days: 1
test:
test-linux:
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
needs:
- build
- build-linux
env:
TEST_IMAGE_BUILD: "0"
TEST_IMAGE_ID: "buildkit-tests"
@@ -162,3 +162,213 @@ jobs:
TESTPKGS: "./${{ matrix.pkg }}"
TESTFLAGS: "-v --parallel=1 --timeout=30m --run=//worker=${{ matrix.worker }}$"
working-directory: buildkit
build-windows:
runs-on: windows-2022
timeout-minutes: 120
needs:
- validate-dco
env:
GOPATH: ${{ github.workspace }}\go
GOBIN: ${{ github.workspace }}\go\bin
BIN_OUT: ${{ github.workspace }}\out
WINDOWS_BASE_IMAGE: mcr.microsoft.com/windows/servercore
WINDOWS_BASE_TAG_2022: ltsc2022
TEST_IMAGE_NAME: moby:test
TEST_CTN_NAME: moby
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/docker/docker
steps:
- name: Checkout
uses: actions/checkout@v4
with:
path: ${{ env.GOPATH }}/src/github.com/docker/docker
- name: Env
run: |
Get-ChildItem Env: | Out-String
- name: Moby - Init
run: |
New-Item -ItemType "directory" -Path "${{ github.workspace }}\go-build"
New-Item -ItemType "directory" -Path "${{ github.workspace }}\go\pkg\mod"
echo "WINDOWS_BASE_IMAGE_TAG=${{ env.WINDOWS_BASE_TAG_2022 }}" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
- name: Cache
uses: actions/cache@v4
with:
path: |
~\AppData\Local\go-build
~\go\pkg\mod
${{ github.workspace }}\go-build
${{ env.GOPATH }}\pkg\mod
key: ${{ inputs.os }}-${{ github.job }}-${{ hashFiles('**/vendor.sum') }}
restore-keys: |
${{ inputs.os }}-${{ github.job }}-
- name: Docker info
run: |
docker info
- name: Build base image
run: |
& docker build `
--build-arg WINDOWS_BASE_IMAGE `
--build-arg WINDOWS_BASE_IMAGE_TAG `
--build-arg GO_VERSION `
-t ${{ env.TEST_IMAGE_NAME }} `
-f Dockerfile.windows .
- name: Build binaries
run: |
& docker run --name ${{ env.TEST_CTN_NAME }} -e "DOCKER_GITCOMMIT=${{ github.sha }}" `
-v "${{ github.workspace }}\go-build:C:\Users\ContainerAdministrator\AppData\Local\go-build" `
-v "${{ github.workspace }}\go\pkg\mod:C:\gopath\pkg\mod" `
${{ env.TEST_IMAGE_NAME }} hack\make.ps1 -Daemon -Client
go install github.com/distribution/distribution/v3/cmd/registry@latest
- name: Checkout BuildKit
uses: actions/checkout@v4
with:
repository: moby/buildkit
ref: master
path: buildkit
- name: Add buildctl to binaries
run: |
go install ./cmd/buildctl
working-directory: buildkit
- name: Copy artifacts
run: |
New-Item -ItemType "directory" -Path "${{ env.BIN_OUT }}"
docker cp "${{ env.TEST_CTN_NAME }}`:c`:\gopath\src\github.com\docker\docker\bundles\docker.exe" ${{ env.BIN_OUT }}\
docker cp "${{ env.TEST_CTN_NAME }}`:c`:\gopath\src\github.com\docker\docker\bundles\dockerd.exe" ${{ env.BIN_OUT }}\
docker cp "${{ env.TEST_CTN_NAME }}`:c`:\gopath\bin\gotestsum.exe" ${{ env.BIN_OUT }}\
docker cp "${{ env.TEST_CTN_NAME }}`:c`:\containerd\bin\containerd.exe" ${{ env.BIN_OUT }}\
docker cp "${{ env.TEST_CTN_NAME }}`:c`:\containerd\bin\containerd-shim-runhcs-v1.exe" ${{ env.BIN_OUT }}\
cp ${{ env.GOPATH }}\bin\registry.exe ${{ env.BIN_OUT }}
cp ${{ env.GOPATH }}\bin\buildctl.exe ${{ env.BIN_OUT }}
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: build-windows
path: ${{ env.BIN_OUT }}/*
if-no-files-found: error
retention-days: 2
test-windows:
runs-on: windows-2022
timeout-minutes: 120 # guardrails timeout for the whole job
needs:
- build-windows
env:
TEST_IMAGE_BUILD: "0"
TEST_IMAGE_ID: "buildkit-tests"
GOPATH: ${{ github.workspace }}\go
GOBIN: ${{ github.workspace }}\go\bin
BIN_OUT: ${{ github.workspace }}\out
TESTFLAGS: "-v --timeout=90m"
TEST_DOCKERD: "1"
strategy:
fail-fast: false
matrix:
worker:
- dockerd-containerd
pkg:
- ./client#1-4
- ./client#2-4
- ./client#3-4
- ./client#4-4
- ./cmd/buildctl
- ./frontend
- ./frontend/dockerfile#1-12
- ./frontend/dockerfile#2-12
- ./frontend/dockerfile#3-12
- ./frontend/dockerfile#4-12
- ./frontend/dockerfile#5-12
- ./frontend/dockerfile#6-12
- ./frontend/dockerfile#7-12
- ./frontend/dockerfile#8-12
- ./frontend/dockerfile#9-12
- ./frontend/dockerfile#10-12
- ./frontend/dockerfile#11-12
- ./frontend/dockerfile#12-12
steps:
- name: Prepare
shell: bash
run: |
disabledFeatures="cache_backend_azblob,cache_backend_s3"
if [ "${{ matrix.worker }}" = "dockerd" ]; then
disabledFeatures="${disabledFeatures},merge_diff"
fi
echo "BUILDKIT_TEST_DISABLE_FEATURES=${disabledFeatures}" >> $GITHUB_ENV
- name: Expose GitHub Runtime
uses: crazy-max/ghaction-github-runtime@v3
- name: Checkout
uses: actions/checkout@v4
with:
path: moby
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
- name: BuildKit ref
shell: bash
run: |
echo "$(./hack/buildkit-ref)" >> $GITHUB_ENV
working-directory: moby
- name: Checkout BuildKit ${{ env.BUILDKIT_REF }}
uses: actions/checkout@v4
with:
repository: ${{ env.BUILDKIT_REPO }}
ref: ${{ env.BUILDKIT_REF }}
path: buildkit
- name: Download Moby artifacts
uses: actions/download-artifact@v4
with:
name: build-windows
path: ${{ env.BIN_OUT }}
- name: Add binaries to PATH
run: |
ls ${{ env.BIN_OUT }}
Write-Output "${{ env.BIN_OUT }}" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
- name: Test Prep
shell: bash
run: |
TESTPKG=$(echo "${{ matrix.pkg }}" | awk '-F#' '{print $1}')
echo "TESTPKG=$TESTPKG" >> $GITHUB_ENV
echo "TEST_REPORT_NAME=${{ github.job }}-$(echo "${{ matrix.pkg }}-${{ matrix.worker }}" | tr -dc '[:alnum:]-\n\r' | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
testFlags="${{ env.TESTFLAGS }}"
testSlice=$(echo "${{ matrix.pkg }}" | awk '-F#' '{print $2}')
testSliceOffset=""
if [ -n "$testSlice" ]; then
testSliceOffset="slice=$testSlice/"
fi
if [ -n "${{ matrix.worker }}" ]; then
testFlags="${testFlags} --run=TestIntegration/$testSliceOffset.*/worker=${{ matrix.worker }}"
fi
echo "TESTFLAGS=${testFlags}" >> $GITHUB_ENV
- name: Test
shell: bash
run: |
mkdir -p ./bin/testreports
gotestsum \
--jsonfile="./bin/testreports/go-test-report-${{ env.TEST_REPORT_NAME }}.json" \
--junitfile="./bin/testreports/junit-report-${{ env.TEST_REPORT_NAME }}.xml" \
--packages="${{ env.TESTPKG }}" \
-- \
"-mod=vendor" \
"-coverprofile" "./bin/testreports/coverage-${{ env.TEST_REPORT_NAME }}.txt" \
"-covermode" "atomic" ${{ env.TESTFLAGS }}
working-directory: buildkit

View File

@@ -154,3 +154,23 @@ jobs:
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ env.DESTDIR }}/govulncheck.out
build-dind:
runs-on: ubuntu-24.04
needs:
- validate-dco
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dind image
uses: docker/bake-action@v6
with:
targets: dind
set: |
*.output=type=cacheonly

View File

@@ -58,7 +58,7 @@ jobs:
- name: Update Go
uses: actions/setup-go@v5
with:
go-version: "1.23.7"
go-version: "1.24.4"
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:

View File

@@ -23,7 +23,7 @@ on:
pull_request:
env:
GO_VERSION: "1.23.7"
GO_VERSION: "1.24.4"
GIT_PAGER: "cat"
PAGER: "cat"
SETUP_BUILDX_VERSION: edge
@@ -83,6 +83,13 @@ jobs:
with:
storage: ${{ matrix.storage }}
test-unit:
needs:
- build-dev
- validate-dco
uses: ./.github/workflows/.test-unit.yml
secrets: inherit
validate-prepare:
runs-on: ubuntu-24.04
timeout-minutes: 10 # guardrails timeout for the whole job

7
.gitignore vendored
View File

@@ -14,10 +14,9 @@ thumbs.db
.editorconfig
# build artifacts
bundles/
cli/winresources/*/*.syso
cli/winresources/*/winres.json
contrib/builder/rpm/*/changelog
/bundles/
/cli/winresources/dockerd/*.syso
/cli/winresources/dockerd/winres.json
# ci artifacts
*.exe

View File

@@ -1,244 +1,345 @@
linters:
enable:
- asasalint # Detects "[]any" used as argument for variadic "func(...any)".
- copyloopvar # Detects places where loop variables are copied.
- depguard
- dogsled # Detects assignments with too many blank identifiers.
- dupword # Detects duplicate words.
- durationcheck # Detect cases where two time.Duration values are being multiplied in possibly erroneous ways.
- errchkjson # Detects unsupported types passed to json encoding functions and reports if checks for the returned error can be omitted.
- exhaustive # Detects missing options in enum switch statements.
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions.
- fatcontext # Detects nested contexts in loops and function literals.
- gocheckcompilerdirectives # Detects invalid go compiler directive comments (//go:).
- goimports
- gosec # Detects security problems.
- gosimple
- govet
- forbidigo
- iface # Detects incorrect use of interfaces. Currently only used for "identical" interfaces in the same package.
- importas
- ineffassign
- makezero # Finds slice declarations with non-zero initial length.
- mirror # Detects wrong mirror patterns of bytes/strings usage.
- misspell # Detects commonly misspelled English words in comments.
- nakedret # Detects uses of naked returns.
- nilnesserr # Detects returning nil errors. It combines the features of nilness and nilerr,
- nosprintfhostport # Detects misuse of Sprintf to construct a host with port in a URL.
- reassign # Detects reassigning a top-level variable in another package.
- revive # Metalinter; drop-in replacement for golint.
- spancheck # Detects mistakes with OpenTelemetry/Census spans.
- staticcheck
- typecheck
- unconvert # Detects unnecessary type conversions.
- unused
- wastedassign # Detects wasted assignment statements.
disable:
- errcheck
version: "2"
run:
# prevent golangci-lint from deducting the go version to lint for through go.mod,
# which causes it to fallback to go1.17 semantics.
go: "1.23.7"
go: "1.24.4"
concurrency: 2
# Only supported with go modules enabled (build flag -mod=vendor only valid when using modules)
# modules-download-mode: vendor
linters-settings:
depguard:
formatters:
enable:
- gofmt
- goimports
linters:
enable:
- asasalint # Detects "[]any" used as argument for variadic "func(...any)".
- copyloopvar # Detects places where loop variables are copied.
- depguard
- dogsled # Detects assignments with too many blank identifiers.
- dupword # Detects duplicate words.
- durationcheck # Detect cases where two time.Duration values are being multiplied in possibly erroneous ways.
- errorlint # Detects code that will cause problems with the error wrapping scheme introduced in Go 1.13.
- errchkjson # Detects unsupported types passed to json encoding functions and reports if checks for the returned error can be omitted.
- exhaustive # Detects missing options in enum switch statements.
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions.
- fatcontext # Detects nested contexts in loops and function literals.
- forbidigo
- gocheckcompilerdirectives # Detects invalid go compiler directive comments (//go:).
- gocritic # Detects for bugs, performance and style issues.
- gosec # Detects security problems.
- govet
- iface # Detects incorrect use of interfaces. Currently only used for "identical" interfaces in the same package.
- importas
- ineffassign
- makezero # Finds slice declarations with non-zero initial length.
- mirror # Detects wrong mirror patterns of bytes/strings usage.
- misspell # Detects commonly misspelled English words in comments.
- nakedret # Detects uses of naked returns.
- nilnesserr # Detects returning nil errors. It combines the features of nilness and nilerr,
- nosprintfhostport # Detects misuse of Sprintf to construct a host with port in a URL.
- reassign # Detects reassigning a top-level variable in another package.
- revive # Metalinter; drop-in replacement for golint.
- spancheck # Detects mistakes with OpenTelemetry/Census spans.
- staticcheck
- thelper
- unconvert # Detects unnecessary type conversions.
- unused
- usestdlibvars # Detects the possibility to use variables/constants from the Go standard library.
- wastedassign # Detects wasted assignment statements.
disable:
- errcheck
- spancheck # FIXME
settings:
depguard:
rules:
main:
deny:
- pkg: "github.com/stretchr/testify/assert"
desc: Use "gotest.tools/v3/assert" instead
- pkg: "github.com/stretchr/testify/require"
desc: Use "gotest.tools/v3/assert" instead
- pkg: "github.com/stretchr/testify/suite"
desc: Do not use
- pkg: "github.com/containerd/containerd/pkg/userns"
desc: Use github.com/moby/sys/userns instead.
- pkg: "github.com/tonistiigi/fsutil"
desc: The fsutil module does not have a stable API, so we should not have a direct dependency unless necessary.
dupword:
ignore:
- "true" # some tests use this as expected output
- "false" # some tests use this as expected output
- "root" # for tests using "ls" output with files owned by "root:root"
errorlint:
# Check whether fmt.Errorf uses the %w verb for formatting errors.
# See the https://github.com/polyfloyd/go-errorlint for caveats.
errorf: false
# Check for plain type assertions and type switches.
asserts: false
exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
# - map # TODO(thaJeztah): also enable for maps
# Presence of "default" case in switch statements satisfies exhaustiveness,
# even if all enum members are not listed.
# Default: false
#
# TODO(thaJeztah): consider not allowing this to catch new values being added (and falling through to "default")
default-signifies-exhaustive: true
forbidigo:
forbid:
- pkg: ^sync/atomic$
pattern: ^atomic\.(Add|CompareAndSwap|Load|Store|Swap).
msg: Go 1.19 atomic types should be used instead.
- pkg: ^regexp$
pattern: ^regexp\.MustCompile
msg: Use internal/lazyregexp.New instead.
- pkg: github.com/vishvananda/netlink$
pattern: ^netlink\.(Handle\.)?(AddrList|BridgeVlanList|ChainList|ClassList|ConntrackTableList|ConntrackDeleteFilter$|ConntrackDeleteFilters|DevLinkGetDeviceList|DevLinkGetAllPortList|DevlinkGetDeviceParams|FilterList|FouList|GenlFamilyList|GTPPDPList|LinkByName|LinkByAlias|LinkList|LinkSubscribeWithOptions|NeighList$|NeighProxyList|NeighListExecute|NeighSubscribeWithOptions|LinkGetProtinfo|QdiscList|RdmaLinkList|RdmaLinkByName|RdmaLinkDel|RouteList|RouteListFilteredIter|RuleListFiltered$|RouteSubscribeWithOptions|RuleList$|RuleListFiltered|SocketGet|SocketDiagTCPInfo|SocketDiagTCP|SocketDiagUDPInfo|SocketDiagUDP|UnixSocketDiagInfo|UnixSocketDiag|VDPAGetDevConfigList|VDPAGetDevList|VDPAGetMGMTDevList|XfrmPolicyList|XfrmStateList)
msg: Use internal nlwrap package for EINTR handling.
- pkg: github.com/docker/docker/internal/nlwrap$
pattern: ^nlwrap.Handle.(BridgeVlanList|ChainList|ClassList|ConntrackDeleteFilter$|DevLinkGetDeviceList|DevLinkGetAllPortList|DevlinkGetDeviceParams|FilterList|FouList|GenlFamilyList|GTPPDPList|LinkByAlias|LinkSubscribeWithOptions|NeighList$|NeighProxyList|NeighListExecute|NeighSubscribeWithOptions|LinkGetProtinfo|QdiscList|RdmaLinkList|RdmaLinkByName|RdmaLinkDel|RouteListFilteredIter|RuleListFiltered$|RouteSubscribeWithOptions|RuleList$|RuleListFiltered|SocketGet|SocketDiagTCPInfo|SocketDiagTCP|SocketDiagUDPInfo|SocketDiagUDP|UnixSocketDiagInfo|UnixSocketDiag|VDPAGetDevConfigList|VDPAGetDevList|VDPAGetMGMTDevList)
msg: Add a wrapper to nlwrap.Handle for EINTR handling and update the list in .golangci.yml.
analyze-types: true
gocritic:
disabled-checks:
- appendAssign
- appendCombine
- assignOp
- builtinShadow
- builtinShadowDecl
- captLocal
- commentedOutCode
- deferInLoop
- dupImport
- dupSubExpr
- elseif
- emptyFallthrough
- equalFold
- evalOrder
- exitAfterDefer
- exposedSyncMutex
- filepathJoin
- hexLiteral
- hugeParam
- ifElseChain
- importShadow
- indexAlloc
- methodExprCall
- nestingReduce
- nilValReturn
- octalLiteral
- paramTypeCombine
- preferStringWriter
- ptrToRefParam
- rangeValCopy
- redundantSprint
- regexpMust
- regexpSimplify
- singleCaseSwitch
- sloppyReassign
- stringXbytes
- typeAssertChain
- typeDefFirst
- typeUnparen
- uncheckedInlineErr
- unlambda
- unnamedResult
- unnecessaryDefer
- unslice
- valSwap
- whyNoLint
enable-all: true
gosec:
excludes:
- G104 # G104: Errors unhandled; (TODO: reduce unhandled errors, or explicitly ignore)
- G115 # G115: integer overflow conversion; (TODO: verify these: https://github.com/moby/moby/issues/48358)
- G204 # G204: Subprocess launched with variable; too many false positives.
- G301 # G301: Expect directory permissions to be 0750 or less (also EXC0009); too restrictive
- G302 # G302: Expect file permissions to be 0600 or less (also EXC0009); too restrictive
- G304 # G304: Potential file inclusion via variable.
- G306 # G306: Expect WriteFile permissions to be 0600 or less (too restrictive; also flags "0o644" permissions)
- G307 # G307: Deferring unsafe method "*os.File" on type "Close" (also EXC0008); (TODO: evaluate these and fix where needed: G307: Deferring unsafe method "*os.File" on type "Close")
- G504 # G504: Blocklisted import net/http/cgi: Go versions < 1.6.3 are vulnerable to Httpoxy attack: (CVE-2016-5386); (only affects go < 1.6.3)
govet:
enable-all: true
disable:
- fieldalignment # TODO: evaluate which ones should be updated.
importas:
# Do not allow unaliased imports of aliased packages.
no-unaliased: true
alias:
# Enforce alias to prevent it accidentally being used instead of our
# own errdefs package (or vice-versa).
- pkg: github.com/containerd/errdefs
alias: cerrdefs
- pkg: github.com/containerd/containerd/images
alias: c8dimages
- pkg: github.com/opencontainers/image-spec/specs-go/v1
alias: ocispec
- pkg: go.etcd.io/bbolt
alias: bolt
# Enforce that gotest.tools/v3/assert/cmp is always aliased as "is"
- pkg: gotest.tools/v3/assert/cmp
alias: is
nakedret:
# Disallow naked returns if func has more lines of code than this setting.
# Default: 30
max-func-lines: 0
revive:
rules:
# FIXME make sure all packages have a description. Currently, there's many packages without.
- name: package-comments
disabled: true
staticcheck:
checks:
- all
- -QF1008 # Omit embedded fields from selector expression; https://staticcheck.dev/docs/checks/#QF1008
- -ST1000 # Incorrect or missing package comment; https://staticcheck.dev/docs/checks/#ST1000
- -ST1003 # Poorly chosen identifier; https://staticcheck.dev/docs/checks/#ST1003
- -ST1005 # Incorrectly formatted error string; https://staticcheck.dev/docs/checks/#ST1005
spancheck:
# Default: ["end"]
checks:
- end # check that `span.End()` is called
- record-error # check that `span.RecordError(err)` is called when an error is returned
- set-status # check that `span.SetStatus(codes.Error, msg)` is called when an error is returned
thelper:
test:
# Check *testing.T is first param (or after context.Context) of helper function.
first: false
# Check t.Helper() begins helper function.
begin: false
benchmark:
# Check *testing.B is first param (or after context.Context) of helper function.
first: false
# Check b.Helper() begins helper function.
begin: false
tb:
# Check *testing.TB is first param (or after context.Context) of helper function.
first: false
# Check *testing.TB param has name tb.
name: false
# Check tb.Helper() begins helper function.
begin: false
fuzz:
# Check *testing.F is first param (or after context.Context) of helper function.
first: false
# Check f.Helper() begins helper function.
begin: false
usestdlibvars:
# Suggest the use of http.MethodXX.
http-method: true
# Suggest the use of http.StatusXX.
http-status-code: true
exclusions:
paths:
- volume/drivers/proxy.go # TODO: this is a generated file but with an invalid header, see https://github.com/moby/moby/pull/46274
rules:
main:
deny:
- pkg: io/ioutil
desc: The io/ioutil package has been deprecated, see https://go.dev/doc/go1.16#ioutil
- pkg: "github.com/stretchr/testify/assert"
desc: Use "gotest.tools/v3/assert" instead
- pkg: "github.com/stretchr/testify/require"
desc: Use "gotest.tools/v3/assert" instead
- pkg: "github.com/stretchr/testify/suite"
desc: Do not use
- pkg: "github.com/containerd/containerd/errdefs"
desc: The errdefs package has moved to a separate module, https://github.com/containerd/errdefs
- pkg: "github.com/containerd/containerd/log"
desc: The logs package has moved to a separate module, https://github.com/containerd/log
- pkg: "github.com/containerd/containerd/pkg/userns"
desc: Use github.com/moby/sys/userns instead.
- pkg: "github.com/tonistiigi/fsutil"
desc: The fsutil module does not have a stable API, so we should not have a direct dependency unless necessary.
# We prefer to use an "linters.exclusions.rules" so that new "default" exclusions are not
# automatically inherited. We can decide whether or not to follow upstream
# defaults when updating golang-ci-lint versions.
# Unfortunately, this means we have to copy the whole exclusion pattern, as
# (unlike the "include" option), the "exclude" option does not take exclusion
# ID's.
#
# These exclusion patterns are copied from the default excludes at:
# https://github.com/golangci/golangci-lint/blob/v1.61.0/pkg/config/issues.go#L11-L104
#
# The default list of exclusions can be found at:
# https://golangci-lint.run/usage/false-positives/#default-exclusions
dupword:
ignore:
- "true" # some tests use this as expected output
- "false" # some tests use this as expected output
- "root" # for tests using "ls" output with files owned by "root:root"
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- errcheck
exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
# - map # TODO(thaJeztah): also enable for maps
# Presence of "default" case in switch statements satisfies exhaustiveness,
# even if all enum members are not listed.
- text: "G404: Use of weak random number generator"
path: _test\.go
linters:
- gosec
# Suppress golint complaining about generated types in api/types/
- text: "type name will be used as (container|volume)\\.(Container|Volume).* by other packages, and that stutters; consider calling this"
path: "api/types/(volume|container)/"
linters:
- revive
# FIXME: ignoring unused assigns to ctx for now; too many hits in libnetwork/xxx functions that setup traces
- text: "assigned to ctx, but never used afterwards"
linters:
- wastedassign
- text: "ineffectual assignment to ctx"
source: "ctx[, ].*=.*\\(ctx[,)]"
linters:
- ineffassign
- text: "SA4006: this value of ctx is never used"
source: "ctx[, ].*=.*\\(ctx[,)]"
linters:
- staticcheck
# FIXME(thaJeztah): ignoring these transitional utilities until BuildKit is vendored with https://github.com/moby/moby/pull/49743
- text: "SA1019: idtools\\.(ToUserIdentityMapping|FromUserIdentityMapping|IdentityMapping) is deprecated"
linters:
- staticcheck
# Ignore "nested context in function literal (fatcontext)" as we intentionally set up tracing on a base-context for tests.
# FIXME(thaJeztah): see if there's a more iodiomatic way to do this.
- text: 'nested context in function literal'
path: '((main|check)_(linux_|)test\.go)|testutil/helpers\.go'
linters:
- fatcontext
- text: '^shadow: declaration of "(ctx|err|ok)" shadows declaration'
linters:
- govet
- text: '^shadow: declaration of "(out)" shadows declaration'
path: _test\.go
linters:
- govet
- text: 'use of `regexp.MustCompile` forbidden'
path: _test\.go
linters:
- forbidigo
- text: 'use of `regexp.MustCompile` forbidden'
path: "internal/lazyregexp"
linters:
- forbidigo
- text: 'use of `regexp.MustCompile` forbidden'
path: "libnetwork/cmd/networkdb-test/dbclient"
linters:
- forbidigo
# Log a warning if an exclusion rule is unused.
# Default: false
#
# TODO(thaJeztah): consider not allowing this to catch new values being added (and falling through to "default")
default-signifies-exhaustive: true
forbidigo:
forbid:
- pkg: ^sync/atomic$
p: ^atomic\.(Add|CompareAndSwap|Load|Store|Swap).
msg: Go 1.19 atomic types should be used instead.
- pkg: ^regexp$
p: ^regexp\.MustCompile
msg: Use internal/lazyregexp.New instead.
- pkg: github.com/vishvananda/netlink$
p: ^netlink\.(Handle\.)?(AddrList|BridgeVlanList|ChainList|ClassList|ConntrackTableList|ConntrackDeleteFilter$|ConntrackDeleteFilters|DevLinkGetDeviceList|DevLinkGetAllPortList|DevlinkGetDeviceParams|FilterList|FouList|GenlFamilyList|GTPPDPList|LinkByName|LinkByAlias|LinkList|LinkSubscribeWithOptions|NeighList$|NeighProxyList|NeighListExecute|NeighSubscribeWithOptions|LinkGetProtinfo|QdiscList|RdmaLinkList|RdmaLinkByName|RdmaLinkDel|RouteList|RouteListFilteredIter|RuleListFiltered$|RouteSubscribeWithOptions|RuleList$|RuleListFiltered|SocketGet|SocketDiagTCPInfo|SocketDiagTCP|SocketDiagUDPInfo|SocketDiagUDP|UnixSocketDiagInfo|UnixSocketDiag|VDPAGetDevConfigList|VDPAGetDevList|VDPAGetMGMTDevList|XfrmPolicyList|XfrmStateList)
msg: Use internal nlwrap package for EINTR handling.
- pkg: github.com/docker/docker/internal/nlwrap$
p: ^nlwrap.Handle.(BridgeVlanList|ChainList|ClassList|ConntrackDeleteFilter$|DevLinkGetDeviceList|DevLinkGetAllPortList|DevlinkGetDeviceParams|FilterList|FouList|GenlFamilyList|GTPPDPList|LinkByAlias|LinkSubscribeWithOptions|NeighList$|NeighProxyList|NeighListExecute|NeighSubscribeWithOptions|LinkGetProtinfo|QdiscList|RdmaLinkList|RdmaLinkByName|RdmaLinkDel|RouteListFilteredIter|RuleListFiltered$|RouteSubscribeWithOptions|RuleList$|RuleListFiltered|SocketGet|SocketDiagTCPInfo|SocketDiagTCP|SocketDiagUDPInfo|SocketDiagUDP|UnixSocketDiagInfo|UnixSocketDiag|VDPAGetDevConfigList|VDPAGetDevList|VDPAGetMGMTDevList)
msg: Add a wrapper to nlwrap.Handle for EINTR handling and update the list in .golangci.yml.
analyze-types: true
gosec:
excludes:
- G104 # G104: Errors unhandled; (TODO: reduce unhandled errors, or explicitly ignore)
- G113 # G113: Potential uncontrolled memory consumption in Rat.SetString (CVE-2022-23772); (only affects go < 1.16.14. and go < 1.17.7)
- G115 # G115: integer overflow conversion; (TODO: verify these: https://github.com/moby/moby/issues/48358)
- G204 # G204: Subprocess launched with variable; too many false positives.
- G301 # G301: Expect directory permissions to be 0750 or less (also EXC0009); too restrictive
- G302 # G302: Expect file permissions to be 0600 or less (also EXC0009); too restrictive
- G304 # G304: Potential file inclusion via variable.
- G306 # G306: Expect WriteFile permissions to be 0600 or less (too restrictive; also flags "0o644" permissions)
- G307 # G307: Deferring unsafe method "*os.File" on type "Close" (also EXC0008); (TODO: evaluate these and fix where needed: G307: Deferring unsafe method "*os.File" on type "Close")
- G504 # G504: Blocklisted import net/http/cgi: Go versions < 1.6.3 are vulnerable to Httpoxy attack: (CVE-2016-5386); (only affects go < 1.6.3)
govet:
enable-all: true
disable:
- fieldalignment # TODO: evaluate which ones should be updated.
importas:
# Do not allow unaliased imports of aliased packages.
no-unaliased: true
alias:
# Enforce alias to prevent it accidentally being used instead of our
# own errdefs package (or vice-versa).
- pkg: github.com/containerd/errdefs
alias: cerrdefs
- pkg: github.com/containerd/containerd/images
alias: c8dimages
- pkg: github.com/opencontainers/image-spec/specs-go/v1
alias: ocispec
# Enforce that gotest.tools/v3/assert/cmp is always aliased as "is"
- pkg: gotest.tools/v3/assert/cmp
alias: is
nakedret:
# Disallow naked returns if func has more lines of code than this setting.
# Default: 30
max-func-lines: 0
revive:
rules:
# FIXME make sure all packages have a description. Currently, there's many packages without.
- name: package-comments
disabled: true
spancheck:
# Default: ["end"]
checks:
- end # check that `span.End()` is called
- record-error # check that `span.RecordError(err)` is called when an error is returned
- set-status # check that `span.SetStatus(codes.Error, msg)` is called when an error is returned
warn-unused: true
issues:
# The default exclusion rules are a bit too permissive, so copying the relevant ones below
exclude-use-default: false
exclude-dirs:
- docs
exclude-rules:
# We prefer to use an "exclude-list" so that new "default" exclusions are not
# automatically inherited. We can decide whether or not to follow upstream
# defaults when updating golang-ci-lint versions.
# Unfortunately, this means we have to copy the whole exclusion pattern, as
# (unlike the "include" option), the "exclude" option does not take exclusion
# ID's.
#
# These exclusion patterns are copied from the default excludes at:
# https://github.com/golangci/golangci-lint/blob/v1.61.0/pkg/config/issues.go#L11-L104
#
# The default list of exclusions can be found at:
# https://golangci-lint.run/usage/false-positives/#default-exclusions
# EXC0001
- text: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*print(f|ln)?|os\\.(Un)?Setenv). is not checked"
linters:
- errcheck
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- errcheck
- text: "G404: Use of weak random number generator"
path: _test\.go
linters:
- gosec
# Suppress golint complaining about generated types in api/types/
- text: "type name will be used as (container|volume)\\.(Container|Volume).* by other packages, and that stutters; consider calling this"
path: "api/types/(volume|container)/"
linters:
- revive
# FIXME: ignoring unused assigns to ctx for now; too many hits in libnetwork/xxx functions that setup traces
- text: "assigned to ctx, but never used afterwards"
linters:
- wastedassign
- text: "ineffectual assignment to ctx"
source: "ctx[, ].*=.*\\(ctx[,)]"
linters:
- ineffassign
- text: "SA4006: this value of `ctx` is never used"
source: "ctx[, ].*=.*\\(ctx[,)]"
linters:
- staticcheck
# Ignore "nested context in function literal (fatcontext)" as we intentionally set up tracing on a base-context for tests.
# FIXME(thaJeztah): see if there's a more iodiomatic way to do this.
- text: 'nested context in function literal'
path: '((main|check)_(linux_|)test\.go)|testutil/helpers\.go'
linters:
- fatcontext
- text: '^shadow: declaration of "(ctx|err|ok)" shadows declaration'
linters:
- govet
- text: '^shadow: declaration of "(out)" shadows declaration'
path: _test\.go
linters:
- govet
- text: 'use of `regexp.MustCompile` forbidden'
path: _test\.go
linters:
- forbidigo
- text: 'use of `regexp.MustCompile` forbidden'
path: "internal/lazyregexp"
linters:
- forbidigo
- text: 'use of `regexp.MustCompile` forbidden'
path: "libnetwork/cmd/networkdb-test/dbclient"
linters:
- forbidigo
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0

View File

@@ -94,8 +94,9 @@ Arnaud Rebillout <arnaud.rebillout@collabora.com>
Arnaud Rebillout <arnaud.rebillout@collabora.com> <elboulangero@gmail.com>
Arthur Gautier <baloo@gandi.net> <superbaloo+registrations.github@superbaloo.net>
Artur Meyster <arthurfbi@yahoo.com>
Austin Vazquez <macedonv@amazon.com>
Austin Vazquez <macedonv@amazon.com> <55906459+austinvazquez@users.noreply.github.com>
Austin Vazquez <austin.vazquez.dev@gmail.com>
Austin Vazquez <austin.vazquez.dev@gmail.com> <55906459+austinvazquez@users.noreply.github.com>
Austin Vazquez <austin.vazquez.dev@gmail.com> <macedonv@amazon.com>
Avi Miller <avi.miller@oracle.com> <avi.miller@gmail.com>
Ben Bonnefoy <frenchben@docker.com>
Ben Golub <ben.golub@dotcloud.com>
@@ -138,6 +139,7 @@ Chen Mingjie <chenmingjie0828@163.com>
Chen Qiu <cheney-90@hotmail.com>
Chen Qiu <cheney-90@hotmail.com> <21321229@zju.edu.cn>
Chengfei Shang <cfshang@alauda.io>
Chengyu Zhu <hudson@cyzhu.com>
Chentianze <cmoman@126.com>
Chris Dias <cdias@microsoft.com>
Chris McKinnel <chris.mckinnel@tangentlabs.co.uk>

12
AUTHORS
View File

@@ -2,6 +2,7 @@
# This file lists all contributors to the repository.
# See hack/generate-authors.sh to make modifications.
17neverends <ionianrise@gmail.com>
7sunarni <710720732@qq.com>
Aanand Prasad <aanand.prasad@gmail.com>
Aarni Koskela <akx@iki.fi>
@@ -189,6 +190,7 @@ Anes Hasicic <anes.hasicic@gmail.com>
Angel Velazquez <angelcar@amazon.com>
Anil Belur <askb23@gmail.com>
Anil Madhavapeddy <anil@recoil.org>
Anirudh Aithal <aithal@amazon.com>
Ankit Jain <ajatkj@yahoo.co.in>
Ankush Agarwal <ankushagarwal11@gmail.com>
Anonmily <michelle@michelleliu.io>
@@ -227,7 +229,7 @@ Arun Gupta <arun.gupta@gmail.com>
Asad Saeeduddin <masaeedu@gmail.com>
Asbjørn Enge <asbjorn@hanafjedle.net>
Ashly Mathew <ashly.mathew@sap.com>
Austin Vazquez <macedonv@amazon.com>
Austin Vazquez <austin.vazquez.dev@gmail.com>
averagehuman <averagehuman@users.noreply.github.com>
Avi Das <andas222@gmail.com>
Avi Kivity <avi@scylladb.com>
@@ -293,6 +295,7 @@ Brandon Liu <bdon@bdon.org>
Brandon Philips <brandon.philips@coreos.com>
Brandon Rhodes <brandon@rhodesmill.org>
Brendan Dixon <brendand@microsoft.com>
Brendon Smith <bws@bws.bio>
Brennan Kinney <5098581+polarathene@users.noreply.github.com>
Brent Salisbury <brent.salisbury@docker.com>
Brett Higgins <brhiggins@arbor.net>
@@ -347,6 +350,7 @@ Casey Bisson <casey.bisson@joyent.com>
Catalin Pirvu <pirvu.catalin94@gmail.com>
Ce Gao <ce.gao@outlook.com>
Cedric Davies <cedricda@microsoft.com>
Cesar Talledo <cesar.talledo@docker.com>
Cezar Sa Espinola <cezarsa@gmail.com>
Chad Swenson <chadswen@gmail.com>
Chance Zibolski <chance.zibolski@gmail.com>
@@ -375,6 +379,7 @@ Chen Qiu <cheney-90@hotmail.com>
Cheng-mean Liu <soccerl@microsoft.com>
Chengfei Shang <cfshang@alauda.io>
Chengguang Xu <cgxu519@gmx.com>
Chengyu Zhu <hudson@cyzhu.com>
Chentianze <cmoman@126.com>
Chenyang Yan <memory.yancy@gmail.com>
chenyuzhu <chenyuzhi@oschina.cn>
@@ -1207,6 +1212,7 @@ K. Heller <pestophagous@gmail.com>
Kai Blin <kai@samba.org>
Kai Qiang Wu (Kennan) <wkq5325@gmail.com>
Kaijie Chen <chen@kaijie.org>
Kaita Nakamura <kaita.nakamura0830@gmail.com>
Kamil Domański <kamil@domanski.co>
Kamjar Gerami <kami.gerami@gmail.com>
Kanstantsin Shautsou <kanstantsin.sha@gmail.com>
@@ -1281,6 +1287,7 @@ Krasi Georgiev <krasi@vip-consult.solutions>
Krasimir Georgiev <support@vip-consult.co.uk>
Kris-Mikael Krister <krismikael@protonmail.com>
Kristian Haugene <kristian.haugene@capgemini.com>
Kristian Heljas <kristian@kristian.ee>
Kristina Zabunova <triara.xiii@gmail.com>
Krystian Wojcicki <kwojcicki@sympatico.ca>
Kunal Kushwaha <kushwaha_kunal_v7@lab.ntt.co.jp>
@@ -1482,6 +1489,7 @@ Matthias Kühnle <git.nivoc@neverbox.com>
Matthias Rampke <mr@soundcloud.com>
Matthieu Fronton <m@tthieu.fr>
Matthieu Hauglustaine <matt.hauglustaine@gmail.com>
Matthieu MOREL <matthieu.morel35@gmail.com>
Mattias Jernberg <nostrad@gmail.com>
Mauricio Garavaglia <mauricio@medallia.com>
mauriyouth <mauriyouth@gmail.com>
@@ -1712,6 +1720,7 @@ Patrick Hemmer <patrick.hemmer@gmail.com>
Patrick St. laurent <patrick@saint-laurent.us>
Patrick Stapleton <github@gdi2290.com>
Patrik Cyvoct <patrik@ptrk.io>
Patrik Leifert <patrikleifert@hotmail.com>
pattichen <craftsbear@gmail.com>
Paul "TBBle" Hampson <Paul.Hampson@Pobox.com>
Paul <paul9869@gmail.com>
@@ -1870,6 +1879,7 @@ Robert Obryk <robryk@gmail.com>
Robert Schneider <mail@shakeme.info>
Robert Shade <robert.shade@gmail.com>
Robert Stern <lexandro2000@gmail.com>
Robert Sturla <robertsturla@outlook.com>
Robert Terhaar <rterhaar@atlanticdynamic.com>
Robert Wallis <smilingrob@gmail.com>
Robert Wang <robert@arctic.tw>

View File

@@ -83,6 +83,39 @@ contributions, see [the advanced contribution
section](https://docs.docker.com/opensource/workflow/advanced-contributing/) in
the contributors guide.
### Where to put your changes
You can make changes to any Go package within Moby outside of the vendor directory. There are no
restrictions on packages but a few guidelines to follow for deciding on making these changes.
When adding new packages, first consider putting them in an internal directory to prevent
unintended importing from other modules. Code changes should either go under `api`, `client`,
or `daemon` modules, or one of the integration test directories.
Try to put a new package under the appropriate directories. The root directory is reserved for
configuration and build files, no source files will be accepted in the root.
- `api` - All types shared by client and daemon along with swagger definitions.
- `client` - All Go files for the docker client
- `contrib` - Files, configurations, and packages related to external tools or libraries
- `daemon` - All Go files and packages for building the daemon
- `docs` - All Moby technical documentation using markdown
- `hack` - All scripts used for testing, development, and CI
- `integration` - Testing the integration of the API, client, and daemon
- `integration-cli` - Deprecated integration tests of the docker cli with the daemon, no new tests allowed
- `pkg` - Legacy Go packages used externally, no new packages should be added here
- `project` - All files related to Moby project governance
- `vendor` - Autogenerated vendor files from `make vendor` command, do not manually edit files here
The daemon module has many subpackages. Consider putting new packages under one of these
directories.
- `daemon/cmd` - All Go main packages and the packages used only for that main package
- `daemon/internal` - All utility packages used by daemon and not intended for external use
- `daemon/man`- All Moby reference manuals used for the `man` command
- `daemon/plugins` - All included daemon plugins which are intended to be registered via init
- `daemon/pkg` - All libraries used by daemon and for integration testing
- `daemon/version` - Version package with the current daemon version
### Connect with other Moby Project contributors
<table class="tg">

View File

@@ -1,22 +1,27 @@
# syntax=docker/dockerfile:1.7
# syntax=docker/dockerfile:1
ARG GO_VERSION=1.23.7
ARG GO_VERSION=1.24.4
ARG BASE_DEBIAN_DISTRO="bookworm"
ARG GOLANG_IMAGE="golang:${GO_VERSION}-${BASE_DEBIAN_DISTRO}"
ARG XX_VERSION=1.6.1
ARG VPNKIT_VERSION=0.5.0
# VPNKIT_VERSION is the version of the vpnkit binary which is used as a fallback
# network driver for rootless.
ARG VPNKIT_VERSION=0.6.0
# DOCKERCLI_VERSION is the version of the CLI to install in the dev-container.
ARG DOCKERCLI_VERSION=v28.0.1
ARG DOCKERCLI_VERSION=v28.2.2
ARG DOCKERCLI_REPOSITORY="https://github.com/docker/cli.git"
# cli version used for integration-cli tests
ARG DOCKERCLI_INTEGRATION_REPOSITORY="https://github.com/docker/cli.git"
ARG DOCKERCLI_INTEGRATION_VERSION=v17.06.2-ce
ARG DOCKERCLI_INTEGRATION_VERSION=v18.06.3-ce
# BUILDX_VERSION is the version of buildx to install in the dev container.
ARG BUILDX_VERSION=0.20.1
ARG COMPOSE_VERSION=v2.33.1
ARG BUILDX_VERSION=0.24.0
# COMPOSE_VERSION is the version of compose to install in the dev container.
ARG COMPOSE_VERSION=v2.36.2
ARG SYSTEMD="false"
ARG FIREWALLD="false"
@@ -26,11 +31,16 @@ ARG DOCKER_STATIC=1
# https://hub.docker.com/r/distribution/distribution. This version of
# the registry is used to test schema 2 manifests. Generally, the version
# specified here should match a current release.
ARG REGISTRY_VERSION=3.0.0-rc.1
ARG REGISTRY_VERSION=3.0.0
# delve is currently only supported on linux/amd64 and linux/arm64;
# https://github.com/go-delve/delve/blob/v1.8.1/pkg/proc/native/support_sentinel.go#L1-L6
ARG DELVE_SUPPORTED=${TARGETPLATFORM#linux/amd64} DELVE_SUPPORTED=${DELVE_SUPPORTED#linux/arm64}
# https://github.com/go-delve/delve/blob/v1.24.1/pkg/proc/native/support_sentinel.go#L1
# https://github.com/go-delve/delve/blob/v1.24.1/pkg/proc/native/support_sentinel_linux.go#L1
#
# ppc64le support was added in v1.21.1, but is still experimental, and requires
# the "-tags exp.linuxppc64le" build-tag to be set:
# https://github.com/go-delve/delve/commit/71f12207175a1cc09668f856340d8a543c87dcca
ARG DELVE_SUPPORTED=${TARGETPLATFORM#linux/amd64} DELVE_SUPPORTED=${DELVE_SUPPORTED#linux/arm64} DELVE_SUPPORTED=${DELVE_SUPPORTED#linux/ppc64le}
ARG DELVE_SUPPORTED=${DELVE_SUPPORTED:+"unsupported"}
ARG DELVE_SUPPORTED=${DELVE_SUPPORTED:-"supported"}
@@ -47,6 +57,11 @@ COPY --from=build-dummy /build /build
# base
FROM --platform=$BUILDPLATFORM ${GOLANG_IMAGE} AS base
COPY --from=xx / /
# Disable collecting local telemetry, as collected by Go and Delve;
#
# - https://github.com/go-delve/delve/blob/v1.24.1/CHANGELOG.md#1231-2024-09-23
# - https://go.dev/doc/telemetry#background
RUN go telemetry off && [ "$(go telemetry)" = "off" ] || { echo "Failed to disable Go telemetry"; exit 1; }
RUN echo 'Binary::apt::APT::Keep-Downloaded-Packages "true";' > /etc/apt/apt.conf.d/keep-cache
RUN apt-get update && apt-get install --no-install-recommends -y file
ENV GO111MODULE=off
@@ -63,41 +78,8 @@ RUN --mount=type=cache,sharing=locked,id=moby-criu-aptlib,target=/var/lib/apt \
&& /build/criu --version
# registry
FROM base AS registry-src
WORKDIR /usr/src/registry
RUN git init . && git remote add origin "https://github.com/distribution/distribution.git"
FROM base AS registry
WORKDIR /go/src/github.com/docker/distribution
# REGISTRY_VERSION_SCHEMA1 specifies the version of the registry to build and
# install from the https://github.com/docker/distribution repository. This is
# an older (pre v2.3.0) version of the registry that only supports schema1
# manifests. This version of the registry is not working on arm64, so installation
# is skipped on that architecture.
ARG REGISTRY_VERSION_SCHEMA1=v2.1.0
ARG TARGETPLATFORM
RUN --mount=from=registry-src,src=/usr/src/registry,rw \
--mount=type=cache,target=/root/.cache/go-build,id=registry-build-$TARGETPLATFORM \
--mount=type=cache,target=/go/pkg/mod \
--mount=type=tmpfs,target=/go/src <<EOT
set -ex
export GOPATH="/go/src/github.com/docker/distribution/Godeps/_workspace:$GOPATH"
# Make the /build directory no matter what so that it doesn't fail on arm64 or
# any other platform where we don't build this registry
mkdir /build
case $TARGETPLATFORM in
linux/amd64|linux/arm/v7|linux/ppc64le|linux/s390x)
git fetch -q --depth 1 origin "${REGISTRY_VERSION_SCHEMA1}" +refs/tags/*:refs/tags/*
git checkout -q FETCH_HEAD
CGO_ENABLED=0 xx-go build -o /build/registry-v2-schema1 -v ./cmd/registry
xx-verify /build/registry-v2-schema1
;;
esac
EOT
FROM distribution/distribution:$REGISTRY_VERSION AS registry-v2
RUN mkdir /build && mv /bin/registry /build/registry-v2
FROM distribution/distribution:$REGISTRY_VERSION AS registry
RUN mkdir /build && mv /bin/registry /build/registry
# go-swagger
FROM base AS swagger-src
@@ -153,7 +135,7 @@ RUN git init . && git remote add origin "https://github.com/go-delve/delve.git"
# from the https://github.com/go-delve/delve repository.
# It can be used to run Docker with a possibility of
# attaching debugger to it.
ARG DELVE_VERSION=v1.23.0
ARG DELVE_VERSION=v1.24.1
RUN git fetch -q --depth 1 origin "${DELVE_VERSION}" +refs/tags/*:refs/tags/* && git checkout -q FETCH_HEAD
FROM base AS delve-supported
@@ -220,10 +202,10 @@ FROM binary-dummy AS containerd-windows
FROM containerd-${TARGETOS} AS containerd
FROM base AS golangci_lint
ARG GOLANGCI_LINT_VERSION=v1.64.5
ARG GOLANGCI_LINT_VERSION=v2.1.5
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOBIN=/build/ GO111MODULE=on go install "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}" \
GOBIN=/build/ GO111MODULE=on go install "github.com/golangci/golangci-lint/v2/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}" \
&& /build/golangci-lint --version
FROM base AS gotestsum
@@ -279,7 +261,7 @@ RUN git init . && git remote add origin "https://github.com/opencontainers/runc.
# that is used. If you need to update runc, open a pull request in the containerd
# project first, and update both after that is merged. When updating RUNC_VERSION,
# consider updating runc in vendor.mod accordingly.
ARG RUNC_VERSION=v1.2.5
ARG RUNC_VERSION=v1.2.6
RUN git fetch -q --depth 1 origin "${RUNC_VERSION}" +refs/tags/*:refs/tags/* && git checkout -q FETCH_HEAD
FROM base AS runc-build
@@ -377,7 +359,8 @@ FROM binary-dummy AS rootlesskit-windows
FROM rootlesskit-${TARGETOS} AS rootlesskit
FROM base AS crun
ARG CRUN_VERSION=1.12
# CRUN_VERSION is the version of crun to install in the dev-container.
ARG CRUN_VERSION=1.21
RUN --mount=type=cache,sharing=locked,id=moby-crun-aptlib,target=/var/lib/apt \
--mount=type=cache,sharing=locked,id=moby-crun-aptcache,target=/var/cache/apt \
apt-get update && apt-get install -y --no-install-recommends \
@@ -408,8 +391,8 @@ FROM scratch AS vpnkit-linux-arm
FROM scratch AS vpnkit-linux-ppc64le
FROM scratch AS vpnkit-linux-riscv64
FROM scratch AS vpnkit-linux-s390x
FROM djs55/vpnkit:${VPNKIT_VERSION} AS vpnkit-linux-amd64
FROM djs55/vpnkit:${VPNKIT_VERSION} AS vpnkit-linux-arm64
FROM moby/vpnkit-bin:${VPNKIT_VERSION} AS vpnkit-linux-amd64
FROM moby/vpnkit-bin:${VPNKIT_VERSION} AS vpnkit-linux-arm64
FROM vpnkit-linux-${TARGETARCH} AS vpnkit-linux
FROM vpnkit-${TARGETOS} AS vpnkit
@@ -451,7 +434,6 @@ COPY --link --from=delve /build/ /usr/local/bin/
COPY --link --from=gowinres /build/ /usr/local/bin/
COPY --link --from=tini /build/ /usr/local/bin/
COPY --link --from=registry /build/ /usr/local/bin/
COPY --link --from=registry-v2 /build/ /usr/local/bin/
# Skip the CRIU stage for now, as the opensuse package repository is sometimes
# unstable, and we're currently not using it in CI.
@@ -498,7 +480,6 @@ RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \
--mount=type=cache,sharing=locked,id=moby-dev-aptcache,target=/var/cache/apt \
apt-get update && apt-get install -y --no-install-recommends \
firewalld
RUN sed -i 's/FirewallBackend=nftables/FirewallBackend=iptables/' /etc/firewalld/firewalld.conf
FROM dev-firewalld-${FIREWALLD} AS dev-base
RUN groupadd -r docker
@@ -531,6 +512,7 @@ RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \
libnl-3-200 \
libprotobuf-c1 \
libyajl2 \
nano \
net-tools \
netcat-openbsd \
patch \
@@ -648,6 +630,15 @@ FROM dev-base AS devcontainer
COPY --link . .
COPY --link --from=gopls /build/ /usr/local/bin/
# usage:
# > docker buildx bake dind
# > docker run -d --restart always --privileged --name devdind -p 12375:2375 docker-dind --debug --host=tcp://0.0.0.0:2375 --tlsverify=false
FROM docker:dind AS dind
COPY --link --from=dockercli /build/docker /usr/local/bin/
COPY --link --from=buildx /buildx /usr/local/libexec/docker/cli-plugins/docker-buildx
COPY --link --from=compose /docker-compose /usr/local/libexec/docker/cli-plugins/docker-compose
COPY --link --from=all / /usr/local/bin/
# usage:
# > make shell
# > SYSTEMD=true make shell

View File

@@ -5,7 +5,7 @@
# This represents the bare minimum required to build and test Docker.
ARG GO_VERSION=1.23.7
ARG GO_VERSION=1.24.4
ARG BASE_DEBIAN_DISTRO="bookworm"
ARG GOLANG_IMAGE="golang:${GO_VERSION}-${BASE_DEBIAN_DISTRO}"
@@ -35,10 +35,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
vim-common \
&& rm -rf /var/lib/apt/lists/*
# Install runc, containerd, tini and docker-proxy
# Install runc, containerd, and tini
# Please edit hack/dockerfile/install/<name>.installer to update them.
COPY hack/dockerfile/install hack/dockerfile/install
RUN for i in runc containerd tini proxy dockercli; \
RUN set -e; for i in runc containerd tini dockercli; \
do hack/dockerfile/install/install.sh $i; \
done
ENV PATH=/usr/local/cli:$PATH

View File

@@ -161,9 +161,11 @@ FROM ${WINDOWS_BASE_IMAGE}:${WINDOWS_BASE_IMAGE_TAG}
# Use PowerShell as the default shell
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ARG GO_VERSION=1.23.7
ARG GO_VERSION=1.24.4
ARG GOTESTSUM_VERSION=v1.12.0
ARG GOWINRES_VERSION=v0.3.1
# GOWINRES_VERSION is the version of go-winres to install.
ARG GOWINRES_VERSION=v0.3.3
ARG CONTAINERD_VERSION=v1.7.27
# Environment variable notes:

View File

@@ -7,6 +7,7 @@
"akerouanton","Albin Kerouanton","albinker@gmail.com"
"AkihiroSuda","Akihiro Suda","akihiro.suda.cz@hco.ntt.co.jp"
"austinvazquez","Austin Vazquez","macedonv@amazon.com"
"corhere","Cory Snider","csnider@mirantis.com"
"cpuguy83","Brian Goff","cpuguy83@gmail.com"
"robmry","Rob Murray","rob.murray@docker.com"
"thaJeztah","Sebastiaan van Stijn","github@gone.nl"
@@ -17,7 +18,6 @@
# REVIEWERS
# GitHub ID, Name, Email address, GPG fingerprint
"coolljt0725","Lei Jitang","leijitang@huawei.com"
"corhere","Cory Snider","csnider@mirantis.com"
"crazy-max","Kevin Alvarez","contact@crazymax.dev"
"dmcgowan","Derek McGowan","derek@mcgstyle.net"
"estesp","Phil Estes","estesp@linux.vnet.ibm.com"

View File

@@ -38,7 +38,6 @@ DOCKER_ENVS := \
-e DOCKERCLI_INTEGRATION_REPOSITORY \
-e DOCKER_DEBUG \
-e DOCKER_EXPERIMENTAL \
-e DOCKER_FIREWALLD \
-e DOCKER_GITCOMMIT \
-e DOCKER_GRAPHDRIVER \
-e DOCKER_LDFLAGS \
@@ -50,6 +49,7 @@ DOCKER_ENVS := \
-e DOCKER_USERLANDPROXY \
-e DOCKERD_ARGS \
-e DELVE_PORT \
-e FIREWALLD \
-e GITHUB_ACTIONS \
-e TEST_FORCE_VALIDATE \
-e TEST_INTEGRATION_DIR \
@@ -57,7 +57,6 @@ DOCKER_ENVS := \
-e TEST_INTEGRATION_FAIL_FAST \
-e TEST_SKIP_INTEGRATION \
-e TEST_SKIP_INTEGRATION_CLI \
-e TEST_IGNORE_CGROUP_CHECK \
-e TESTCOVERAGE \
-e TESTDEBUG \
-e TESTDIRS \
@@ -84,11 +83,11 @@ DOCKER_ENVS := \
# to allow `make BIND_DIR=. shell` or `make BIND_DIR= test`
# (default to no bind mount if DOCKER_HOST is set)
# note: BINDDIR is supported for backwards-compatibility here
BIND_DIR := $(if $(BINDDIR),$(BINDDIR),$(if $(DOCKER_HOST),,bundles))
BIND_DIR := $(if $(BINDDIR),$(BINDDIR),$(if $(DOCKER_HOST),,.))
# DOCKER_MOUNT can be overridden, but use at your own risk!
ifndef DOCKER_MOUNT
DOCKER_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/docker/docker/$(BIND_DIR)")
DOCKER_MOUNT := $(if $(BIND_DIR),-v "$(BIND_DIR):/go/src/github.com/docker/docker/$(BIND_DIR)")
DOCKER_MOUNT := $(if $(DOCKER_BINDDIR_MOUNT_OPTS),$(DOCKER_MOUNT):$(DOCKER_BINDDIR_MOUNT_OPTS),$(DOCKER_MOUNT))
# This allows the test suite to be able to run without worrying about the underlying fs used by the container running the daemon (e.g. aufs-on-aufs), so long as the host running the container is running a supported fs.
@@ -150,7 +149,7 @@ DOCKER_BUILD_ARGS += --build-arg=DOCKERCLI_INTEGRATION_REPOSITORY
ifdef DOCKER_SYSTEMD
DOCKER_BUILD_ARGS += --build-arg=SYSTEMD=true
endif
ifdef DOCKER_FIREWALLD
ifdef FIREWALLD
DOCKER_BUILD_ARGS += --build-arg=FIREWALLD=true
endif
@@ -204,7 +203,7 @@ build: shell_target := --target=dev-base
else
build: shell_target := --target=dev
endif
build: bundles
build: validate-bind-dir bundles
$(BUILD_CMD) $(BUILD_OPTS) $(shell_target) --load -t "$(DOCKER_IMAGE)" .
.PHONY: shell
@@ -285,3 +284,10 @@ generate-files:
--file "./hack/dockerfiles/generate-files.Dockerfile" .
cp -R "$($@_TMP_OUT)"/. .
rm -rf "$($@_TMP_OUT)"/*
.PHONY: validate-bind-dir
validate-bind-dir:
@case "$(BIND_DIR)" in \
".."*|"/"*) echo "Make needs to be run from the project-root directory, with BIND_DIR set to \".\" or a subdir"; \
exit 1 ;; \
esac

View File

@@ -1,9 +1,9 @@
package api // import "github.com/docker/docker/api"
package api
// Common constants for daemon and client.
const (
// DefaultVersion of the current REST API.
DefaultVersion = "1.48"
DefaultVersion = "1.51"
// MinSupportedAPIVersion is the minimum API version that can be supported
// by the API server, specified as "major.minor". Note that the daemon

View File

@@ -1,4 +1,4 @@
package build // import "github.com/docker/docker/api/server/backend/build"
package build
import (
"context"
@@ -6,8 +6,8 @@ import (
"strconv"
"github.com/distribution/reference"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/build"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/builder"
buildkit "github.com/docker/docker/builder/builder-next"
@@ -52,37 +52,37 @@ func (b *Backend) RegisterGRPC(s *grpc.Server) {
// Build builds an image from a Source
func (b *Backend) Build(ctx context.Context, config backend.BuildConfig) (string, error) {
options := config.Options
useBuildKit := options.Version == types.BuilderBuildKit
useBuildKit := options.Version == build.BuilderBuildKit
tags, err := sanitizeRepoAndTags(options.Tags)
if err != nil {
return "", err
}
var build *builder.Result
var buildResult *builder.Result
if useBuildKit {
build, err = b.buildkit.Build(ctx, config)
buildResult, err = b.buildkit.Build(ctx, config)
if err != nil {
return "", err
}
} else {
build, err = b.builder.Build(ctx, config)
buildResult, err = b.builder.Build(ctx, config)
if err != nil {
return "", err
}
}
if build == nil {
if buildResult == nil {
return "", nil
}
imageID := build.ImageID
imageID := buildResult.ImageID
if options.Squash {
if imageID, err = squashBuild(build, b.imageComponent); err != nil {
if imageID, err = squashBuild(buildResult, b.imageComponent); err != nil {
return "", err
}
if config.ProgressWriter.AuxFormatter != nil {
if err = config.ProgressWriter.AuxFormatter.Emit("moby.image.id", types.BuildResult{ID: imageID}); err != nil {
if err = config.ProgressWriter.AuxFormatter.Emit("moby.image.id", build.Result{ID: imageID}); err != nil {
return "", err
}
}
@@ -97,7 +97,7 @@ func (b *Backend) Build(ctx context.Context, config backend.BuildConfig) (string
}
// PruneCache removes all cached build sources
func (b *Backend) PruneCache(ctx context.Context, opts types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error) {
func (b *Backend) PruneCache(ctx context.Context, opts build.CachePruneOptions) (*build.CachePruneReport, error) {
buildCacheSize, cacheIDs, err := b.buildkit.Prune(ctx, opts)
if err != nil {
return nil, errors.Wrap(err, "failed to prune build cache")
@@ -107,7 +107,7 @@ func (b *Backend) PruneCache(ctx context.Context, opts types.BuildCachePruneOpti
"reclaimed": strconv.FormatInt(buildCacheSize, 10),
},
})
return &types.BuildCachePruneReport{SpaceReclaimed: uint64(buildCacheSize), CachesDeleted: cacheIDs}, nil
return &build.CachePruneReport{SpaceReclaimed: uint64(buildCacheSize), CachesDeleted: cacheIDs}, nil
}
// Cancel cancels the build by ID

View File

@@ -1,4 +1,4 @@
package build // import "github.com/docker/docker/api/server/backend/build"
package build
import (
"context"
@@ -24,7 +24,7 @@ func tagImages(ctx context.Context, ic ImageComponent, stdout io.Writer, imageID
// sanitizeRepoAndTags parses the raw "t" parameter received from the client
// to a slice of repoAndTag. It removes duplicates, and validates each name
// to not contain a digest.
func sanitizeRepoAndTags(names []string) (repoAndTags []reference.Named, err error) {
func sanitizeRepoAndTags(names []string) (repoAndTags []reference.Named, _ error) {
uniqNames := map[string]struct{}{}
for _, repo := range names {
if repo == "" {

View File

@@ -1,4 +1,4 @@
package httpstatus // import "github.com/docker/docker/api/server/httpstatus"
package httpstatus
import (
"context"
@@ -8,15 +8,10 @@ import (
cerrdefs "github.com/containerd/errdefs"
"github.com/containerd/log"
"github.com/docker/distribution/registry/api/errcode"
"github.com/docker/docker/errdefs"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
)
type causer interface {
Cause() error
}
// FromError retrieves status code from error message.
func FromError(err error) int {
if err == nil {
@@ -24,48 +19,55 @@ func FromError(err error) int {
return http.StatusInternalServerError
}
// Stop right there
// Are you sure you should be adding a new error class here? Do one of the existing ones work?
// Resolve the error to ensure status is chosen from the first outermost error
rerr := cerrdefs.Resolve(err)
// Note that the below functions are already checking the error causal chain for matches.
// Only check errors from the errdefs package, no new error type checking may be added
switch {
case errdefs.IsNotFound(err):
case cerrdefs.IsNotFound(rerr):
return http.StatusNotFound
case errdefs.IsInvalidParameter(err):
case cerrdefs.IsInvalidArgument(rerr):
return http.StatusBadRequest
case errdefs.IsConflict(err):
case cerrdefs.IsConflict(rerr):
return http.StatusConflict
case errdefs.IsUnauthorized(err):
case cerrdefs.IsUnauthorized(rerr):
return http.StatusUnauthorized
case errdefs.IsUnavailable(err):
case cerrdefs.IsUnavailable(rerr):
return http.StatusServiceUnavailable
case errdefs.IsForbidden(err):
case cerrdefs.IsPermissionDenied(rerr):
return http.StatusForbidden
case errdefs.IsNotModified(err):
case cerrdefs.IsNotModified(rerr):
return http.StatusNotModified
case errdefs.IsNotImplemented(err):
case cerrdefs.IsNotImplemented(rerr):
return http.StatusNotImplemented
case errdefs.IsSystem(err) || errdefs.IsUnknown(err) || errdefs.IsDataLoss(err) || errdefs.IsDeadline(err) || errdefs.IsCancelled(err):
case cerrdefs.IsInternal(rerr) || cerrdefs.IsDataLoss(rerr) || cerrdefs.IsDeadlineExceeded(rerr) || cerrdefs.IsCanceled(rerr):
return http.StatusInternalServerError
default:
if statusCode := statusCodeFromGRPCError(err); statusCode != http.StatusInternalServerError {
return statusCode
}
if statusCode := statusCodeFromContainerdError(err); statusCode != http.StatusInternalServerError {
return statusCode
}
if statusCode := statusCodeFromDistributionError(err); statusCode != http.StatusInternalServerError {
return statusCode
}
if e, ok := err.(causer); ok {
return FromError(e.Cause())
switch e := err.(type) {
case interface{ Unwrap() error }:
return FromError(e.Unwrap())
case interface{ Unwrap() []error }:
for _, ue := range e.Unwrap() {
if statusCode := FromError(ue); statusCode != http.StatusInternalServerError {
return statusCode
}
}
}
log.G(context.TODO()).WithFields(log.Fields{
"module": "api",
"error": err,
"error_type": fmt.Sprintf("%T", err),
}).Debug("FIXME: Got an API for which error does not match any expected type!!!")
if !cerrdefs.IsUnknown(err) {
log.G(context.TODO()).WithFields(log.Fields{
"module": "api",
"error": err,
"error_type": fmt.Sprintf("%T", err),
}).Debug("FIXME: Got an API for which error does not match any expected type!!!")
}
return http.StatusInternalServerError
}
@@ -120,24 +122,3 @@ func statusCodeFromDistributionError(err error) int {
}
return http.StatusInternalServerError
}
// statusCodeFromContainerdError returns status code for containerd errors when
// consumed directly (not through gRPC)
func statusCodeFromContainerdError(err error) int {
switch {
case cerrdefs.IsInvalidArgument(err):
return http.StatusBadRequest
case cerrdefs.IsNotFound(err):
return http.StatusNotFound
case cerrdefs.IsAlreadyExists(err):
return http.StatusConflict
case cerrdefs.IsFailedPrecondition(err):
return http.StatusPreconditionFailed
case cerrdefs.IsUnavailable(err):
return http.StatusServiceUnavailable
case cerrdefs.IsNotImplemented(err):
return http.StatusNotImplemented
default:
return http.StatusInternalServerError
}
}

View File

@@ -1,4 +1,4 @@
package httputils // import "github.com/docker/docker/api/server/httputils"
package httputils
import (
"io"

View File

@@ -1,4 +1,4 @@
package httputils // import "github.com/docker/docker/api/server/httputils"
package httputils
import (
"encoding/json"
@@ -16,8 +16,12 @@ import (
// BoolValue transforms a form value in different formats into a boolean type.
func BoolValue(r *http.Request, k string) bool {
s := strings.ToLower(strings.TrimSpace(r.FormValue(k)))
return !(s == "" || s == "0" || s == "no" || s == "false" || s == "none")
switch strings.ToLower(strings.TrimSpace(r.FormValue(k))) {
case "", "0", "no", "false", "none":
return false
default:
return true
}
}
// BoolValueOrDefault returns the default bool passed if the query param is
@@ -158,3 +162,22 @@ func DecodePlatform(platformJSON string) (*ocispec.Platform, error) {
return &p, nil
}
// DecodePlatforms decodes the OCI platform JSON string into a Platform struct.
//
// Typically, the argument is a value of: r.Form["platform"]
func DecodePlatforms(platformJSONs []string) ([]ocispec.Platform, error) {
if len(platformJSONs) == 0 {
return nil, nil
}
var output []ocispec.Platform
for _, platform := range platformJSONs {
p, err := DecodePlatform(platform)
if err != nil {
return nil, err
}
output = append(output, *p)
}
return output, nil
}

View File

@@ -1,4 +1,4 @@
package httputils // import "github.com/docker/docker/api/server/httputils"
package httputils
import (
"math"
@@ -7,7 +7,7 @@ import (
"strconv"
"testing"
"github.com/docker/docker/errdefs"
cerrdefs "github.com/containerd/errdefs"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
@@ -30,7 +30,7 @@ func TestBoolValue(t *testing.T) {
for c, e := range cases {
v := url.Values{}
v.Set("test", c)
r, _ := http.NewRequest(http.MethodPost, "", nil)
r, _ := http.NewRequest(http.MethodPost, "", http.NoBody)
r.Form = v
a := BoolValue(r, "test")
@@ -41,14 +41,14 @@ func TestBoolValue(t *testing.T) {
}
func TestBoolValueOrDefault(t *testing.T) {
r, _ := http.NewRequest(http.MethodGet, "", nil)
r, _ := http.NewRequest(http.MethodGet, "", http.NoBody)
if !BoolValueOrDefault(r, "queryparam", true) {
t.Fatal("Expected to get true default value, got false")
}
v := url.Values{}
v.Set("param", "")
r, _ = http.NewRequest(http.MethodGet, "", nil)
r, _ = http.NewRequest(http.MethodGet, "", http.NoBody)
r.Form = v
if BoolValueOrDefault(r, "param", true) {
t.Fatal("Expected not to get true")
@@ -66,7 +66,7 @@ func TestInt64ValueOrZero(t *testing.T) {
for c, e := range cases {
v := url.Values{}
v.Set("test", c)
r, _ := http.NewRequest(http.MethodPost, "", nil)
r, _ := http.NewRequest(http.MethodPost, "", http.NoBody)
r.Form = v
a := Int64ValueOrZero(r, "test")
@@ -86,7 +86,7 @@ func TestInt64ValueOrDefault(t *testing.T) {
for c, e := range cases {
v := url.Values{}
v.Set("test", c)
r, _ := http.NewRequest(http.MethodPost, "", nil)
r, _ := http.NewRequest(http.MethodPost, "", http.NoBody)
r.Form = v
a, err := Int64ValueOrDefault(r, "test", -1)
@@ -102,7 +102,7 @@ func TestInt64ValueOrDefault(t *testing.T) {
func TestInt64ValueOrDefaultWithError(t *testing.T) {
v := url.Values{}
v.Set("test", "invalid")
r, _ := http.NewRequest(http.MethodPost, "", nil)
r, _ := http.NewRequest(http.MethodPost, "", http.NoBody)
r.Form = v
_, err := Int64ValueOrDefault(r, "test", -1)
@@ -150,7 +150,7 @@ func TestUint32Value(t *testing.T) {
}
for _, tc := range tests {
t.Run(tc.value, func(t *testing.T) {
r, _ := http.NewRequest(http.MethodPost, "", nil)
r, _ := http.NewRequest(http.MethodPost, "", http.NoBody)
r.Form = url.Values{}
if tc.value != valueNotSet {
r.Form.Set("field", tc.value)
@@ -225,7 +225,7 @@ func TestDecodePlatform(t *testing.T) {
p, err := DecodePlatform(tc.platformJSON)
assert.Check(t, is.DeepEqual(p, tc.expected))
if tc.expectedErr != "" {
assert.Check(t, errdefs.IsInvalidParameter(err))
assert.Check(t, cerrdefs.IsInvalidArgument(err))
assert.Check(t, is.Error(err, tc.expectedErr))
} else {
assert.Check(t, err)

View File

@@ -1,4 +1,4 @@
package httputils // import "github.com/docker/docker/api/server/httputils"
package httputils
import (
"context"
@@ -74,7 +74,7 @@ func ReadJSON(r *http.Request, out interface{}) error {
err = dec.Decode(out)
defer r.Body.Close()
if err != nil {
if err == io.EOF {
if errors.Is(err, io.EOF) {
return errdefs.InvalidParameter(errors.New("invalid JSON: got EOF while reading request body"))
}
return errdefs.InvalidParameter(errors.Wrap(err, "invalid JSON"))

View File

@@ -1,4 +1,4 @@
package httputils // import "github.com/docker/docker/api/server/httputils"
package httputils
import (
"net/http"
@@ -33,7 +33,7 @@ func TestJsonContentType(t *testing.T) {
func TestReadJSON(t *testing.T) {
t.Run("nil body", func(t *testing.T) {
req, err := http.NewRequest(http.MethodPost, "https://example.com/some/path", nil)
req, err := http.NewRequest(http.MethodPost, "https://example.com/some/path", http.NoBody)
if err != nil {
t.Error(err)
}

View File

@@ -1,4 +1,4 @@
package httputils // import "github.com/docker/docker/api/server/httputils"
package httputils
import (
"context"

View File

@@ -1,4 +1,4 @@
package server // import "github.com/docker/docker/api/server"
package server
import (
"github.com/containerd/log"

View File

@@ -1,4 +1,4 @@
package middleware // import "github.com/docker/docker/api/server/middleware"
package middleware
import (
"bufio"
@@ -17,7 +17,7 @@ import (
// DebugRequestMiddleware dumps the request to logger
func DebugRequestMiddleware(handler func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error) func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) (retErr error) {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
logger := log.G(ctx)
// Use a variable for fields to prevent overhead of repeatedly
@@ -28,25 +28,27 @@ func DebugRequestMiddleware(handler func(ctx context.Context, w http.ResponseWri
"request-url": r.RequestURI,
"vars": vars,
}
logger.WithFields(fields).Debugf("handling %s request", r.Method)
defer func() {
if retErr != nil {
handleWithLogs := func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
logger.WithFields(fields).Debugf("handling %s request", r.Method)
err := handler(ctx, w, r, vars)
if err != nil {
// TODO(thaJeztah): unify this with Server.makeHTTPHandler, which also logs internal server errors as error-log. See https://github.com/moby/moby/pull/48740#discussion_r1816675574
fields["error-response"] = retErr
fields["status"] = httpstatus.FromError(retErr)
fields["error-response"] = err
fields["status"] = httpstatus.FromError(err)
logger.WithFields(fields).Debugf("error response for %s request", r.Method)
}
}()
return err
}
if r.Method != http.MethodPost {
return handler(ctx, w, r, vars)
return handleWithLogs(ctx, w, r, vars)
}
if err := httputils.CheckForJSON(r); err != nil {
return handler(ctx, w, r, vars)
return handleWithLogs(ctx, w, r, vars)
}
maxBodySize := 4096 // 4KB
if r.ContentLength > int64(maxBodySize) {
return handler(ctx, w, r, vars)
return handleWithLogs(ctx, w, r, vars)
}
body := r.Body
@@ -56,7 +58,7 @@ func DebugRequestMiddleware(handler func(ctx context.Context, w http.ResponseWri
b, err := bufReader.Peek(maxBodySize)
if err != io.EOF {
// either there was an error reading, or the buffer is full (in which case the request is too large)
return handler(ctx, w, r, vars)
return handleWithLogs(ctx, w, r, vars)
}
var postForm map[string]interface{}
@@ -74,7 +76,7 @@ func DebugRequestMiddleware(handler func(ctx context.Context, w http.ResponseWri
}
}
return handler(ctx, w, r, vars)
return handleWithLogs(ctx, w, r, vars)
}
}

View File

@@ -1,4 +1,4 @@
package middleware // import "github.com/docker/docker/api/server/middleware"
package middleware
import (
"testing"

View File

@@ -1,4 +1,4 @@
package middleware // import "github.com/docker/docker/api/server/middleware"
package middleware
import (
"context"

View File

@@ -1,4 +1,4 @@
package middleware // import "github.com/docker/docker/api/server/middleware"
package middleware
import (
"context"

View File

@@ -1,4 +1,4 @@
package middleware // import "github.com/docker/docker/api/server/middleware"
package middleware
import (
"context"

View File

@@ -1,4 +1,4 @@
package middleware // import "github.com/docker/docker/api/server/middleware"
package middleware
import (
"context"
@@ -79,7 +79,7 @@ func TestVersionMiddlewareVersion(t *testing.T) {
assert.NilError(t, err)
h := m.WrapHandler(handler)
req, _ := http.NewRequest(http.MethodGet, "/containers/json", nil)
req, _ := http.NewRequest(http.MethodGet, "/containers/json", http.NoBody)
resp := httptest.NewRecorder()
ctx := context.Background()
@@ -121,7 +121,7 @@ func TestVersionMiddlewareVersion(t *testing.T) {
func TestVersionMiddlewareWithErrorsReturnsHeaders(t *testing.T) {
handler := func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
v := httputils.VersionFromContext(ctx)
assert.Check(t, len(v) != 0)
assert.Check(t, v != "")
return nil
}
@@ -129,7 +129,7 @@ func TestVersionMiddlewareWithErrorsReturnsHeaders(t *testing.T) {
assert.NilError(t, err)
h := m.WrapHandler(handler)
req, _ := http.NewRequest(http.MethodGet, "/containers/json", nil)
req, _ := http.NewRequest(http.MethodGet, "/containers/json", http.NoBody)
resp := httptest.NewRecorder()
ctx := context.Background()

View File

@@ -1,10 +1,10 @@
package build // import "github.com/docker/docker/api/server/router/build"
package build
import (
"context"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/build"
)
// Backend abstracts an image builder whose only purpose is to build an image referenced by an imageID.
@@ -13,8 +13,8 @@ type Backend interface {
// TODO: make this return a reference instead of string
Build(context.Context, backend.BuildConfig) (string, error)
// Prune build cache
PruneCache(context.Context, types.BuildCachePruneOptions) (*types.BuildCachePruneReport, error)
// PruneCache prunes the build cache.
PruneCache(context.Context, build.CachePruneOptions) (*build.CachePruneReport, error)
Cancel(context.Context, string) error
}

View File

@@ -1,10 +1,10 @@
package build // import "github.com/docker/docker/api/server/router/build"
package build
import (
"runtime"
"github.com/docker/docker/api/server/router"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/build"
)
// buildRouter is a router to talk with the build controller
@@ -25,15 +25,15 @@ func NewRouter(b Backend, d experimentalProvider) router.Router {
}
// Routes returns the available routers to the build controller
func (r *buildRouter) Routes() []router.Route {
return r.routes
func (br *buildRouter) Routes() []router.Route {
return br.routes
}
func (r *buildRouter) initRoutes() {
r.routes = []router.Route{
router.NewPostRoute("/build", r.postBuild),
router.NewPostRoute("/build/prune", r.postPrune),
router.NewPostRoute("/build/cancel", r.postCancel),
func (br *buildRouter) initRoutes() {
br.routes = []router.Route{
router.NewPostRoute("/build", br.postBuild),
router.NewPostRoute("/build/prune", br.postPrune),
router.NewPostRoute("/build/cancel", br.postCancel),
}
}
@@ -46,15 +46,22 @@ func (r *buildRouter) initRoutes() {
//
// This value is only a recommendation as advertised by the daemon, and it is
// up to the client to choose which builder to use.
func BuilderVersion(features map[string]bool) types.BuilderVersion {
func BuilderVersion(features map[string]bool) build.BuilderVersion {
// TODO(thaJeztah) move the default to daemon/config
bv := build.BuilderBuildKit
if runtime.GOOS == "windows" {
return types.BuilderV1
// BuildKit is not yet the default on Windows.
bv = build.BuilderV1
}
bv := types.BuilderBuildKit
if v, ok := features["buildkit"]; ok && !v {
bv = types.BuilderV1
// Allow the features field in the daemon config to override the
// default builder to advertise.
if enable, ok := features["buildkit"]; ok {
if enable {
bv = build.BuilderBuildKit
} else {
bv = build.BuilderV1
}
}
return bv
}

View File

@@ -1,4 +1,4 @@
package build // import "github.com/docker/docker/api/server/router/build"
package build
import (
"bufio"
@@ -17,8 +17,8 @@ import (
"github.com/containerd/log"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/build"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/registry"
@@ -35,9 +35,9 @@ type invalidParam struct {
func (e invalidParam) InvalidParameter() {}
func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBuildOptions, error) {
options := &types.ImageBuildOptions{
Version: types.BuilderV1, // Builder V1 is the default, but can be overridden
func newImageBuildOptions(ctx context.Context, r *http.Request) (*build.ImageBuildOptions, error) {
options := &build.ImageBuildOptions{
Version: build.BuilderV1, // Builder V1 is the default, but can be overridden
Dockerfile: r.FormValue("dockerfile"),
SuppressOutput: httputils.BoolValue(r, "q"),
NoCache: httputils.BoolValue(r, "nocache"),
@@ -81,7 +81,7 @@ func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBui
if versions.GreaterThanOrEqualTo(version, "1.40") {
outputsJSON := r.FormValue("outputs")
if outputsJSON != "" {
var outputs []types.ImageBuildOutput
var outputs []build.ImageBuildOutput
if err := json.Unmarshal([]byte(outputsJSON), &outputs); err != nil {
return nil, invalidParam{errors.Wrap(err, "invalid outputs specified")}
}
@@ -159,12 +159,12 @@ func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBui
return options, nil
}
func parseVersion(s string) (types.BuilderVersion, error) {
switch types.BuilderVersion(s) {
case types.BuilderV1:
return types.BuilderV1, nil
case types.BuilderBuildKit:
return types.BuilderBuildKit, nil
func parseVersion(s string) (build.BuilderVersion, error) {
switch build.BuilderVersion(s) {
case build.BuilderV1:
return build.BuilderV1, nil
case build.BuilderBuildKit:
return build.BuilderBuildKit, nil
default:
return "", invalidParam{errors.Errorf("invalid version %q", s)}
}
@@ -179,7 +179,7 @@ func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *
return err
}
opts := types.BuildCachePruneOptions{
opts := build.CachePruneOptions{
All: httputils.BoolValue(r, "all"),
Filters: fltrs,
}
@@ -197,17 +197,18 @@ func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *
version := httputils.VersionFromContext(ctx)
if versions.GreaterThanOrEqualTo(version, "1.48") {
bs, err := parseBytesFromFormValue("reserved-space")
if err != nil {
if bs, err := parseBytesFromFormValue("reserved-space"); err != nil {
return err
} else if bs == 0 {
// Deprecated parameter. Only checked if reserved-space is not used.
bs, err = parseBytesFromFormValue("keep-storage")
if err != nil {
return err
} else {
if bs == 0 {
// Deprecated parameter. Only checked if reserved-space is not used.
bs, err = parseBytesFromFormValue("keep-storage")
if err != nil {
return err
}
}
opts.ReservedSpace = bs
}
opts.ReservedSpace = bs
if bs, err := parseBytesFromFormValue("max-used-space"); err != nil {
return err
@@ -222,11 +223,11 @@ func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *
}
} else {
// Only keep-storage was valid in pre-1.48 versions.
bs, err := parseBytesFromFormValue("keep-storage")
if err != nil {
if bs, err := parseBytesFromFormValue("keep-storage"); err != nil {
return err
} else {
opts.ReservedSpace = bs
}
opts.ReservedSpace = bs
}
report, err := br.backend.PruneCache(ctx, opts)

View File

@@ -1,4 +1,4 @@
package checkpoint // import "github.com/docker/docker/api/server/router/checkpoint"
package checkpoint
import "github.com/docker/docker/api/types/checkpoint"

View File

@@ -1,4 +1,4 @@
package checkpoint // import "github.com/docker/docker/api/server/router/checkpoint"
package checkpoint
import (
"github.com/docker/docker/api/server/httputils"
@@ -23,14 +23,14 @@ func NewRouter(b Backend, decoder httputils.ContainerDecoder) router.Router {
}
// Routes returns the available routers to the checkpoint controller
func (r *checkpointRouter) Routes() []router.Route {
return r.routes
func (cr *checkpointRouter) Routes() []router.Route {
return cr.routes
}
func (r *checkpointRouter) initRoutes() {
r.routes = []router.Route{
router.NewGetRoute("/containers/{name:.*}/checkpoints", r.getContainerCheckpoints, router.Experimental),
router.NewPostRoute("/containers/{name:.*}/checkpoints", r.postContainerCheckpoint, router.Experimental),
router.NewDeleteRoute("/containers/{name}/checkpoints/{checkpoint}", r.deleteContainerCheckpoint, router.Experimental),
func (cr *checkpointRouter) initRoutes() {
cr.routes = []router.Route{
router.NewGetRoute("/containers/{name:.*}/checkpoints", cr.getContainerCheckpoints, router.Experimental),
router.NewPostRoute("/containers/{name:.*}/checkpoints", cr.postContainerCheckpoint, router.Experimental),
router.NewDeleteRoute("/containers/{name}/checkpoints/{checkpoint}", cr.deleteContainerCheckpoint, router.Experimental),
}
}

View File

@@ -1,4 +1,4 @@
package checkpoint // import "github.com/docker/docker/api/server/router/checkpoint"
package checkpoint
import (
"context"
@@ -8,7 +8,7 @@ import (
"github.com/docker/docker/api/types/checkpoint"
)
func (s *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (cr *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -18,7 +18,7 @@ func (s *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.R
return err
}
err := s.backend.CheckpointCreate(vars["name"], options)
err := cr.backend.CheckpointCreate(vars["name"], options)
if err != nil {
return err
}
@@ -27,12 +27,12 @@ func (s *checkpointRouter) postContainerCheckpoint(ctx context.Context, w http.R
return nil
}
func (s *checkpointRouter) getContainerCheckpoints(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (cr *checkpointRouter) getContainerCheckpoints(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
checkpoints, err := s.backend.CheckpointList(vars["name"], checkpoint.ListOptions{
checkpoints, err := cr.backend.CheckpointList(vars["name"], checkpoint.ListOptions{
CheckpointDir: r.Form.Get("dir"),
})
if err != nil {
@@ -42,12 +42,12 @@ func (s *checkpointRouter) getContainerCheckpoints(ctx context.Context, w http.R
return httputils.WriteJSON(w, http.StatusOK, checkpoints)
}
func (s *checkpointRouter) deleteContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (cr *checkpointRouter) deleteContainerCheckpoint(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
err := s.backend.CheckpointDelete(vars["name"], checkpoint.DeleteOptions{
err := cr.backend.CheckpointDelete(vars["name"], checkpoint.DeleteOptions{
CheckpointDir: r.Form.Get("dir"),
CheckpointID: vars["checkpoint"],
})

View File

@@ -1,4 +1,4 @@
package container // import "github.com/docker/docker/api/server/router/container"
package container
import (
"context"
@@ -7,8 +7,7 @@ import (
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
containerpkg "github.com/docker/docker/container"
"github.com/docker/docker/pkg/archive"
"github.com/moby/go-archive"
)
// execBackend includes functions to implement to provide exec functionality.
@@ -41,7 +40,7 @@ type stateBackend interface {
ContainerStop(ctx context.Context, name string, options container.StopOptions) error
ContainerUnpause(name string) error
ContainerUpdate(name string, hostConfig *container.HostConfig) (container.UpdateResponse, error)
ContainerWait(ctx context.Context, name string, condition containerpkg.WaitCondition) (<-chan containerpkg.StateStatus, error)
ContainerWait(ctx context.Context, name string, condition container.WaitCondition) (<-chan container.StateStatus, error)
}
// monitorBackend includes functions to implement to provide containers monitoring functionality.

View File

@@ -1,4 +1,4 @@
package container // import "github.com/docker/docker/api/server/router/container"
package container
import (
"github.com/docker/docker/api/server/httputils"

View File

@@ -1,4 +1,4 @@
package container // import "github.com/docker/docker/api/server/router/container"
package container
import (
"context"
@@ -21,7 +21,6 @@ import (
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/versions"
containerpkg "github.com/docker/docker/container"
networkSettings "github.com/docker/docker/daemon/network"
"github.com/docker/docker/errdefs"
"github.com/docker/docker/libnetwork/netlabel"
@@ -164,7 +163,7 @@ func (c *containerRouter) getContainersLogs(ctx context.Context, w http.Response
// any error after the stream starts (i.e. container not found, wrong parameters)
// with the appropriate status code.
stdout, stderr := httputils.BoolValue(r, "stdout"), httputils.BoolValue(r, "stderr")
if !(stdout || stderr) {
if !stdout && !stderr {
return errdefs.InvalidParameter(errors.New("Bad parameters: you must choose at least one stream"))
}
@@ -337,7 +336,7 @@ func (c *containerRouter) postContainersWait(ctx context.Context, w http.Respons
legacyRemovalWaitPre134 := false
// The wait condition defaults to "not-running".
waitCondition := containerpkg.WaitConditionNotRunning
waitCondition := container.WaitConditionNotRunning
if !legacyBehaviorPre130 {
if err := httputils.ParseForm(r); err != nil {
return err
@@ -345,11 +344,11 @@ func (c *containerRouter) postContainersWait(ctx context.Context, w http.Respons
if v := r.Form.Get("condition"); v != "" {
switch container.WaitCondition(v) {
case container.WaitConditionNotRunning:
waitCondition = containerpkg.WaitConditionNotRunning
waitCondition = container.WaitConditionNotRunning
case container.WaitConditionNextExit:
waitCondition = containerpkg.WaitConditionNextExit
waitCondition = container.WaitConditionNextExit
case container.WaitConditionRemoved:
waitCondition = containerpkg.WaitConditionRemoved
waitCondition = container.WaitConditionRemoved
legacyRemovalWaitPre134 = versions.LessThan(version, "1.34")
default:
return errdefs.InvalidParameter(errors.Errorf("invalid condition: %q", v))
@@ -960,21 +959,17 @@ func (c *containerRouter) postContainersResize(ctx context.Context, w http.Respo
}
func (c *containerRouter) postContainersAttach(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
err := httputils.ParseForm(r)
if err != nil {
if err := httputils.ParseForm(r); err != nil {
return err
}
containerName := vars["name"]
_, upgrade := r.Header["Upgrade"]
detachKeys := r.FormValue("detachKeys")
hijacker, ok := w.(http.Hijacker)
if !ok {
return errdefs.InvalidParameter(errors.Errorf("error attaching to container %s, hijack connection missing", containerName))
}
contentType := types.MediaTypeRawStream
_, upgrade := r.Header["Upgrade"]
setupStreams := func(multiplexed bool, cancel func()) (io.ReadCloser, io.Writer, io.Writer, error) {
conn, _, err := hijacker.Hijack()
if err != nil {
@@ -1004,18 +999,16 @@ func (c *containerRouter) postContainersAttach(ctx context.Context, w http.Respo
return ioutils.NewReadCloserWrapper(conn, closer), conn, conn, nil
}
attachConfig := &backend.ContainerAttachConfig{
if err := c.backend.ContainerAttach(containerName, &backend.ContainerAttachConfig{
GetStreams: setupStreams,
UseStdin: httputils.BoolValue(r, "stdin"),
UseStdout: httputils.BoolValue(r, "stdout"),
UseStderr: httputils.BoolValue(r, "stderr"),
Logs: httputils.BoolValue(r, "logs"),
Stream: httputils.BoolValue(r, "stream"),
DetachKeys: detachKeys,
DetachKeys: r.FormValue("detachKeys"),
MuxStreams: true,
}
if err = c.backend.ContainerAttach(containerName, attachConfig); err != nil {
}); err != nil {
log.G(ctx).WithError(err).Errorf("Handler for %s %s returned error", r.Method, r.URL.Path)
// Remember to close stream if error happens
conn, _, errHijack := hijacker.Hijack()
@@ -1037,9 +1030,6 @@ func (c *containerRouter) wsContainersAttach(ctx context.Context, w http.Respons
}
containerName := vars["name"]
var err error
detachKeys := r.FormValue("detachKeys")
done := make(chan struct{})
started := make(chan struct{})
@@ -1076,18 +1066,16 @@ func (c *containerRouter) wsContainersAttach(ctx context.Context, w http.Respons
useStderr = httputils.BoolValue(r, "stderr")
}
attachConfig := &backend.ContainerAttachConfig{
err := c.backend.ContainerAttach(containerName, &backend.ContainerAttachConfig{
GetStreams: setupStreams,
UseStdin: useStdin,
UseStdout: useStdout,
UseStderr: useStderr,
Logs: httputils.BoolValue(r, "logs"),
Stream: httputils.BoolValue(r, "stream"),
DetachKeys: detachKeys,
DetachKeys: r.FormValue("detachKeys"),
MuxStreams: false, // never multiplex, as we rely on websocket to manage distinct streams
}
err = c.backend.ContainerAttach(containerName, attachConfig)
})
close(done)
select {
case <-started:

View File

@@ -1,4 +1,4 @@
package container // import "github.com/docker/docker/api/server/router/container"
package container
import (
"compress/flate"

View File

@@ -1,4 +1,4 @@
package container // import "github.com/docker/docker/api/server/router/container"
package container
import (
"context"

View File

@@ -1,7 +1,7 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.22
//go:build go1.23
package container // import "github.com/docker/docker/api/server/router/container"
package container
import (
"context"

View File

@@ -1,4 +1,4 @@
package debug // import "github.com/docker/docker/api/server/router/debug"
package debug
import (
"context"

View File

@@ -1,4 +1,4 @@
package debug // import "github.com/docker/docker/api/server/router/debug"
package debug
import (
"context"

View File

@@ -1,4 +1,4 @@
package distribution // import "github.com/docker/docker/api/server/router/distribution"
package distribution
import (
"context"

View File

@@ -1,4 +1,4 @@
package distribution // import "github.com/docker/docker/api/server/router/distribution"
package distribution
import "github.com/docker/docker/api/server/router"
@@ -18,14 +18,14 @@ func NewRouter(backend Backend) router.Router {
}
// Routes returns the available routes
func (r *distributionRouter) Routes() []router.Route {
return r.routes
func (dr *distributionRouter) Routes() []router.Route {
return dr.routes
}
// initRoutes initializes the routes in the distribution router
func (r *distributionRouter) initRoutes() {
r.routes = []router.Route{
func (dr *distributionRouter) initRoutes() {
dr.routes = []router.Route{
// GET
router.NewGetRoute("/distribution/{name:.*}/json", r.getDistributionInfo),
router.NewGetRoute("/distribution/{name:.*}/json", dr.getDistributionInfo),
}
}

View File

@@ -1,10 +1,9 @@
package distribution // import "github.com/docker/docker/api/server/router/distribution"
package distribution
import (
"context"
"encoding/json"
"net/http"
"os"
"github.com/distribution/reference"
"github.com/docker/distribution"
@@ -19,7 +18,7 @@ import (
"github.com/pkg/errors"
)
func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (dr *distributionRouter) getDistributionInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -45,7 +44,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
// For a search it is not an error if no auth was given. Ignore invalid
// AuthConfig to increase compatibility with the existing API.
authConfig, _ := registry.DecodeAuthConfig(r.Header.Get(registry.AuthHeader))
repos, err := s.backend.GetRepositories(ctx, namedRef, authConfig)
repos, err := dr.backend.GetRepositories(ctx, namedRef, authConfig)
if err != nil {
return err
}
@@ -66,7 +65,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
// - https://github.com/moby/moby/blob/12c7411b6b7314bef130cd59f1c7384a7db06d0b/distribution/pull.go#L76-L152
var lastErr error
for _, repo := range repos {
distributionInspect, err := s.fetchManifest(ctx, repo, namedRef)
distributionInspect, err := dr.fetchManifest(ctx, repo, namedRef)
if err != nil {
lastErr = err
continue
@@ -76,7 +75,7 @@ func (s *distributionRouter) getDistributionInfo(ctx context.Context, w http.Res
return lastErr
}
func (s *distributionRouter) fetchManifest(ctx context.Context, distrepo distribution.Repository, namedRef reference.Named) (registry.DistributionInspect, error) {
func (dr *distributionRouter) fetchManifest(ctx context.Context, distrepo distribution.Repository, namedRef reference.Named) (registry.DistributionInspect, error) {
var distributionInspect registry.DistributionInspect
if canonicalRef, ok := namedRef.(reference.Canonical); !ok {
namedRef = reference.TagNameOnly(namedRef)
@@ -109,14 +108,14 @@ func (s *distributionRouter) fetchManifest(ctx context.Context, distrepo distrib
}
mnfst, err := mnfstsrvc.Get(ctx, distributionInspect.Descriptor.Digest)
if err != nil {
switch err {
case reference.ErrReferenceInvalidFormat,
reference.ErrTagInvalidFormat,
reference.ErrDigestInvalidFormat,
reference.ErrNameContainsUppercase,
reference.ErrNameEmpty,
reference.ErrNameTooLong,
reference.ErrNameNotCanonical:
switch {
case errors.Is(err, reference.ErrReferenceInvalidFormat),
errors.Is(err, reference.ErrTagInvalidFormat),
errors.Is(err, reference.ErrDigestInvalidFormat),
errors.Is(err, reference.ErrNameContainsUppercase),
errors.Is(err, reference.ErrNameEmpty),
errors.Is(err, reference.ErrNameTooLong),
errors.Is(err, reference.ErrNameNotCanonical):
return registry.DistributionInspect{}, errdefs.InvalidParameter(err)
}
return registry.DistributionInspect{}, err
@@ -154,15 +153,10 @@ func (s *distributionRouter) fetchManifest(ctx context.Context, distrepo distrib
distributionInspect.Platforms = append(distributionInspect.Platforms, platform)
}
}
// TODO(thaJeztah); we only use this to produce a nice error, but as a result, we can't remove libtrust as dependency - see if we can reduce the dependencies, but still able to detect it's a deprecated manifest
case *schema1.SignedManifest:
if os.Getenv("DOCKER_ENABLE_DEPRECATED_PULL_SCHEMA_1_IMAGE") == "" {
return registry.DistributionInspect{}, distributionpkg.DeprecatedSchema1ImageError(namedRef)
}
platform := ocispec.Platform{
Architecture: mnfstObj.Architecture,
OS: "linux",
}
distributionInspect.Platforms = append(distributionInspect.Platforms, platform)
return registry.DistributionInspect{}, distributionpkg.DeprecatedSchema1ImageError(namedRef)
}
return distributionInspect, nil
}

View File

@@ -1,4 +1,4 @@
package router // import "github.com/docker/docker/api/server/router"
package router
import (
"context"

View File

@@ -1,4 +1,4 @@
package grpc // import "github.com/docker/docker/api/server/router/grpc"
package grpc
import "google.golang.org/grpc"

View File

@@ -1,7 +1,7 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.22
//go:build go1.23
package grpc // import "github.com/docker/docker/api/server/router/grpc"
package grpc
import (
"context"
@@ -60,7 +60,7 @@ func (gr *grpcRouter) initRoutes() {
}
}
func unaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {
func unaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, _ error) {
// This method is used by the clients to send their traces to buildkit so they can be included
// in the daemon trace and stored in the build history record. This method can not be traced because
// it would cause an infinite loop.
@@ -68,11 +68,11 @@ func unaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo,
return handler(ctx, req)
}
resp, err = handler(ctx, req)
resp, err := handler(ctx, req)
if err != nil {
log.G(ctx).WithError(err).Error(info.FullMethod)
if log.GetLevel() >= log.DebugLevel {
fmt.Fprintf(os.Stderr, "%+v", stack.Formatter(grpcerrors.FromGRPC(err)))
_, _ = fmt.Fprintf(os.Stderr, "%+v", stack.Formatter(grpcerrors.FromGRPC(err)))
}
}
return resp, err

View File

@@ -1,4 +1,4 @@
package grpc // import "github.com/docker/docker/api/server/router/grpc"
package grpc
import (
"context"

View File

@@ -1,4 +1,4 @@
package image // import "github.com/docker/docker/api/server/router/image"
package image
import (
"context"
@@ -22,7 +22,7 @@ type Backend interface {
}
type imageBackend interface {
ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]image.DeleteResponse, error)
ImageDelete(ctx context.Context, imageRef string, options image.RemoveOptions) ([]image.DeleteResponse, error)
ImageHistory(ctx context.Context, imageName string, platform *ocispec.Platform) ([]*image.HistoryResponseItem, error)
Images(ctx context.Context, opts image.ListOptions) ([]*image.Summary, error)
GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*dockerimage.Image, error)

View File

@@ -1,24 +1,21 @@
package image // import "github.com/docker/docker/api/server/router/image"
package image
import (
"github.com/docker/docker/api/server/router"
"github.com/docker/docker/reference"
)
// imageRouter is a router to talk with the image controller
type imageRouter struct {
backend Backend
searcher Searcher
referenceBackend reference.Store
routes []router.Route
backend Backend
searcher Searcher
routes []router.Route
}
// NewRouter initializes a new image router
func NewRouter(backend Backend, searcher Searcher, referenceBackend reference.Store) router.Router {
func NewRouter(backend Backend, searcher Searcher) router.Router {
ir := &imageRouter{
backend: backend,
searcher: searcher,
referenceBackend: referenceBackend,
backend: backend,
searcher: searcher,
}
ir.initRoutes()
return ir

View File

@@ -1,4 +1,4 @@
package image // import "github.com/docker/docker/api/server/router/image"
package image
import (
"context"
@@ -110,7 +110,7 @@ func (ir *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrit
return errdefs.InvalidParameter(err)
}
if len(comment) == 0 {
if comment == "" {
comment = "Imported from " + src
}
@@ -323,7 +323,20 @@ func (ir *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter,
force := httputils.BoolValue(r, "force")
prune := !httputils.BoolValue(r, "noprune")
list, err := ir.backend.ImageDelete(ctx, name, force, prune)
var platforms []ocispec.Platform
if versions.GreaterThanOrEqualTo(httputils.VersionFromContext(ctx), "1.50") {
p, err := httputils.DecodePlatforms(r.Form["platforms"])
if err != nil {
return err
}
platforms = p
}
list, err := ir.backend.ImageDelete(ctx, name, imagetypes.RemoveOptions{
Force: force,
PruneChildren: prune,
Platforms: platforms,
})
if err != nil {
return err
}
@@ -341,13 +354,35 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
manifests = httputils.BoolValue(r, "manifests")
}
imageInspect, err := ir.backend.ImageInspect(ctx, vars["name"], backend.ImageInspectOpts{
var platform *ocispec.Platform
if r.Form.Get("platform") != "" && versions.GreaterThanOrEqualTo(httputils.VersionFromContext(ctx), "1.49") {
p, err := httputils.DecodePlatform(r.Form.Get("platform"))
if err != nil {
return errdefs.InvalidParameter(err)
}
platform = p
}
if manifests && platform != nil {
return errdefs.InvalidParameter(errors.New("conflicting options: manifests and platform options cannot both be set"))
}
resp, err := ir.backend.ImageInspect(ctx, vars["name"], backend.ImageInspectOpts{
Manifests: manifests,
Platform: platform,
})
if err != nil {
return err
}
// inspectResponse preserves fields in the response that have an
// "omitempty" in the OCI spec, but didn't omit such fields in
// legacy responses before API v1.50.
imageInspect := &inspectCompatResponse{
InspectResponse: resp,
legacyConfig: legacyConfigFields["current"],
}
// Make sure we output empty arrays instead of nil. While Go nil slice is functionally equivalent to an empty slice,
// it matters for the JSON representation.
if imageInspect.RepoTags == nil {
@@ -374,6 +409,10 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
if versions.LessThan(version, "1.48") {
imageInspect.Descriptor = nil
}
if versions.LessThan(version, "1.50") {
imageInspect.legacyConfig = legacyConfigFields["v1.49"]
}
return httputils.WriteJSON(w, http.StatusOK, imageInspect)
}
@@ -420,6 +459,7 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
useNone := versions.LessThan(version, "1.43")
withVirtualSize := versions.LessThan(version, "1.44")
noDescriptor := versions.LessThan(version, "1.48")
noContainers := versions.LessThan(version, "1.51")
for _, img := range images {
if useNone {
if len(img.RepoTags) == 0 && len(img.RepoDigests) == 0 {
@@ -440,6 +480,9 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
if noDescriptor {
img.Descriptor = nil
}
if noContainers {
img.Containers = -1
}
}
return httputils.WriteJSON(w, http.StatusOK, images)

View File

@@ -0,0 +1,88 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.23
package image
import (
"encoding/json"
"maps"
"github.com/docker/docker/api/types/image"
)
// legacyConfigFields defines legacy image-config fields to include in
// API responses on older API versions.
var legacyConfigFields = map[string]map[string]any{
// Legacy fields for API v1.49 and lower. These fields are deprecated
// and omitted in newer API versions; see https://github.com/moby/moby/pull/48457
"v1.49": {
"AttachStderr": false,
"AttachStdin": false,
"AttachStdout": false,
"Cmd": nil,
"Domainname": "",
"Entrypoint": nil,
"Env": nil,
"Hostname": "",
"Image": "",
"Labels": nil,
"OnBuild": nil,
"OpenStdin": false,
"StdinOnce": false,
"Tty": false,
"User": "",
"Volumes": nil,
"WorkingDir": "",
},
// Legacy fields for current API versions (v1.50 and up). These fields
// did not have an "omitempty" and were always included in the response,
// even if not set; see https://github.com/moby/moby/issues/50134
"current": {
"Cmd": nil,
"Entrypoint": nil,
"Env": nil,
"Labels": nil,
"OnBuild": nil,
"User": "",
"Volumes": nil,
"WorkingDir": "",
},
}
// inspectCompatResponse is a wrapper around [image.InspectResponse] with a
// custom marshal function for legacy [api/types/container.Config} fields
// that have been removed, or did not have omitempty.
type inspectCompatResponse struct {
*image.InspectResponse
legacyConfig map[string]any
}
// MarshalJSON implements a custom marshaler to include legacy fields
// in API responses.
func (ir *inspectCompatResponse) MarshalJSON() ([]byte, error) {
type tmp *image.InspectResponse
base, err := json.Marshal((tmp)(ir.InspectResponse))
if err != nil {
return nil, err
}
if len(ir.legacyConfig) == 0 {
return base, nil
}
type resp struct {
*image.InspectResponse
Config map[string]any
}
var merged resp
err = json.Unmarshal(base, &merged)
if err != nil {
return base, nil
}
// prevent mutating legacyConfigFields.
cfg := maps.Clone(ir.legacyConfig)
maps.Copy(cfg, merged.Config)
merged.Config = cfg
return json.Marshal(merged)
}

View File

@@ -0,0 +1,74 @@
package image
import (
"encoding/json"
"testing"
"github.com/docker/docker/api/types/image"
dockerspec "github.com/moby/docker-image-spec/specs-go/v1"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
func TestInspectResponse(t *testing.T) {
tests := []struct {
doc string
cfg *ocispec.ImageConfig
legacyConfig map[string]any
expected string
}{
{
doc: "empty",
expected: `null`,
},
{
doc: "no legacy config",
cfg: &ocispec.ImageConfig{
Cmd: []string{"/bin/sh"},
StopSignal: "SIGQUIT",
},
expected: `{"Cmd":["/bin/sh"],"StopSignal":"SIGQUIT"}`,
},
{
doc: "api < v1.50",
cfg: &ocispec.ImageConfig{
Cmd: []string{"/bin/sh"},
StopSignal: "SIGQUIT",
},
legacyConfig: legacyConfigFields["v1.49"],
expected: `{"AttachStderr":false,"AttachStdin":false,"AttachStdout":false,"Cmd":["/bin/sh"],"Domainname":"","Entrypoint":null,"Env":null,"Hostname":"","Image":"","Labels":null,"OnBuild":null,"OpenStdin":false,"StdinOnce":false,"StopSignal":"SIGQUIT","Tty":false,"User":"","Volumes":null,"WorkingDir":""}`,
},
{
doc: "api >= v1.50",
cfg: &ocispec.ImageConfig{
Cmd: []string{"/bin/sh"},
StopSignal: "SIGQUIT",
},
legacyConfig: legacyConfigFields["current"],
expected: `{"Cmd":["/bin/sh"],"Entrypoint":null,"Env":null,"Labels":null,"OnBuild":null,"StopSignal":"SIGQUIT","User":"","Volumes":null,"WorkingDir":""}`,
},
}
for _, tc := range tests {
t.Run(tc.doc, func(t *testing.T) {
imgInspect := &image.InspectResponse{}
if tc.cfg != nil {
// Verify that fields that are set override the legacy values,
// or appended if not part of the legacy values.
imgInspect.Config = &dockerspec.DockerOCIImageConfig{
ImageConfig: *tc.cfg,
}
}
out, err := json.Marshal(&inspectCompatResponse{
InspectResponse: imgInspect,
legacyConfig: tc.legacyConfig,
})
assert.NilError(t, err)
var outMap struct{ Config json.RawMessage }
err = json.Unmarshal(out, &outMap)
assert.NilError(t, err)
assert.Check(t, is.Equal(string(outMap.Config), tc.expected))
})
}
}

View File

@@ -1,4 +1,4 @@
package router // import "github.com/docker/docker/api/server/router"
package router
import (
"net/http"

View File

@@ -1,4 +1,4 @@
package network // import "github.com/docker/docker/api/server/router/network"
package network
import (
"context"
@@ -12,7 +12,7 @@ import (
// to provide network specific functionality.
type Backend interface {
GetNetworks(filters.Args, backend.NetworkListConfig) ([]network.Inspect, error)
CreateNetwork(nc network.CreateRequest) (*network.CreateResponse, error)
CreateNetwork(ctx context.Context, nc network.CreateRequest) (*network.CreateResponse, error)
ConnectContainerToNetwork(ctx context.Context, containerName, networkName string, endpointConfig *network.EndpointSettings) error
DisconnectContainerFromNetwork(containerName string, networkName string, force bool) error
DeleteNetwork(networkID string) error

View File

@@ -1,4 +1,4 @@
package network // import "github.com/docker/docker/api/server/router/network"
package network
import (
"github.com/docker/docker/api/server/router"
@@ -22,22 +22,22 @@ func NewRouter(b Backend, c ClusterBackend) router.Router {
}
// Routes returns the available routes to the network controller
func (r *networkRouter) Routes() []router.Route {
return r.routes
func (n *networkRouter) Routes() []router.Route {
return n.routes
}
func (r *networkRouter) initRoutes() {
r.routes = []router.Route{
func (n *networkRouter) initRoutes() {
n.routes = []router.Route{
// GET
router.NewGetRoute("/networks", r.getNetworksList),
router.NewGetRoute("/networks/", r.getNetworksList),
router.NewGetRoute("/networks/{id:.+}", r.getNetwork),
router.NewGetRoute("/networks", n.getNetworksList),
router.NewGetRoute("/networks/", n.getNetworksList),
router.NewGetRoute("/networks/{id:.+}", n.getNetwork),
// POST
router.NewPostRoute("/networks/create", r.postNetworkCreate),
router.NewPostRoute("/networks/{id:.*}/connect", r.postNetworkConnect),
router.NewPostRoute("/networks/{id:.*}/disconnect", r.postNetworkDisconnect),
router.NewPostRoute("/networks/prune", r.postNetworksPrune),
router.NewPostRoute("/networks/create", n.postNetworkCreate),
router.NewPostRoute("/networks/{id:.*}/connect", n.postNetworkConnect),
router.NewPostRoute("/networks/{id:.*}/disconnect", n.postNetworkDisconnect),
router.NewPostRoute("/networks/prune", n.postNetworksPrune),
// DELETE
router.NewDeleteRoute("/networks/{id:.*}", r.deleteNetwork),
router.NewDeleteRoute("/networks/{id:.*}", n.deleteNetwork),
}
}

View File

@@ -1,4 +1,4 @@
package network // import "github.com/docker/docker/api/server/router/network"
package network
import (
"context"
@@ -145,7 +145,7 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r
// ex: overlay/partial_ID or name/swarm_scope
if nwv, ok := listByPartialID[nwk.ID]; ok {
nwk = nwv
} else if nwv, ok := listByFullName[nwk.ID]; ok {
} else if nwv, ok = listByFullName[nwk.ID]; ok {
nwk = nwv
}
return httputils.WriteJSON(w, http.StatusOK, nwk)
@@ -223,7 +223,7 @@ func (n *networkRouter) postNetworkCreate(ctx context.Context, w http.ResponseWr
// validate the configuration. The network will not be created but, if the
// configuration is valid, ManagerRedirectError will be returned and handled
// below.
nw, err := n.backend.CreateNetwork(create)
nw, err := n.backend.CreateNetwork(ctx, create)
if err != nil {
if _, ok := err.(libnetwork.ManagerRedirectError); !ok {
return err

View File

@@ -1,4 +1,4 @@
package plugin // import "github.com/docker/docker/api/server/router/plugin"
package plugin
import (
"context"

View File

@@ -1,4 +1,4 @@
package plugin // import "github.com/docker/docker/api/server/router/plugin"
package plugin
import "github.com/docker/docker/api/server/router"
@@ -18,22 +18,22 @@ func NewRouter(b Backend) router.Router {
}
// Routes returns the available routers to the plugin controller
func (r *pluginRouter) Routes() []router.Route {
return r.routes
func (pr *pluginRouter) Routes() []router.Route {
return pr.routes
}
func (r *pluginRouter) initRoutes() {
r.routes = []router.Route{
router.NewGetRoute("/plugins", r.listPlugins),
router.NewGetRoute("/plugins/{name:.*}/json", r.inspectPlugin),
router.NewGetRoute("/plugins/privileges", r.getPrivileges),
router.NewDeleteRoute("/plugins/{name:.*}", r.removePlugin),
router.NewPostRoute("/plugins/{name:.*}/enable", r.enablePlugin),
router.NewPostRoute("/plugins/{name:.*}/disable", r.disablePlugin),
router.NewPostRoute("/plugins/pull", r.pullPlugin),
router.NewPostRoute("/plugins/{name:.*}/push", r.pushPlugin),
router.NewPostRoute("/plugins/{name:.*}/upgrade", r.upgradePlugin),
router.NewPostRoute("/plugins/{name:.*}/set", r.setPlugin),
router.NewPostRoute("/plugins/create", r.createPlugin),
func (pr *pluginRouter) initRoutes() {
pr.routes = []router.Route{
router.NewGetRoute("/plugins", pr.listPlugins),
router.NewGetRoute("/plugins/{name:.*}/json", pr.inspectPlugin),
router.NewGetRoute("/plugins/privileges", pr.getPrivileges),
router.NewDeleteRoute("/plugins/{name:.*}", pr.removePlugin),
router.NewPostRoute("/plugins/{name:.*}/enable", pr.enablePlugin),
router.NewPostRoute("/plugins/{name:.*}/disable", pr.disablePlugin),
router.NewPostRoute("/plugins/pull", pr.pullPlugin),
router.NewPostRoute("/plugins/{name:.*}/push", pr.pushPlugin),
router.NewPostRoute("/plugins/{name:.*}/upgrade", pr.upgradePlugin),
router.NewPostRoute("/plugins/{name:.*}/set", pr.setPlugin),
router.NewPostRoute("/plugins/create", pr.createPlugin),
}
}

View File

@@ -1,4 +1,4 @@
package plugin // import "github.com/docker/docker/api/server/router/plugin"
package plugin
import (
"context"

View File

@@ -1,4 +1,4 @@
package router // import "github.com/docker/docker/api/server/router"
package router
import "github.com/docker/docker/api/server/httputils"

View File

@@ -1,4 +1,4 @@
package session // import "github.com/docker/docker/api/server/router/session"
package session
import (
"context"

View File

@@ -1,4 +1,4 @@
package session // import "github.com/docker/docker/api/server/router/session"
package session
import "github.com/docker/docker/api/server/router"
@@ -18,12 +18,12 @@ func NewRouter(b Backend) router.Router {
}
// Routes returns the available routers to the session controller
func (r *sessionRouter) Routes() []router.Route {
return r.routes
func (sr *sessionRouter) Routes() []router.Route {
return sr.routes
}
func (r *sessionRouter) initRoutes() {
r.routes = []router.Route{
router.NewPostRoute("/session", r.startSession),
func (sr *sessionRouter) initRoutes() {
sr.routes = []router.Route{
router.NewPostRoute("/session", sr.startSession),
}
}

View File

@@ -1,4 +1,4 @@
package session // import "github.com/docker/docker/api/server/router/session"
package session
import (
"context"

View File

@@ -1,9 +1,8 @@
package swarm // import "github.com/docker/docker/api/server/router/swarm"
package swarm
import (
"context"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/swarm"
@@ -18,24 +17,24 @@ type Backend interface {
Update(uint64, swarm.Spec, swarm.UpdateFlags) error
GetUnlockKey() (string, error)
UnlockSwarm(req swarm.UnlockRequest) error
GetServices(types.ServiceListOptions) ([]swarm.Service, error)
GetServices(swarm.ServiceListOptions) ([]swarm.Service, error)
GetService(idOrName string, insertDefaults bool) (swarm.Service, error)
CreateService(swarm.ServiceSpec, string, bool) (*swarm.ServiceCreateResponse, error)
UpdateService(string, uint64, swarm.ServiceSpec, types.ServiceUpdateOptions, bool) (*swarm.ServiceUpdateResponse, error)
UpdateService(string, uint64, swarm.ServiceSpec, swarm.ServiceUpdateOptions, bool) (*swarm.ServiceUpdateResponse, error)
RemoveService(string) error
ServiceLogs(context.Context, *backend.LogSelector, *container.LogsOptions) (<-chan *backend.LogMessage, error)
GetNodes(types.NodeListOptions) ([]swarm.Node, error)
GetNodes(swarm.NodeListOptions) ([]swarm.Node, error)
GetNode(string) (swarm.Node, error)
UpdateNode(string, uint64, swarm.NodeSpec) error
RemoveNode(string, bool) error
GetTasks(types.TaskListOptions) ([]swarm.Task, error)
GetTasks(swarm.TaskListOptions) ([]swarm.Task, error)
GetTask(string) (swarm.Task, error)
GetSecrets(opts types.SecretListOptions) ([]swarm.Secret, error)
GetSecrets(opts swarm.SecretListOptions) ([]swarm.Secret, error)
CreateSecret(s swarm.SecretSpec) (string, error)
RemoveSecret(idOrName string) error
GetSecret(id string) (swarm.Secret, error)
UpdateSecret(idOrName string, version uint64, spec swarm.SecretSpec) error
GetConfigs(opts types.ConfigListOptions) ([]swarm.Config, error)
GetConfigs(opts swarm.ConfigListOptions) ([]swarm.Config, error)
CreateConfig(s swarm.ConfigSpec) (string, error)
RemoveConfig(id string) error
GetConfig(id string) (swarm.Config, error)

View File

@@ -1,4 +1,4 @@
package swarm // import "github.com/docker/docker/api/server/router/swarm"
package swarm
import "github.com/docker/docker/api/server/router"

View File

@@ -1,4 +1,4 @@
package swarm // import "github.com/docker/docker/api/server/router/swarm"
package swarm
import (
"context"
@@ -8,7 +8,6 @@ import (
"github.com/containerd/log"
"github.com/docker/docker/api/server/httputils"
basictypes "github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/registry"
@@ -140,7 +139,7 @@ func (sr *swarmRouter) getUnlockKey(ctx context.Context, w http.ResponseWriter,
return err
}
return httputils.WriteJSON(w, http.StatusOK, &basictypes.SwarmUnlockKeyResponse{
return httputils.WriteJSON(w, http.StatusOK, &types.UnlockKeyResponse{
UnlockKey: unlockKey,
})
}
@@ -166,7 +165,7 @@ func (sr *swarmRouter) getServices(ctx context.Context, w http.ResponseWriter, r
}
}
services, err := sr.backend.GetServices(basictypes.ServiceListOptions{Filters: filter, Status: status})
services, err := sr.backend.GetServices(types.ServiceListOptions{Filters: filter, Status: status})
if err != nil {
log.G(ctx).WithContext(ctx).WithError(err).Debug("Error getting services")
return err
@@ -245,7 +244,7 @@ func (sr *swarmRouter) updateService(ctx context.Context, w http.ResponseWriter,
return errdefs.InvalidParameter(err)
}
var flags basictypes.ServiceUpdateOptions
var flags types.ServiceUpdateOptions
// Get returns "" if the header does not exist
flags.EncodedRegistryAuth = r.Header.Get(registry.AuthHeader)
@@ -314,7 +313,7 @@ func (sr *swarmRouter) getNodes(ctx context.Context, w http.ResponseWriter, r *h
return err
}
nodes, err := sr.backend.GetNodes(basictypes.NodeListOptions{Filters: filter})
nodes, err := sr.backend.GetNodes(types.NodeListOptions{Filters: filter})
if err != nil {
log.G(ctx).WithContext(ctx).WithError(err).Debug("Error getting nodes")
return err
@@ -385,7 +384,7 @@ func (sr *swarmRouter) getTasks(ctx context.Context, w http.ResponseWriter, r *h
return err
}
tasks, err := sr.backend.GetTasks(basictypes.TaskListOptions{Filters: filter})
tasks, err := sr.backend.GetTasks(types.TaskListOptions{Filters: filter})
if err != nil {
log.G(ctx).WithContext(ctx).WithError(err).Debug("Error getting tasks")
return err
@@ -416,7 +415,7 @@ func (sr *swarmRouter) getSecrets(ctx context.Context, w http.ResponseWriter, r
return err
}
secrets, err := sr.backend.GetSecrets(basictypes.SecretListOptions{Filters: filters})
secrets, err := sr.backend.GetSecrets(types.SecretListOptions{Filters: filters})
if err != nil {
return err
}
@@ -439,7 +438,7 @@ func (sr *swarmRouter) createSecret(ctx context.Context, w http.ResponseWriter,
return err
}
return httputils.WriteJSON(w, http.StatusCreated, &basictypes.SecretCreateResponse{
return httputils.WriteJSON(w, http.StatusCreated, &types.SecretCreateResponse{
ID: id,
})
}
@@ -487,7 +486,7 @@ func (sr *swarmRouter) getConfigs(ctx context.Context, w http.ResponseWriter, r
return err
}
configs, err := sr.backend.GetConfigs(basictypes.ConfigListOptions{Filters: filters})
configs, err := sr.backend.GetConfigs(types.ConfigListOptions{Filters: filters})
if err != nil {
return err
}
@@ -511,7 +510,7 @@ func (sr *swarmRouter) createConfig(ctx context.Context, w http.ResponseWriter,
return err
}
return httputils.WriteJSON(w, http.StatusCreated, &basictypes.ConfigCreateResponse{
return httputils.WriteJSON(w, http.StatusCreated, &types.ConfigCreateResponse{
ID: id,
})
}

View File

@@ -1,4 +1,4 @@
package swarm // import "github.com/docker/docker/api/server/router/swarm"
package swarm
import (
"context"
@@ -22,7 +22,7 @@ func (sr *swarmRouter) swarmLogs(ctx context.Context, w http.ResponseWriter, r *
// any error after the stream starts (i.e. container not found, wrong parameters)
// with the appropriate status code.
stdout, stderr := httputils.BoolValue(r, "stdout"), httputils.BoolValue(r, "stderr")
if !(stdout || stderr) {
if !stdout && !stderr {
return fmt.Errorf("Bad parameters: you must choose at least one stream")
}

View File

@@ -1,4 +1,4 @@
package swarm // import "github.com/docker/docker/api/server/router/swarm"
package swarm
import (
"reflect"

View File

@@ -1,10 +1,11 @@
package system // import "github.com/docker/docker/api/server/router/system"
package system
import (
"context"
"time"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/build"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/registry"
@@ -29,7 +30,7 @@ type DiskUsageOptions struct {
type Backend interface {
SystemInfo(context.Context) (*system.Info, error)
SystemVersion(context.Context) (types.Version, error)
SystemDiskUsage(ctx context.Context, opts DiskUsageOptions) (*types.DiskUsage, error)
SystemDiskUsage(ctx context.Context, opts DiskUsageOptions) (*system.DiskUsage, error)
SubscribeToEvents(since, until time.Time, ef filters.Args) ([]events.Message, chan interface{})
UnsubscribeFromEvents(chan interface{})
AuthenticateToRegistry(ctx context.Context, authConfig *registry.AuthConfig) (string, string, error)
@@ -41,6 +42,11 @@ type ClusterBackend interface {
Info(context.Context) swarm.Info
}
// BuildBackend provides build specific system information.
type BuildBackend interface {
DiskUsage(context.Context) ([]*build.CacheRecord, error)
}
// StatusProvider provides methods to get the swarm status of the current node.
type StatusProvider interface {
Status() string

View File

@@ -0,0 +1,39 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.23
package system
import (
"encoding/json"
"github.com/docker/docker/api/types/system"
)
// infoResponse is a wrapper around [system.Info] with a custom
// marshal function for legacy fields.
type infoResponse struct {
*system.Info
// extraFields is for internal use to include deprecated fields on older API versions.
extraFields map[string]any
}
// MarshalJSON implements a custom marshaler to include legacy fields
// in API responses.
func (sc *infoResponse) MarshalJSON() ([]byte, error) {
type tmp *system.Info
base, err := json.Marshal((tmp)(sc.Info))
if err != nil {
return nil, err
}
if len(sc.extraFields) == 0 {
return base, nil
}
var merged map[string]any
_ = json.Unmarshal(base, &merged)
for k, v := range sc.extraFields {
merged[k] = v
}
return json.Marshal(merged)
}

View File

@@ -0,0 +1,33 @@
package system
import (
"encoding/json"
"strings"
"testing"
"github.com/docker/docker/api/types/system"
)
func TestLegacyFields(t *testing.T) {
infoResp := &infoResponse{
Info: &system.Info{
Containers: 10,
},
extraFields: map[string]any{
"LegacyFoo": false,
"LegacyBar": true,
},
}
data, err := json.MarshalIndent(infoResp, "", " ")
if err != nil {
t.Fatal(err)
}
if expected := `"LegacyFoo": false`; !strings.Contains(string(data), expected) {
t.Errorf("legacy fields should contain %s: %s", expected, string(data))
}
if expected := `"LegacyBar": true`; !strings.Contains(string(data), expected) {
t.Errorf("legacy fields should contain %s: %s", expected, string(data))
}
}

View File

@@ -1,12 +1,10 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.22
//go:build go1.23
package system // import "github.com/docker/docker/api/server/router/system"
package system
import (
"github.com/docker/docker/api/server/router"
"github.com/docker/docker/api/types/system"
buildkit "github.com/docker/docker/builder/builder-next"
"resenje.org/singleflight"
)
@@ -16,17 +14,17 @@ type systemRouter struct {
backend Backend
cluster ClusterBackend
routes []router.Route
builder *buildkit.Builder
builder BuildBackend
features func() map[string]bool
// collectSystemInfo is a single-flight for the /info endpoint,
// unique per API version (as different API versions may return
// a different API response).
collectSystemInfo singleflight.Group[string, *system.Info]
collectSystemInfo singleflight.Group[string, *infoResponse]
}
// NewRouter initializes a new system router
func NewRouter(b Backend, c ClusterBackend, builder *buildkit.Builder, features func() map[string]bool) router.Router {
func NewRouter(b Backend, c ClusterBackend, builder BuildBackend, features func() map[string]bool) router.Router {
r := &systemRouter{
backend: b,
cluster: c,

View File

@@ -1,4 +1,7 @@
package system // import "github.com/docker/docker/api/server/router/system"
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.23
package system
import (
"context"
@@ -11,6 +14,7 @@ import (
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/server/router/build"
"github.com/docker/docker/api/types"
buildtypes "github.com/docker/docker/api/types/build"
"github.com/docker/docker/api/types/events"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/registry"
@@ -59,7 +63,7 @@ func (s *systemRouter) swarmStatus() string {
func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
version := httputils.VersionFromContext(ctx)
info, _, _ := s.collectSystemInfo.Do(ctx, version, func(ctx context.Context) (*system.Info, error) {
info, _, _ := s.collectSystemInfo.Do(ctx, version, func(ctx context.Context) (*infoResponse, error) {
info, err := s.backend.SystemInfo(ctx)
if err != nil {
return nil, err
@@ -103,20 +107,40 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
if versions.LessThan(version, "1.47") {
// Field is omitted in API 1.48 and up, but should still be included
// in older versions, even if no values are set.
info.RegistryConfig.AllowNondistributableArtifactsCIDRs = []*registry.NetIPNet{}
info.RegistryConfig.AllowNondistributableArtifactsHostnames = []string{}
info.RegistryConfig.ExtraFields = map[string]any{
"AllowNondistributableArtifactsCIDRs": json.RawMessage(nil),
"AllowNondistributableArtifactsHostnames": json.RawMessage(nil),
}
}
if versions.LessThan(version, "1.49") {
// FirewallBackend field introduced in API v1.49.
info.FirewallBackend = nil
}
// TODO(thaJeztah): Expected commits are deprecated, and should no longer be set in API 1.49.
info.ContainerdCommit.Expected = info.ContainerdCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
info.RuncCommit.Expected = info.RuncCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
info.InitCommit.Expected = info.InitCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
extraFields := map[string]any{}
if versions.LessThan(version, "1.49") {
// Expected commits are omitted in API 1.49, but should still be
// included in older versions.
info.ContainerdCommit.Expected = info.ContainerdCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
info.RuncCommit.Expected = info.RuncCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
info.InitCommit.Expected = info.InitCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
}
if versions.GreaterThanOrEqualTo(version, "1.42") {
info.KernelMemory = false
}
return info, nil
if versions.LessThan(version, "1.50") {
info.DiscoveredDevices = nil
// These fields are omitted in > API 1.49, and always false
// older API versions.
extraFields = map[string]any{
"BridgeNfIptables": json.RawMessage("false"),
"BridgeNfIp6tables": json.RawMessage("false"),
}
}
return &infoResponse{Info: info, extraFields: extraFields}, nil
})
return httputils.WriteJSON(w, http.StatusOK, info)
}
@@ -159,7 +183,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
eg, ctx := errgroup.WithContext(ctx)
var systemDiskUsage *types.DiskUsage
var systemDiskUsage *system.DiskUsage
if getContainers || getImages || getVolumes {
eg.Go(func() error {
var err error
@@ -172,7 +196,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
})
}
var buildCache []*types.BuildCache
var buildCache []*buildtypes.CacheRecord
if getBuildCache {
eg.Go(func() error {
var err error
@@ -183,7 +207,7 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
if buildCache == nil {
// Ensure empty `BuildCache` field is represented as empty JSON array(`[]`)
// instead of `null` to be consistent with `Images`, `Containers` etc.
buildCache = []*types.BuildCache{}
buildCache = []*buildtypes.CacheRecord{}
}
return nil
})
@@ -208,23 +232,42 @@ func (s *systemRouter) getDiskUsage(ctx context.Context, w http.ResponseWriter,
b.Parent = "" //nolint:staticcheck // ignore SA1019 (Parent field is deprecated)
}
}
if versions.LessThan(version, "1.44") {
for _, b := range systemDiskUsage.Images {
if versions.LessThan(version, "1.44") && systemDiskUsage != nil && systemDiskUsage.Images != nil {
for _, b := range systemDiskUsage.Images.Items {
b.VirtualSize = b.Size //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
}
}
du := types.DiskUsage{
BuildCache: buildCache,
BuilderSize: builderSize,
du := system.DiskUsage{}
if getBuildCache {
du.BuildCache = &buildtypes.CacheDiskUsage{
TotalSize: builderSize,
Items: buildCache,
}
}
if systemDiskUsage != nil {
du.LayersSize = systemDiskUsage.LayersSize
du.Images = systemDiskUsage.Images
du.Containers = systemDiskUsage.Containers
du.Volumes = systemDiskUsage.Volumes
}
return httputils.WriteJSON(w, http.StatusOK, du)
// Use the old struct for the API return value.
var v types.DiskUsage
if du.Images != nil {
v.LayersSize = du.Images.TotalSize
v.Images = du.Images.Items
}
if du.Containers != nil {
v.Containers = du.Containers.Items
}
if du.Volumes != nil {
v.Volumes = du.Volumes.Items
}
if du.BuildCache != nil {
v.BuildCache = du.BuildCache.Items
}
v.BuilderSize = builderSize
return httputils.WriteJSON(w, http.StatusOK, v)
}
type invalidRequestError struct {

View File

@@ -1,4 +1,4 @@
package volume // import "github.com/docker/docker/api/server/router/volume"
package volume
import (
"context"

View File

@@ -1,4 +1,4 @@
package volume // import "github.com/docker/docker/api/server/router/volume"
package volume
import "github.com/docker/docker/api/server/router"
@@ -20,21 +20,21 @@ func NewRouter(b Backend, cb ClusterBackend) router.Router {
}
// Routes returns the available routes to the volumes controller
func (r *volumeRouter) Routes() []router.Route {
return r.routes
func (v *volumeRouter) Routes() []router.Route {
return v.routes
}
func (r *volumeRouter) initRoutes() {
r.routes = []router.Route{
func (v *volumeRouter) initRoutes() {
v.routes = []router.Route{
// GET
router.NewGetRoute("/volumes", r.getVolumesList),
router.NewGetRoute("/volumes/{name:.*}", r.getVolumeByName),
router.NewGetRoute("/volumes", v.getVolumesList),
router.NewGetRoute("/volumes/{name:.*}", v.getVolumeByName),
// POST
router.NewPostRoute("/volumes/create", r.postVolumesCreate),
router.NewPostRoute("/volumes/prune", r.postVolumesPrune),
router.NewPostRoute("/volumes/create", v.postVolumesCreate),
router.NewPostRoute("/volumes/prune", v.postVolumesPrune),
// PUT
router.NewPutRoute("/volumes/{name:.*}", r.putVolumesUpdate),
router.NewPutRoute("/volumes/{name:.*}", v.putVolumesUpdate),
// DELETE
router.NewDeleteRoute("/volumes/{name:.*}", r.deleteVolumes),
router.NewDeleteRoute("/volumes/{name:.*}", v.deleteVolumes),
}
}

View File

@@ -1,4 +1,4 @@
package volume // import "github.com/docker/docker/api/server/router/volume"
package volume
import (
"context"
@@ -6,6 +6,7 @@ import (
"net/http"
"strconv"
cerrdefs "github.com/containerd/errdefs"
"github.com/containerd/log"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types/filters"
@@ -69,7 +70,7 @@ func (v *volumeRouter) getVolumeByName(ctx context.Context, w http.ResponseWrite
// if the volume is not found in the regular volume backend, and the client
// is using an API version greater than 1.42 (when cluster volumes were
// introduced), then check if Swarm has the volume.
if errdefs.IsNotFound(err) && versions.GreaterThanOrEqualTo(version, clusterVolumesVersion) && v.cluster.IsManager() {
if cerrdefs.IsNotFound(err) && versions.GreaterThanOrEqualTo(version, clusterVolumesVersion) && v.cluster.IsManager() {
swarmVol, err := v.cluster.GetVolume(vars["name"])
// if swarm returns an error and that error indicates that swarm is not
// initialized, return original NotFound error. Otherwise, we'd return
@@ -164,7 +165,7 @@ func (v *volumeRouter) deleteVolumes(ctx context.Context, w http.ResponseWriter,
// errors at this stage. Note that no "not found" error is produced if
// "force" is enabled.
err := v.backend.Remove(ctx, vars["name"], opts.WithPurgeOnError(force))
if err != nil && !errdefs.IsNotFound(err) {
if err != nil && !cerrdefs.IsNotFound(err) {
return err
}
@@ -172,7 +173,7 @@ func (v *volumeRouter) deleteVolumes(ctx context.Context, w http.ResponseWriter,
// is enabled, the volume backend won't return an error for non-existing
// volumes, so we don't know if removal succeeded (or not volume existed).
// In that case we always try to delete cluster volumes as well.
if errdefs.IsNotFound(err) || force {
if cerrdefs.IsNotFound(err) || force {
version := httputils.VersionFromContext(ctx)
if versions.GreaterThanOrEqualTo(version, clusterVolumesVersion) && v.cluster.IsManager() {
err = v.cluster.RemoveVolume(vars["name"], force)

View File

@@ -5,11 +5,13 @@ import (
"context"
"encoding/json"
"fmt"
"net/http"
"net/http/httptest"
"testing"
"gotest.tools/v3/assert"
cerrdefs "github.com/containerd/errdefs"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume"
@@ -20,7 +22,7 @@ import (
func callGetVolume(v *volumeRouter, name string) (*httptest.ResponseRecorder, error) {
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
vars := map[string]string{"name": name}
req := httptest.NewRequest("GET", fmt.Sprintf("/volumes/%s", name), nil)
req := httptest.NewRequest(http.MethodGet, fmt.Sprintf("/volumes/%s", name), http.NoBody)
resp := httptest.NewRecorder()
err := v.getVolumeByName(ctx, resp, req, vars)
@@ -30,7 +32,7 @@ func callGetVolume(v *volumeRouter, name string) (*httptest.ResponseRecorder, er
func callListVolumes(v *volumeRouter) (*httptest.ResponseRecorder, error) {
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
vars := map[string]string{}
req := httptest.NewRequest("GET", "/volumes", nil)
req := httptest.NewRequest(http.MethodGet, "/volumes", http.NoBody)
resp := httptest.NewRecorder()
err := v.getVolumesList(ctx, resp, req, vars)
@@ -46,7 +48,7 @@ func TestGetVolumeByNameNotFoundNoSwarm(t *testing.T) {
_, err := callGetVolume(v, "notReal")
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsNotFound(err))
assert.Assert(t, cerrdefs.IsNotFound(err))
}
func TestGetVolumeByNameNotFoundNotManager(t *testing.T) {
@@ -58,7 +60,7 @@ func TestGetVolumeByNameNotFoundNotManager(t *testing.T) {
_, err := callGetVolume(v, "notReal")
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsNotFound(err))
assert.Assert(t, cerrdefs.IsNotFound(err))
}
func TestGetVolumeByNameNotFound(t *testing.T) {
@@ -70,7 +72,7 @@ func TestGetVolumeByNameNotFound(t *testing.T) {
_, err := callGetVolume(v, "notReal")
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsNotFound(err))
assert.Assert(t, cerrdefs.IsNotFound(err))
}
func TestGetVolumeByNameFoundRegular(t *testing.T) {
@@ -193,7 +195,7 @@ func TestCreateRegularVolume(t *testing.T) {
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/create", &buf)
req := httptest.NewRequest(http.MethodPost, "/volumes/create", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
@@ -231,13 +233,13 @@ func TestCreateSwarmVolumeNoSwarm(t *testing.T) {
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/create", &buf)
req := httptest.NewRequest(http.MethodPost, "/volumes/create", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
err = v.postVolumesCreate(ctx, resp, req, nil)
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsUnavailable(err))
assert.Assert(t, cerrdefs.IsUnavailable(err))
}
func TestCreateSwarmVolumeNotManager(t *testing.T) {
@@ -260,13 +262,13 @@ func TestCreateSwarmVolumeNotManager(t *testing.T) {
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/create", &buf)
req := httptest.NewRequest(http.MethodPost, "/volumes/create", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
err = v.postVolumesCreate(ctx, resp, req, nil)
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsUnavailable(err))
assert.Assert(t, cerrdefs.IsUnavailable(err))
}
func TestCreateVolumeCluster(t *testing.T) {
@@ -292,7 +294,7 @@ func TestCreateVolumeCluster(t *testing.T) {
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/create", &buf)
req := httptest.NewRequest(http.MethodPost, "/volumes/create", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
@@ -339,7 +341,7 @@ func TestUpdateVolume(t *testing.T) {
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/vol1/update?version=0", &buf)
req := httptest.NewRequest(http.MethodPost, "/volumes/vol1/update?version=0", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
@@ -368,14 +370,14 @@ func TestUpdateVolumeNoSwarm(t *testing.T) {
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/vol1/update?version=0", &buf)
req := httptest.NewRequest(http.MethodPost, "/volumes/vol1/update?version=0", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
err = v.putVolumesUpdate(ctx, resp, req, map[string]string{"name": "vol1"})
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsUnavailable(err))
assert.Assert(t, cerrdefs.IsUnavailable(err))
}
func TestUpdateVolumeNotFound(t *testing.T) {
@@ -400,14 +402,14 @@ func TestUpdateVolumeNotFound(t *testing.T) {
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/vol1/update?version=0", &buf)
req := httptest.NewRequest(http.MethodPost, "/volumes/vol1/update?version=0", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
err = v.putVolumesUpdate(ctx, resp, req, map[string]string{"name": "vol1"})
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsNotFound(err))
assert.Assert(t, cerrdefs.IsNotFound(err))
}
func TestVolumeRemove(t *testing.T) {
@@ -426,7 +428,7 @@ func TestVolumeRemove(t *testing.T) {
}
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("DELETE", "/volumes/vol1", nil)
req := httptest.NewRequest(http.MethodDelete, "/volumes/vol1", http.NoBody)
resp := httptest.NewRecorder()
err := v.deleteVolumes(ctx, resp, req, map[string]string{"name": "vol1"})
@@ -453,7 +455,7 @@ func TestVolumeRemoveSwarm(t *testing.T) {
}
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("DELETE", "/volumes/vol1", nil)
req := httptest.NewRequest(http.MethodDelete, "/volumes/vol1", http.NoBody)
resp := httptest.NewRecorder()
err := v.deleteVolumes(ctx, resp, req, map[string]string{"name": "vol1"})
@@ -470,12 +472,12 @@ func TestVolumeRemoveNotFoundNoSwarm(t *testing.T) {
}
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("DELETE", "/volumes/vol1", nil)
req := httptest.NewRequest(http.MethodDelete, "/volumes/vol1", http.NoBody)
resp := httptest.NewRecorder()
err := v.deleteVolumes(ctx, resp, req, map[string]string{"name": "vol1"})
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsNotFound(err), err.Error())
assert.Assert(t, cerrdefs.IsNotFound(err), err.Error())
}
func TestVolumeRemoveNotFoundNoManager(t *testing.T) {
@@ -487,12 +489,12 @@ func TestVolumeRemoveNotFoundNoManager(t *testing.T) {
}
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("DELETE", "/volumes/vol1", nil)
req := httptest.NewRequest(http.MethodDelete, "/volumes/vol1", http.NoBody)
resp := httptest.NewRecorder()
err := v.deleteVolumes(ctx, resp, req, map[string]string{"name": "vol1"})
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsNotFound(err))
assert.Assert(t, cerrdefs.IsNotFound(err))
}
func TestVolumeRemoveFoundNoSwarm(t *testing.T) {
@@ -511,7 +513,7 @@ func TestVolumeRemoveFoundNoSwarm(t *testing.T) {
}
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("DELETE", "/volumes/vol1", nil)
req := httptest.NewRequest(http.MethodDelete, "/volumes/vol1", http.NoBody)
resp := httptest.NewRecorder()
err := v.deleteVolumes(ctx, resp, req, map[string]string{"name": "vol1"})
@@ -534,12 +536,12 @@ func TestVolumeRemoveNoSwarmInUse(t *testing.T) {
}
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("DELETE", "/volumes/inuse", nil)
req := httptest.NewRequest(http.MethodDelete, "/volumes/inuse", http.NoBody)
resp := httptest.NewRecorder()
err := v.deleteVolumes(ctx, resp, req, map[string]string{"name": "inuse"})
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsConflict(err))
assert.Assert(t, cerrdefs.IsConflict(err))
}
func TestVolumeRemoveSwarmForce(t *testing.T) {
@@ -562,16 +564,16 @@ func TestVolumeRemoveSwarmForce(t *testing.T) {
}
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("DELETE", "/volumes/vol1", nil)
req := httptest.NewRequest(http.MethodDelete, "/volumes/vol1", http.NoBody)
resp := httptest.NewRecorder()
err := v.deleteVolumes(ctx, resp, req, map[string]string{"name": "vol1"})
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsConflict(err))
assert.Assert(t, cerrdefs.IsConflict(err))
ctx = context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req = httptest.NewRequest("DELETE", "/volumes/vol1?force=1", nil)
req = httptest.NewRequest(http.MethodDelete, "/volumes/vol1?force=1", http.NoBody)
resp = httptest.NewRecorder()
err = v.deleteVolumes(ctx, resp, req, map[string]string{"name": "vol1"})

View File

@@ -1,4 +1,4 @@
package server // import "github.com/docker/docker/api/server"
package server
import (
"context"
@@ -10,9 +10,12 @@ import (
"github.com/docker/docker/api/server/middleware"
"github.com/docker/docker/api/server/router"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/dockerversion"
"github.com/docker/docker/internal/otelutil"
"github.com/gorilla/mux"
"go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp"
"go.opentelemetry.io/otel/baggage"
)
// versionMatcher defines a variable matcher to be parsed by the router
@@ -42,7 +45,10 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc, operation string) ht
// use intermediate variable to prevent "should not use basic type
// string as key in context.WithValue" golint errors
ctx := context.WithValue(r.Context(), dockerversion.UAStringKey{}, r.Header.Get("User-Agent"))
ua := r.Header.Get("User-Agent")
ctx := baggage.ContextWithBaggage(context.WithValue(r.Context(), dockerversion.UAStringKey{}, ua), otelutil.MustNewBaggage(
otelutil.MustNewMemberRaw(otelutil.TriggerKey, "api"),
))
r = r.WithContext(ctx)
handlerFunc := s.handlerWithGlobalMiddlewares(handler)
@@ -54,12 +60,23 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc, operation string) ht
if err := handlerFunc(ctx, w, r, vars); err != nil {
statusCode := httpstatus.FromError(err)
if statusCode >= 500 {
if statusCode >= http.StatusInternalServerError {
log.G(ctx).Errorf("Handler for %s %s returned error: %v", r.Method, r.URL.Path, err)
}
_ = httputils.WriteJSON(w, statusCode, &types.ErrorResponse{
Message: err.Error(),
})
// While we no longer support API versions older 1.24 [api.MinSupportedAPIVersion],
// a client may try to connect using an older version and expect a plain-text error
// instead of a JSON error. This would result in an "API version too old" error
// formatted in JSON being printed as-is.
//
// Let's be nice, and return errors in plain-text to provide a more readable error
// to help the user understand the API version they're using is no longer supported.
if v := vars["version"]; v != "" && versions.LessThan(v, "1.24") {
http.Error(w, err.Error(), statusCode)
} else {
_ = httputils.WriteJSON(w, statusCode, &types.ErrorResponse{
Message: err.Error(),
})
}
}
}), operation).ServeHTTP
}

View File

@@ -1,4 +1,4 @@
package server // import "github.com/docker/docker/api/server"
package server
import (
"context"
@@ -21,7 +21,7 @@ func TestMiddlewares(t *testing.T) {
}
srv.UseMiddleware(*m)
req, _ := http.NewRequest(http.MethodGet, "/containers/json", nil)
req, _ := http.NewRequest(http.MethodGet, "/containers/json", http.NoBody)
resp := httptest.NewRecorder()
ctx := context.Background()

View File

@@ -19,10 +19,10 @@ produces:
consumes:
- "application/json"
- "text/plain"
basePath: "/v1.48"
basePath: "/v1.51"
info:
title: "Docker Engine API"
version: "1.48"
version: "1.51"
x-logo:
url: "https://docs.docker.com/assets/images/logo-docker-main.png"
description: |
@@ -55,8 +55,8 @@ info:
the URL is not supported by the daemon, a HTTP `400 Bad Request` error message
is returned.
If you omit the version-prefix, the current version of the API (v1.48) is used.
For example, calling `/info` is the same as calling `/v1.48/info`. Using the
If you omit the version-prefix, the current version of the API (v1.50) is used.
For example, calling `/info` is the same as calling `/v1.51/info`. Using the
API without a version-prefix is deprecated and will be removed in a future release.
Engine releases in the near future should support this version of the API,
@@ -1428,63 +1428,10 @@ definitions:
when starting a container from the image.
type: "object"
properties:
Hostname:
description: |
The hostname to use for the container, as a valid RFC 1123 hostname.
<p><br /></p>
> **Deprecated**: this field is not part of the image specification and is
> always empty. It must not be used, and will be removed in API v1.48.
type: "string"
example: ""
Domainname:
description: |
The domain name to use for the container.
<p><br /></p>
> **Deprecated**: this field is not part of the image specification and is
> always empty. It must not be used, and will be removed in API v1.48.
type: "string"
example: ""
User:
description: "The user that commands are run as inside the container."
type: "string"
example: "web:web"
AttachStdin:
description: |
Whether to attach to `stdin`.
<p><br /></p>
> **Deprecated**: this field is not part of the image specification and is
> always false. It must not be used, and will be removed in API v1.48.
type: "boolean"
default: false
example: false
AttachStdout:
description: |
Whether to attach to `stdout`.
<p><br /></p>
> **Deprecated**: this field is not part of the image specification and is
> always false. It must not be used, and will be removed in API v1.48.
type: "boolean"
default: false
example: false
AttachStderr:
description: |
Whether to attach to `stderr`.
<p><br /></p>
> **Deprecated**: this field is not part of the image specification and is
> always false. It must not be used, and will be removed in API v1.48.
type: "boolean"
default: false
example: false
ExposedPorts:
description: |
An object mapping ports to an empty object in the form:
@@ -1501,39 +1448,6 @@ definitions:
"80/tcp": {},
"443/tcp": {}
}
Tty:
description: |
Attach standard streams to a TTY, including `stdin` if it is not closed.
<p><br /></p>
> **Deprecated**: this field is not part of the image specification and is
> always false. It must not be used, and will be removed in API v1.48.
type: "boolean"
default: false
example: false
OpenStdin:
description: |
Open `stdin`
<p><br /></p>
> **Deprecated**: this field is not part of the image specification and is
> always false. It must not be used, and will be removed in API v1.48.
type: "boolean"
default: false
example: false
StdinOnce:
description: |
Close `stdin` after one attached client disconnects.
<p><br /></p>
> **Deprecated**: this field is not part of the image specification and is
> always false. It must not be used, and will be removed in API v1.48.
type: "boolean"
default: false
example: false
Env:
description: |
A list of environment variables to set inside the container in the
@@ -1559,18 +1473,6 @@ definitions:
default: false
example: false
x-nullable: true
Image:
description: |
The name (or reference) of the image to use when creating the container,
or which was used when the container was created.
<p><br /></p>
> **Deprecated**: this field is not part of the image specification and is
> always empty. It must not be used, and will be removed in API v1.48.
type: "string"
default: ""
example: ""
Volumes:
description: |
An object mapping mount point paths inside the container to empty
@@ -1599,30 +1501,6 @@ definitions:
items:
type: "string"
example: []
NetworkDisabled:
description: |
Disable networking for the container.
<p><br /></p>
> **Deprecated**: this field is not part of the image specification and is
> always omitted. It must not be used, and will be removed in API v1.48.
type: "boolean"
default: false
example: false
x-nullable: true
MacAddress:
description: |
MAC address of the container.
<p><br /></p>
> **Deprecated**: this field is not part of the image specification and is
> always omitted. It must not be used, and will be removed in API v1.48.
type: "string"
default: ""
example: ""
x-nullable: true
OnBuild:
description: |
`ONBUILD` metadata that were defined in the image's `Dockerfile`.
@@ -1645,17 +1523,6 @@ definitions:
type: "string"
example: "SIGTERM"
x-nullable: true
StopTimeout:
description: |
Timeout to stop a container in seconds.
<p><br /></p>
> **Deprecated**: this field is not part of the image specification and is
> always omitted. It must not be used, and will be removed in API v1.48.
type: "integer"
default: 10
x-nullable: true
Shell:
description: |
Shell for when `RUN`, `CMD`, and `ENTRYPOINT` uses a shell.
@@ -1666,19 +1533,11 @@ definitions:
example: ["/bin/sh", "-c"]
# FIXME(thaJeztah): temporarily using a full example to remove some "omitempty" fields. Remove once the fields are removed.
example:
"Hostname": ""
"Domainname": ""
"User": "web:web"
"AttachStdin": false
"AttachStdout": false
"AttachStderr": false
"ExposedPorts": {
"80/tcp": {},
"443/tcp": {}
}
"Tty": false
"OpenStdin": false
"StdinOnce": false
"Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"]
"Cmd": ["/bin/sh"]
"Healthcheck": {
@@ -1690,7 +1549,6 @@ definitions:
"StartInterval": 0
}
"ArgsEscaped": true
"Image": ""
"Volumes": {
"/app/data": {},
"/app/config": {}
@@ -2338,8 +2196,7 @@ definitions:
Number of containers using this image. Includes both stopped and running
containers.
This size is not calculated by default, and depends on which API endpoint
is used. `-1` indicates that the value has not been set / calculated.
`-1` indicates that the value has not been set / calculated.
x-nullable: false
type: "integer"
example: 2
@@ -2956,6 +2813,23 @@ definitions:
progressDetail:
$ref: "#/definitions/ProgressDetail"
DeviceInfo:
type: "object"
description: |
DeviceInfo represents a device that can be used by a container.
properties:
Source:
type: "string"
example: "cdi"
description: |
The origin device driver.
ID:
type: "string"
example: "vendor.com/gpu=0"
description: |
The unique identifier for the device within its source driver.
For CDI devices, this would be an FQDN like "vendor.com/gpu=0".
ErrorDetail:
type: "object"
properties:
@@ -5988,7 +5862,7 @@ definitions:
type: "integer"
format: "uint64"
x-nullable: true
example: 18446744073709551615
example: "18446744073709551615"
ContainerThrottlingData:
description: |
@@ -6856,6 +6730,17 @@ definitions:
description: "The network pool size"
type: "integer"
example: "24"
FirewallBackend:
$ref: "#/definitions/FirewallInfo"
DiscoveredDevices:
description: |
List of devices discovered by device drivers.
Each device includes information about its source driver, kind, name,
and additional driver-specific attributes.
type: "array"
items:
$ref: "#/definitions/DeviceInfo"
Warnings:
description: |
List of warnings / informational messages about missing features, or
@@ -6939,6 +6824,37 @@ definitions:
default: "plugins.moby"
example: "plugins.moby"
FirewallInfo:
description: |
Information about the daemon's firewalling configuration.
This field is currently only used on Linux, and omitted on other platforms.
type: "object"
x-nullable: true
properties:
Driver:
description: |
The name of the firewall backend driver.
type: "string"
example: "nftables"
Info:
description: |
Information about the firewall backend, provided as
"label" / "value" pairs.
<p><br /></p>
> **Note**: The information returned in this field, including the
> formatting of values and labels, should not be considered stable,
> and may change without notice.
type: "array"
items:
type: "array"
items:
type: "string"
example:
- ["ReloadedAt", "2025-01-01T00:00:00Z"]
# PluginsInfo is a temp struct holding Plugins name
# registered with docker daemon. It is used by Info struct
PluginsInfo:
@@ -6984,32 +6900,6 @@ definitions:
type: "object"
x-nullable: true
properties:
AllowNondistributableArtifactsCIDRs:
description: |
List of IP ranges to which nondistributable artifacts can be pushed,
using the CIDR syntax [RFC 4632](https://tools.ietf.org/html/4632).
<p><br /></p>
> **Deprecated**: Pushing nondistributable artifacts is now always enabled
> and this field is always `null`. This field will be removed in a API v1.49.
type: "array"
items:
type: "string"
example: []
AllowNondistributableArtifactsHostnames:
description: |
List of registry hostnames to which nondistributable artifacts can be
pushed, using the format `<hostname>[:<port>]` or `<IP address>[:<port>]`.
<p><br /></p>
> **Deprecated**: Pushing nondistributable artifacts is now always enabled
> and this field is always `null`. This field will be removed in a API v1.49.
type: "array"
items:
type: "string"
example: []
InsecureRegistryCIDRs:
description: |
List of IP ranges of insecure registries, using the CIDR syntax
@@ -7179,13 +7069,6 @@ definitions:
description: "Actual commit ID of external tool."
type: "string"
example: "cfb82a876ecc11b5ca0977d1733adbe58599088a"
Expected:
description: |
Commit ID of external tool expected by dockerd as set at build time.
**Deprecated**: This field is deprecated and will be omitted in a API v1.49.
type: "string"
example: "2d41c047c83e09a6d61d464906feb2a2f3c52aa4"
SwarmInfo:
description: |
@@ -9934,6 +9817,18 @@ paths:
description: "Do not delete untagged parent images"
type: "boolean"
default: false
- name: "platforms"
in: "query"
description: |
Select platform-specific content to delete.
Multiple values are accepted.
Each platform is a OCI platform encoded as a JSON string.
type: "array"
items:
# This should be OCIPlatform
# but $ref is not supported for array in query in Swagger 2.0
# $ref: "#/definitions/OCIPlatform"
type: "string"
tags: ["Image"]
/images/search:
get:
@@ -10491,13 +10386,9 @@ paths:
### Image tarball format
An image tarball contains one directory per image layer (named using its long ID), each containing these files:
An image tarball contains [Content as defined in the OCI Image Layout Specification](https://github.com/opencontainers/image-spec/blob/v1.1.1/image-layout.md#content).
- `VERSION`: currently `1.0` - the file format version
- `json`: detailed layer information, similar to `docker inspect layer_id`
- `layer.tar`: A tarfile containing the filesystem changes in this layer
The `layer.tar` file contains `aufs` style `.wh..wh.aufs` files and directories for storing attribute changes and deletions.
Additionally, includes the manifest.json file associated with a backwards compatible docker save format.
If the tarball defines a repository, the tarball should also include a `repositories` file at the root that contains a list of repository and tag names mapped to layer IDs.
@@ -10537,6 +10428,7 @@ paths:
If not provided, the full multi-platform image will be saved.
Example: `{"os": "linux", "architecture": "arm", "variant": "v5"}`
tags: ["Image"]
/images/get:
get:
summary: "Export several images"
@@ -10571,6 +10463,16 @@ paths:
type: "array"
items:
type: "string"
- name: "platform"
type: "string"
in: "query"
description: |
JSON encoded OCI platform describing a platform which will be used
to select a platform-specific image to be saved if the image is
multi-platform.
If not provided, the full multi-platform image will be saved.
Example: `{"os": "linux", "architecture": "arm", "variant": "v5"}`
tags: ["Image"]
/images/load:
post:

View File

@@ -1,4 +1,4 @@
package {{ .Package }} // import "github.com/docker/docker/api/types/{{ .Package }}"
package {{ .Package }}
// ----------------------------------------------------------------------------
// Code generated by `swagger generate operation`. DO NOT EDIT.

View File

@@ -1,5 +1,5 @@
// Package backend includes types to send information to server backends.
package backend // import "github.com/docker/docker/api/types/backend"
package backend
import (
"io"
@@ -153,13 +153,14 @@ type GetImageOpts struct {
// ImageInspectOpts holds parameters to inspect an image.
type ImageInspectOpts struct {
Manifests bool
Platform *ocispec.Platform
}
// CommitConfig is the configuration for creating an image as part of a build.
type CommitConfig struct {
Author string
Comment string
Config *container.Config
Config *container.Config // TODO(thaJeztah); change this to [dockerspec.DockerOCIImageConfig]
ContainerConfig *container.Config
ContainerID string
ContainerMountLabel string

View File

@@ -1,9 +1,9 @@
package backend // import "github.com/docker/docker/api/types/backend"
package backend
import (
"io"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/build"
"github.com/docker/docker/api/types/registry"
"github.com/docker/docker/pkg/streamformatter"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
@@ -34,7 +34,7 @@ type ProgressWriter struct {
type BuildConfig struct {
Source io.ReadCloser
ProgressWriter ProgressWriter
Options *types.ImageBuildOptions
Options *build.ImageBuildOptions
}
// GetImageAndLayerOptions are the options supported by GetImageAndReleasableLayer

View File

@@ -1,4 +1,4 @@
package blkiodev // import "github.com/docker/docker/api/types/blkiodev"
package blkiodev
import "fmt"

91
api/types/build/build.go Normal file
View File

@@ -0,0 +1,91 @@
package build
import (
"io"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/registry"
)
// BuilderVersion sets the version of underlying builder to use
type BuilderVersion string
const (
// BuilderV1 is the first generation builder in docker daemon
BuilderV1 BuilderVersion = "1"
// BuilderBuildKit is builder based on moby/buildkit project
BuilderBuildKit BuilderVersion = "2"
)
// Result contains the image id of a successful build.
type Result struct {
ID string
}
// ImageBuildOptions holds the information
// necessary to build images.
type ImageBuildOptions struct {
Tags []string
SuppressOutput bool
RemoteContext string
NoCache bool
Remove bool
ForceRemove bool
PullParent bool
Isolation container.Isolation
CPUSetCPUs string
CPUSetMems string
CPUShares int64
CPUQuota int64
CPUPeriod int64
Memory int64
MemorySwap int64
CgroupParent string
NetworkMode string
ShmSize int64
Dockerfile string
Ulimits []*container.Ulimit
// BuildArgs needs to be a *string instead of just a string so that
// we can tell the difference between "" (empty string) and no value
// at all (nil). See the parsing of buildArgs in
// api/server/router/build/build_routes.go for even more info.
BuildArgs map[string]*string
AuthConfigs map[string]registry.AuthConfig
Context io.Reader
Labels map[string]string
// squash the resulting image's layers to the parent
// preserves the original image and creates a new one from the parent with all
// the changes applied to a single layer
Squash bool
// CacheFrom specifies images that are used for matching cache. Images
// specified here do not need to have a valid parent chain to match cache.
CacheFrom []string
SecurityOpt []string
ExtraHosts []string // List of extra hosts
Target string
SessionID string
Platform string
// Version specifies the version of the underlying builder to use
Version BuilderVersion
// BuildID is an optional identifier that can be passed together with the
// build request. The same identifier can be used to gracefully cancel the
// build with the cancel request.
BuildID string
// Outputs defines configurations for exporting build results. Only supported
// in BuildKit mode
Outputs []ImageBuildOutput
}
// ImageBuildOutput defines configuration for exporting a build result
type ImageBuildOutput struct {
Type string
Attrs map[string]string
}
// ImageBuildResponse holds information
// returned by a server after building
// an image.
type ImageBuildResponse struct {
Body io.ReadCloser
OSType string
}

52
api/types/build/cache.go Normal file
View File

@@ -0,0 +1,52 @@
package build
import (
"time"
"github.com/docker/docker/api/types/filters"
)
// CacheRecord contains information about a build cache record.
type CacheRecord struct {
// ID is the unique ID of the build cache record.
ID string
// Parent is the ID of the parent build cache record.
//
// Deprecated: deprecated in API v1.42 and up, as it was deprecated in BuildKit; use Parents instead.
Parent string `json:"Parent,omitempty"`
// Parents is the list of parent build cache record IDs.
Parents []string `json:" Parents,omitempty"`
// Type is the cache record type.
Type string
// Description is a description of the build-step that produced the build cache.
Description string
// InUse indicates if the build cache is in use.
InUse bool
// Shared indicates if the build cache is shared.
Shared bool
// Size is the amount of disk space used by the build cache (in bytes).
Size int64
// CreatedAt is the date and time at which the build cache was created.
CreatedAt time.Time
// LastUsedAt is the date and time at which the build cache was last used.
LastUsedAt *time.Time
UsageCount int
}
// CachePruneOptions hold parameters to prune the build cache.
type CachePruneOptions struct {
All bool
ReservedSpace int64
MaxUsedSpace int64
MinFreeSpace int64
Filters filters.Args
KeepStorage int64 // Deprecated: deprecated in API 1.48.
}
// CachePruneReport contains the response for Engine API:
// POST "/build/prune"
type CachePruneReport struct {
CachesDeleted []string
SpaceReclaimed uint64
}

View File

@@ -0,0 +1,8 @@
package build
// CacheDiskUsage contains disk usage for the build cache.
type CacheDiskUsage struct {
TotalSize int64
Reclaimable int64
Items []*CacheRecord
}

View File

@@ -1,14 +1,9 @@
package types // import "github.com/docker/docker/api/types"
package types
import (
"bufio"
"context"
"io"
"net"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/registry"
)
// NewHijackedResponse initializes a [HijackedResponse] type.
@@ -51,165 +46,6 @@ func (h *HijackedResponse) CloseWrite() error {
return nil
}
// ImageBuildOptions holds the information
// necessary to build images.
type ImageBuildOptions struct {
Tags []string
SuppressOutput bool
RemoteContext string
NoCache bool
Remove bool
ForceRemove bool
PullParent bool
Isolation container.Isolation
CPUSetCPUs string
CPUSetMems string
CPUShares int64
CPUQuota int64
CPUPeriod int64
Memory int64
MemorySwap int64
CgroupParent string
NetworkMode string
ShmSize int64
Dockerfile string
Ulimits []*container.Ulimit
// BuildArgs needs to be a *string instead of just a string so that
// we can tell the difference between "" (empty string) and no value
// at all (nil). See the parsing of buildArgs in
// api/server/router/build/build_routes.go for even more info.
BuildArgs map[string]*string
AuthConfigs map[string]registry.AuthConfig
Context io.Reader
Labels map[string]string
// squash the resulting image's layers to the parent
// preserves the original image and creates a new one from the parent with all
// the changes applied to a single layer
Squash bool
// CacheFrom specifies images that are used for matching cache. Images
// specified here do not need to have a valid parent chain to match cache.
CacheFrom []string
SecurityOpt []string
ExtraHosts []string // List of extra hosts
Target string
SessionID string
Platform string
// Version specifies the version of the underlying builder to use
Version BuilderVersion
// BuildID is an optional identifier that can be passed together with the
// build request. The same identifier can be used to gracefully cancel the
// build with the cancel request.
BuildID string
// Outputs defines configurations for exporting build results. Only supported
// in BuildKit mode
Outputs []ImageBuildOutput
}
// ImageBuildOutput defines configuration for exporting a build result
type ImageBuildOutput struct {
Type string
Attrs map[string]string
}
// BuilderVersion sets the version of underlying builder to use
type BuilderVersion string
const (
// BuilderV1 is the first generation builder in docker daemon
BuilderV1 BuilderVersion = "1"
// BuilderBuildKit is builder based on moby/buildkit project
BuilderBuildKit BuilderVersion = "2"
)
// ImageBuildResponse holds information
// returned by a server after building
// an image.
type ImageBuildResponse struct {
Body io.ReadCloser
OSType string
}
// NodeListOptions holds parameters to list nodes with.
type NodeListOptions struct {
Filters filters.Args
}
// NodeRemoveOptions holds parameters to remove nodes with.
type NodeRemoveOptions struct {
Force bool
}
// ServiceCreateOptions contains the options to use when creating a service.
type ServiceCreateOptions struct {
// EncodedRegistryAuth is the encoded registry authorization credentials to
// use when updating the service.
//
// This field follows the format of the X-Registry-Auth header.
EncodedRegistryAuth string
// QueryRegistry indicates whether the service update requires
// contacting a registry. A registry may be contacted to retrieve
// the image digest and manifest, which in turn can be used to update
// platform or other information about the service.
QueryRegistry bool
}
// Values for RegistryAuthFrom in ServiceUpdateOptions
const (
RegistryAuthFromSpec = "spec"
RegistryAuthFromPreviousSpec = "previous-spec"
)
// ServiceUpdateOptions contains the options to be used for updating services.
type ServiceUpdateOptions struct {
// EncodedRegistryAuth is the encoded registry authorization credentials to
// use when updating the service.
//
// This field follows the format of the X-Registry-Auth header.
EncodedRegistryAuth string
// TODO(stevvooe): Consider moving the version parameter of ServiceUpdate
// into this field. While it does open API users up to racy writes, most
// users may not need that level of consistency in practice.
// RegistryAuthFrom specifies where to find the registry authorization
// credentials if they are not given in EncodedRegistryAuth. Valid
// values are "spec" and "previous-spec".
RegistryAuthFrom string
// Rollback indicates whether a server-side rollback should be
// performed. When this is set, the provided spec will be ignored.
// The valid values are "previous" and "none". An empty value is the
// same as "none".
Rollback string
// QueryRegistry indicates whether the service update requires
// contacting a registry. A registry may be contacted to retrieve
// the image digest and manifest, which in turn can be used to update
// platform or other information about the service.
QueryRegistry bool
}
// ServiceListOptions holds parameters to list services with.
type ServiceListOptions struct {
Filters filters.Args
// Status indicates whether the server should include the service task
// count of running and desired tasks.
Status bool
}
// ServiceInspectOptions holds parameters related to the "service inspect"
// operation.
type ServiceInspectOptions struct {
InsertDefaults bool
}
// TaskListOptions holds parameters to list tasks with.
type TaskListOptions struct {
Filters filters.Args
}
// PluginRemoveOptions holds parameters to remove plugins.
type PluginRemoveOptions struct {
Force bool
@@ -243,13 +79,6 @@ type PluginInstallOptions struct {
Args []string
}
// SwarmUnlockKeyResponse contains the response for Engine API:
// GET /swarm/unlockkey
type SwarmUnlockKeyResponse struct {
// UnlockKey is the unlock key in ASCII-armored format.
UnlockKey string
}
// PluginCreateOptions hold all options to plugin create.
type PluginCreateOptions struct {
RepoName string

View File

@@ -1,4 +1,4 @@
package container // import "github.com/docker/docker/api/types/container"
package container
import (
"time"

Some files were not shown because too many files have changed in this diff Show More