582 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
f658ea3152 Fix parsing of user/group during copy operation
If a container was started with

- a numeric uid
- both a user and group (username:groupname)
- uid and gid (uid:gid)

The copy action failed, because the "username:groupname"
was looked up using getent.

This patch;

- splits `user` and `group` before looking up
- if numeric `uid` or `gid` is used and lookup fails,
  the `uid` / `gid` is used as-is

The code also looked up the user and group on the host
instead of in the container when using getent; this patch
fixes the lookup to only use the container's /etc/passwd
and /etc/group instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 12:45:29 +01:00
Tianon Gravi
078c5edcd7 Adjust test to support cgroupv1
This has to be careful to do something non-destructive, which this *should* be.

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2025-01-16 17:20:55 -08:00
Tianon Gravi
c75e333b6f Satisfy linter
integration/container/run_linux_test.go:459:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)

(thanks Go)

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2025-01-16 16:12:50 -08:00
Tianon Gravi
ce3e34816a Add support for bare writable-cgroups security-opt
This requires changes in the CLI to support fully, but matches our other boolean option handling (`no-new-privileges`).

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2025-01-16 16:00:44 -08:00
Tianon Gravi
f8187c0214 Error on invalid requests for writable-cgroups
This makes `WritableCgroups` a pointer so we can error when it's specified in invalid configurations (both rootless and user namespaces).

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2025-01-16 15:59:06 -08:00
Tianon Gravi
bc7d118fd7 Adjust TestCgroupRW to test output before exit code
This should give us more useful test output on failures.

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2025-01-16 15:27:33 -08:00
Tianon Gravi
081b9d97db Update TestCgroupRW with subtests + nil case fix
Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2025-01-16 12:58:24 -08:00
Vincent Batts
b5b5b7e983 integration/container: test the writable-cgroups security option
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2025-01-16 12:58:24 -08:00
Sebastiaan van Stijn
16cbb27e4e use StatsResponse instead of Stats in tests
The StatsResponse type  was a compatibility-wrapper introduced in
d3379946ec to differentiate responses
for  API < 1.21 and API >= 1.21. API versions lower than 1.24 are
deprecated, and we should merge StatsResponse and Stats, but let's
start with using the StatsResponse in our tests.

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

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-01-15 14:09:30 +01:00
Sebastiaan van Stijn
6d24a21643 improve validation of cpu-shares, and migrate TestRunInvalidCPUShares
This test was testing errors produced by runc; both the "maximum" and
"minimum" values originate from the OCI runtime;
d48d9cfefc/libcontainer/cgroups/fs/cpu.go (L66-L83)

    docker run --cpu-shares=1 alpine
    docker: Error response from daemon: failed to create shim task: OCI runtime create failed: runc create failed: unable to start container process: error during container init: error setting cgroup config for procHooks process: the minimum allowed cpu-shares is 2: unknown.

Happy path for this setting is covered by TestRunWithCPUShares, and
various other tests, so we validate that the options take effect;
f5af46d4d5/integration-cli/docker_cli_run_unix_test.go (L494-L503)

This patch:

- removes the test and migrates it to an integration test
- removes the checks for errors that might be produced by runc
- updates our validation for invalid (negative) values to happen
  when creating the contaienr; the existing check that happened when
  creating the OCI spec is preserved, so that configs of existing containers
  are still validated.
- updates validateResources to return the correct error-type
- updated unit-test to validate

With this patch:

    make TEST_FILTER='TestCreateInvalidHostConfig' TEST_SKIP_INTEGRATION_CLI=1 test-integration
    --- PASS: TestCreateInvalidHostConfig (0.00s)
        --- PASS: TestCreateInvalidHostConfig/invalid_IpcMode (0.00s)
        --- PASS: TestCreateInvalidHostConfig/invalid_CPUShares (0.00s)
        --- PASS: TestCreateInvalidHostConfig/invalid_PidMode (0.00s)
        --- PASS: TestCreateInvalidHostConfig/invalid_PidMode_without_container_ID (0.00s)
        --- PASS: TestCreateInvalidHostConfig/invalid_Annotations (0.00s)
        --- PASS: TestCreateInvalidHostConfig/invalid_UTSMode (0.00s)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-09 13:24:02 +01:00
