Commit graph

8220 commits

Author SHA1 Message Date
Sebastiaan van Stijn
f66f464802
Merge pull request #46913 from thaJeztah/local_logs_timezone
daemon/logger/local: always use UTC for timestamps
2023-12-08 19:56:09 +01:00
Sebastiaan van Stijn
afe281964d
daemon/logger/local: always use UTC for timestamps
When reading logs, timestamps should always be presented in UTC. Unlike
the "json-file" and other logging drivers, the "local" logging driver
was using local time.

Thanks to Roman Valov for reporting this issue, and locating the bug.

Before this change:

    echo $TZ
    Europe/Amsterdam

    docker run -d --log-driver=local nginx:alpine
    fc166c6b2c35c871a13247dddd95de94f5796459e2130553eee91cac82766af3

    docker logs --timestamps fc166c6b2c35c871a13247dddd95de94f5796459e2130553eee91cac82766af3
    2023-12-08T18:16:56.291023422+01:00 /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
    2023-12-08T18:16:56.291056463+01:00 /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
    2023-12-08T18:16:56.291890130+01:00 /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
    ...

With this patch:

    echo $TZ
    Europe/Amsterdam

    docker run -d --log-driver=local nginx:alpine
    14e780cce4c827ce7861d7bc3ccf28b21f6e460b9bfde5cd39effaa73a42b4d5

    docker logs --timestamps 14e780cce4c827ce7861d7bc3ccf28b21f6e460b9bfde5cd39effaa73a42b4d5
    2023-12-08T17:18:46.635967625Z /docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
    2023-12-08T17:18:46.635989792Z /docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
    2023-12-08T17:18:46.636897417Z /docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
    ...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-08 18:31:30 +01:00
Paweł Gronowski
bea729c030
c8d/prune: Familiarize image names that were untagged
To align with the graphdriver implementation.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-12-08 16:39:33 +01:00
Paweł Gronowski
8ba8a59697
c8d/prune: Default dangling filter to true
If no `dangling` filter is specified, prune should only delete dangling
images.

This wasn't visible by doing `docker image prune` because the CLI
explicitly sets this filter to true.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-12-08 13:58:09 +01:00
Sebastiaan van Stijn
7cb1efebec
api/types: move NetworkListConfig to api/types/backend
This struct is intended for internal use only for the backend, and is
not intended to be used externally.

This moves the plugin-related `NetworkListConfig` types to the backend
package to prevent it being imported in the client, and to make it more
clear that this is part of internal APIs, and not public-facing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-06 02:21:21 +01:00
Sebastiaan van Stijn
a58b0a3d9c
api/types: move Plugin-types to api/types/backend
These structs are intended for internal use only for the backend, and are
not intended to be used externally.

This moves the plugin-related `PluginRmConfig`, `PluginEnableConfig`, and
`PluginDisableConfig` types to the backend package to prevent them being
imported in the client, and to make it more clear that this is part of
internal APIs, and not public-facing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-06 02:16:02 +01:00
Sebastiaan van Stijn
08e4e88482
daemon: raise default minimum API version to v1.24
The daemon currently provides support for API versions all the way back
to v1.12, which is the version of the API that shipped with docker 1.0. On
Windows, the minimum supported version is v1.24.

Such old versions of the client are rare, and supporting older API versions
has accumulated significant amounts of code to remain backward-compatible
(which is largely untested, and a "best-effort" at most).

This patch updates the minimum API version to v1.24, which is the fallback
API version used when API-version negotiation fails. The intent is to start
deprecating older API versions, but no code is removed yet as part of this
patch, and a DOCKER_MIN_API_VERSION environment variable is added, which
allows overriding the minimum version (to allow restoring the behavior from
before this patch).

With this patch the daemon defaults to API v1.24 as minimum:

    docker version
    Client:
     Version:           24.0.2
     API version:       1.43
     Go version:        go1.20.4
     Git commit:        cb74dfc
     Built:             Thu May 25 21:50:49 2023
     OS/Arch:           linux/arm64
     Context:           default

    Server:
     Engine:
      Version:          dev
      API version:      1.44 (minimum version 1.24)
      Go version:       go1.21.3
      Git commit:       0322a29b9ef8806aaa4b45dc9d9a2ebcf0244bf4
      Built:            Mon Dec  4 15:22:17 2023
      OS/Arch:          linux/arm64
      Experimental:     false
     containerd:
      Version:          v1.7.9
      GitCommit:        4f03e100cb967922bec7459a78d16ccbac9bb81d
     runc:
      Version:          1.1.10
      GitCommit:        v1.1.10-0-g18a0cb0
     docker-init:
      Version:          0.19.0
      GitCommit:        de40ad0

Trying to use an older version of the API produces an error:

    DOCKER_API_VERSION=1.23 docker version
    Client:
     Version:           24.0.2
     API version:       1.23 (downgraded from 1.43)
     Go version:        go1.20.4
     Git commit:        cb74dfc
     Built:             Thu May 25 21:50:49 2023
     OS/Arch:           linux/arm64
     Context:           default
    Error response from daemon: client version 1.23 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

To restore the previous minimum, users can start the daemon with the
DOCKER_MIN_API_VERSION environment variable set:

    DOCKER_MIN_API_VERSION=1.12 dockerd

API 1.12 is the oldest supported API version on Linux;

    docker version
    Client:
     Version:           24.0.2
     API version:       1.43
     Go version:        go1.20.4
     Git commit:        cb74dfc
     Built:             Thu May 25 21:50:49 2023
     OS/Arch:           linux/arm64
     Context:           default

    Server:
     Engine:
      Version:          dev
      API version:      1.44 (minimum version 1.12)
      Go version:       go1.21.3
      Git commit:       0322a29b9ef8806aaa4b45dc9d9a2ebcf0244bf4
      Built:            Mon Dec  4 15:22:17 2023
      OS/Arch:          linux/arm64
      Experimental:     false
     containerd:
      Version:          v1.7.9
      GitCommit:        4f03e100cb967922bec7459a78d16ccbac9bb81d
     runc:
      Version:          1.1.10
      GitCommit:        v1.1.10-0-g18a0cb0
     docker-init:
      Version:          0.19.0
      GitCommit:        de40ad0

When using the `DOCKER_MIN_API_VERSION` with a version of the API that
is not supported, an error is produced when starting the daemon;

    DOCKER_MIN_API_VERSION=1.11 dockerd --validate
    invalid DOCKER_MIN_API_VERSION: minimum supported API version is 1.12: 1.11

    DOCKER_MIN_API_VERSION=1.45 dockerd --validate
    invalid DOCKER_MIN_API_VERSION: maximum supported API version is 1.44: 1.45

Specifying a malformed API version also produces the same error;

    DOCKER_MIN_API_VERSION=hello dockerd --validate
    invalid DOCKER_MIN_API_VERSION: minimum supported API version is 1.12: hello

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-05 23:11:02 +01:00
Sebastiaan van Stijn
484e6b784c
api/types: move ContainerCreateConfig, ContainerRmConfig to api/types/backend
The `ContainerCreateConfig` and `ContainerRmConfig` structs are used for
options to be passed to the backend, and are not used in client code.

Thess struct currently is intended for internal use only (for example, the
`AdjustCPUShares` is an internal implementation details to adjust the container's
config when older API versions are used).

Somewhat ironically, the signature of the Backend has a nicer UX than that
of the client's `ContainerCreate` signature (which expects all options to
be passed as separate arguments), so we may want to update that signature
to be closer to what the backend is using, but that can be left as a future
exercise.

This patch moves the `ContainerCreateConfig` and `ContainerRmConfig` structs
to the backend package to prevent it being imported in the client, and to make
it more clear that this is part of internal APIs, and not public-facing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-05 16:41:36 +01:00
Sebastiaan van Stijn
e18f5a5304
container: internalize InitAttachContext
Move the initialization logic to the attachContext itself, so that
the container doesn't have to be aware about mutexes and other logic.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-30 15:26:53 +01:00
Sebastiaan van Stijn
c8b9dfb25e
Merge pull request #46867 from thaJeztah/log_info
daemon: kill: use log level to "warn" if container doesn't exit in time
2023-11-30 14:41:32 +01:00
Sebastiaan van Stijn
61d8f57f2a
daemon: kill: use log level to "warn" if container doesn't exit in time
I noticed this log being logged as an error, but the kill logic actually
proceeds after this (doing a "direct" kill instead). While usually containers
are expected to be exiting within the given timeout, I don't think this
needs to be logged as an error (an error is returned after we fail to
kill the container).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-29 16:18:34 +01:00
Paweł Gronowski
c5ea3d595c
liverestore: Don't remove --rm containers on restart
When live-restore is enabled, containers with autoremove enabled
shouldn't be forcibly killed when engine restarts.
They still should be removed if they exited while the engine was down
though.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-11-28 12:59:38 +01:00
Paweł Gronowski
4cd2654a9d
Merge pull request #46770 from vvoland/c8d-unmount-empty-basefs
daemon/c8d: Unmount container fs after unclean shutdown
2023-11-27 13:52:00 +01:00
Paweł Gronowski
203bac0ec4
daemon/c8d: Unmount container fs after unclean shutdown
BaseFS is not serialized and is lost after an unclean shutdown. Unmount
method in the containerd image service implementation will not work
correctly in that case.
This patch will allow Unmount to restore the BaseFS if the target is
still mounted.

