Commit Graph
6095 Commits
Author SHA1 Message Date
Paweł Gronowski b9b109e4d3 Merge pull request #53522 from thaJeztah/integration_slices
integration, integration-cli:  rewrite asserts with slices and cmpopts
2026-09-03 18:47:43 +02:00
Paweł Gronowski 06f0da3056 integration-cli: Wait for restarted Swarm nodes to rejoin
TestSwarmLockUnlockCluster checked local node state immediately or
within one second after restarting managers. The daemon API can become
ready while the swarm node is still reconnecting, so the check could
fail as a Raft cluster converged.

Poll restart state with the existing reconciliation timeout and report
the last observed state on timeout. Reuse the wait for
TestSwarmJoinPromoteLocked, which crosses the same restart boundary.
The restarts remain because loading the encrypted node key from disk
is part of the behavior under test.

This addresses the node-state timeout only. Shutdown failures with
exit status 130 have a separate cause.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-09-03 10:38:01 +02:00
Sebastiaan van Stijn 4f82cda223 integration-cli: rewrite asserts with slices and cmpopts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-08-31 16:32:08 +02:00
Sebastiaan van Stijn f675ce2ae9 Merge pull request #52771 from vvoland/apparmor-custom-profiles
daemon: add ability for custom AppArmor profiles
2026-08-28 22:27:21 +02:00
Paweł Gronowski f022c9a953 Merge pull request #53148 from GordonTheTurtle/fix/flaky-TestDaemonNoSpaceLeftOnDeviceError
integration-cli: fix flaky TestDaemonNoSpaceLeftOnDeviceError
2026-08-26 22:25:52 +02:00
Aleksa Sarai 7bdd547617 daemon: add ability for custom AppArmor profiles
This is a long-requested feature, and it solves several usability
problems with the default AppArmor profile:

1. The profile is completely opaque because we don't write to
  /etc/apparmor.d anymore -- this leads to lots of headaches when
  trying to run certain semi-privileged programs inside containers.
  It's much nicer to be able to have a starting point for a custom
  AppArmor profile.

2. Changes to AppArmor have broken backwards compatibility in the past
  (leading to containers not working properly) -- the poster-child for
  this problem was signal mediation. In order to fix this problem,
  distributions had to patch Docker when it would've been much nicer
  to provide a hotfix in the form of a custom configuration they could
  apply to their hosts.