Sebastiaan van Stijn
641e2fca5b Merge pull request #49198 from thaJeztah/migrate_TestCreateByImageID
integration-cli: migrate TestCreateByImageID to integration suite
2025-01-08 10:28:17 +01:00
Sebastiaan van Stijn
a646467a66 integration-cli: migrate TestCreateByImageID to integration suite
This test originally added in 4352da7803,
and was a bit involved as it involved building an image, and had some
dubious test-cases, such as  using `wrongimage:<ID of other image>` as
reference, and expecting that to produce a "not found" error. Possibly
this format was supported in the past, but currently it fails equally with
`correctimage:<ID of image>`.

This patch rewrites the test to an integration test, and removes the test
from integration-cli. It also removes TestCreate64ByteHexID, as it was
duplicated by this test.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-03 00:11:53 +01:00
Sebastiaan van Stijn
839b0afbc7 integration/container: use is.ErrorType for some tests
It provides more details about the actual error-type obtained
on failures.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 19:43:08 +01:00
Sebastiaan van Stijn
4504ca6bf6 integration/container: rename vars that shadowed imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 19:43:08 +01:00
Sebastiaan van Stijn
6b0085eebd integration/container: use consistent name for api-client
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 19:43:08 +01:00
Sebastiaan van Stijn
fa0b9f9505 integration/container: use consistent alias for test-container pkg
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 19:43:08 +01:00
Sebastiaan van Stijn
b8db6d143a Merge pull request #48956 from thaJeztah/poll_default_delay
integration: remove default poll delay and timeouts
2024-11-27 22:20:36 +01:00
Akihiro Suda
fb6e650ab9 integration: add wait
Cherry-picked several WIP commits from
b0a592798f/

Originally-authored-by: Rodrigo Campos <rodrigoca@microsoft.com>
Co-Authored-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-27 15:52:49 +01:00
Sebastiaan van Stijn
b57aa7f3b7 integration: remove default poll delay and timeouts
The default delay is 100ms and default timeout is 10s, so we can
remove cases where we are setting the defaults;

d8fa0581ee/vendor/gotest.tools/v3/poll/poll.go (L115)
d8fa0581ee/vendor/gotest.tools/v3/poll/poll.go (L39-L40)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-26 14:05:02 +01:00
Aleksa Sarai
caae3c051d tests: migrate to assert.ErrorContains when possible
If we have an error type that we're checking a substring against, we
should really be checking using ErrorContains to indicate the right
semantics to assert.

Mostly done using these transforms:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r 'assert.Assert(t, is.ErrorContains(e, s)) -> assert.ErrorContains(t, e, s)'
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r 'assert.Assert(t, is.Contains(err.Error(), s)) -> assert.ErrorContains(t, err, s)'
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r 'assert.Check(t, is.Contains(err.Error(), s)) -> assert.Check(t, is.ErrorContains(err, s))'