The reason it works with graphdrivers is that it doesn't directly
operate on BaseFS. It uses RWLayer, which is explicitly restored
immediately as soon as container is loaded.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-11-27 12:33:33 +01:00
Sebastiaan van Stijn
ce1ee98aba
Merge pull request #46447 from akerouanton/api-predefined-networks
api: Add consts for predefined networks
2023-11-24 12:26:48 +01:00
Albin Kerouanton
5ce8eee0a4
Merge pull request #46846 from akerouanton/refactor/container-rename-move-log-args
daemon: ContainerRename: move log args to log fields
2023-11-24 11:56:38 +01:00
Albin Kerouanton
b1676a289c
daemon: ContainerRename: move log args to log fields
Also, err `e` is renamed into the more standard `err` as the defer
already uses `retErr` to avoid clashes (changed in f5a611a74).

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-11-24 11:05:02 +01:00
Albin Kerouanton
d2865f1e8a
daemon: win: set DNS config on all adapters
DNS config is a property of each adapter on Windows, thus we've a
dedicated `EndpointOption` for that.

The list of `EndpointOption` that should be applied to a given endpoint
is built by `buildCreateEndpointOptions`. This function contains a
seemingly flawed condition that adds the DNS config _iff_:

1. the network isn't internal ;
2. no ports are published / exposed through another sandbox endpoint ;

While 1. does make sense, there's actually no justification for 2.,
hence this commit remove this part of the condition.

This logic flaw has been made obvious by 0fd0e82, but it was originally
introduced by d1e0a78. Commit and PR comments don't mention why this is
done like so. Most probably, this was overlooked both by the original
author and the PR reviewers.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-11-23 18:40:58 +01:00
Albin Kerouanton
0fd0e8255f
daemon: build ports-related ep options in a dedicated func
The `buildCreateEndpointOptions` does a lot of things to build the list
of `libnetwork.EndpointOption` from the `EndpointSettings` spec. To skip
ports-related options, an early return was put in the middle of that
function body.

Early returns are generally great, but put in the middle of a 150-loc
long function that does a lot, they're just a potential footgun. And I'm
the one who pulled the trigger in 052562f. Since this commit, generic
options won't be applied to endpoints if there's already one with
exposed/published ports. As a consequence, only the first endpoint can
have a user-defined MAC address right now.

Instead of moving up the code line that adds generic options, a better
change IMO is to move ports-related options, and the early-return gating
those options, to a dedicated func to make `buildCreateEndpointOptions`
slightly easier to read and reason about.

There was actually one oddity in the original
`buildCreateEndpointOptions`: the early-return also gates the addition
of `CreateOptionDNS`. These options are Windows-specific; a comment is
added to explain that. But the oddity is really: why are we checking if
an endpoint with exposed / published ports joined this sandbox to decide
whether we want to configure DNS server on the endpoint's adapter? Well,
this early-return was most probably overlooked by the original author
and by reviewers at the time these options were added (in commit d1e0a78)

Let's fix that in a follow-up commit.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-11-23 16:26:01 +01:00
Albin Kerouanton
8e84bc3931
Merge pull request #46481 from akerouanton/fix-deprecation-message-servicespec-networks
api/t/swarm: Fix deprecation for ServiceSpec.Networks
2023-11-21 14:24:15 +01:00
Albin Kerouanton
f877360dc1
api/t/swarm: Fix deprecation for ServiceSpec.Networks
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-11-21 10:54:53 +01:00
Paweł Gronowski
d154421092
Merge pull request #46444 from cpuguy83/docker_info_slow
Plumb context through info endpoint
2023-11-20 12:10:30 +01:00
Sebastiaan van Stijn
604f4eed65
Merge pull request #46819 from dmcgowan/c8d-fix-pull-by-digest
c8d: fix support for pull by digest
2023-11-16 20:00:07 +01:00
Sebastiaan van Stijn
847f3060d4
Merge pull request #46803 from thaJeztah/daemon_no_custom_opts
daemon/config: change DNSConfig.DNS to a []net.IP
2023-11-15 14:23:49 +01:00
Derek McGowan
0ab7267ae3
Fix support for pull by digest
Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-11-13 21:38:51 -08:00
Rob Murray
a3fdad84ad graphdriver/copy: faster copy of hard links
The DirCopy() function in "graphdriver/copy/copy.go" has a special case for
skip file-attribute copying when making a hard link to an already-copied
file, if "copyMode == Hardlink". Do the same for copies of hard-links in
the source filesystem.

Significantly speeds up vfs's copy of a BusyBox filesystem (which
consists mainly of hard links to a single binary), making moby's
integration tests run more quickly and more reliably in a dev container.

Fixes #46810

Signed-off-by: Rob Murray <rob.murray@docker.com>
2023-11-13 18:22:03 +00:00
Sebastiaan van Stijn
9b02a84a5a
Merge pull request #46785 from rumpl/c8d-userns-commit
c8d: handle user namespace remapping on commit
2023-11-13 16:31:32 +01:00
Sebastiaan van Stijn
84036d3e18
daemon/config: change DNSConfig.DNS to a []net.IP
Use a strong type for the DNS IP-addresses so that we can use flags.IPSliceVar,
instead of implementing our own option-type and validation.

Behavior should be the same, although error-messages have slightly changed:

Before this patch:

    dockerd --dns 1.1.1.1oooo --validate
    Status: invalid argument "1.1.1.1oooo" for "--dns" flag: 1.1.1.1oooo is not an ip address
    See 'dockerd --help'., Code: 125

    cat /etc/docker/daemon.json
    {"dns": ["1.1.1.1"]}

    dockerd --dns 2.2.2.2 --validate
    unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: dns: (from flag: [2.2.2.2], from file: [1.1.1.1])

    cat /etc/docker/daemon.json
    {"dns": ["1.1.1.1oooo"]}

    dockerd --validate
    unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: 1.1.1.1ooooo is not an ip address

With this patch:

    dockerd --dns 1.1.1.1oooo --validate
    Status: invalid argument "1.1.1.1oooo" for "--dns" flag: invalid string being converted to IP address: 1.1.1.1oooo
    See 'dockerd --help'., Code: 125

    cat /etc/docker/daemon.json
    {"dns": ["1.1.1.1"]}

    dockerd --dns 2.2.2.2 --validate
    unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: dns: (from flag: [2.2.2.2], from file: [1.1.1.1])

    cat /etc/docker/daemon.json
    {"dns": ["1.1.1.1oooo"]}

    dockerd --validate
    unable to configure the Docker daemon with file /etc/docker/daemon.json: invalid IP address: 1.1.1.1oooo

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-13 12:22:51 +01:00
Sebastiaan van Stijn
1eadfb0e28
opts: ValidateIPAddress: improve error, godoc, and tests
- document accepted values
- add test-coverage for the function's behavior (including whitespace handling),
  and use sub-tests.
- improve error-message to use uppercase for "IP", and to use a common prefix.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-11 15:31:19 +01:00
Brian Goff
677d41aa3b Plumb context through info endpoint
I was trying to find out why `docker info` was sometimes slow so
plumbing a context through to propagate trace data through.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2023-11-10 20:09:25 +00:00
Albin Kerouanton
7e66d9900c
Merge pull request #46788 from akerouanton/container-rename-refactor
daemon: ContainerRename: use named error-return
2023-11-08 20:37:22 +01:00
Albin Kerouanton
f5a611a74c
daemon: ContainerRename: use named error-return
It's used in various defers, but was using `err` as name, which can be
confusing, and increases the risk of accidentally shadowing the error.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-11-08 18:53:13 +01:00
Sebastiaan van Stijn
5504ef7a84
Merge pull request #46784 from rumpl/image-builder-cleanup
c8d: cleanup imports in the image builder file
2023-11-08 17:27:52 +01:00
Djordje Lukic
d06af368ad
c8d: "unremap" the user namespace on commit
We remap the snapshot when we create a container, we have to to the
inverse when we commit the container into an image

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-11-08 13:28:45 +01:00
Djordje Lukic
876d4e5484
c8d: cleanup imports in the image builder file
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-11-08 12:31:03 +01:00
Rachit Sharma
7995e3288f
Add until filter to docker image ls
Signed-off-by: Rachit Sharma <rachitsharma613@gmail.com>

add handling for multiple filters

Signed-off-by: Rachit Sharma <rachitsharma613@gmail.com>

Update integration/image/list_test.go

Co-authored-by: Cory Snider <corhere@gmail.com>
Signed-off-by: Rachit Sharma <rachitsharma613@gmail.com>

Add documentation of filter

Signed-off-by: Rachit Sharma <rachitsharma613@gmail.com>

Update integration/image/list_test.go

Co-authored-by: Cory Snider <corhere@gmail.com>
Signed-off-by: Rachit Sharma <rachitsharma613@gmail.com>

Fix bug with CommitOptions

Signed-off-by: Rachit Sharma <rachitsharma613@gmail.com>

add wrapping of text to 80 chars

Signed-off-by: Rachit Sharma <rachitsharma613@gmail.com>
2023-11-08 12:12:23 +01:00
Sebastiaan van Stijn
c14694a424
Merge pull request #46779 from dmcgowan/c8d-default-auth-domain
Default the auth config domain to the target image domain
2023-11-07 16:44:31 +01:00
Sebastiaan van Stijn
49cea49cfa
Merge pull request #45905 from akerouanton/endpoint-specific-mac-address
api: Add a field MacAddress to EndpointSettings
2023-11-07 16:37:27 +01:00
Derek McGowan
755f008c1e
Default the auth config domain to the target image domain
When server address is not provided with the auth configuration,
use the domain from the image provided with the auth.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-11-06 17:02:18 -08:00
Evan Lezar
49e04102c1 Update container-device-interface to v0.6.2
This includes migrating from the github.com/container-orchestrated-devices
repo to tags.cncf.io.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
2023-11-04 01:00:19 +01:00
Paweł Gronowski
3cb8e9526e
Merge pull request #46769 from vvoland/c8d-shared-mounter-impl
daemon/snapshotter: Align mounter implementations
2023-11-03 18:45:36 +01:00
Paweł Gronowski
26f63600c1
daemon/snapshotter: Align mounter implementations
Change the non-refcounted implementation to perform the mount using the
same identity and access right. They should be the same regardless if
we're refcounting or not.

