Commit Graph

1075 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
42d149e45d fix duplicate import, and force consistent alias for bolt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-22 11:31:10 +02:00
Sebastiaan van Stijn
7c52c4d92e update go:build tags to go1.23 to align with vendor.mod
Go maintainers started to unconditionally update the minimum go version
for golang.org/x/ dependencies to go1.23, which means that we'll no longer
be able to support any version below that when updating those dependencies;

> all: upgrade go directive to at least 1.23.0 [generated]
>
> By now Go 1.24.0 has been released, and Go 1.22 is no longer supported
> per the Go Release Policy (https://go.dev/doc/devel/release#policy).
>
> For golang/go#69095.

This updates our minimum version to go1.23, as we won't be able to maintain
compatibility with older versions because of the above.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-04-17 15:43:19 +02:00
Derek McGowan
d0154d3e59 Update to use github.com/moby/go-archive
Update use of idtools to moby/user for archive and other deprecated uses

Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-08 17:35:05 -07:00
Derek McGowan
3fc36bcac4 Update daemon to use moby sys/user identity mapping
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-04-04 08:24:09 -07:00
Paweł Gronowski
82ec984d10 daemon: Update to any from interface{}
Only files that have go build version enforcing tag

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-25 13:38:28 +01:00
Sebastiaan van Stijn
b2363f0363 Merge pull request #49602 from thaJeztah/remove_layerstore_experimental
layer: remove StoreOptions.ExperimentalEnabled
2025-03-18 14:23:21 +01:00
Sebastiaan van Stijn
ca00f9eacf Merge pull request #49603 from vvoland/daemon-containerd-timeout
daemon: Fix giving up too early while connecting to containerd socket
2025-03-11 22:42:29 +01:00
Sebastiaan van Stijn
42ca9154e9 layer: remove StoreOptions.ExperimentalEnabled
I noticed that the only reason we kept this was so that we could produce
a more targeted error for the deprecated storage-driver plugins, but it's
very unlikely someone used those, and if they did, we already had the
"DOCKERD_DEPRECATED_GRAPHDRIVER_PLUGINS" added as requirement. Let's
just produce an error if that option is set (and remove that altogether in
a later release, but just that check doesn't add significant complexity).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-07 22:39:55 +01:00
Paweł Gronowski
df519e9e1a daemon: Fix giving up too early while connecting to containerd socket
Explicitly set the gRPC connection params to take the timeout into
account to workaround the containerd v2 client not passing down the
stack.

containerd v2 replaced usages of deprecated gRPC functions but didn't
pass the timeout to the actual dial connection options.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-07 19:03:40 +01:00
Sebastiaan van Stijn
d34e1ff826 layer: remove StoreOptions.MetadataStorePathTemplate
This field was added to allow templating the storage-location of the storage
driver as part of a refactor in f5916b10ae.

In practice, the template is never customized, and always set to;
`/<data-root>/image/<driver-name>/layerdb`, where `<driver-name>` is
passed in by the driver.

This patch removes the field and its uses.

- 00ab386b5a/daemon/daemon.go (L1074-L1075)
- 00ab386b5a/integration/image/remove_unix_test.go (L50-L51)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-07 00:50:02 +01:00
Sebastiaan van Stijn
387ec71630 daemon: fix naked returns
daemon/daemon.go:1570:2: naked return in func `RemapContainerdNamespaces` with 21 lines of code (nakedret)
        return
        ^
    daemon/daemon_linux.go:128:2: naked return in func `getCleanPatterns` with 14 lines of code (nakedret)
        return
        ^
    daemon/logs.go:180:2: naked return in func `getLogger` with 11 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:14 +01:00
Sebastiaan van Stijn
9c7112d118 daemon: configureMaxThreads: remove unused arg
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-07 02:24:31 +01:00
Sebastiaan van Stijn
52ea449c55 daemon: Daemon.restore: make legacy-link code conditional
Make it more clear that this loop is for legacy-links, and the timer is
only needed for that purpose.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-30 14:23:10 +01:00
Sebastiaan van Stijn
9a69161992 daemon: remove Daemon.children(), Daemon.parents() wrappers
Remove the wrappers to make it more explicit that these are related to
the legacy links feature.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-30 14:23:10 +01:00
Sebastiaan van Stijn
131441b37f daemon: NewDaemon: align max backoff delay with containerd 2.0
containerd 1.7 and lower set this value to a fixed, 3-second delay;
https://github.com/containerd/containerd/blob/v1.7.22/client.go#L117-L121

containerd 2.0 (starting with [containerd@63b4688]) aligned this value
with clientopts.timeout (WithTimeout()), which we set to 60 seconds;
https://github.com/containerd/containerd/blob/v2.0.2/client/client.go#L129-L136

This patch aligns our code with containerd client's defaults.

[containerd@63b4688]: 63b4688175

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 12:17:46 +01:00
Sebastiaan van Stijn
21870ad796 daemon: NewDaemon: update grpc options for containerd 2.0
Now that we moved to use containerd 2.0, the changes from
63b4688175
can now be used, removing some of gRPC's deprecated
options.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-17 23:17:50 +01:00
Sebastiaan van Stijn
b750eb87cd daemon: NewDaemon: remove grpc options that are the default
The default message size is set unconditionally in containerd's client,
so unlike Dial-options, there's no risk of implicitly dropping these
options.

TThis patch removes the options, as they were the same as the default
already set in containerd itself.

https://github.com/containerd/containerd/blob/v1.7.22/client.go#L133-L138

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-17 22:54:19 +01:00
Sebastiaan van Stijn
e94114305e daemon: NewDaemon: align grpc options with containerd's defaults
Dial-options passed to containerd _override_ all defaults that are set
in containerd, and containerd does not provide an option to provide
the defaults in other ways, which makes it slightly more complicated
to use the defaults combined with some custom options.
https://github.com/containerd/containerd/blob/v1.7.22/client.go#L122-L132

This patch aligns the options we set with the defaults in containerd.

grpc.FailOnNonTempDialError was added together with WithBlock in [containerd@64bc516],
but it looks like this was not copied to our options when the equivalent was
added in this repository through 9f73396dab.

grpc.WithReturnConnectionError was added in [containerd@73d28dd] to improve
handling of connection errors;

Permission errors:

    % ./bin/ctr t ls
    ctr: failed to dial "/run/containerd/containerd.sock": connection error: desc = "transport: error while dialing: dial unix /run/containerd/containerd.sock: connect: permission denied"
    %

Non-existent sockets:

    % ./bin/ctr -a notfound t ls
    ctr: failed to dial "notfound": context deadline exceeded: connection error: desc = "transport: error while dialing: dial unix://notfound: timeout"
    %

That commit failed to notice that WithReturnConnectionError implies WithBlock,
so removing that option from the list.

Note that both WithBlock and WithReturnConnectionError are deprecated in
newer versions of grpc, so we should remove these once [containerd@63b4688]
makes it into the containerd 1.7 branch (and vendored).

[containerd@64bc516]: 64bc516bbe
[containerd@73d28dd]: 73d28ddeb2
[containerd@63b4688]: 63b4688175

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-17 22:54:19 +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
Albin Kerouanton
49ec488036 logger/fluentd: remove deprecated fluentd-async-connect option
This option was marked as deprecated in cc1f3c750 (released in v20.10).
The option `fluentd-async`, introduced in the same commit, should be
used instead.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-01-13 18:43:32 +01:00
Paweł Gronowski
15d3c99ff6 daemon: Remove "Error: " error message prefix
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-09 17:31:22 +01:00
Paweł Gronowski
cd9c292de9 imageService: Unify Mount and Unmount
After implementing `RWLayer` for containerd image store, implementation
of these methods is identical for both stores.

Move the logic out of the image service into the daemon.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-09 17:31:21 +01:00
Paweł Gronowski
0cbb604665 c8d: Implement RWLayer and remove PrepareSnapshot
Implement containerd image store backed `RWLayer` and remove the
containerd-specific `PrepareSnapshot` method from the ImageService
interface.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-09 17:31:20 +01:00
Paweł Gronowski
bafebbbd8a container: Decouple RWLayer from graphdriver implementation
Introduce a separate `RWLayer` interface for the `container.RWLayer`
to remove coupling with the graphdriver implementation.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-09 17:31:15 +01:00
Paweł Gronowski
51c2689427 daemon/metrics: Move out to internal/metrics
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-07 14:13:06 +01:00
Sebastiaan van Stijn
b1af6ddb52 Merge pull request #49163 from thaJeztah/daemon_unhandled_errs
daemon: ignore some errors when setting env-vars
2025-01-02 16:30:39 +01:00
Sebastiaan van Stijn
e19e4de775 daemon: ignore some errors when setting env-vars
These are unlikely to ever fail, and were not handled, so
explicitly ignoring any error.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-21 14:43:28 +01:00
Sebastiaan van Stijn
c759fb20d6 daemon: remove uses of deprecated system.MkdirAll
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-21 14:39:43 +01:00
Sebastiaan van Stijn
c2c0046d11 remove logentries check and migration code
This code was added in 3b1d9f1a26 when the
logentries logging-driver was removed in v25.0.0. The logentries service
was already defunct, so unlikely to have any consumers, so let's remove
this code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-18 10:42:00 +01:00
Sebastiaan van Stijn
b453aa65fa update go:build tags to use go1.22
commit a0807e7cfe configured golangci-lint
to use go1.23 semantics, which alowed linters like `copyloopvar` to lint
using thee correct semantics.

go1.22 now creates a copy of variables when assigned in a loop; make sure we
don't have files that may downgrade semantics to go1.21 in case that also means
disabling that feature; https://go.dev/ref/spec#Go_1.22

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:09 +01:00
Rob Murray
788db583b1 Make buildSandboxOption a function instead of a Daemon method
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-05 10:00:10 +00:00
Paweł Gronowski
dc225798cb Merge pull request #47380 from dmcgowan/registry-http-fallback
Registry host configuration cleanup
2024-10-30 13:55:40 +00:00
Rob Murray
9be6e902b5 Restore 27.x path for libnet's Bolt database
In 27.x and earlier releases libnetwork's database file was in a
sub-directory "network/files" under the daemon's root data dir.

That part of the path got lost in commit ed08486ec7

So, libnet data ended up in the daemon's main Bolt db. Then, on
upgrade, config in the original file was no longer accessible.

libnet doesn't need access to any data outside its sub-dir, so
change the meaning of its OptionDataDir - it now points at libnet's
sub-dir, so the db will be created in the right place. Also, update
other uses of that data dir to match.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-29 17:31:21 +00:00
Derek McGowan
7c087c3267 Fork buildkit resolver logic to daemon package
This logic is going to be updated to use the new containerd resolver and
needs all the logic handling resolution in the package where it is used.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-10-22 07:50:59 -07:00
Sebastiaan van Stijn
5208e2954c daemon: deprecate Daemon.Register and make it internal
This function was only used internally in the daemon. This patch splits
the implementation to a non-exported version and deprecates the exported
one.

While at it, also pass through the context (which is used for tracing),
and added a note about the function potentially not being atomic.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-20 13:23:12 +02:00
Sebastiaan van Stijn
3cf90ca73f container: deprecate ErrNameReserved, ErrNameNotReserved
Use errdefs definitions instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-15 12:32:26 +02:00
Sebastiaan van Stijn
2e699872bc vendor: google.golang.org/grpc v1.66.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 02:39:19 +02: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
1ad5b5abb2 daemon: fix non-constant format string in call (govet)
daemon/daemon.go:942:21: printf: non-constant format string in call to (*github.com/docker/docker/vendor/github.com/sirupsen/logrus.Entry).Errorf (govet)
            log.G(ctx).Errorf(err.Error())
                              ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:41:58 +02:00
Sebastiaan van Stijn
7b0ef10a9a migrate to github.com/moby/sys/userns
Commit 2ce811e632 migrated the use of the
userns package to the github.com/moby/sys/user module.

After further discussion with maintainers, it was decided to move the
userns package to a separate module, as it has no direct relation with
"user" operations (other than having "user" in its name).

This patch migrates our code to use the new module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-08 10:52:33 +02:00
Sebastiaan van Stijn
c1b7972d02 Merge pull request #48210 from thaJeztah/remove_setMayDetachMounts
daemon: remove setMayDetachMounts (set may_detach_mounts=1 on startup)
2024-07-29 15:02:42 +02:00
Sebastiaan van Stijn
2ce811e632 migrate to github.com/moby/sys/user/userns
The userns package in libcontainer was integrated into the moby/sys/user
module at commit [3778ae603c706494fd1e2c2faf83b406e38d687d][1].

The userns package is used in many places, and currently either depends
on runc/libcontainer, or on containerd, both of which have a complex
dependency tree. This patch is part of a series of patches to unify the
implementations, and to migrate toward that implementation to simplify
the dependency tree.

[1]: 3778ae603c

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-25 12:47:34 +02:00
Sebastiaan van Stijn
6d0b508699 daemon: remove setMayDetachMounts (set may_detach_mounts=1 on startup)
This function was added in 83c2152de5 to
automatically set `/proc/sys/fs/may_detach_mounts=1` on startup.

This is a kernel config available in RHEL7.4 based kernels that enables
mountpoint removal where the mountpoint exists in other namespaces. This
setting is the default, and non-configurable, on upstream kernels since
3.15.

As this option was only supported in RHEL 7.x systems, which reached EOL,
we can remove this code, as it's not doing anything on current kernels.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-22 21:51:23 +02:00
Cory Snider
71a299ff6a daemon: switch to Go 1.19 atomics
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-05 19:05:15 -04: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
555dac5e14 daemon/graphdriver: remove support for external graphdriver plugins
This is a follow-up to 6da604aa6a, which
deprecated external graphdriver plugins.

This patch removes the functionality; some warnings / errors are kept in
place, but can be removed in a follow-up release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 14:25:14 +02:00
Sebastiaan van Stijn
5a4595466b Merge pull request #48008 from thaJeztah/deprecate_runconfig_DefaultDaemonNetworkMode
runconfig: deprecate DefaultDaemonNetworkMode, move to daemon/network
2024-06-18 14:13:07 +02:00
Rob Murray
74d77d8811 Revert "Internal resolver for default bridge network"
This reverts commit 18f4f775ed.

Because buildkit doesn't run an internal resolver, and it bases its
/etc/resolv.conf on the host's ... when buildkit is run in a container
that has 'nameserver 127.0.0.11', its build containers will use Google's
DNS servers as a fallback (unless the build container uses host
networking).

Before, when the 127.0.0.11 resolver was not used for the default network,
the buildkit container would have inherited a site-local nameserver. So,
the build containers it created would also have inherited that DNS
server - and they'd be able to resolve site-local hostnames.

By replacing the site-local nameserver with Google's, we broke access
to local DNS and its hostnames.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-17 20:19:20 +01:00
Sebastiaan van Stijn
8e91b64e07 runconfig: deprecate DefaultDaemonNetworkMode, move to daemon/network
This function returns the default network to use for the daemon platform;
moving this to a location separate from runconfig, which is planned to
be dismantled and moved to the API.

While it might be convenient to move this utility inside api/types/container,
we don't want to advertise this function too widely, as the default returned
can ONLY be considered correct when ran on the daemon-side. An alternative
would be to introduce an argument (daemonPlatform), which isn't very convenient
to use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 17:32:56 +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