As well as some small fixups to helpers that were doing
strings.Contains explicitly.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-11-22 23:59:21 +11:00
Aleksa Sarai
1b470d15d8 tests: migrate away from assert.Assert(v == nil)
If a values is non-nil when we don't expect it, it would be quite
helpful to get an error message explaining what happened.

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, a == nil) -> assert.Assert(t, is.Nil(a))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, a == nil) -> assert.Check(t, is.Nil(a))"

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-11-22 23:59:20 +11:00
Sebastiaan van Stijn
b9a904c48a integration/container: TestCDISpecDirsAreInSystemInfo: use fixtures
Set the daemon.json config as a string-literal in the tests, instead of
using a map[string]interface{} as intermediary format.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-22 10:55:55 +01:00
Sebastiaan van Stijn
d3609fa9c2 Merge pull request #48855 from vvoland/c8d-inspect-imagemanifest
c8d/container/inspect: Return `ImageManifestDescriptor`
2024-11-19 16:47:47 +01:00
Paweł Gronowski
44ed3067ca c8d/container/inspect: Return ImageManifestDescriptor
`ImageManifestDescriptor` will contain an OCI descriptor of
platform-specific manifest of the image that was picked when creating
the container.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-19 13:55:56 +01:00
Rodrigo Campos
f96994ec17 Skip tests that are flaky for 4 already
Some other tests on this file where skipped with this same line. Let's
skip this one, that seems to be flaky too.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-11-19 12:44:25 +01:00
Sebastiaan van Stijn
53d78d73e6 integration/container: remove redundant capturing of loop vars (copyloopvar)
integration/container/attach_test.go:39:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/container_test.go:28:3: The copy of the 'for' variable "ep" can be deleted (Go 1.22+) (copyloopvar)
            ep := ep
            ^
    integration/container/create_test.go:57:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/create_test.go:120:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/create_test.go:406:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/create_test.go:583:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/exec_test.go:218:4: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
                tc := tc
                ^
    integration/container/kill_test.go:70:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/kill_test.go:110:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/logs_test.go:130:3: The copy of the 'for' variable "tC" can be deleted (Go 1.22+) (copyloopvar)
            tC := tC
            ^
    integration/container/overlayfs_linux_test.go:59:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/resize_test.go:107:4: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
                tc := tc
                ^
    integration/container/restart_test.go:78:5: The copy of the 'for' variable "stopDaemon" can be deleted (Go 1.22+) (copyloopvar)
                    stopDaemon := stopDaemon
                    ^
    integration/container/restart_test.go:188:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/run_linux_test.go:341:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/stop_linux_test.go:58:3: The copy of the 'for' variable "d" can be deleted (Go 1.22+) (copyloopvar)
            d := d
            ^
    integration/container/wait_test.go:40:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/wait_test.go:83:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/wait_test.go:133:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/container/wait_test.go:205:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:13 +01:00
Sebastiaan van Stijn
c1652ab357 volume/service: use local driver as default for anonymous volumes
Anonymous volumes get a unique, 64-character name, and intended to be a new
volume (not an existing one). While it's theoretically possible for this name
to exist in other volume drivers, this would be very unlikely, so we should
not need to check other drivers to have this volume.

This patch uses the default ("local") volume-driver for anonymous volumes,
unless the user explicitly asked for a specific driver to use. Setting the
driver skips looking up existing volumes in other drivers.

Before this patch:

    DEBU[2024-10-26T15:51:12.681547126Z] container mounted via snapshotter: /var/lib/docker/rootfs/overlayfs/7e947822249514b6239657a0c54d091d90e0fed4b09da472f3f6258f2b4920bc  container=7e947822249514b6239657a0c54d091d90e0fed4b09da472f3f6258f2b4920bc
    DEBU[2024-10-26T15:51:12.681616084Z] Creating anonymous volume                     volume-name=fd46d688247c3e7d39d9bae4532d6b2dc69e82e354c4a3bf305c50bbfb9ebc6c
    DEBU[2024-10-26T15:51:12.681638959Z] Probing all drivers for volume                volume-name=fd46d688247c3e7d39d9bae4532d6b2dc69e82e354c4a3bf305c50bbfb9ebc6c
    DEBU[2024-10-26T15:51:12.681688917Z] Registering new volume reference              driver=local volume-name=fd46d688247c3e7d39d9bae4532d6b2dc69e82e354c4a3bf305c50bbfb9ebc6c

With this patch:

    DEBU[2024-10-27T17:28:28.574956716Z] container mounted via snapshotter: /var/lib/docker/rootfs/overlayfs/7085cb3991b61cbb79edffcb6980ad926f99f6b6b3be617cc3e3b92673cc2eb8  container=7085cb3991b61cbb79edffcb6980ad926f99f6b6b3be617cc3e3b92673cc2eb8
    DEBU[2024-10-27T17:28:28.575002549Z] Creating anonymous volume                     driver=local volume-name=db11c053566362499103213542402af2770a6622fe7a90b9a938a5bed84ca937
    DEBU[2024-10-27T17:28:28.575016299Z] Registering new volume reference              driver=local volume-name=db11c053566362499103213542402af2770a6622fe7a90b9a938a5bed84ca937

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-28 09:11:05 +01:00
Sebastiaan van Stijn
10d57fde44 volume/mounts: fix anonymous volume not being labeled
`Parser.ParseMountRaw()` labels anonymous volumes with a `AnonymousLabel` label
(`com.docker.volume.anonymous`) label based on whether a volume has a name
(named volume) or no name (anonymous) (see [1]).