This also allows to refactor refCountMounter into a mounter decorator.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-11-03 18:13:14 +01:00
Albin Kerouanton
6fd893bd3a
Merge pull request #46768 from akerouanton/dedicated-default-nw-config-struct
daemon/config: Put params for the default network into a dedicated struct
2023-11-03 17:03:05 +01:00
Albin Kerouanton
d5d41c2849
daemon/config: Put params for the default network into a dedicated struct
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-11-03 14:10:41 +01:00
Brian Goff
02a932d63f Fix case where health start interval is 0 uses default
When the start interval is 0 we should treat that as unset.
This is especially important for older API versions where we reset the
value to 0.

Instead of using the default probe value we should be using the
configured `interval` value (which may be a default as well) which gives
us back the old behavior before support for start interval was added.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2023-11-02 20:02:16 +00:00
Brian Goff
2f138d860e
Merge pull request #46685 from rumpl/c8d-tag-does-not-exist
c8d: Return the "tag does not exist error"
2023-11-02 12:33:36 -07:00
Sebastiaan van Stijn
d9dce8e0d0
Merge pull request #46618 from vvoland/c8d-pull-all-tags-2
c8d/pull: Handle pull all tags (2nd approach)
2023-10-31 16:45:18 +01:00
Sebastiaan van Stijn
1c50526092
daemon: improve daemon start informational log message
When starting a daemon in debug mode (such as used in CI), many log-messages
are printed during startup. As a result, the log message indicating whether
graph-drivers or snapshotters are used may appear far separate from the
informational log about the daemon (and selected storage-driver).

The existing log-driver also unconditionally uses the legacy "graph-driver"
terminology, instead of the more generic "storage-driver".

This patch changes the log message shown during startup to use the generic
"graph-driver" as field, and adds a new field that indicates wheter we're
using snapshotters or graph-drivers.

Given that snapshotters will be the default at some point, an alternative
could be to include the _type_ of driver used, for example;
`io.containerd.snapshotter.v1`, which may continue to be relevant after
snapshotters become the default, and at which point (potentially) the
type of snapshotter becomes more relevant.

Before this change:

    TEST_INTEGRATION_USE_SNAPSHOTTER=1 DOCKER_GRAPHDRIVER=overlayfs dockerd
    ...
    INFO[2023-10-31T09:12:33.586269801Z] Starting daemon with containerd snapshotter integration enabled
    INFO[2023-10-31T09:12:33.586322176Z] Loading containers: start.
    INFO[2023-10-31T09:12:33.640514759Z] Loading containers: done.
    INFO[2023-10-31T09:12:33.646498134Z] Docker daemon                                 commit=dcf7287d647bcb515015e389df46ccf1e09855b7 graphdriver=overlayfs version=dev
    INFO[2023-10-31T09:12:33.646706551Z] Daemon has completed initialization
    INFO[2023-10-31T09:12:33.658840592Z] API listen on /var/run/docker.sock

With this change;

    TEST_INTEGRATION_USE_SNAPSHOTTER=1 DOCKER_GRAPHDRIVER=overlayfs dockerd
    ...
    INFO[2023-10-31T08:41:38.841155928Z] Starting daemon with containerd snapshotter integration enabled
    INFO[2023-10-31T08:41:38.841207512Z] Loading containers: start.
    INFO[2023-10-31T08:41:38.902461053Z] Loading containers: done.
    INFO[2023-10-31T08:41:38.910535137Z] Docker daemon                                 commit=dcf7287d647bcb515015e389df46ccf1e09855b7 containerd-snapshotter=true storage-driver=overlayfs version=dev
    INFO[2023-10-31T08:41:38.910936803Z] Daemon has completed initialization

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-31 10:20:27 +01:00
Sebastiaan van Stijn
e9efc0a361
Merge pull request #46741 from vvoland/c8d-push-notags
c8d/push: Return error when repository has no tags
2023-10-30 20:08:31 +01:00
Sebastiaan van Stijn
dcf7287d64
Merge pull request #46662 from vvoland/c8d-pull-access-denied-msg-2
c8d/pull: Don't wrap `no basic auth` error
2023-10-30 12:43:41 +01:00
Paweł Gronowski
cd95cd0671
c8d/push: Return error when repository has no tags
In case of `docker push -a`, we need to return an error if there is no
image for the given repository.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-30 10:55:08 +01:00
Paweł Gronowski
df34db1158
c8d/pull: Don't wrap no basic auth error
Don't wrap the `no basic auth credentials` error from containerd and
return it as-is.

The error will look like:
```
failed to resolve reference "docker.io/library/aodkoakds:latest": pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed
```

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-30 09:40:08 +01:00
Paweł Gronowski
27e064e7e9
c8d/history: Fix nil dereference
Check if `Created` is not nil before dereferencing.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-26 15:37:45 +02:00
Sebastiaan van Stijn
1b9411ef77
Merge pull request #46723 from laurazard/cleanup-redundant-calls
daemon/exec_linux: assorted cleanups
2023-10-26 09:54:51 +02:00
Sebastiaan van Stijn
e0476beb78
Merge pull request #46688 from thaJeztah/restart_nocancel
daemon: daemon.containerRestart: don't cancel restart on context cancel
2023-10-26 09:50:20 +02:00
Laura Brehm
9d578a2e6d
Cleanup duplicate imports
Kept `coci` import alias since we use it elsewhere,
maybe to prevent confusion with our own `oci` package.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-10-26 00:10:23 +01:00
Albin Kerouanton
61c78d9438
daemon: Validate MacAddress on container create
This was previously checked only on ContainerStart.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-10-25 22:55:59 +02:00
Albin Kerouanton
ee9f0ed895
api: Deprecate ContainerConfig.MacAddress
Having a sandbox/container-wide MacAddress field makes little sense
since a container can be connected to multiple networks at the same
time. This field is an artefact of old times where a container could be
connected to a single network only.

As we now have a way to specify per-endpoint mac address, this field is
now deprecated.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-25 22:55:59 +02:00
Albin Kerouanton
052562ffd5
api: Add a field MacAddress to EndpointSettings
Prior to this commit, only container.Config had a MacAddress field and
it's used only for the first network the container connects to. It's a
relic of old times where custom networks were not supported.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-10-25 22:52:26 +02:00
Sebastiaan van Stijn
4776a9e6fb
Merge pull request #46722 from thaJeztah/dedup_additionalgroups
daemon: remove redundant withResetAdditionalGIDs option
2023-10-25 22:48:19 +02:00
Sebastiaan van Stijn
460e1b3600
Merge pull request #46720 from akerouanton/container-create-init-structs
api: ContainerCreate: clean up BC conditions
2023-10-25 22:47:29 +02:00
Albin Kerouanton
91eee33f62
api: ContainerCreate: return an error when config is nil
The same error is already returned by `(*Daemon).containerCreate()` but
since this function is also called by the cluster executor, the error
has to be duplicated.

Doing that allows to remove a nil check on container config in
`postContainersCreate`.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-10-25 21:25:17 +02:00
Sebastiaan van Stijn
1f096174d6
Merge pull request #46717 from rumpl/c8d-image-children
c8d: Use the labels to get the children of an image
2023-10-25 18:00:46 +02:00
Sebastiaan van Stijn
a54a34ef0e
Merge pull request #46718 from rumpl/c8d-tag-label
c8d: Preserve image labels when tagging
2023-10-25 17:55:43 +02:00
Djordje Lukic
7d5445e312
Merge pull request #46719 from rumpl/c8d-image-created-date
c8d: show the real image creation date when listing images
2023-10-25 17:38:01 +02:00
Sebastiaan van Stijn
417018659b
daemon: remove redundant withResetAdditionalGIDs option
containerd's `WithUser` function now resets this property, starting with
[3eda46af12b1deedab3d0802adb2e81cb3521950][1] (v1.7.0-beta.4), so we no
longer need this function.

[1]: 3eda46af12

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-25 17:15:05 +02:00
Sebastiaan van Stijn
e36260f39a
Merge pull request #46715 from laurazard/c8d-fix-swarm-failures
c8d/exec: Add additional groups on exec
2023-10-25 17:10:45 +02:00
Djordje Lukic
8f756fe679
c8d: show the real image creation date when listing images
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-10-25 16:43:24 +02:00
Djordje Lukic
7e0cb4c46f
c8d: Use the labels to get the children of an image
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-10-25 15:12:42 +02:00
Djordje Lukic
f5535d516f
c8d: Preserve image labels when tagging
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-10-25 14:56:36 +02:00
Laura Brehm
d7266afc7e
c8d/exec: Add additional groups on exec
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2023-10-25 02:28:39 +01:00
Sebastiaan van Stijn
df3a321164
migrate to github.com/moby/sys/user
The github.com/opencontainers/runc/libcontainer/user package was moved
to a separate module. While there's still uses of the old module in
our code-base, runc itself is migrating to the new module, and deprecated
the old package (for runc 1.2).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-24 15:45:02 +02:00
Sebastiaan van Stijn
aeb8972281
daemon: daemon.containerRestart: don't cancel restart on context cancel
commit def549c8f6 passed through the context
to the daemon.ContainerStart function. As a result, restarting containers
no longer is an atomic operation, because a context cancellation could
interrupt the restart (between "stopping" and "(re)starting"), resulting
in the container being stopped, but not restarted.