It also bridges the feature gap between the default seccomp profile
(which has been configurable for a very long time). This patch also
fixes a few minor bugs in the AppArmor profile implementation (notably,
Docker would not forcefully load its built-in profile at start time --
meaning a Docker update wouldn't actually update the profile).

This feature should probably be ported to other container runtimes
(containerd, podman/cri-o, etc) so that we can continue with the effort
to merge all of the disparate AppArmor profile implementations. Ideally
they would all use the same template variables too.

Signed-off-by: Aleksa Sarai <asarai@suse.de>

---

The above was reapplied from the original commit on top of the current
daemon code.

The daemon already force-loads the default AppArmor profile at startup,
so this change wires the configured template into that existing reload
path instead of introducing the reload behavior itself.

The built-in profile now lives in github.com/moby/profiles/apparmor, so
the custom template data follows the current profile variables.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-08-24 13:13:35 +02:00
Sebastiaan van Stijn a94b6bf29c integration-cli: TestDaemonDebugLog don't color-match output
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-08-13 19:07:12 +02:00
Sebastiaan van Stijn 3d1c758e92 Merge pull request #53263 from rzlink/rzlink/fix-47107-unskip-build-symlink-breakout
integration-cli: unskip TestBuildSymlinkBreakout
2026-08-04 22:39:21 +02:00
Paweł Gronowski 0feb69afe1 integration-cli: Keep Swarm cleanup failures from blocking tests
Swarm suite teardown stopped daemons while holding daemonsLock. A
nonzero daemon exit made Stop call Fatalf, so the test goroutine left
the mutex locked and retained stale daemons for the next test.

Snapshot and clear suite state under the lock, then stop each daemon
in its own cleanup subtest. A failed stop now releases suite state,
cleanup still runs for that daemon, and teardown continues with the
remaining daemons.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-08-03 16:58:01 +02:00
Dawei Wei 64886d7f49 integration-cli: unskip TestBuildSymlinkBreakout
Signed-off-by: Dawei Wei <wei.dawei.cn@gmail.com>
2026-07-31 11:05:43 -07:00
Gordon 2c77661013 integration-cli: extend Windows poll timeout for --rm flag tests
Extend the poll.WaitOn timeout for TestRunContainerWithRmFlagCannotStartContainer
and TestRunContainerWithRmFlagExitCodeNotEqualToZero on Windows from the default
10 seconds to 60 seconds.

On Windows, container teardown after docker run --rm involves:
1. HCS layer unmount (ReleaseLayer call via HCSSHIM)
2. EnsureRemoveAll with up to 50 retries × 100ms sleep on ERROR_ACCESS_DENIED /
   ERROR_SHARING_VIOLATION / ERROR_LOCK_VIOLATION / ERROR_DIR_NOT_EMPTY

Under CI load this can exceed the default 10-second poll budget, causing:
timeout hit after 10s: waiting for container 'sparkles' to be removed

This fix applies the same pattern already used in TestRunStdinBlockedAfterContainerExit
(added in a81aa78ceb) to the two --rm flag tests.

Signed-off-by: Gordon <GordonTheTurtle@users.noreply.github.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-29 17:25:46 +02:00
Gordon 536e828c13 integration-cli: TestDaemonNoSpaceLeftOnDeviceError use local registry
Pull a large image into a tiny 3 MiB ext4 filesystem to trigger ENOSPC.

Use a local registry instead of Docker Hub to eliminate Docker Hub rate
limits and transient internet network errors as sources of flakiness.
127.0.0.0/8 is automatically treated as insecure by the Docker daemon,
so no extra --insecure-registry flags are needed.

A synthetic 4 MiB image is created via the host daemon (using the
specialimage test utility and the Docker API) and pushed to a local V2
registry before the test daemon starts; the test daemon's 3 MiB data-root
is too small to store images, so the host daemon handles setup.

Signed-off-by: Gordon <GordonTheTurtle@users.noreply.github.com>
2026-07-27 13:02:19 +00:00
Paweł Gronowski da0ac18188 Merge pull request #53199 from thaJeztah/TestBuildCopyFromForcePull_check_push
integration-cli: TestBuildCopyFromForcePull: check push results
2026-07-27 13:43:12 +02:00
Sebastiaan van Stijn 9fbe504209 Merge pull request #53174 from vvoland/test-flakyfix
integration: Replace flaky TestRunAttachDetachFromInvalidFlag
2026-07-27 12:47:12 +02:00
Sebastiaan van Stijn 4c1d53a232 integration-cli: TestBuildCopyFromForcePull: check push results
This test was discarding the push progress, therefore potentially
missing failed pushes.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-26 18:43:17 +02:00
Paweł Gronowski 639406e104 integration: Replace flaky TestRunAttachDetachFromInvalidFlag
The legacy test raced cmd.Wait against reads from its stderr pipe and
only asserted the bundled CLI's generic HTTP upgrade error.

Rewrite it into a pure API integration test.
The cli side is already covered by
`TestNewAttachCommandErrors/invalid-detach-keys` test in docker/cli.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-07-24 17:15:54 +02:00
Paweł Gronowski a8a1cfd111 daemon: Add embedded containerd mode
Run containerd inside dockerd when the experimental
`embedded-containerd` feature is enabled through `--feature` or the
daemon configuration.

Serve containerd's gRPC API on a Unix socket, or a named pipe on
Windows, for the plugin executor and external tools.
Use an in-memory listener for dockerd's own containerd client. Serve
TTRPC on a platform endpoint so task shims can publish events.

Register only the containerd plugins dockerd needs. Leave CRI, sandbox,
streaming, transfer, NRI, and the restart monitor out of the embedded
server.
Reject `--cri-containerd` when embedded mode is enabled instead of
silently ignoring the requested CRI support.

Check the feature before `ContainerdAddr` so it can override the default
containerd socket supplied by packaged service units. Continue to use
the configured external containerd when the feature is disabled.

Derive the Windows named-pipe address from the daemon state directory so
multiple daemons can run on the same host. Restrict the pipes to the
built-in Administrators group and LocalSystem with the same protected
DACL as dockerd's API pipe, as the default security descriptor depends
on the process token and can expose the containerd endpoints more
broadly than intended. Treat embedded mode as a containerd runtime in
the Windows test environment.

Add the `no_embedded_containerd` build tag so distributors can omit the
embedded plugin graph and its dependencies.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-07-24 16:39:06 +02:00
Dawei Wei deef0ea2d7 daemon: fix empty docker stats for Windows containerd runtime
When the daemon uses the containerd runtime (io.containerd.runhcs.v1),
the runhcs shim emits container metrics as the typeurl
`containerd.runhcs.stats.v1.Statistics`. moby never imported the package
that registers this type, so `typeurl.UnmarshalAny` failed with "type not
found" and `docker stats` reported all zeros for running Windows
containers.

Import the hcsshim runhcs stats package so its proto init registers the
typeurl, and handle `*wstats.Statistics` in `InterfaceToStats`, converting
the Windows container statistics (processor time is reported in
nanoseconds and converted to the 100ns units used by hcsshim.Statistics)
into the shape consumed by stats_windows.go. Also replace the bare type
assertion with a type switch so unexpected payloads no longer panic.

Un-skip TestStatsAllNoStream and TestStatsAllRunningNoStream, and add a
unit test for the conversion.

Signed-off-by: Dawei Wei <wei.dawei.cn@gmail.com>
2026-07-20 11:47:18 -07:00
Paweł Gronowski 4994a3ba0b daemon/containerd: Enforce global transfer concurrency limits
Before this commit containerd-backed pulls and pushes ignored the
daemon's max concurrent transfer settings, so each operation can
independently consume the full configured concurrency.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-07-16 12:48:39 +02:00
Sebastiaan van Stijn a9f5a70610 integration-cli: fix perfsprint linting
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-06 15:36:16 +02:00
Sebastiaan van Stijn ddb2f8933a integration-cli: fmt.Sprintf -> fmt.Sprint
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-07-03 18:19:03 +02:00
Paweł Gronowski 01115e84b3 Merge pull request #52906 from vvoland/fix-TestContainerWithConflictingNoneNetwork
TestContainerWithConflictingNoneNetwork: Extend Windows timeout
2026-06-18 19:56:14 +02:00
Paweł Gronowski b36296ffc0 Merge pull request #52913 from thaJeztah/windows_does_stats
integration-cli: un-skip stats tests on Windows
2026-06-18 18:34:22 +02:00
Paweł Gronowski a81aa78ceb TestContainerWithConflictingNoneNetwork: Extend Windows timeout
Increase stop timeout on Windows and split container and CLI exit waits.

Wait for the container to reach `exited` before timing how long the
`docker run -i` process takes to exit with stdin still open.

This keeps the regression check focused on the post-exit CLI behavior
instead of combining it with container startup time. Use a unique
container name to avoid collisions with leftovers from previous runs.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-06-18 18:08:48 +02:00
Paweł Gronowski 908a35a91b Merge pull request #52914 from thaJeztah/no_stderr
integration-cli: runSleepingContainerInImage: don't capture stderr
2026-06-18 18:06:31 +02:00
Paweł Gronowski 04d33b5de6 Merge pull request #52912 from thaJeztah/cleanup_GenerateRandomAlphaOnlyString
internal/testutil: cleanup GenerateRandomAlphaOnlyString
2026-06-18 17:41:43 +02:00
Paweł Gronowski 3b2f5575b2 Merge pull request #52722 from notandruu/integration/migrate-TestInspectAPIImageResponse
integration: migrate TestInspectAPIImageResponse to integration suite
2026-06-18 17:41:26 +02:00
Sebastiaan van Stijn 11d334268a integration-cli: un-skip stats tests on Windows
These tests were skipped because "Windows does not support stats",
which should no longer be the case.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-18 16:56:18 +02:00
Andrew Liu 1567f9e65f integration: migrate TestInspectAPIImageResponse to integration suite
Signed-off-by: Andrew Liu <andrewjliu22@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-18 13:27:35 +02:00
Sebastiaan van Stijn 67e7274c95 internal/testutil: cleanup GenerateRandomAlphaOnlyString
- use math/rand/v2
- change the util to only produce lowercase; some tests only could
  use lowercase, and we don't need uppercase here, as long as it's
  random.
- drop the Uniqueness test; it was effectively just testing stdlib
  functionality (math/rand/v2 to be random).
- rename to RandomAlpha while we had to update call-sites

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-18 13:05:17 +02:00
Paweł Gronowski 77bebe7030 Merge pull request #52096 from deahtstroke/50159-migrate-TestAPIStatsNetworkStats-from-integration-cli
integration/container: Migrate TestAPIStatsNetworkStats to integratio…
2026-06-18 12:54:22 +02:00
Sebastiaan van Stijn f5890a5eda integration-cli: runSleepingContainerInImage: don't capture stderr
The runSleepingContainerInImage (and runSleepingContainer) utils are
expected to return the container's ID (or name). They already assert
the command executed successfully, so let's avoid capturing output
from stderr (which could be warnings or logs).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-18 12:32:06 +02:00
Daniel Villavicencio 47f6e9248b integration/container: migrate TestAPIStatsNetworkStats to integration suite
Signed-off-by: Daniel Villavicencio <dvm3099@pm.me>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-18 10:56:51 +02:00
5h4rk-lab c8f44969df integration: migrate TestAPICreateDeletePredefinedNetworks from integration-cli
Signed-off-by: Go Charan Kilaru <sharkmagic07@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-18 02:12:52 +02:00
Paweł Gronowski e7ac69f482 integration-cli: Migrate restart suite
Migrate non-redundant `DockerCLIRestartSuite` cases to modern integration tests:

- `TestRestartStoppedContainer` -> `TestContainerRestartStoppedContainer`
- `TestRestartWithVolumes` -> `TestContainerRestartWithVolumes`
- `TestRestartContainerSuccess` -> `TestContainerRestartPolicyAfterProcessExit/direct-process-exit`
- `TestRestartPolicyAfterRestart` -> `TestContainerRestartPolicyAfterProcessExit/after-manual-restart`
- `TestRestartWithPolicyUserDefinedNetwork` -> `TestContainerRestartPolicyUserDefinedNetwork`

Drop redundant deprecated cases:

- `TestRestartRunningContainer`
  covered by `TestWaitRestartedContainer`.
- `TestRestartPolicyNO`, `TestRestartPolicyAlways`, `TestRestartPolicyOnFailure`
  covered by modern create/restart-policy tests.
- `TestRestartAutoRemoveContainer`
   covered by `TestContainerWithAutoRemoveCanBeRestarted`.
- `TestRestartDisconnectedContainer`
  low-value adjacent coverage already exercised by networking restart tests.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-06-17 18:43:05 +02:00
Sebastiaan van Stijn b2b1e91323 Merge pull request #50631 from carsontham/migrate-test-container-api-stop
integration-cli: migrated test TestContainerAPIStop
2026-06-16 19:54:13 +02:00
Sebastiaan van Stijn 532e50b773 Merge pull request #50494 from Abubacarr075/50159-migrate-test-api-images
migrate TestAPIImagesSearchJSONContentType to integration
2026-06-16 19:05:07 +02:00
carsontham cfe61f52d6 migrated TestContainerAPIStop
This test was already migrated as integration/container.TestStopContainerWithTimeout

Signed-off-by: carsontham <carsontham@outlook.com>
2026-06-16 17:45:17 +02:00
Sebastiaan van Stijn c891cf6dcb Merge pull request #52858 from vvoland/fix-flaky-windows
integration-cli: Migrate TestContainersAPICreateMountsCreate
2026-06-16 17:32:29 +02:00
Abubacarr Ceesay 269c1eda0f migrate TestAPIImagesSearchJSONContentType to integration
Migrate test api images search json content type from integration cli to integration tests

Signed-off-by: Abubacarr Ceesay <abubacarr671@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-06-16 17:14:22 +02:00
Paweł Gronowski cfe0e72854 integration-cli: Migrate TestContainersAPICreateMountsCreate
Move the useful Mounts API create coverage out of integration-cli and
into the container integration tests that own the behavior.

Add volume mount inspect assertions to TestContainerVolumeAnonymous for
destination normalization, read-only named volumes, explicit driver
configuration, and NoCopy mounts.

Add a focused bind mount inspect test for read-only bind mounts and
shared propagation.

Do not port the full integration-cli matrix. Existing integration tests
already cover anonymous volume creation and labeling, anonymous volume
removal with RemoveVolumes, and generic bind propagation handling.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-06-15 21:10:34 +02:00
Paweł Gronowski b764e28d55 integration-cli/container: Rewrite on-failure restart tests
Replace flaky legacy CLI restart-policy tests with container API
integration coverage.

The CLI tests poll inspect output after short-lived detached containers
exit, which can observe transient daemon monitor state while cleanup or
restart-policy handling is still settling.

On Windows this can race a manual restart against an `on-failure:3`
container that has not exhausted its automatic retries.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-06-15 19:35:31 +02:00
Paweł Gronowski 29f6cd5c90 Merge pull request #41963 from thaJeztah/prefix_slash
testing: refactor uses of "getPrefixAndSlashFromDaemonPlatform()"
2026-06-11 17:33:42 +02:00
Cory Snider 1dd67f8dea integration-cli: get container id from stdout only
TestDaemonRestartWithNames in the DockerDaemonSuite has been broken
since commit 72ec7cd6cc. The test takes
the combined output of a `docker run` command as the ID of the created
container. This works fine so long as the command emits no warnings,
otherwise it will corrupt the ID that the test captures. Modify the test
to read the ID from the command's stdout to make the test robust to
warnings being printed.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2026-06-10 15:57:48 -04:00
Paweł Gronowski b571092d29 integration-cli: Deflake TestDockerCLICpSuite
The cp integration fixture only needs a stopped container with prepared
filesystem content.

Running the container detached and immediately calling `docker wait`
adds an extra daemon wait request that can race with short-lived fixture
containers and fail before the copy behavior is exercised.

Run the fixture command in the foreground and capture the resulting
container ID with a cidfile so the container remains available for later
cp assertions without the separate wait endpoint.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-05-29 19:25:59 +02:00
Sebastiaan van Stijn 1cba169996 integration-cli: remove some redundant fmt.Sprintf()
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-05-18 23:21:46 +02:00
Sebastiaan van Stijn f806aacca8 testing: refactor uses of "getPrefixAndSlashFromDaemonPlatform()"
Implement a `dPath()` utility function that converts paths to Windows paths
(add `c:` drive-letter, and convert to backslashes) if the daemon is running
on Windows.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-05-18 23:21:39 +02:00
Paweł Gronowski 160a0112e1 integration-cli: Deflake TestBuildEmitsEvents
The test queried `docker events` without `--until` and relied on a 300ms
timeout to collect output.

On slow CI, events may not stream back within that window, resulting in
empty stdout and assertion failures.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2026-05-14 14:07:40 +02:00
Sahana Narasipura Vasudevarao 07a5e924ce Fix typos and misspellings in comments, tests, and docs
Signed-off-by: Sahana Narasipura Vasudevarao <nvsahanarao@gmail.com>
2026-04-02 14:20:22 -07:00
Sebastiaan van Stijn 210cdcbd46 daemon/server/router: fix "no stream selected" error and status
Tweak the wording, and make sure we return a 400 status, not a 500

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2026-03-03 21:53:23 +01:00