However both `VolumesService.Create()` (see [1]) and `Parser.ParseMountRaw()`
(see [2], [3]) were generating a random name for anonymous volumes. The latter
is called before `VolumesService.Create()` is called, resulting in such volumes
not being labeled as anonymous.

Generating the name was originally done in Create (fc7b904dce),
but duplicated in b3b7eb2723 with the introduction
of the new Mounts field in HostConfig. Duplicating this effort didn't have a
real effect until (`Create` would just skip generating the name), until
618f26ccbc introduced the `AnonymousLabel` in
(v24.0.0, backported to v23.0.0).

Parsing generally should not fill in defaults / generate names, so this patch;

- Removes generating volume names from  `Parser.ParseMountRaw()`
- Adds a debug-log entry to `VolumesService.Create()`
- Touches up some logs to use structured logs for easier correlating logs

With this patch applied:

    docker run --rm --mount=type=volume,target=/toto hello-world

    DEBU[2024-10-24T22:50:36.359990376Z] creating anonymous volume                     volume-name=0cfd63d4df363571e7b3e9c04e37c74054cc16ff1d00d9a005232d83e92eda02
    DEBU[2024-10-24T22:50:36.360069209Z] probing all drivers for volume                volume-name=0cfd63d4df363571e7b3e9c04e37c74054cc16ff1d00d9a005232d83e92eda02
    DEBU[2024-10-24T22:50:36.360341209Z] Registering new volume reference              driver=local volume-name=0cfd63d4df363571e7b3e9c04e37c74054cc16ff1d00d9a005232d83e92eda02

[1]: 032721ff75/volume/service/service.go (L72-L83)
[2]: 032721ff75/volume/mounts/linux_parser.go (L330-L336)
[3]: 032721ff75/volume/mounts/windows_parser.go (L394-L400)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-25 01:57:22 +02:00
Sebastiaan van Stijn
2b2aa69100 api: exec resize: improve errors for invalid width/height
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-17 14:04:37 +02:00
Sebastiaan van Stijn
d19aa0c590 api: container resize: improve errors for invalid width/height
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-17 14:04:36 +02:00
Sebastiaan van Stijn
44010e76c2 integration/container: add TestExecResize
Add integration tests for resizing exec's.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-15 17:58:57 +02:00
Sebastiaan van Stijn
944dc4a559 integration/container: TestResize: add more test-cases
Add tests for various (invalid) sizes for resizing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-15 17:56:46 +02:00
Rob Murray
91f74c2fe0 Disable iptables/ip6tables in two tests to remove conflict
TestAttachDisconnectLeak starts its own daemon with iptables disabled,
but disabling ip6tables was missed when we enabled ip6tables by default.

TestNetworkStateCleanupOnDaemonStart also starts its own daemon, with
iptables and ip6tables both enabled. It isn't trying to test anything
iptables related.

These tests run in parallel, so they both modify ip6tables in the host
namespace - and could break each other by adding/removing chains at
awkward moments.

Disable iptables and ip6tables in both tests.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-11 14:45:49 +01:00
Laura Brehm
c866a7e5f8 daemon/exec: don't overwrite exit code if set
If we fail to start an exec, the deferred error-handling block in [L181-L193](c7e42d855e/daemon/exec.go (L181-L193))
would set the exit code to `126` (`EACCES`). However, if we get far enough along
attempting to start the exec, we set the exit code according to the error returned
from starting the task [L288-L291](c7e42d855e/daemon/exec.go (L288-L291)).

For some situations (such as `docker exec [some-container]
missing-binary`), the 2nd block returns the correct exit code (`127`)
but that then gets overwritten by the 1st block.