Restarting a container, or more factually; making a successful request on
the `/containers/{id]/restart` endpoint, should be an atomic operation.

This patch uses a context.WithoutCancel for restart requests.

It's worth noting that daemon.containerStop already uses context.WithoutCancel,
so in that function, we'll be wrapping the context twice, but this should
likely not cause issues (just redundant for this code-path).

Before this patch, starting a container that bind-mounts the docker socket,
then restarting itself from within the container would cancel the restart
operation. The container would be stopped, but not started after that:

    docker run -dit --name myself -v /var/run/docker.sock:/var/run/docker.sock docker:cli sh
    docker exec myself sh -c 'docker restart myself'

    docker ps -a
    CONTAINER ID   IMAGE         COMMAND                  CREATED          STATUS                       PORTS     NAMES
    3a2a741c65ff   docker:cli    "docker-entrypoint.s…"   26 seconds ago   Exited (128) 7 seconds ago             myself

With this patch: the stop still cancels the exec, but does not cancel the
restart operation, and the container is started again:

    docker run -dit --name myself -v /var/run/docker.sock:/var/run/docker.sock docker:cli sh
    docker exec myself sh -c 'docker restart myself'
    docker ps
    CONTAINER ID   IMAGE        COMMAND                  CREATED              STATUS         PORTS     NAMES
    4393a01f7c75   docker:cli   "docker-entrypoint.s…"   About a minute ago   Up 4 seconds             myself

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-24 12:56:45 +02:00
Sebastiaan van Stijn
164167ea91
Merge pull request #46687 from thaJeztah/more_nocancel
daemon: use context.WithoutCancel in more places
2023-10-20 19:36:44 +02:00
Sebastiaan van Stijn
aad51c0b4e
daemon: daemon.shutdownContainer: use context.WithoutCancel
Use context.WithoutCancel so that both the containerStop and
container.Wait can share the same parent context. This context is still
a "TODO", but can be wired up in future.

It's worth noting that daemon.containerStop already uses context.WithoutCancel,
so in that function, we'll be wrapping the context twice, but this should
likely not cause issues (just redundant for this code-path).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-20 17:50:06 +02:00
Sebastiaan van Stijn
dca89c67ef
daemon: daemon.containerStop: use context.WithoutCancel
Follow-up to fc94ed0a86. Now that
f6e44bc0e8 added the compatcontext
package, we can start using context.WithoutCancel.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-20 17:44:30 +02:00
Djordje Lukic
f800215946
Merge pull request #46570 from dmcgowan/fix-disk-usage-test
integration: fix disk usage test for c8d
2023-10-20 17:11:31 +02:00
Djordje Lukic
8166818791
c8d: Return the "tag does not exist error"
In the tagged case the error message when the image/tag is not found
should be "tag does not exist: ref"

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-10-20 16:55:20 +02:00
Paweł Gronowski
cdb44010c9
c8d/history: Fill ID for parents without the label
When choosing the next image, don't reject images without the classic
builder parent label. The intention was to *prefer* images them instead
of making that a condition.
This fixes the ID not being filled for parent images that weren't built
with the classic builder.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-19 16:41:45 +02:00
Djordje Lukic
29d863d451
Merge pull request #46653 from vvoland/c8d-history-fix-tags
c8d/history: Fix Tags assigned from parents
2023-10-19 14:53:09 +02:00
Djordje Lukic
0253fedf03
Merge pull request #46655 from vvoland/c8d-push-propagate-source-children
c8d/push: Set distribution source recursively
2023-10-19 10:30:47 +02:00
Paweł Gronowski
d28bd54f2a
c8d/history: Fix Tags assigned from parents
The `Tags` slice of each history entry was filled with tags of parent
image. Change it to correctly assign the current image tags.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-19 10:19:04 +02:00
Derek McGowan
e97716a95a
Fix disk usage test
Check for accurate values that may contain content sizes unknown to the
usage test in the calculation. Avoid asserting using deep equals when
only the expected value range is known to the test.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-10-18 21:20:54 -07:00
Bjorn Neergaard
fd3066c168
Merge pull request #46646 from thaJeztah/start_interval_validation
HealthCheck: add validation for minimum accepted start-interval (1ms)
2023-10-16 11:07:14 -07:00
Sebastiaan van Stijn
a7dd561c4a
Merge pull request #46651 from akerouanton/releaseNetwork-NetworkDisabled
daemon: release sandbox even when NetworkDisabled
2023-10-16 19:33:08 +02:00
Paweł Gronowski
9357bcb582
c8d/pull: Return same access denied error as graphdrivers
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-16 17:54:01 +02:00
Paweł Gronowski
488559a330
c8d/push: Set distribution source recursively
After a successful push, all pushed blobs should have a
distribution.source label pointing to the new registry.

Before this commit, the label was only appended to the top-level blob
(manifest or manifest list). Adjust this to also do that recursively to
its children.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-16 17:07:39 +02:00
Paweł Gronowski
d9b5445f39
c8d/pull: Handle pull all tags
Use the distribution code to query the remote repository for tags and
pull them sequentially just like the non-c8d pull.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-16 14:19:29 +02:00
Paweł Gronowski
6040283f23
Merge pull request #46581 from vvoland/c8d-push-hide-jsons
c8d/push: Show progress only on blobs
2023-10-16 13:39:25 +02:00
payall4u
9664f33e0d
daemon: release sandbox even when NetworkDisabled
When the default bridge is disabled by setting dockerd's `--bridge=none`
option, the daemon still creates a sandbox for containers with no
network attachment specified. In that case `NetworkDisabled` will be set
to true.

However, currently the `releaseNetwork` call will early return if
NetworkDisabled is true. Thus, these sandboxes won't be deleted until
the daemon is restarted. If a high number of such containers are
created, the daemon would then take few minutes to start.

See https://github.com/moby/moby/issues/42461.

Signed-off-by: payall4u <payall4u@qq.com>
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-10-16 12:08:01 +02:00
Sebastiaan van Stijn
2df698025c
HealthCheck: add validation for minimum accepted start-interval
This is a follow-up to 2216d3ca8d, which
implemented the StartInterval for health-checks, but did not add validation
for the minimum accepted interval;

> The time to wait between checks in nanoseconds during the start period.
> It should be 0 or at least 1000000 (1 ms). 0 means inherit.

This patch adds validation for the minimum accepted interval (1ms).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-16 10:46:18 +02:00
Sebastiaan van Stijn
80a9fc6d36
Merge pull request #46565 from vvoland/c8d-mirrors-fix
daemon/RegistryHosts: Don't lose mirrors
2023-10-13 22:31:24 +02:00
Bjorn Neergaard
40fde69be9
Revert "Return no basic auth creds error when needed"
This reverts commit 8777592397, which
turns out to break other test cases/the registry flow.

The correct place to handle missing credentials is instead
15bf23df09/remotes/docker/authorizer.go (L200).

Co-authored-by: Djordje Lukic <djordje.lukic@docker.com>
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-10-13 11:39:48 -06:00
Sebastiaan van Stijn
c2aa895908
Merge pull request #46638 from vvoland/c8d-diff-singleflight
c8d/changes: Fix concurrents diffs
2023-10-13 18:12:24 +02:00
Paweł Gronowski
5a34c7c245
Merge pull request #46533 from vvoland/c8d-save-multiple-repo
c8d/save-load: Reimplement non-c8d idiosyncrasies
2023-10-13 14:41:33 +02:00
Paweł Gronowski
bb7408e851
c8d/changes: Fix concurrents diffs
Use a unique parent view snapshot key for each diff request.