This commit changes that logic to only set the default exit code `126`
if the exit code has not been set yet.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-09-30 15:49:04 +01:00
Nathan Baulch
59eba0ae13 Fix typos
Signed-off-by: Nathan Baulch <nathan.baulch@gmail.com>
2024-09-06 21:53:09 +10:00
Sebastiaan van Stijn
1804f0c911 integration/container: rename var that collided with import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-19 13:28:17 +02:00
Sebastiaan van Stijn
1abc8f6158 api/types: move container-inspect types to api/types/container
This moves the `ContainerJSONBase`, `ContainerJSON` and `ContainerNode`
types to the api/types/container package and deprecates the old location.

- `ContainerJSONBase` was renamed to `InspectBase`
- `ContainerJSON` was rnamed to `InspectResponse`

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 12:50:24 +02:00
Sebastiaan van Stijn
05b0e653dd api/types: move Container to api/types/container
This moves the `Container` type to the containere package, rename
it to `Summary`, and deprecates the old location.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 12:46:48 +02:00
Sebastiaan van Stijn
c130ce1f5d api/types: move container Health types to api/types/container
This moves the `Health` and `HealthcheckResult` types to the container package,
as well as the related `NoHealthcheck`, `Starting`, `Healthy`, and `Unhealthy`
consts.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 12:46:47 +02:00
Sebastiaan van Stijn
0a4277abf4 api/types: move stats-types to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-20 10:21:42 +02:00
Sebastiaan van Stijn
ad716b223b integration/container: use consistent alias for import
The canonical alias is "containertypes" for this import.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 13:11:37 +02:00
Brian Goff
2851ddc44c Add containerd image ref to created containers
This populates the "Image" field on containerd containers, but only when
using the containerd image store.
This allows containerd clients to look up the image information.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 14:45:17 +02:00
Sebastiaan van Stijn
b2441c7419 Merge pull request #45052 from cpuguy83/attach_fd_leak
Fix attach goroutine/fd leak when no I/O is ready
2024-06-17 13:16:08 +02:00
Sebastiaan van Stijn
805ccd2365 pkg/dmesg: deprecate, and use internal utility instead
This package was originally added in 46833ee1c3
for use in the devicemapper graphdriver. The devicemapper graphdriver was
deprecated and has been removed. The only remaining consumer is an integration
test.

Deprecate the package and mark it for removal in the next release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 12:41:39 +02:00
Albin Kerouanton
955b923352 daemon: releaseNetwork: clear SandboxID, SandboxKey
When the container stops or during `restore`, `daemon.releaseNetwork` is
used to clear all net-related state carried by a container. However, the
fields `SandboxID` and `SandboxKey` are never cleared. On the next start,
these fields will be replaced with new values. There's no point in
preserving these data since they became invalid as soon as the container
stopped.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-14 18:35:31 +02:00
Albin Kerouanton
e3c5665d21 daemon: restore: clear net state for stopped containers
When the daemon crashes, the host unexpectedly reboot, or the daemon
restarts with live-restore enabled, running containers might stop and the
on-disk state for containers might diverge from reality. All these
situations are currently handled by the daemon's `restore` method.

That method calls `daemon.Cleanup()` for all the dead containers. In
turn, `Cleanup` calls `daemon.releaseNetwork()`. However, this last
method won't do anything because it expects the `netController` to be
initialized when it's called. That's not the case in the `restore` code
path -- the `netController` is initialized _after_ cleaning up dead
containers.

There's a chicken-egg problem here, and fixing that would require some
important architectural changes (eg. change the way libnet's controller
is initialized).

Since `releaseNetwork()` early exits, dead containers won't ever have
their networking state cleaned. This led to bugs in Docker Desktop,
among other things.

Fix that by calling `releaseNetwork` after initializing the
`netController`.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-14 18:35:31 +02:00
Akihiro Suda
896de6d426 seccomp: allow specifying a custom profile with --privileged
`--privileged --security-opt seccomp=<CUSTOM.json>` was ignoring
`<CUSTOM.json>`.

Fix issue 47499

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-06-11 03:37:54 +09:00
Sebastiaan van Stijn
eb675cce71 api/types: move ImageImportSource to api/types/image
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:21:25 +02:00
Sebastiaan van Stijn
b5f15bc0aa api/types: move EventsOptions to api/types/events
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:21:24 +02:00