I considered using singleflight at first, but I realized it wouldn't
really be correct.
The diff can take some time, so there's a window of time between the
diff start and finish, where the file system can change.
These changes not always will be reflected in the running diff.
With singleflight, the second diff request which happened before the
previous diff was finished, would not include changes made to the
container filesystem after the first diff request has started.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-13 13:15:50 +02:00
Sebastiaan van Stijn
6c1c76d02a
Merge pull request #46631 from rumpl/c8d-no-basic-auth
Return no basic auth creds error when needed
2023-10-13 13:03:26 +02:00
Paweł Gronowski
f51c5e1a5c
c8d/save: Don't save name if exported by digest
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-13 11:52:11 +02:00
Paweł Gronowski
b5f5987959
c8d/load: Fix Loaded image message
It should also contain the image tag, not just repository name.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-13 11:52:09 +02:00
Paweł Gronowski
42af8795a3
c8d/save: Implement exporting all tags
Implement a behavior from the graphdriver's export where `docker save
something` (untagged reference) would export all images matching the
specified repository.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-13 11:52:07 +02:00
Sebastiaan van Stijn
0a82696d70
Merge pull request #46483 from thaJeztah/api_move_image_types
api/types: move various types to api/types/(images|containers|swarm)
2023-10-12 15:29:11 +02:00
Djordje Lukic
8777592397
Return no basic auth creds error when needed
If the auth config contains an empty username/password we should return
an error

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-10-12 15:02:09 +02:00
Sebastiaan van Stijn
ebef4efb88
api/types: move ContainerLogsOptions to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-12 11:30:12 +02:00
Sebastiaan van Stijn
9670d9364d
api/types: move ContainerListOptions to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-12 11:29:24 +02:00
Sebastiaan van Stijn
ec69501e94
api/types: move ServiceCreateResponse, and generate from swagger
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-12 11:29:23 +02:00
Sebastiaan van Stijn
5b3e6555a3
api/types: move ServiceUpdateResponse
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-12 11:29:22 +02:00
Sebastiaan van Stijn
48cacbca24
api/types: move image-types to api/types/image
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-12 11:29:20 +02:00
Paweł Gronowski
44dbbeb196
c8d/progress: Remove unused mountable
It's no longer needed as we get this information from containerd
directly.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-12 11:08:11 +02:00
Paweł Gronowski
bcbbd9538f
c8d/progress: Show Mounted/Exists status
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-12 11:08:08 +02:00
Sebastiaan van Stijn
056be8b7b0
Merge pull request #46473 from thaJeztah/c8d_logs
migrate to github.com/containerd/log v0.1.0
2023-10-12 10:35:02 +02:00
Bjorn Neergaard
bea1462f4f
Merge pull request #46564 from AkihiroSuda/fix-46563
Limit OOMScoreAdj when running in UserNS ("Rootful-in-Rootless")
2023-10-11 12:06:18 -07:00
Sebastiaan van Stijn
cff4f20c44
migrate to github.com/containerd/log v0.1.0
The github.com/containerd/containerd/log package was moved to a separate
module, which will also be used by upcoming (patch) releases of containerd.

This patch moves our own uses of the package to use the new module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-11 17:52:23 +02:00
Sebastiaan van Stijn
d7caea206e
Merge pull request #46585 from cpuguy83/fix_etwlogs
Revert "daemon/logger/etwlogs: rewrite to use go-winio/pkg/etw"
2023-10-11 17:07:50 +02:00
Sebastiaan van Stijn
f0698dae14
Merge pull request #46590 from vvoland/c8d-tag-ctx-withoutcancel
daemon/c8d: Use WithoutCancel instead of context.Background
2023-10-11 16:55:16 +02:00
Paweł Gronowski
e78152aecb
Merge pull request #46605 from vvoland/c8d-load-compressed
c8d/load: Handle compressed archives
2023-10-11 13:48:30 +02:00
Paweł Gronowski
d871a665de
daemon/RegistryHosts: Don't lose mirrors
`docker.io` is present in the `IndexConfigs` so the `Mirrors` property
would get lost because a fresh `RegistryConfig` object was created.

Instead of creating a new object, reuse the existing one and just
mutate its fields.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-11 11:43:54 +02:00
Sebastiaan van Stijn
a67b7554c8
Merge pull request #46595 from vvoland/c8d-rmi-untaggeddangling
c8d/rmi: Don't emit Untagged for dangling images
2023-10-10 18:45:21 +02:00
Djordje Lukic
f3aa9e151d
c8d: Simplify error handling and distribution source label
Extract the distribution source label append into its own function and
make it not fail on any error, we do still log the error.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-10-10 14:13:34 +02:00
Sebastiaan van Stijn
3149c3efe6
Merge pull request #46588 from vvoland/c8d-history-ids
c8d/history: Fill ID and Tags for all entries
2023-10-10 10:05:01 +02:00
Paweł Gronowski
fcabc48ee4
c8d/load: Handle compressed archives
Allow to load images from compressed tars.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-09 14:03:22 +02:00
Paweł Gronowski
b8ba263099
c8d/rmi: Handle explicit dangling name
This isn't something that user should do, but technically the dangling
images exist in the image store and user can pass its name (`moby-dangling@digest`).
Change it so rmi now recognizes that it's actually a dangling image and
doesn't handle it like a regular tagged image.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-06 10:20:37 +02:00
Paweł Gronowski
25a813e924
c8d/rmi: Don't emit Untagged for dangling images
A dangling image isn't really a tag.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-06 10:20:35 +02:00
Brian Goff
f6fa56194f
Merge pull request #46448 from xinfengliu/improve-stats-collector
Make one-shot stats faster
2023-10-05 08:10:29 -07:00
Paweł Gronowski
f99c4ec798
c8d/history: Fill ID and Tags for all entries
Find the parent images by image set by the legacy builder.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-04 16:01:17 +02:00
Paweł Gronowski
e0e6ae741e
daemon/c8d: Use WithoutCancel instead of context.Background
Instead of passing a completely fresh context without any values, just
discard the cancellation.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-04 13:17:51 +02:00
Brian Goff
c47cdd5f39 Revert "daemon/logger/etwlogs: rewrite to use go-winio/pkg/etw"
This reverts commit a9fa147a92.
The commit is unfortunately broken as it is still using `providerHandle`
to write events but that handle is never actually set, so it is always
invalid. All logging fails.

Note: This is note a straight revert due to the change to
containerd/log.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2023-10-03 22:42:36 +00:00
Paweł Gronowski
6f27bef9fc
daemon/c8d: Use non cancellable context in defers
Fixes leases not being released when operation was cancelled.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-03 15:27:40 +02:00
Paweł Gronowski
77f7c83114
c8d/push: Show progress only on blobs
To match the graphdriver's push behavior which only shows the progress
for layers.
Exclude indexes, manifests and image configs from the push progress.
Don't explicitly check for `IsLayerType` to also handle other
potentially big blobs (like buildkit attestations).

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-10-03 14:59:19 +02:00
Akihiro Suda
ad877271f3
Limit OOMScoreAdj when running in UserNS ("Rootful-in-Rootless")
Fix issue 46563 "Rootful-in-Rootless dind doesn't work since systemd v250 (due to oom score adj)"

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2023-09-29 21:50:08 +09:00
Djordje Lukic
7d30dafd69
Merge pull request #46543 from rumpl/c8d-fix-manifest-platform 2023-09-29 13:58:57 +02:00
Xinfeng Liu
3d70af4ee4 adjust stats sampling order
Signed-off-by: Xinfeng Liu <XinfengLiu@icloud.com>
2023-09-29 15:33:48 +08:00
Djordje Lukic
f66c000229 c8d: Fix getting the platform of a single-platform image
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-28 00:16:51 +02:00
Sebastiaan van Stijn
3197160114
daemon: Daemon.SetNetworkBootstrapKeys: make error-handling idiomatic
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-27 12:08:28 +02:00
Sebastiaan van Stijn
f91c3cfda6
daemon: Daemon.initNetworkController: remove intermediate var
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-27 12:08:28 +02:00
Xinfeng Liu
95aea39348 Make one-shot stats faster
This commit moves one-shot stats processing out of the publishing
channels, i.e. collect stats directly.

Also changes the method of getSystemCPUUsage() on Linux to return
number of online CPUs also.

Signed-off-by: Xinfeng Liu <XinfengLiu@icloud.com>
2023-09-27 14:10:23 +08:00
Drew Erny
42a51cb285 Add support for swarm seccomp and apparmor
And also no-new-privileges

Signed-off-by: Drew Erny <derny@mirantis.com>
2023-09-25 12:38:26 -05:00
Chiranjeevi Tirunagari
0c66111c40
daemon: containers list code refactor
Signed-off-by: Chiranjeevi Tirunagari <vchiranjeeviak.tirunagari@gmail.com>
2023-09-25 10:28:31 +05:30
Sebastiaan van Stijn
3614749b55
Merge pull request #45966 from neersighted/buildkit_0.12
Update to BuildKit 0.12
2023-09-22 02:13:15 +02:00
Bjorn Neergaard
2246297ae6
builder-next: adopt new wrapped types
With BuildKit 0.12, some existing types are now required to be wrapped
by new types:

* containerd's LeaseManager and ContentStore have to be a
  (namespace-aware) BuildKit type since f044e0a946
* BuildKit's solver.CacheManager is used instead of
  bboltstorage.CacheKeyStorage since 2b30693409
* The MaxAge config field is a bkconfig.Duration since e06c96274f

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-09-21 14:18:48 -06:00
Bjorn Neergaard
8cd5f04ea3
daemon/c8d: use new containerd LabelDistributionSource constant
Introduced in dd3eedf3c3

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-09-21 14:18:42 -06:00
Bjorn Neergaard
fd6dd6935b
vendor: github.com/containerd/containerd v1.7.6
The DeepEqual ignore required in the daemon tests is a bit ugly, but it
works given the new protoc output.

We also have to ignore lints related to schema1 deprecations; these do
not apply as we must continue to support this schema version.

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-09-21 14:18:40 -06:00
Bjorn Neergaard
0e80073e01
daemon: strongly type containerd log.OutputFormat
This type was introduced in
0a79e67e4f

Make use of it throughout our log-format handling code, and convert back
to a string before we pass it to the containerd client.

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-09-21 05:40:17 -06:00
Sebastiaan van Stijn
4dbfe7e17e
Merge pull request #46502 from rumpl/c8d-fix-diff
c8d: Fix `docker diff`
2023-09-20 21:16:08 +02:00
Djordje Lukic
7444b88f5d
Merge pull request #46495 from rumpl/c8d-fix-create-platform 2023-09-20 16:39:38 +02:00
Djordje Lukic
207c4d537c c8d: Fix docker diff
Diffing a container yielded some extra changes that come from the
files/directories that we mount inside the container (/etc/resolv.conf
for example). To avoid that we create an intermediate snapshot that has
these files, with this we can now diff the container fs with its parent
and only get the differences that were made inside the container.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-20 14:16:22 +02:00
Paweł Gronowski
601c9b29e6
c8d/pull: Fix stale Downloading progress
Final progress messages were sent after the progress updater finished
which made the "Downloading" progress not being updated into "Download
complete".

Fix by sending the final messages after the progress has finished.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-20 14:10:58 +02:00
Sebastiaan van Stijn
34dc2f10b4
Merge pull request #46479 from vvoland/pull-check-reserved-name-in-api
api/pull: Move reference parsing from imageService, validate repo
2023-09-19 17:17:31 +02:00
Sebastiaan van Stijn
54d84229ce
Merge pull request #46511 from rumpl/c8d-system-df-image-containers
c8d: Number of containers using an image
2023-09-19 17:08:01 +02:00
Paweł Gronowski
3ff75aeb07
c8d/pull: Deprecation notice for schema1 manifests
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-19 15:46:42 +02:00
Djordje Lukic
39fe25b69e
c8d: Fix getting image with platform
We weren't checking for the asked platform in the case the image was a
manifest, only if it was a manifest list.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-19 13:54:24 +02:00
Paweł Gronowski
68b67b3230
c8d/pull: Support legacy schema1 prettyjws manifests
Makes it possible to pull `application/vnd.docker.distribution.manifest.v1+prettyjws`
legacy manifests.

They are not stored in their original form but are converted to the OCI
manifests.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-19 13:17:12 +02:00
Sebastiaan van Stijn
f13065b1f7
Merge pull request #46183 from akerouanton/validate-NetworkingConfig
daemon: Improve NetworkingConfig & EndpointSettings validation
2023-09-18 22:09:29 +02:00
Djordje Lukic
2394b07bce
c8d: Number of containers using an image
Return the number of containers that use an image if it was asked,
during a `docker system df` call for example.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-18 19:36:49 +02:00
Albin Kerouanton
3092b261e2
daemon: move most of validateEndpointSettings into api/t/net
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-09-18 18:26:56 +02:00
Albin Kerouanton
19c07198b6
daemon: Check if endpoint address is in allowed range
This issue wasn't caught on ContainerCreate or NetworkConnect (when
container wasn't started yet).

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-09-18 17:28:07 +02:00
Albin Kerouanton
bfd8c6deb7
daemon: Validate EndpointSettings.IPAMConfig.LinkLocalIPs
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-09-18 17:28:07 +02:00
Albin Kerouanton
4bd0553274
daemon: Return all validation errors for NetworkingConfig and EndpointSettings
Thus far, validation code would stop as soon as a bad value was found.
Now, we try to validate as much as we can, to return all errors to the
API client.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-09-18 17:25:06 +02:00
Albin Kerouanton
ff503882f7
daemon: Improve NetworkingConfig & EndpointSettings validation
So far, only a subset of NetworkingConfig was validated when calling
ContainerCreate. Other parameters would be validated when the container
was started. And the same goes for EndpointSettings on NetworkConnect.

This commit adds two validation steps:

1. Check if the IP addresses set in endpoint's IPAMConfig are valid,
   when ContainerCreate and ConnectToNetwork is called ;
2. Check if the network allows static IP addresses, only on
   ConnectToNetwork as we need the libnetwork's Network for that and it
   might not exist until NetworkAttachment requests are sent to the
   Swarm leader (which happens only when starting the container) ;

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-09-18 17:21:06 +02:00
Paweł Gronowski
ccb37fa567
imageService/PullImage: Move reference parse to api
Make `PullImage` accept `reference.Named` directly instead of
duplicating the parsing code for both graphdriver and containerd image
service implementations.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-18 15:23:12 +02:00
Djordje Lukic
32e2c53467
c8d: Fix pull progress update
We were sending the "Pulling from ..." message too early, if the pull
progress wasn't able to resolve the image we wouldn't sent the error
back. Sending that first message would have flushed the output stream
and image_routes.go would return a nil error.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-16 13:07:13 +02:00
Sebastiaan van Stijn
bd523abd44
remove more direct uses of logrus
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-15 20:12:27 +02:00
Sebastiaan van Stijn
a07f6470b7
Merge pull request #46488 from thaJeztah/bump_containerd_1.6.24
vendor: github.com/containerd/containerd v1.6.24
2023-09-15 20:11:53 +02:00
Paweł Gronowski
a33043f0e0
Merge pull request #46485 from vvoland/c8d-push-all-tags
c8d/push: Support pushing all tags
2023-09-15 17:38:05 +02:00
Sebastiaan van Stijn
1ffbbe798a
vendor: github.com/containerd/containerd v1.6.24
full diff: https://github.com/containerd/containerd/compare/v1.6.22...v1.6.24

v1.6.24 release notes:

full diff: https://github.com/containerd/containerd/compare/v1.6.23...v1.6.24

The twenty-fourth patch release for containerd 1.6 contains various fixes
and updates.

Notable Updates

- CRI: fix leaked shim caused by high IO pressure
- Update to go1.20.8
- Update runc to v1.1.9
- Backport: add configurable mount options to overlay snapshotter
- log: cleanups and improvements to decouple more from logrus

v1.6.23 release notes:

full diff: https://github.com/containerd/containerd/compare/v1.6.22...v1.6.23

The twenty-third patch release for containerd 1.6 contains various fixes
and updates.

Notable Updates

- Add stable ABI support in windows platform matcher + update hcsshim tag
- cri: Don't use rel path for image volumes
- Upgrade GitHub actions packages in release workflow
- update to go1.19.12
- backport: ro option for userxattr mount check + cherry-pick: Fix ro mount option being passed

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-15 17:34:58 +02:00
Paweł Gronowski
7f281907dd
c8d/push: Add missing message about repository
Add "The push referers to repository X" message which is present in the
push output when using the graphdrivers.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-15 16:27:45 +02:00
Paweł Gronowski
babf907bfd
c8d/push: Support pushing all tags
Implement missing feature that pushes all tags from the provided local
repository.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-15 16:27:43 +02:00
Albin Kerouanton
7ec9f304e9
daemon/cluster: create managed ctr with multiple EndpointsConfig
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-09-15 14:30:03 +02:00
Albin Kerouanton
bbcd662532
api: Allow ContainerCreate to take several EndpointsConfig for >= 1.44
The API endpoint `/containers/create` accepts several EndpointsConfig
since v1.22 but the daemon would error out in such case. This check is
moved from the daemon to the api and is now applied only for API < 1.44,
effectively allowing the daemon to create containers connected to
several networks.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-09-15 10:07:29 +02:00
Sebastiaan van Stijn
20f9635469
Merge pull request #46475 from dmcgowan/c8d-registry-token-support
Add support for registry token in containerd pull logic
2023-09-14 17:18:07 +02:00
Derek McGowan
62e55fd58a
Add support for registry token in containerd pull logic
When registry token is provided, the authorization header can be
directly applied to the registry request. No other type of
authorization will be attempted when the registry token is provided.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-09-14 06:35:23 -07:00
Sebastiaan van Stijn
01cc1cc923
Merge pull request #46471 from foundriesio/atomic-layer-data-write
daemon: overlay2: Write layer metadata atomically
2023-09-14 12:10:17 +02:00
Sebastiaan van Stijn
39b2bf51ca
Merge pull request #46406 from akerouanton/issue-46404
daemon: fix under what conditions container's mac-address is applied
2023-09-13 23:35:07 +02:00
Mike Sul
de2447c2ab
daemon: overlay2: Write layer metadata atomically
When the daemon process or the host running it is abruptly terminated,
the layer metadata file can become inconsistent on the file system.
Specifically, `link` and `lower` files may exist but be empty, leading
to overlay mounting errors during layer extraction, such as:
"failed to register layer: error creating overlay mount to <path>:
too many levels of symbolic links."

This commit introduces the use of `AtomicWriteFile` to ensure that the
layer metadata files contain correct data when they exist on the file system.

Signed-off-by: Mike <mike.sul@foundries.io>
2023-09-13 15:07:32 +02:00
Albin Kerouanton
78479b1915
libnet: Make sure network names are unique
Fixes #18864, #20648, #33561, #40901.

[This GH comment][1] makes clear network name uniqueness has never been
enforced due to the eventually consistent nature of Classic Swarm
datastores:

> there is no guaranteed way to check for duplicates across a cluster of
> docker hosts.

And this is further confirmed by other comments made by @mrjana in that
same issue, eg. [this one][2]:

> we want to adopt a schema which can pave the way in the future for a
> completely decentralized cluster of docker hosts (if scalability is
> needed).

This decentralized model is what Classic Swarm was trying to be. It's
been superseded since then by Docker Swarm, which has a centralized
control plane.

To circumvent this drawback, the `NetworkCreate` endpoint accepts a
`CheckDuplicate` flag. However it's not perfectly reliable as it won't
catch concurrent requests.

Due to this design decision, API clients like Compose have to implement
workarounds to make sure names are really unique (eg.
docker/compose#9585). And the daemon itself has seen a string of issues
due to that decision, including some that aren't fixed to this day (for
instance moby/moby#40901):

> The problem is, that if you specify a network for a container using
> the ID, it will add that network to the container but it will then
> change it to reference the network by using the name.

To summarize, this "feature" is broken, has no practical use and is a
source of pain for Docker users and API consumers. So let's just remove
it for _all_ API versions.

[1]: https://github.com/moby/moby/issues/18864#issuecomment-167201414
[2]: https://github.com/moby/moby/issues/18864#issuecomment-167202589

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-09-12 10:40:13 +02:00
Sebastiaan van Stijn
4f28802f09
Merge pull request #46413 from thaJeztah/builder_diffid_type
daemon/containerd: use "DiffID" type for diff fields
2023-09-12 10:08:46 +02:00
Sebastiaan van Stijn
fd15ddbc30
daemon: GetImageAndReleasableLayer: simplify "FROM scratch" case
Windows doesn't support "FROM scratch", and the platform was only used
for validation on other platforms if a platform was provided, so no need
to set defaults.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-11 23:18:13 +02:00
Sebastiaan van Stijn
4229032676
daemon/containerd: use "DiffID" type for diff fields
strong-type the fields with the expected type, to make it more explicit
what we're expecting here.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-11 23:15:04 +02:00
Sebastiaan van Stijn
cdb5947316
Merge pull request #46455 from akerouanton/enable-ipv6-automatically
daemon: automatically set network EnableIPv6 if needed
2023-09-11 22:18:22 +02:00
Albin Kerouanton
5d5eeac310
daemon: automatically set network EnableIPv6 if needed
PR 4f47013feb added a validation step to `NetworkCreate` to ensure
no IPv6 subnet could be set on a network if its `EnableIPv6` parameter
is false.

Before that, the daemon was accepting such request but was doing nothing
with the IPv6 subnet.

This validation step is now deleted, and we automatically set
`EnableIPv6` if an IPv6 subnet was specified.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-09-11 20:53:29 +02:00
Sebastiaan van Stijn
51d647122a
Merge pull request #46383 from vvoland/c8d-legacybuilder-fix-layer-parent-snapshot
c8d/legacybuilder: Assorted fixes
2023-09-11 20:41:59 +02:00
Djordje Lukic
d0d3ddd045
Merge pull request #46375 from rumpl/c8d-userns-remap
c8d: Handle userns properly
2023-09-11 19:04:35 +02:00
Djordje Lukic
0313544f4a
c8d: Handle userns properly
If the daemon is run with --userns-remap we need to chown the prepared
snapshot

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-11 16:39:29 +02:00
Paweł Gronowski
c63a952dc9
c8d/builder: Don't append empty tar layer to manifest
To match the number of layers in config created in
`images.CreateChildImage`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-11 16:22:44 +02:00
Paweł Gronowski
9127285985
c8d/builder: Lease layer snapshots
Create a lease for the snapshot and hold it until the layer is released.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-11 16:22:39 +02:00
Paweł Gronowski
f22b112005
c8d/commit: Unpack committed image
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-11 16:20:14 +02:00
Paweł Gronowski
8832cdf6e1
c8d: Common unpack code for specific manifest
Use `ImageService.unpackImage` when we want to unpack an image and we
know the exact platform-manifest to be unpacked beforehand.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-11 16:20:10 +02:00
Paweł Gronowski
c6bded3475
c8d/builder: Don't use diffID as snapshot parent
DiffID is only a digest of the one tar layer and matches the snapshot ID
only for the first layer (DiffID = ChainID).

Instead of generating random ID as a key for rolayer, just use the
snapshot ID of the unpacked image content and use it later as a parent
for creating a new RWLayer.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-11 16:20:04 +02:00
Paweł Gronowski
8c7e19c5ff
c8d/builder: Set empty diffID for rolayer
diffID is the digest of a tar archive containing changes to the parent
layer - rolayer doesn't have any changes to the parent.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-11 16:20:02 +02:00
Paweł Gronowski
6ebfa57364
c8d/builder: Don't mount the rolayer snapshot
The view snapshot and its mounts are not used.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-11 16:19:59 +02:00
Sebastiaan van Stijn
ccae064209
Merge pull request #46423 from vvoland/c8d-images-all
c8d/builder: Store parent in c8d image label
2023-09-11 14:51:20 +02:00
Djordje Lukic
833b514d98
c8d/mount: Create same directory owners as graphdrivers
Graph drivers create the parent directory with
rootPair().GID:CurrentIdentity().UID owner. This change brings these in
line

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-11 13:24:42 +02:00
Albin Kerouanton
a8975c9042
api: Add consts for predefined networks
Constants for both platform-specific and platform-independent networks
are added to the api/network package.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-09-10 15:39:54 +02:00
Sebastiaan van Stijn
c3ab3f1dde
Merge pull request #46412 from rumpl/c8d-pull-progress
c8d: Better pull progress
2023-09-08 23:10:23 +02:00
Albin Kerouanton
6cc6682f5f
daemon: fix under what conditions container's mac-address is applied
The daemon would pass an EndpointCreateOption to set the interface MAC
address if the network name and the provided network mode were matching.
Obviously, if the network mode is a network ID, it won't work. To make
things worse, the network mode is never normalized if it's a partial ID.

To fix that: 1. the condition under what the container's mac-address is
applied is updated to also match the full ID; 2. the network mode is
normalized to a full ID when it's only a partial one.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-09-08 18:15:00 +02:00
Sebastiaan van Stijn
0434b653c8
Merge pull request #46435 from vvoland/c8d-inspect-prefix
c8d/image: Allow truncated id to have sha256: prefix
2023-09-08 15:59:24 +02:00
Paweł Gronowski
5728516371
c8d/image: Allow truncated id to have sha256: prefix
Fixes TestInspectByPrefix when running with c8d snapshotters enabled.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-08 14:10:10 +02:00
Djordje Lukic
9e797a6db9
c8d: Remove the panic from UpdateConfig
We don't really want the daemon to panic for this so let's log a warning
about max downloads and uploads

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-08 12:21:16 +02:00
Paweł Gronowski
081b74b97d
c8d/builder: Store parent in c8d image label
Images built by classic builder will have an additional label (in the
containerd image object, not image config) pointing to a parent of that
image.

This allows to differentiate intermediate images (dangling
images created as a result of a each Dockerfile instruction) from the
final images.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-08 09:47:53 +02:00
Sebastiaan van Stijn
06499c52e2
Merge pull request #46416 from thaJeztah/move_IsOSSupported
pkg/system: deprecate IsOSSupported() and ErrNotSupportedOperatingSystem, and implement image.CheckOS
2023-09-08 00:25:36 +02:00
Bjorn Neergaard
ce4e325504
Merge pull request #45652 from cpuguy83/otel
Add otel tracing
2023-09-07 15:42:08 -06:00
Sebastiaan van Stijn
a3c97beee0
image: implement CheckOS, deprecate pkg/system IsOSSupported
Implement a function that returns an error to replace existing uses of
the IsOSSupported utility, where callers had to produce the error after
checking.

The IsOSSupported function was used in combination with images, so implementing
a utility in "image" to prevent having to import pkg/system (which contains many
unrelated functions)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-07 22:14:44 +02:00
Brian Goff
642e9917ff Add otel support
This uses otel standard environment variables to configure tracing in
the daemon.
It also adds support for propagating trace contexts in the client and
reading those from the API server.

See
https://opentelemetry.io/docs/specs/otel/configuration/sdk-environment-variables/
for details on otel environment variables.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2023-09-07 18:38:19 +00:00
Djordje Lukic
776c376227
c8d: Better pull progress
- check if we have to download layers and print the approriate message
- show the digest of the pulled manifest(list)
- skip pulling if we already have the right manifest

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-07 15:34:20 +02:00
Paweł Gronowski
1cb45e582c
c8d/import: Don't close compressed stream twice
The compressor is already closed a few lines below and there's no error
returns between so the defer is not needed.

Calling Close twice on a writerCloserWrapper is unsafe as it causes it
to put the same buffer to the pool multiple times.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-09-07 10:33:25 +02:00
Sebastiaan van Stijn
150b1c8c73
daemon: daemon.createSpec: remove uses of logrus
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-06 13:30:33 +02:00
Djordje Lukic
dbb4d54e01
c8d: Add image save events
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-05 17:29:15 +02:00
Djordje Lukic
09470db089
c8d: Add image pull events
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-05 17:29:13 +02:00
Djordje Lukic
1847dc4b7f
c8d: Add image push events
Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-05 17:28:57 +02:00
Sebastiaan van Stijn
1148a24e64
migrate to new github.com/distribution/reference module
The "reference" package was moved to a separate module, which was extracted
from b9b19409cf

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-09-05 12:09:26 +02:00
Sebastiaan van Stijn
9c4e82435e
Merge pull request #46351 from thaJeztah/api_events_actions_enum
api/types/events: define "Action" type and consts
2023-09-05 11:11:42 +02:00
Djordje Lukic
96516002cc
c8d: Print the tag, digest and size after push
After a push is completed we must return this information back to the
caller.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-09-04 13:43:19 +02:00
Paweł Gronowski
0ffa3dd870
daemon/c8d: Use Docker imagespec
This makes the c8d code which creates/reads OCI types not lose
Docker-specific features like ONBUILD or Healthcheck.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-08-31 17:15:05 +02:00
Sebastiaan van Stijn
b9f9e20f01
daemon: Daemon.killWithSignal(): don't discard snapshotting errors
While there's not much we can do if we failed to store a snapshot of the
container's state, let's log the error in case it happens in stad of discarding.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-29 23:11:06 +02:00
Sebastiaan van Stijn
af535233cc
daemon: Daemon.killWithSignal(): don't discard handleContainerExit error
Daemon.handleContainerExit() returns an error if snapshotting the container's
state to disk fails. There's not much we can do with the error if it occurs,
but let's log the error if that happens, instead of discarding it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-29 23:11:06 +02:00
Sebastiaan van Stijn
e10eca3d1a
daemon/containerd: rename some vars that collided with imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-29 12:54:36 +02:00
Sebastiaan van Stijn
aefbd49038
daemon/containerd: newROLayerForImage: remove unused args
Also rename variables that collided with imports.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-29 12:54:19 +02:00
Sebastiaan van Stijn
28d201feb7
daemon/containerd: log errors when releasing leases
Log a warning if we encounter an error when releasing leases. While it
may not have direct consequences, failing to release the lease should be
unexpected, so let's make them visible.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-29 12:54:14 +02:00
Sebastiaan van Stijn
0f871f8cb7
api/types/events: define "Action" type and consts
Define consts for the Actions we use for events, instead of "ad-hoc" strings.
Having these consts makes it easier to find where specific events are triggered,
makes the events less error-prone, and allows documenting each Action (if needed).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-29 00:38:08 +02:00
Sebastiaan van Stijn
10a3a3bc49
daemon: inline some variables when emitting events
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-29 00:38:08 +02:00
Sebastiaan van Stijn
9331d6de1e
daemon/events; fix TestLoadBufferedEventsOnlyFromPast
commit 70ad5b818f changed event.Type
to be a strong type, no longer an alias for string. for some reason,
this test passed on the PR, but failed later on;

    === Failed
    === FAIL: daemon/events TestLoadBufferedEventsOnlyFromPast (0.00s)
        events_test.go:203: assertion failed: network (messages[0].Type events.Type) != network (string)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-28 22:11:00 +02:00
Sebastiaan van Stijn
a65c948e7e
Merge pull request #46335 from thaJeztah/api_move_checkpoint_types
api/types: move checkpoint-types to api/types/checkpoint
2023-08-28 19:02:19 +02:00
Sebastiaan van Stijn
8309206160
Merge pull request #46350 from thaJeztah/strongtype_eventstype
api/types/events: make events.Type an actual type
2023-08-28 16:44:26 +02:00
Sebastiaan van Stijn
5123ae4352
daemon: TestLogContainerEventCopyLabels: inline vars
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-28 13:17:01 +02:00
Sebastiaan van Stijn
2928c5ae92
daemon: TestHealthStates: don't depend on deprecated fields
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-28 13:17:00 +02:00
Sebastiaan van Stijn
62ec14d9ec
daemon/events: verify non-deprecated fields
Some tests were testing the deprecated fields, instead of their non-deprecated
alternatives.

This patch adds a utility to verify that they match, and rewrites the tests
to check the non-deprecated fields instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-28 13:17:00 +02:00
Sebastiaan van Stijn
f443006fa2
daemon/events: rewrite test-assertions with gotest.tools
- clean up "//import" comment, as test-files cannot be imported, and only
  one "//import" comment is needed per package.
- remove some intermediate variables
- rewrite assertions to use gotest.tools
- use assert.Check()) (non-fatal) where possible

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-28 13:16:57 +02:00
Sebastiaan van Stijn
70ad5b818f
api/types/events: make events.Type an actual type
This type was added in 247f4796d2, and
at the time was added as an alias for string;

> api/types/events: add "Type" type for event-type enum
>
> Currently just an alias for string, but we can change it to be an
> actual type.

Now that all code uses the defined types, we should be able to make
this an actual type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-28 13:12:38 +02:00
Sebastiaan van Stijn
8569e8684f
Merge pull request #46338 from thaJeztah/daemon_events_cleanup
daemon: clean up event handling-code, and remove some dead code
2023-08-28 13:12:10 +02:00
Sebastiaan van Stijn
9ea50365d6
daemon/events: use events-consts in tests, and fix vars that collided
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-27 22:23:29 +02:00
Sebastiaan van Stijn
ebe2347ac6
daemon: remove LogPluginEventWithAttributes as it's not used
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-26 22:04:43 +02:00
Sebastiaan van Stijn
aa764e6009
daemon: logNetworkEvent, logSecretEvent, logConfigEvent rm unused args
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-26 22:04:43 +02:00
Sebastiaan van Stijn
a3867992b7
daemon: rename max/min as it collides with go1.21 builtin
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-26 22:02:21 +02:00
Sebastiaan van Stijn
8f64e2e925
daemon: daemon.logClusterEvent: use events.Type for event-types
Also swapping the order of arguments; putting the "attributes" arguments
last, so that variables can be more cleanly inlined.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-26 19:20:42 +02:00
Sebastiaan van Stijn
3dea2f230a
daemon: inline some vars when producing events
Also moves the clusterEventAction closer to where it's used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-26 17:45:21 +02:00
Sebastiaan van Stijn
b688af2226
api/types: move checkpoint-types to api/types/checkpoint
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-26 12:37:41 +02:00
Sebastiaan van Stijn
cd49f9affd
update golangci-lint to v1.54.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-25 02:19:35 +02:00
Sebastiaan van Stijn
6d5204b63e
Merge pull request #46316 from thaJeztah/rm_more_buildtags
remove some remaining pre-go1.17 build-tags
2023-08-25 01:06:39 +02:00
Sebastiaan van Stijn
f10e182ca7
Merge pull request #46317 from thaJeztah/gofumpt_all_the_things
Format code with gofumpt
2023-08-25 01:06:05 +02:00
Sebastiaan van Stijn
ce01d779df
daemon: format code with gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-24 17:59:22 +02:00
Sebastiaan van Stijn
498da44aab
remove some remaining pre-go1.17 build-tags
commit ab35df454d removed most of the pre-go1.17
build-tags, but for some reason, "go fix" doesn't remove these, so removing
the remaining ones manually

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-24 17:51:07 +02:00
Sebastiaan van Stijn
04422f5ec1
daemon: WithNamespaces(): add notes about user-namespaces
While working on this code, I noticed that there's currently an issue
with userns enabled. When userns is enabled, joining another container's
namespace must also join its user-namespace.

However, a container can only be in a single user namespace, so if a
container joins namespaces from multiple containers, latter user-namespaces
overwrite former ones.

We must add validation for this, but in the meantime, add notes / todo's.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-24 16:21:26 +02:00
Sebastiaan van Stijn
dd26e6b15e
daemon: Daemon.getIpcContainer: make errors less repetitive
- Most error-message returned would already include "container" and the
  container ID in the error-message (e.g. "container %s is not running"),
  so there's no need to add a custom prefix for that.
- os.Stat returns a PathError, which already includes the operation ("stat"),
  the path, and the underlying error that occurred.

And while updating, let's also fix the name to be proper camelCase :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-24 16:20:42 +02:00
Sebastiaan van Stijn
3d94eb9bcd
daemon: Daemon.getPidContainer: change to accept "id" argument
This function didn't need the whole container, only its ID, so let's
use that as argument. This also makes it consistent with getIpcContainer.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-24 16:20:42 +02:00
Sebastiaan van Stijn
bc7f341f29
daemon: WithNamespaces(): fix incorrect error for PID, IPC namespace
`Daemon.getPidContainer()` was wrapping the error-message with a message
("cannot join PID of a non running container") that did not reflect the
actual reason for the error; `Daemon.GetContainer()` could either return
an invalid parameter (invalid / empty identifier), or a "not found" error
if the specified container-ID could not be found.

In the latter case, we don't want to return a "not found" error through
the API, as this would indicate that the container we're _starting_ was
not found (which is not the case), so we need to convert the error into
an `errdefs.ErrInvalidParameter` (the container-ID specified for the PID
namespace is invalid if the container doesn't exist).

This logic is similar to what we do for IPC namespaces. which received
a similar fix in c3d7a0c603.

This patch updates the error-types, and moves them into the getIpcContainer
and getPidContainer container functions, both of which should return
an "invalid parameter" if the container was not found.

It's worth noting that, while `WithNamespaces()` may return an "invalid
parameter" error, the `start` endpoint itself may _not_ be. as outlined
in commit bf1fb97575, starting a container
that has an invalid configuration should be considered an internal server
error, and is not an invalid _request_. However, for uses other than
container "start", `WithNamespaces()` should return the correct error
to allow code to handle it accordingly.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-24 16:19:07 +02:00
Sebastiaan van Stijn
bd5d6480e7
daemon: WithNamespaces(): remove redundant "if"
This check was originally used to only validate the mode if it was set to
a non-empty value (see commit 072400fc4b), but
validation was made unconditional in c3d7a0c603.

Given that a `CgroupnsMode` can't be both [`CgroupnsMode.IsEmpty()`][1]
and [`CgroupnsMode.IsPrivate`][2], we can remove the extra check.

[1]: e0da5cb929/api/types/container/hostconfig.go (L33-L36)
[2]: e0da5cb929/api/types/container/hostconfig.go (L23-L26)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-24 16:12:22 +02:00
Sebastiaan van Stijn
6eaefe5bf5
daemon: WithNamespaces(): use switch instead of if/else if/else
We were using a mixture of approaches for these; aligning them a bit
to all use switch statements.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-24 16:12:22 +02:00
Sebastiaan van Stijn
43aa67a982
daemon: WithNamespaces(): use OCI-spec consts for namespaces
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-24 16:12:21 +02:00
Sebastiaan van Stijn
759698581e
daemon: WithNamespaces(): inline variables
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-24 16:12:21 +02:00
Sebastiaan van Stijn
13648a0e21
daemon: remove Daemon.checkContainer and related utils
This was added in 12485d62ee to save some
duplication, but was really over-engineered to save a few lines of code,
at the cost of hiding away what it does and also potentially returning
inconsistent errors (not addressed in this patch). Let's start with
inlining these.

This removes;

- Daemon.checkContainer
- daemon.containerIsRunning
- daemon.containerIsNotRestarting

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-08-24 16:12:18 +02:00
Sebastiaan van Stijn
64f5d9b119
Merge pull request #46213 from thaJeztah/daemon_remove_errors
daemon: cleanupContainer: don't fail if container is already stopped
2023-08-24 13:34:43 +02:00