Compare commits

...

2888 Commits

Author SHA1 Message Date
Paweł Gronowski
bea4de2500 Merge pull request #49656 from austinvazquez/bump-container-1.7.27-binary
Dockerfile: update containerd binary to v1.7.27
2025-03-18 18:44:02 +00:00
Paweł Gronowski
97ee08e1fa Merge pull request #49657 from akerouanton/fix-missing-port-mappings
daemon: return port-mappings from all endpoints
2025-03-18 18:43:32 +00:00
Albin Kerouanton
f2a183a991 daemon: return port-mappings from all endpoints
With improved IPv6 support, a dual-stack container can map a port using
two different networks -- one IPv4-only, the other IPv6-only.

The daemon was updating containers' `EndpointSettings.Ports` by looking
for the first network providing port-mappings. This was incorrect.

Instead, iterate over the whole list of endpoints, and merge everything
together.

The function doing that, ie. `getEndpointPortMapInfo`, is also
considered exposed ports, and nil the PortMap entry if an exposed port
is found. However, exposed ports are always set on a bridge network, so
this was erasing port-mappings found for other networks.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-03-18 18:08:39 +01:00
Albin Kerouanton
6b3b479192 daemon: getEndpointPortMapInfo: err is never used
Instead, log the error returned by `nat.NewPort` and move on to the
next port mapping / exposed port.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-03-18 18:08:20 +01:00
Austin Vazquez
35766af7d2 Dockerfile: update containerd binary to v1.7.27
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2025-03-18 15:07:33 +00: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
Albin Kerouanton
c9a763ecc9 daemon: remove redundant call to getEndpointPortMapInfo
The function `getEndpointPortMapInfo` is called by `updateJoinInfo` to
update the field `NetworkSettings.Ports` of a container.

However, `updateJoinInfo` is only called by `connectToNetwork` which is
also calling `getPortMapInfo` (which in turn calls
`getEndpointPortMapInfo`).

So, remove the call to `getEndpointPortMapInfo` from `updateJoinInfo`.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-03-18 12:43:37 +01:00
Sebastiaan van Stijn
2043aa92da Merge pull request #49652 from vvoland/vendor-containerd
vendor: github.com/containerd/containerd/v2 v2.0.4
2025-03-18 12:12:46 +01:00
Albin Kerouanton
7cdd1b5d15 Merge pull request #49649 from akerouanton/proxy-concurrent-write-close
cmd/docker-proxy: UDP: fix race & aggressive GC
2025-03-18 08:34:09 +01:00
Paweł Gronowski
fb3cce1988 vendor: github.com/containerd/containerd/v2 v2.0.4
full diff: https://github.com/containerd/containerd/v2/compare/v2.0.3...v2.0.4

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-17 19:05:57 +01:00
Albin Kerouanton
4276f330fc cmd/docker-proxy: do not eagerly GC one-sided UDP conns
The UDP proxy is setting a deadline of 90 seconds when reading from the
backend. If no data is received within this interval, it reclaims the
connection.

This means, the backend would see a different connection every 90
seconds if the backend never sends back any reply to a client.

This change prevents the proxy from eagerly GC'ing such connections by
taking into account the last time a datagram was proxyed to the backend.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-03-17 17:51:50 +01:00
Albin Kerouanton
0356854327 cmd/docker-proxy: make the conntrack timeout a property of UDPProxy
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-03-17 17:50:38 +01:00
Albin Kerouanton
d70fd32a18 cmd/docker-proxy: UDP: thread-safe Write and Close
The UDP proxy used by cmd/docker-proxy is executing Write and Close in
two separate goroutines, such that a Close could interrupt an in-flight
Write.

Introduce a `connTrackEntry` that wraps a `net.Conn` and a `sync.Mutex`
to ensure that Write and Close are serialized.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-03-17 17:50:38 +01:00
Paweł Gronowski
3e1b15dc97 Merge pull request #49618 from vvoland/container-wait-deflake
integration/container: Deflake TestWaitBlocked and TestWaitRestartedContainer
2025-03-14 13:32:05 +00:00
Paweł Gronowski
ac34bd9bda integration/container: Remove Parallel from TestWait*
It seems to help with the flakiness in the CI.
However, I can't reproduce the flakiness locally.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-13 18:09:32 +01:00
Paweł Gronowski
dd7f9f08d8 integration/container: Increase stop timeout for TestWaitRestartedContainer
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-13 18:09:29 +01:00
Rob Murray
97c397112a Merge pull request #49560 from ctalledo/mask-thermal-interrupt-info
Mask Linux thermal interrupt info in /proc and /sys.
2025-03-13 15:16:34 +00:00
Albin Kerouanton
d2ad7c36dc Merge pull request #49577 from robmry/routed_no_skip_dnat
Don't skip DNAT for a routed network without userland-proxy
2025-03-13 13:28:26 +01:00
Albin Kerouanton
d1ecb3b828 Merge pull request #49630 from robmry/macvlan_parent_down
Allow macvlan endpoint to start with parent down
2025-03-13 13:12:27 +01:00
Albin Kerouanton
4ff19b21dc Merge pull request #49621 from robmry/skip_raw_rules
Add an opt-out for iptables 'raw' rules
2025-03-13 12:10:21 +01:00
Paweł Gronowski
8701ff684f Merge pull request #49553 from thaJeztah/bump_containerd_1.7.26
Dockerfile: update containerd binary to v1.7.26
2025-03-12 18:29:55 +00:00
Paweł Gronowski
64b72a8db1 Merge pull request #49365 from ctalledo/47581-fix
Improve performance of daemon.Containers()
2025-03-12 18:28:55 +00:00
Sebastiaan van Stijn
a8f14e06d6 Improve performance of daemon.Containers().
Improve performance of function daemon.Containers() (used by docker ps) to
mitigate a latency increase when running large number of containers using the
containerd image store.

We do this by refactoring daemon.Containers() to collect info for containers in
parallel, rather than sequentially, using up to log2(N) worker threads. This
improves the performance from O(N) to O(log2(N)), where N is the number of
containers.

To verify correctness, this commits adds unit and integration tests.

Signed-off-by: Cesar Talledo <cesar.talledo@docker.com>
2025-03-12 09:59:52 -07: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
Paweł Gronowski
03349f2dde Merge pull request #49626 from vvoland/windows-fix-panic
daemon: Fix panic on Windows when restoring pre v28 container
2025-03-11 14:38:32 +00:00
Rob Murray
c0ca783edb Allow macvlan endpoint to start with parent down
When a macvlan's parent interface is down it's not possible
to send NA messages. So, ignore the error.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-11 14:35:19 +00:00
Paweł Gronowski
26fea35942 daemon: Fix panic on Windows when restoring pre v28 container
The container platform migration tries to deduce the platform data from
the containerd content store if it's available.

However, on Windows we currently default to a non-containerd runtime
setup, so the containerd client is nil and accessing its content store
paniced:

```
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x11b48e4]

goroutine 87 [running]:
github.com/containerd/containerd/v2/client.(*Client).ContentStore(0xc0003a0008?)
	/go/src/github.com/docker/docker/vendor/github.com/containerd/containerd/v2/client/client.go:645 +0x24
github.com/docker/docker/daemon.(*Daemon).load(0xc00026e488, {0xc000c13d40, 0x40})
	/go/src/github.com/docker/docker/daemon/container.go:84 +0x289
github.com/docker/docker/daemon.(*Daemon).restore.func1({0xc000c13d40, 0x40})
	/go/src/github.com/docker/docker/daemon/daemon.go:236 +0x207
created by github.com/docker/docker/daemon.(*Daemon).restore in goroutine 1
	/go/src/github.com/docker/docker/daemon/daemon.go:229 +0x1a7
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x11b48e4]

goroutine 90 [running]:
github.com/containerd/containerd/v2/client.(*Client).ContentStore(0xc000313608?)
	/go/src/github.com/docker/docker/vendor/github.com/containerd/containerd/v2/client/client.go:645 +0x24
github.com/docker/docker/daemon.(*Daemon).load(0xc00026e488, {0xc000c13e00, 0x40})
	/go/src/github.com/docker/docker/daemon/container.go:84 +0x289
github.com/docker/docker/daemon.(*Daemon).restore.func1({0xc000c13e00, 0x40})
	/go/src/github.com/docker/docker/daemon/daemon.go:236 +0x207
created by github.com/docker/docker/daemon.(*Daemon).restore in goroutine 1
	/go/src/github.com/docker/docker/daemon/daemon.go:229 +0x1a7
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xc0000005 code=0x0 addr=0x0 pc=0x11b48e4]
```

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-11 12:25:42 +01:00
Paweł Gronowski
9352aacfbb Merge pull request #49623 from tonistiigi/fix-free-space-filter
builder-next: fix min-free-space prune with graphdriver backend
2025-03-11 10:11:37 +00:00
Rob Murray
e0f3d89d72 Merge pull request #49605 from br3ndonland/runconfig/errors/split-ErrConflictHostNetwork
runconfig/errors: split `ErrConflictHostNetwork`
2025-03-11 10:10:59 +00:00
Brendon Smith
90a83063ee runconfig/errors: split ErrConflictHostNetwork
Split the `ErrConflictHostNetwork` error into two distinct errors:

1. `ErrConflictConnectToHostNetwork` when attempting to change the
   network mode of a running container from a different mode to `host`
2. `ErrConflictDisconnectFromHostNetwork` when the network mode of a
   running container is `host` and attempting to disconnect from `host`

This commit clarifies error messaging by differentiating between the two
errors, making it clearer which operation failed and how to fix it.

Signed-off-by: Brendon Smith <bws@bws.bio>
2025-03-10 21:27:38 -04:00
Cesar Talledo
a3fef5debc Mask Linux thermal interrupt info in /proc and /sys.
On Linux, mask "/proc/interrupts" and "/sys/devices/system/cpu/cpu<x>/thermal_throttle"
inside containers by default. Privileged containers or containers started
with --security-opt="systempaths=unconfined" are not affected.

Mitigates potential Thermal Side-Channel Vulnerability Exploit
(https://github.com/moby/moby/security/advisories/GHSA-6fw5-f8r9-fgfm).

Also: improve integration test TestCreateWithCustomMaskedPaths() to ensure
default masked paths don't apply to privileged containers.

Signed-off-by: Cesar Talledo <cesar.talledo@docker.com>
2025-03-10 17:18:10 -07:00
Sebastiaan van Stijn
5f0d6731eb Merge pull request #49612 from thaJeztah/registry_deprecate_SetCertsDir
registry: deprecate SetCertsDir, HostCertsDir
2025-03-10 20:56:28 +01:00
Sebastiaan van Stijn
cc9eec6c31 Merge pull request #49610 from thaJeztah/dismantle_ParseRepositoryInfo_step2
registry: rewrite ParseRepositoryInfo to not depend on IndexInfo
2025-03-10 20:07:36 +01:00
Rob Murray
cf3e42abaf Add an opt-out for iptables 'raw' rules
For kernels that don't have CONFIG_IP_NF_RAW, if the env
var DOCKER_INSECURE_NO_IPTABLES_RAW is set to "1", don't
try to create raw rules.

This means direct routing to published ports is possible
from other hosts on the local network, even if the port
is published to a loopback address.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-10 18:32:49 +00:00
Sebastiaan van Stijn
0f11ee1ae2 registry: ReadCertsDirectory: don't process same file multiple times
This function needs more cleaning up, because hitting either a ".cert" or
a ".key" file means that we're doing an extra loop over all files to see
if the corresponding file is also present, but let's start with only
processing each file once by using a switch;

b4bdf12dae/registry/registry.go (L81)
b4bdf12dae/registry/registry.go (L94)
b4bdf12dae/registry/registry.go (L43-L50)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-10 19:13:22 +01:00
Sebastiaan van Stijn
dd7ab0e82b registry: deprecate HostCertsDir
This function was only used internally, but it still has at least one
external consumer, so adding a "deprecated" comment.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-10 19:12:55 +01:00
Sebastiaan van Stijn
3cc9881ab7 registry: always set a non-empty CertDir
[homedir.GetConfigHome] only returns an error if the value is empty,
so we can check for a non-empty value instead of an error, which also
means that this value would never be empty.

[homedir.GetConfigHome]: b4bdf12dae/pkg/homedir/homedir_linux.go (L86-L95)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-10 19:11:11 +01:00
Sebastiaan van Stijn
b633c4cc33 registry: deprecate SetCertsDir
This function had to be called both in the daemon startup, as well as
the CLI startup. Which, in case of the cli, meant that the registry
package became a required dependency for all CLI-plugins.

Make the package itself aware of situations where it's running with
rootlessKit enabled. Altogether we should get rid of this package-level
variable, and instead store this in our configuration, and pass through
where it's used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-10 19:11:09 +01:00
Tonis Tiigi
d0dd035278 builder-next: fix min-free-space prune with graphdriver backend
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-03-10 10:47:26 -07:00
Sebastiaan van Stijn
a1c1340196 Merge pull request #49622 from robmry/check-config_ip_nf_raw
Include CONFIG_IP_NF_RAW and IP6 iptables modules in check-config
2025-03-10 18:26:24 +01:00
Rob Murray
4d8cff7bd4 Don't skip DNAT for a routed network without userland-proxy
If the userland-proxy is running, packets from one bridge network
addressed to the host port are not DNAT'd - so that docker-proxy
can pick them up, and therefore the packet bypasses the network
isolation rules.

Without the userland-proxy, there's no way for a packet from one
bridge network to bypass the network isolation rules. So, in this
case, DNAT is not skipped - and that at-least allows packets
originating from the network that published the port to access
the host port.

Commit 0546d90 improved support for routed mode networks (allowing
nat-mode networks access to containers in routed-mode networks, as
well as just remote access).

That commit changed the "SKIP DNAT" logic, making sure DNAT was
skipped for a routed-mode network if the userland-proxy was enabled
(so, containers in routed mode networks could access ports published
by other networks).

But, it still skipped DNAT for a routed mode network if the userland
proxy was disabled - packets from the routed mode network aimed at
any other network would be dropped by the network isolation rules
anyway, and containers in a routed mode network don't need access to
ports published from that network (because, by definition, there
can't be any).

However, network isolation rules can be worked-around with a rule
in the DOCKER-USER chain, but the SKIP DNAT rule is harder to deal
with.

So, for routed-mode, only skip DNAT if the userland-proxy is
enabled (just like nat-mode networks).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-10 17:15:10 +00:00
Sebastiaan van Stijn
ece64ccdbd Merge pull request #45365 from vvoland/deduplicate-test-stop
integration: Deduplicate TestStopContainerWithTimeout
2025-03-10 18:12:50 +01:00
Sebastiaan van Stijn
93181d98ad Merge pull request #49614 from AkihiroSuda/rootlesskit
update RootlessKit to v2.3.4
2025-03-10 18:01:04 +01:00
Paweł Gronowski
1a7b13d6c1 Merge pull request #49584 from vvoland/c8d-split-usage-calc
daemon/c8d: Refactor singlePlatformSize into separate functions
2025-03-10 16:40:08 +00:00
Sebastiaan van Stijn
68e4d31fc2 Merge pull request #49613 from thaJeztah/validate_mountopts
client: add API-version dependent validation for mount options
2025-03-10 17:16:02 +01:00
Paweł Gronowski
2124706447 integration: Increase timeouts in TestStopContainerWithTimeout
To reduce flakiness

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-10 17:04:33 +01:00
Paweł Gronowski
946bf70f89 integration: Deduplicate TestStopContainerWithTimeout
The test had 2 almost identical separate  implementations (Linux and
Windows). The Windows one was skipped anyway.
Make one test that covers all test cases.

The test still needs to be fixed for Windows, so don't unskip it yet.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-10 17:04:29 +01:00
Sebastiaan van Stijn
4341ce9ebb Merge pull request #49590 from vvoland/container-streams-err
container/stream: Don't log error when streams are properly closed
2025-03-10 15:35:00 +01:00
Paweł Gronowski
fee063f01e daemon/c8d: Refactor singlePlatformSize into separate functions
Split singlePlatformSize into a separate methods of the `ImageManifest`
that calculate the corresponding usage.

This also allows us to simplify a part of the `multiPlatformSummary`
because we don't calculate the content size twice now.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-10 14:48:47 +01:00
Rob Murray
f7d7fd9c52 contrib/check-config: add IPv6 modules
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-10 13:03:00 +00:00
Rob Murray
2a109e6c32 contrib/check-config: add ip_nf_raw
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-10 13:03:00 +00:00
Paweł Gronowski
c3c3eb2d09 Merge pull request #49607 from thaJeztah/atomicwriter_enhance
pkg/atomicwriter: New(): prevent creating temp-file on errors, and use absolute paths
2025-03-10 12:57:14 +00:00
Paweł Gronowski
be49e2f760 Merge pull request #49606 from thaJeztah/api_update_secrets_docs
api: improve docs for Secret and Config data fields
2025-03-10 12:54:46 +00:00
Akihiro Suda
0e54920e01 Dockerfile: update RootlessKit to v2.3.4
https://github.com/rootless-containers/rootlesskit/releases/tag/v2.3.3
https://github.com/rootless-containers/rootlesskit/releases/tag/v2.3.4

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-03-10 11:22:37 +09:00
Akihiro Suda
7ae9e41ff6 vendor: github.com/rootless-containers/rootlesskit/v2 v2.3.4
full diff: https://github.com/rootless-containers/rootlesskit/compare/v2.3.2...v2.3.4

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-03-10 11:22:04 +09:00
Akihiro Suda
55ff0062ca vendor: github.com/containernetworking/plugins v1.6.2
full diff: https://github.com/containernetworking/plugins/compare/v1.5.1...v1.6.2

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-03-10 10:15:36 +09:00
Akihiro Suda
125aa3a682 vendor: golang.org/x/sys v0.31.0
full diff: https://github.com/golang/sys/compare/v0.30.0...v0.31.0

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-03-10 10:14:45 +09:00
Sebastiaan van Stijn
5d6b56699d client: add API-version dependent validation for mount options
[docker/cli@fc6976d] added support for recursive readonly mounts in the
CLI, adding a ValidateMountWithAPIVersion utility to verify if options
used were supported by the API version.

We usually keep API-version dependent checks in the client, so that
docker/cli (and other users of the client) don't have to implement
their own validation for these.

This patch moves the functionality of ValidateMountWithAPIVersion to
the client.

Once the docker/cli vendoring was updated, we can remove the utility
there.

[docker/cli@fc6976d]: fc6976db45

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-09 22:03:00 +01:00
Sebastiaan van Stijn
aa33bdaa71 registry: move emptyServiceConfig to test-file
It's no longer used for anything other than in a test, so move
it local to that test.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-09 17:03:56 +01:00
Sebastiaan van Stijn
907773160b registry: rewrite ParseSearchIndexInfo to not depend on IndexInfo
This function was implemented to use various parts of the registry package
that were designed for the daemon code, which was written with the assumption
that it had registry-config available from the daemon's configuration.
However, `ParseSearchIndexInfo` is used by the client / CLI, which does
not have this information.

To work around this problem, the code used a dummy "emptyServiceConfig"
to allow the `Insecure` and `Mirrors` fields to be propagated based on
the same defaults as used by the daemon. The `Mirrors` field would always
be empty, as there are no default mirrors, and (lacking access to the
daemon's config) the `Insecure` field would always default to registries
running on a loopback address (`::1/128`, `127.0.0.1/8`). It's worth noting
that neither the `Mirrors`, nor the `Insecure` field is used by the CLI.

This patch rewrites `ParseSearchIndexInfo` to be self-contained, and not
depend on these constructs (and the `emptyServiceConfig`). For now, the
existing logic for `Insecure` is kept, but replaced by a simplified function
(`isInsecure`) with some optimizations for well-known loopback addresses
(`localhost`, `::1`, `127.0.0.1`) to prevent redundant DNS lookups or
parsing.

Note that similar changes should be made for [ParseRepositoryInfo], which
has a similar fate and is also only used by the client / CLI.

[ResolveRepositoryName]: 11e47996dc/registry/registry.go (L199-L222)
[ParseRepositoryInfo]: d86dd75948/registry/config.go (L375-L381)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-09 16:32:54 +01:00
Sebastiaan van Stijn
b22431ee9c pkg/atomicwriter: New(): use absolute path for temp-file
Use an absolute path for both the temp-file and the destination-file.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-09 15:00:00 +01:00
Sebastiaan van Stijn
58bd93a625 pkg/atomicwriter: New(): prevent creating temp-file on errors
The temp-file was created before trying to make the given filename an
absolute path. Reverse the order of code so that we don't create
a temp-file if an error happens.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-09 14:55:11 +01:00
Sebastiaan van Stijn
49c89b0177 docs/api: improve doc for Secret and Config data fields (API v1.31-v1.48)
Document the size constraints as defined by swarm;

- 500KB ([MaxSecretSize]) for secrets
- 1000KB ([MaxConfigSize]) for configs

[MaxSecretSize]: https://pkg.go.dev/github.com/moby/swarmkit/v2@v2.0.0-20250103191802-8c1959736554/api/validation#MaxSecretSize
[MaxConfigSize]: https://pkg.go.dev/github.com/moby/swarmkit/v2@v2.0.0-20250103191802-8c1959736554/manager/controlapi#MaxConfigSize

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-09 12:42:23 +01:00
Sebastiaan van Stijn
df0cefcc95 api/swagger: improve doc for Secret and Config data fields
Document the size constraints as defined by swarm;

- 500KB ([MaxSecretSize]) for secrets
- 1000KB ([MaxConfigSize]) for configs

[MaxSecretSize]: https://pkg.go.dev/github.com/moby/swarmkit/v2@v2.0.0-20250103191802-8c1959736554/api/validation#MaxSecretSize
[MaxConfigSize]: https://pkg.go.dev/github.com/moby/swarmkit/v2@v2.0.0-20250103191802-8c1959736554/manager/controlapi#MaxConfigSize

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-09 12:39:42 +01:00
Sebastiaan van Stijn
f2d53142b0 api/types/swarm: document Secret and Config data fields
Document the size constraints as defined by swarm;

- 500KB ([MaxSecretSize]) for secrets
- 1000KB ([MaxConfigSize]) for configs

[MaxSecretSize]: https://pkg.go.dev/github.com/moby/swarmkit/v2@v2.0.0-20250103191802-8c1959736554/api/validation#MaxSecretSize
[MaxConfigSize]: https://pkg.go.dev/github.com/moby/swarmkit/v2@v2.0.0-20250103191802-8c1959736554/manager/controlapi#MaxConfigSize

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-09 12:34:18 +01:00
Sebastiaan van Stijn
c2c3d593cf registry: rewrite ParseRepositoryInfo to not depend on IndexInfo
This function was introduced in 568f86eb18
to replace [ResolveRepositoryName]. The function was implemented to use
various parts of the registry package that were designed for the daemon
code, which was written with the assumption that it had registry-config
available from the daemon's configuration. However, `ParseRepositoryInfo`
was used in the client / CLI, which does not have this information.

To work around this problem, the code used a dummy "emptyServiceConfig"
to allow the `Insecure` and `Mirrors` fields to be propagated based on
the same defaults as used by the daemon. The `Mirrors` field would always
be empty, as there are no default mirrors, and (lacking access to the
daemon's config) the `Insecure` field would always default to registries
running on a loopback address (`::1/128`, `127.0.0.1/8`). It's worth noting
that neither the `Mirrors`, nor the `Insecure` field is used by the CLI.

This patch rewrites `ParseRepositoryInfo` to be self-contained, and not
depend on these constructs (and the `emptyServiceConfig`). For now, the
existing logic for `Insecure` is kept, but replaced by a simplified function
(`isInsecure`) with some optimizations for well-known loopback addresses
(`localhost`, `::1`, `127.0.0.1`) to prevent redundant DNS lookups or
parsing.

Note that similar changes should be made for [ParseSearchIndexInfo], which
has a similar fate and is also only used by the client / CLI.

[ResolveRepositoryName]: 11e47996dc/registry/registry.go (L199-L222)
[ParseSearchIndexInfo]: d86dd75948/registry/search.go (L153-L162)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-08 17:07:10 +01:00
Sebastiaan van Stijn
b4bdf12dae Merge pull request #49581 from vvoland/vendor-x-net
vendor: golang.org/x/net v0.36.0
2025-03-08 01:17:15 +01:00
Sebastiaan van Stijn
42f1e38e20 integration/image: TestRemoveImageGarbageCollector: don't set zero-values
This test was setting some fields to their zero / default-value, which
was redundant, and added additional imports. Remove them as they are
not needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-07 22:40:01 +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
Sebastiaan van Stijn
037f25c9e0 Merge pull request #49598 from thaJeztah/remove_MetadataStorePathTemplate
layer: remove StoreOptions.MetadataStorePathTemplate
2025-03-07 22:39:23 +01:00
Sebastiaan van Stijn
677048f22c Merge pull request #49597 from thaJeztah/cmd_dockerd_config_handling
cmd/dockerd: assorted cleanups on config handling
2025-03-07 21:54:24 +01:00
Sebastiaan van Stijn
0a4c0902a5 Merge pull request #49578 from dmcgowan/update-governance
Update governance and maintainers file
2025-03-07 20:22: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
Paweł Gronowski
ace8c9c94f vendor: golang.org/x/net v0.36.0
full diff: https://github.com/golang/net/compare/v0.35.0...v0.36.0

Version v0.36.0 of golang.org/x/net fixes a vulnerability in the
golang.org/x/net/proxy and golang.org/x/net/http/httpproxy packages
which could cause the proxy to be bypassed.

Matching of hosts against proxy patterns could improperly treat an IPv6
zone ID as a hostname component. For example, when the NO_PROXY
environment variable was set to "*.example.com", a request to
"[::1%25.example.com]:80` would incorrectly match and not be proxied.

Thanks to Juho Forsén of Mattermost for reporting this issue.

This is CVE-2025-22870 and Go issue https://go.dev/issue/71984.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-07 18:28:01 +01:00
Paweł Gronowski
bc0ca67b1c vendor: golang.org/x/net v0.35.0
full diff: https://github.com/golang/net/compare/v0.33.0...v0.35.0

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-07 18:27:58 +01:00
Paweł Gronowski
c90cbc89c0 Merge pull request #49589 from vvoland/deflake-TestAccessPublishedPortFromAnotherNetwork
integration/net: Deflake TestAccessPublishedPortFromAnotherNetwork
2025-03-07 17:01:22 +00:00
Sebastiaan van Stijn
9278110260 Dockerfile: update containerd binary to v1.7.26
- full diff: https://github.com/containerd/containerd/compare/v1.7.25...v1.7.26
- release notes: https://github.com/containerd/containerd/releases/tag/v1.7.26

Welcome to the v1.7.26 release of containerd!

The twenty-sixth patch release for containerd 1.7 contains various fixes
and updates.

Highlights

- Add support for syncfs after unpack
- Update runc binary to v1.2.55
- Fix race between serve and immediate shutdown on the server
- Reject oversized messages from the sender

Container Runtime Interface (CRI)

- Fix fatal concurrency error in port forwarding

Node Resource Interface (NRI)

- Fix initial sync race when registering NRI plugins
- Add API support for reading Pod IPs
- Fix plugin sync to use multiple messages if ttrpc max message limit is hit
- Update API to pass configured timeouts to plugins.
- Fix mount removal in adjustments
- Close plugin if initial synchronization fails
- Add support for adjusting OOM score
- Add API support for NRI-native CDI injection
- Add support for pids cgroup

Runtime

- Fix console TTY leak in runc shim

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-07 17:47:59 +01:00
Sebastiaan van Stijn
51db0f1b1b Merge pull request #49543 from thaJeztah/bump_crypto_oauth2
vendor: golang.org/x/crypto v0.35.0, golang.org/x/oauth2 v0.27.0
2025-03-07 17:23:27 +01:00
Sebastiaan van Stijn
75f6c4ab9d Merge pull request #49579 from thaJeztah/bump_ubuntu
gha: update various workflows to use Ubuntu 24.04
2025-03-07 15:39:51 +01:00
Paweł Gronowski
0a58c73e0d integration/net: Retry TestAccessPublishedPortFromAnotherNetwork
Allow each test case to be retried up to 5 times.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-07 14:57:00 +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
556633ca47 cmd/dockerd: daemonCLI.start: scope local errors
Scope errors locally and don't use special names if there's no reason
for it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-07 00:27:12 +01:00
Sebastiaan van Stijn
8b59e1a398 cmd/dockerd: daemonCLI.start: return error instead of log.Fatal
We return errors in this function, except for this one, which was logged
as Fatal. If we want errors to be logged, we should probably do so in
the function calling daemonCLI.start.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-07 00:15:16 +01:00
Sebastiaan van Stijn
8a8cdaaa11 cmd/dockerd: daemonCLI.start: don't log warnings before failing
This function could produce various logs ("Running in rootless mode") at
the start, but further steps could still fail (such as running with
RootlessKit, but not being configured as rootless).

This patch moves the informational / warning logs further down, so that
we don't produce logs before failing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-07 00:08:45 +01:00
Sebastiaan van Stijn
6e30a4cc0c cmd/dockerd: explicitly access Config fields
Explicitly access config field through the Config field, instead
of the top-level "cli". This allows spotting locations where we don't
depend on the CLI, but really just the Config.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:50:26 +01:00
Sebastiaan van Stijn
dfecaaf908 cmd/dockerd: rewrite getContainerdDaemonOpts to a func
This method only depended on the CLI config; rewrite it to a
regular function, returning the opts to use for the containerd
daemon.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:50:26 +01:00
Sebastiaan van Stijn
b95fdcd084 cmd/dockerd: createAndStartCluster: change to accept Config
This function took the whole daemon CLI as argument, but only needed
the config; change the signature to accept that.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:50:26 +01:00
Sebastiaan van Stijn
29aa7e15bd cmd/dockerd: rewrite getSwarmRunRoot to a regular func
This method only required the config to be passed; rewrite it to a
regular func that accepts the config.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:50:26 +01:00
Sebastiaan van Stijn
29c296e1dd cmd/dockerd: rename vars that shadowed imports
Also use a consistent name for "config" arguments.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:50:26 +01:00
Sebastiaan van Stijn
f87ae7c914 gha: test-prepare: update to Ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:16:05 +01:00
Sebastiaan van Stijn
c41ed7c98c gha: build, cross: update to Ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:14:54 +01:00
Sebastiaan van Stijn
d29038d1cb gha: integration-cli-prepare: update to Ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:14:53 +01:00
Sebastiaan van Stijn
a23058e0d7 gha: integration-cli-report: update to Ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:14:53 +01:00
Sebastiaan van Stijn
de69b552ff gha: integration-report: update to Ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:14:53 +01:00
Sebastiaan van Stijn
b61f409972 gha: test: update Ubuntu 22.04 -> 24.04
Don't upgrade rootless yet, as it doesn't like running on 24.04;

    ---> Making bundle: .integration-daemon-start (in bundles/test-integration)
    Using test binary /usr/local/cli-integration/docker
    # DOCKER_EXPERIMENTAL is set: starting daemon with experimental features enabled!
    Not: starting.
    Starting dockerd
    INFO: Waiting for daemon to start...
    ...........................................................
    error: daemon at unix:///go/src/github.com/docker/docker/bundles/test-integration/docker.sock fails to '/usr/local/cli-integration/docker version':
    Client:
     Version:      17.06.2-ce
     API version:  1.30
     Go version:   go1.8.3
     Git commit:   cec0b72
     Built:        Tue Sep  5 19:57:21 2017
     OS/Arch:      linux/amd64
    Cannot connect to the Docker daemon at unix:///go/src/github.com/docker/docker/bundles/test-integration/docker.sock. Is the docker daemon running?
    make: *** [Makefile:231: test-integration] Error 1
    Error: Process completed with exit code 2.

logs:

    + [ -w /tmp/docker-1000 ]
    + [ -d /home/unprivilegeduser ]
    + rootlesskit=
    + command -v docker-rootlesskit
    + command -v rootlesskit
    + rootlesskit=rootlesskit
    + break
    + [ -z rootlesskit ]
    + : /tmp/docker-1000/dockerd-rootless
    + :
    + :
    + : builtin
    + : auto
    + : auto
    + :
    + net=
    + mtu=
    + [ -z  ]
    + command -v slirp4netns
    + [ -z  ]
    + command -v vpnkit
    + net=vpnkit
    + [ -z  ]
    + mtu=1500
    + host_loopback=--disable-host-loopback
    + [  = false ]
    + dockerd=dockerd
    + [ -z  ]
    + _DOCKERD_ROOTLESS_CHILD=1
    + export _DOCKERD_ROOTLESS_CHILD
    + id -u
    + [ 1000 = 0 ]
    + command -v selinuxenabled
    + exec rootlesskit --state-dir=/tmp/docker-1000/dockerd-rootless --net=vpnkit --mtu=1500 --slirp4netns-sandbox=auto --slirp4netns-seccomp=auto --disable-host-loopback --port-driver=builtin --copy-up=/etc --copy-up=/run --propagation=rslave /usr/local/bin/dockerd-rootless.sh --debug --host unix:///go/src/github.com/docker/docker/bundles/test-integration/docker.sock --storage-driver overlay2 --pidfile bundles/test-integration/docker.pid --userland-proxy=true --experimental
    [rootlesskit:parent] error: failed to start the child: fork/exec /proc/self/exe: operation not permitted

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:14:15 +01:00
Sebastiaan van Stijn
60276fafca gha: integration-prepare: update to ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:02 +01:00
Sebastiaan van Stijn
651fb91c4d gha: arm64: update Ubuntu 22.04 -> 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:02 +01:00
Sebastiaan van Stijn
f6a9ed5f0a gha: arm64: test-integration-report: update to Ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:02 +01:00
Sebastiaan van Stijn
13e1ef6277 gha: arm64: test-unit-report: update to ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:01 +01:00
Sebastiaan van Stijn
27404044a6 gha: validate, build-dev: update to Ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:01 +01:00
Sebastiaan van Stijn
3571982458 gha: smoke: update to Ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:01 +01:00
Sebastiaan van Stijn
ee73f2e5da gha: docker-py: update to ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:01 +01:00
Sebastiaan van Stijn
b9ca3d198e gha: unit: update to ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:01 +01:00
Sebastiaan van Stijn
1a0afb0f9e gha: bin-image: update to ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:00 +01:00
Sebastiaan van Stijn
4919bf9f41 gha: buildkit: update to ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:00 +01:00
Sebastiaan van Stijn
7b1fd61864 gha: validate-pr: update to ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:00 +01:00
Sebastiaan van Stijn
eeffc099ef gha: dco: update to ubuntu 24.04
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:00 +01:00
Sebastiaan van Stijn
06b87d80ee gha: docker-py: set TEST_SKIP_INTEGRATION_CLI=1
These tests don't actually run the integration-cli suite, but
the global hack/xxx script errors because it's not set;

    ---> Making bundle: test-docker-py (in bundles/test-docker-py)
    ---> Making bundle: .integration-daemon-start (in bundles/test-docker-py)
    Using test binary /usr/local/cli-integration/docker
    # DOCKER_EXPERIMENTAL is set: starting daemon with experimental features enabled!
    # cgroup v2 requires TEST_SKIP_INTEGRATION_CLI to be set
    make: *** [Makefile:220: test-docker-py] Error 1
    Error: Process completed with exit code 2.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 23:12:00 +01:00
Cesar Talledo
c9f53d506a Merge ps_test.go into list_test.go.
Signed-off-by: Cesar Talledo <cesar.talledo@docker.com>
2025-03-06 10:42:07 -08:00
Paweł Gronowski
95bf53fb6c container/stream: Don't log error when streams are properly closed
This fixes unnecessary errors being written to the daemon log after
copying container streams failed due the streams being closed explicitly:

time="2025-03-06T13:20:53.473232423Z" level=error msg="copy stream failed" error="io: read/write on closed pipe" stream=stdin

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-06 14:28:17 +01:00
Derek McGowan
6e55f83747 Remove unused toml validation
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-03-06 01:44:06 -08:00
Derek McGowan
bf8a27a55a Remove inactive maintainers with no activity in last two years
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-03-06 01:07:10 -08:00
Derek McGowan
9e814fc0d7 Remove inactive former curators
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-03-06 01:07:10 -08:00
Derek McGowan
b868fad5e3 Update governance to replace TSC and add maintainer roles
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-03-06 01:07:10 -08:00
Sebastiaan van Stijn
690f758505 vendor: golang.org/x/oauth2 v0.27.0
We have tagged version v0.27.0 of golang.org/x/oauth2 in order to address
a security issue.

jws: unexpected memory consumption during token parsing

Version v0.27.0 of golang.org/x/oauth2 fixes a vulnerability in the
golang.org/x/oauth2/jws package which could cause a denial of service.
An attacker can pass a malicious malformed token which causes unexpected
memory to be consumed during parsing.

Thanks to jub0bs for reporting this issue.
This is CVE-2025-22868 and Go issue https://go.dev/issue/71490.

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 10:00:25 +01:00
Sebastiaan van Stijn
55599fd9b3 vendor: golang.org/x/oauth2 v0.26.0
No code changes, only comments (warnings) added;

- google: add warning about externally-provided credentials

> Important: If you accept a credential configuration (credential JSON/File/Stream) from an
> external source for authentication to Google Cloud Platform, you must validate it before
> providing it to any Google API or library. Providing an unvalidated credential configuration to
> Google APIs can compromise the security of your systems and data. For more information, refer to
> [Validate credential configurations from external sources](https://cloud.google.com/docs/authentication/external/externally-sourced-credentials).

full diff: https://github.com/golang/oauth2/compare/v0.23.0...v0.26.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 10:00:25 +01:00
Sebastiaan van Stijn
a47d9c5f58 vendor: golang.org/x/crypto v0.35.0
We have tagged version v0.35.0 of golang.org/x/crypto in order to address
a security issue. Version v0.35.0 of golang.org/x/crypto fixes a vulnerability
in the golang.org/x/crypto/ssh package which could cause a denial of service.
SSH servers which implement file transfer protocols are vulnerable to a denial
of service attack from clients which complete the key exchange slowly, or not
at all, causing pending content to be read into memory, but never transmitted.
Thanks to Yuichi Watanabe for reporting this issue.
This is CVE-2025-22869 and Go issue https://go.dev/issue/71931.

full diff: https://github.com/golang/crypto/compare/v0.31.0...v0.35.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 10:00:25 +01:00
Sebastiaan van Stijn
3a28163007 vendor: golang.org/x/crypto v0.34.0
No code-changes, but updates the minimum go version to go1.23:

> 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.

full diff: https://github.com/golang/crypto/compare/v0.33.0...v0.34.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 10:00:25 +01:00
Sebastiaan van Stijn
ffc91fd76a vendor: golang.org/x/crypto v0.33.0
Relevant changes;

- go.mod: update golang.org/x dependencies
- ssh: add ServerConfig.PreAuthConnCallback, ServerPreAuthConn (banner)
  interface

full diff: https://github.com/golang/crypto/compare/v0.31.0...v0.33.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 10:00:25 +01:00
Sebastiaan van Stijn
7cba8aef1c vendor: golang.org/x/text v0.22.0
no code-changes in vendored files.

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 10:00:24 +01:00
Sebastiaan van Stijn
995d71a033 vendor: golang.org/x/sync v0.11.0
no code-changes, only a godoc comment updated

full diff: https://github.com/golang/sync/compare/v0.10.0...v0.11.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 10:00:24 +01:00
Sebastiaan van Stijn
e325564f38 vendor: golang.org/x/sys v0.30.0
full diff: https://github.com/golang/sys/compare/v0.29.0...v0.30.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-06 10:00:24 +01:00
Akihiro Suda
a9c9d5bb25 Merge pull request #49465 from thaJeztah/vendor_runc_filepath_securejoin
vendor: github.com/opencontainers/runc v1.2.5, cyphar/filepath-securejoin v0.4.1
2025-03-06 09:34:23 +09:00
Akihiro Suda
4e60c49f0d Merge pull request #49587 from crazy-max/buildkit-0.20.1
vendor: update buildkit to v0.20.1
2025-03-06 09:33:56 +09:00
Sebastiaan van Stijn
f049fd0533 Merge pull request #49541 from thaJeztah/bump_go_version
update minimum go version to go1.23
2025-03-05 20:36:17 +01:00
Sebastiaan van Stijn
2e4ef1ace9 Merge pull request #49580 from vvoland/update-go
update to go1.23.7
2025-03-05 18:40:11 +01:00
Sebastiaan van Stijn
01d8303167 Merge pull request #49582 from robmry/flush_bridge_chains
Flush iptables chains DOCKER-CT, DOCKER-BRIDGE on startup
2025-03-05 18:38:10 +01:00
CrazyMax
65b460b9ef vendor: update buildkit to v0.20.1
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-03-05 17:07:25 +01:00
Sebastiaan van Stijn
6e8eb8a90f vendor.mod: update minimum go version to go1.23
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-03-05 13:39:50 +01:00
Sebastiaan van Stijn
3c817d02a9 Merge pull request #49575 from thaJeztah/refactor_resolvconf_build
libnetwork/resolvconf: re-implement "Build" with the new libnetwork/internal/resolvconf code
2025-03-05 13:17:47 +01:00
Rob Murray
26edf2d0a7 Flush iptables chains DOCKER-CT, DOCKER-BRIDGE on startup
These chains were added in commit 76417bf ("Don't use ipset"), but
not included in the list of chains that get flushed and deleted
on daemon startup.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-03-05 11:47:36 +00:00
Sebastiaan van Stijn
113c296ce7 Merge pull request #49493 from thaJeztah/enable_nakedret
golangci-lint: enable nakedret linter
2025-03-05 00:38:28 +01:00
Paweł Gronowski
5f912e4cf5 update to go1.23.7
- https://github.com/golang/go/issues?q=milestone%3AGo1.23.7+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.23.6...go1.23.7

These minor releases include 1 security fixes following the security policy:

net/http, x/net/proxy, x/net/http/httpproxy: proxy bypass using IPv6 zone IDs

Matching of hosts against proxy patterns could improperly treat an IPv6
zone ID as a hostname component. For example, when the NO_PROXY
environment variable was set to "*.example.com", a request to
"[::1%25.example.com]:80` would incorrectly match and not be proxied.

Thanks to Juho Forsén of Mattermost for reporting this issue.

This is CVE-2025-22870 and Go issue https://go.dev/issue/71984.

View the release notes for more information:
https://go.dev/doc/devel/release#go1.23.7

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-04 22:57:35 +01:00
Sebastiaan van Stijn
65c2f799b4 Merge pull request #49573 from thaJeztah/denoise_ci
integration/volume: remove some debug logs and minor fixes/cleanups
2025-03-04 15:22:16 +01:00
Sebastiaan van Stijn
a8178613af golangci-lint: enable nakedret linter
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:16 +01:00
Sebastiaan van Stijn
c359cc6829 api/types/registry: fix naked returns
api/types/registry/registry.go:60:2: naked return in func `UnmarshalJSON` with 9 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:16 +01:00
Sebastiaan van Stijn
b1c008c007 api/server/router/build: fix naked returns
api/server/router/build/build_routes.go:359:2: naked return in func `Write` with 5 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:16 +01:00
Sebastiaan van Stijn
4aecdd5744 image/tarexport: fix naked returns and slight refactor
image/tarexport/load.go:429:2: naked return in func `validatedParentLinks` with 12 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:15 +01:00
Sebastiaan van Stijn
99b6012a02 daemon/logger/awslogs: remove unused named return
daemon/logger/awslogs/cloudwatchlogs.go:684:2: naked return in func `findValidSplit` with 10 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:15 +01:00
Sebastiaan van Stijn
4fa9ec3192 daemon/logger: fix naked returns and slight refactor
daemon/logger/proxy.go:35:3: naked return in func `StartLogging` with 17 lines of code (nakedret)
            return
            ^
    daemon/logger/proxy.go:42:2: naked return in func `StartLogging` with 17 lines of code (nakedret)
        return
        ^
    daemon/logger/proxy.go:61:3: naked return in func `StopLogging` with 16 lines of code (nakedret)
            return
            ^
    daemon/logger/proxy.go:68:2: naked return in func `StopLogging` with 16 lines of code (nakedret)
        return
        ^
    daemon/logger/proxy.go:80:3: naked return in func `Capabilities` with 14 lines of code (nakedret)
            return
            ^
    daemon/logger/proxy.go:89:2: naked return in func `Capabilities` with 14 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:15 +01:00
Sebastiaan van Stijn
eeb5651de5 daemon/graohdriver/fuse-overlayfs/: fix naked returns and slight refactor
daemon/graphdriver/fuse-overlayfs/fuseoverlayfs.go:527:2: naked return in func `fusermountU` with 25 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:15 +01:00
Sebastiaan van Stijn
02b4610246 daemon/graohdriver: fix naked returns
daemon/graphdriver/fsdiff.go:140:3: naked return in func `ApplyDiff` with 20 lines of code (nakedret)
            return
            ^
    daemon/graphdriver/fsdiff.go:149:3: naked return in func `ApplyDiff` with 20 lines of code (nakedret)
            return
            ^
    daemon/graphdriver/fsdiff.go:153:2: naked return in func `ApplyDiff` with 20 lines of code (nakedret)
        return
        ^
    daemon/graphdriver/fsdiff.go:164:3: naked return in func `DiffSize` with 15 lines of code (nakedret)
            return
            ^
    daemon/graphdriver/fsdiff.go:169:3: naked return in func `DiffSize` with 15 lines of code (nakedret)
            return
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:15 +01:00
Sebastiaan van Stijn
964413c3a1 daemon/cluster: fix naked returns
daemon/cluster/cluster.go:423:2: naked return in func `managerStats` with 24 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
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
85c8fb7fda daemon: getSystemCPUUsage(): fix naked returns, output vars
Remove output variables, and use explicit returns

    daemon/stats_unix.go:359:2: naked return in func `getSystemCPUUsage` with 38 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
5c85847a55 registry: fix naked returns, output vars
registry/service.go:83:4: naked return in func `Auth` with 38 lines of code (nakedret)
                return
                ^
    registry/search_session.go:91:2: naked return in func `Read` with 6 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
17448ef1c8 plugin: fix naked returns, output vars
plugin/backend_linux.go:722:3: naked return in func `CreateFromContext` with 112 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
faa9cb125b pkg/tarsum: fix naked returns
pkg/tarsum/versioning.go:150:2: naked return in func `v1TarHeaderSelect` with 35 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:13 +01:00
Sebastiaan van Stijn
b5b514ab04 pkg/stdcopy: fix naked returns
pkg/stdcopy/stdcopy.go:68:2: naked return in func `Write` with 23 lines of code (nakedret)
        return
        ^
    pkg/stdcopy/stdcopy_test.go:93:3: naked return in func `getSrcBuffer` with 10 lines of code (nakedret)
            return
            ^
    pkg/stdcopy/stdcopy_test.go:97:2: naked return in func `getSrcBuffer` with 10 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:13 +01:00
Sebastiaan van Stijn
d3d84bde4b pkg/pools: fix naked returns
pkg/pools/pools.go:83:2: naked return in func `Copy` with 5 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:13 +01:00
Sebastiaan van Stijn
52b8298975 pkg/chrootarchive: remove unused named return
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:13 +01:00
Sebastiaan van Stijn
b38f0dd804 pkg/archive: fix naked returns, output variables in tests
pkg/archive/copy_unix_test.go:54:3: naked return in func `fileContentsEqual` with 35 lines of code (nakedret)
            return
            ^
    pkg/archive/copy_unix_test.go:60:3: naked return in func `fileContentsEqual` with 35 lines of code (nakedret)
            return
            ^
    pkg/archive/copy_unix_test.go:67:3: naked return in func `fileContentsEqual` with 35 lines of code (nakedret)
            return
            ^
    pkg/archive/copy_unix_test.go:74:3: naked return in func `fileContentsEqual` with 35 lines of code (nakedret)
            return
            ^
    pkg/archive/copy_unix_test.go:83:2: naked return in func `fileContentsEqual` with 35 lines of code (nakedret)
        return
        ^
    pkg/archive/diff_test.go:314:3: naked return in func `makeTestLayer` with 35 lines of code (nakedret)
            return
            ^
    pkg/archive/diff_test.go:326:5: naked return in func `makeTestLayer` with 35 lines of code (nakedret)
                    return
                    ^
    pkg/archive/diff_test.go:330:5: naked return in func `makeTestLayer` with 35 lines of code (nakedret)
                    return
                    ^
    pkg/archive/diff_test.go:336:3: naked return in func `makeTestLayer` with 35 lines of code (nakedret)
            return
            ^
    pkg/archive/copy_unix_test.go:36:2: naked return in func `getTestTempDirs` with 10 lines of code (nakedret)
        return
        ^
    pkg/stdcopy/stdcopy_test.go:93:3: naked return in func `getSrcBuffer` with 10 lines of code (nakedret)
            return
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:13 +01:00
Sebastiaan van Stijn
d59a9d9b10 pkg/archive: fix naked returns, output variables
pkg/archive/archive_linux.go:65:2: naked return in func `ConvertWrite` with 43 lines of code (nakedret)
        return
        ^
    pkg/archive/archive.go:265:2: naked return in func `Read` with 11 lines of code (nakedret)
        return
        ^
    pkg/archive/copy.go:32:2: naked return in func `copyWithBuffer` with 5 lines of code (nakedret)
        return
        ^
    pkg/archive/copy.go:114:3: naked return in func `TarResourceRebase` with 16 lines of code (nakedret)
            return
            ^
    pkg/archive/copy.go:449:4: naked return in func `ResolveHostSourcePath` with 26 lines of code (nakedret)
                return
                ^
    pkg/archive/copy.go:460:4: naked return in func `ResolveHostSourcePath` with 26 lines of code (nakedret)
                return
                ^
    pkg/archive/wrap.go:58:2: naked return in func `parseStringPairs` with 11 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:56:08 +01:00
Sebastiaan van Stijn
c62f5aff42 libnetwork: fix naked returns
libnetwork/drivers/remote/driver_test.go:29:2: naked return in func `decodeToMap` with 3 lines of code (nakedret)
        return
        ^
    libnetwork/ipams/remote/remote_test.go:23:2: naked return in func `decodeToMap` with 3 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:46 +01:00
Sebastiaan van Stijn
8978b30b1a libnetwork/types: fix naked returns
libnetwork/types/types.go:330:2: naked return in func `ParseCIDR` with 6 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:46 +01:00
Sebastiaan van Stijn
619e8f8148 libnetwork/osl: fix naked returns
libnetwork/osl/namespace_linux.go:324:2: naked return in func `DisableARPForVIP` with 28 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:46 +01:00
Sebastiaan van Stijn
02b4c7cc52 libnetwork/drivers/overlay: fix naked returns, output variables
libnetwork/drivers/overlay/encryption.go:370:2: naked return in func `programSA` with 64 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:46 +01:00
Sebastiaan van Stijn
94afddb18d libnetwork/cmd/networkdb-test: fix naked return
libnetwork/cmd/networkdb-test/dbclient/ndbClient.go:251:5: naked return in func `checkTable` with 42 lines of code (nakedret)
                    return
                    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:45 +01:00
Sebastiaan van Stijn
379b82862f layer: fix naked returns
layer/layer_store.go:524:4: naked return in func `CreateRWLayer` with 72 lines of code (nakedret)
                return
                ^
    layer/layer_store.go:534:3: naked return in func `CreateRWLayer` with 72 lines of code (nakedret)
            return
            ^
    layer/layer_store.go:537:3: naked return in func `CreateRWLayer` with 72 lines of code (nakedret)
            return
            ^
    layer/migration.go:19:3: naked return in func `ChecksumForGraphID` with 28 lines of code (nakedret)
            return
            ^
    layer/migration.go:25:3: naked return in func `ChecksumForGraphID` with 28 lines of code (nakedret)
            return
            ^
    layer/migration.go:36:3: naked return in func `ChecksumForGraphID` with 28 lines of code (nakedret)
            return
            ^
    layer/migration.go:40:3: naked return in func `ChecksumForGraphID` with 28 lines of code (nakedret)
            return
            ^
    layer/migration.go:43:2: naked return in func `ChecksumForGraphID` with 28 lines of code (nakedret)
        return
        ^
    layer/ro_layer.go:176:2: naked return in func `Read` with 13 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:45 +01:00
Sebastiaan van Stijn
b1c617681f internal/unix_noeintr: fix naked returns
In fairness, these could possibly be an exception to the rule, but adding
explicit returns isn't too bad either, and allows running the nakedret
linter without //nolint tags or exceptions in .golangci-lint.yaml

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:45 +01:00
Sebastiaan van Stijn
51f574ea0e internal/mod: fix naked returns
internal/mod/mod.go:22:3: naked return in func `moduleVersion` with 38 lines of code (nakedret)
            return
            ^
    internal/mod/mod.go:36:4: naked return in func `moduleVersion` with 38 lines of code (nakedret)
                return
                ^
    internal/mod/mod.go:57:2: naked return in func `moduleVersion` with 38 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:45 +01:00
Sebastiaan van Stijn
e1538336c7 integration-cli: fix naked returns, output vars
Remove output variables, and use explicit returns

    integration-cli/check_test.go:86:3: naked return in func `testRun` with 43 lines of code (nakedret)
            return
            ^
    integration-cli/check_test.go:97:3: naked return in func `testRun` with 43 lines of code (nakedret)
            return
            ^
    integration-cli/docker_cli_cp_utils_test.go:167:2: naked return in func `makeTestContainer` with 44 lines of code (nakedret)
        return
        ^
    integration-cli/docker_api_attach_test.go:299:3: naked return in func `readTimeout` with 12 lines of code (nakedret)
            return
            ^
    integration-cli/docker_cli_cp_utils_test.go:215:2: naked return in func `startContainerGetOutput` with 11 lines of code (nakedret)
        return
        ^
    integration-cli/docker_cli_logs_test.go:276:4: naked return in func `ConsumeWithSpeed` with 18 lines of code (nakedret)
                return
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:45 +01:00
Sebastiaan van Stijn
220b3c591f container/stream/bytespipe: fix naked returns, output vars
Remove output variables, and use explicit returns

    container/stream/bytespipe/bytespipe.go:165:2: naked return in func `Read` with 37 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:44 +01:00
Sebastiaan van Stijn
0cd39d7b23 builder/remotecontext: fix naked returns
builder/remotecontext/detect.go:47:2: naked return in func `Detect` with 17 lines of code (nakedret)
        return
        ^
    builder/remotecontext/archive.go:127:2: naked return in func `normalize` with 7 lines of code (nakedret)
        return
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:44 +01:00
Sebastiaan van Stijn
0c1b37c50a builder/dockerfile: fix minor linting issues
- remove/rename vars that shadowed
- suppress some unhandled errors
- remove naked return

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:44 +01:00
Sebastiaan van Stijn
8302cd2d29 builder/dockerfile: downloadSource: fix naked returns, output vars
- use explicit returns
- rename error-return that's used in a defer
- move closing the tmpFile on error to a defer
- add debug logs for cases where either closing the file, or failing to
  remove the temp-directory

    builder/dockerfile/copy.go:369:3: naked return in func `downloadSource` with 67 lines of code (nakedret)
            return
            ^
    builder/dockerfile/copy.go:374:3: naked return in func `downloadSource` with 67 lines of code (nakedret)
            return
            ^
    builder/dockerfile/copy.go:382:3: naked return in func `downloadSource` with 67 lines of code (nakedret)
            return
            ^
    builder/dockerfile/copy.go:398:3: naked return in func `downloadSource` with 67 lines of code (nakedret)
            return
            ^
    builder/dockerfile/copy.go:407:3: naked return in func `downloadSource` with 67 lines of code (nakedret)
            return
            ^
    builder/dockerfile/copy.go:428:3: naked return in func `downloadSource` with 67 lines of code (nakedret)
            return
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 13:55:44 +01:00
Sebastiaan van Stijn
69deeaa03d Merge pull request #49571 from thaJeztah/registry_improve_tests
registry: improve test-coverage, and some minor fixes
2025-03-04 13:16:55 +01:00
Sebastiaan van Stijn
00bd916203 libnetwork/resolvconf: Build: re-implement using new implementation
Re-implement the Build function using  the new implementation from
libnetwork/internal/resolvconf.

BuildKit is the only consumer of the Build function currently, and we
should consider either moving the internal package out of internal, or
to provide a more customized variant of Build that fits BuildKit's
needs (i.e., only patch content, but not write to a file).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 12:34:09 +01:00
Sebastiaan van Stijn
2f19577877 libnetwork/resolvconf: Build: align order with new implementation
The new resolvconf implementation in libnetwork/internal/resolvconf
uses a different order for "search" and puts it after the resolvers.

While this changes the checksum of the file, and thus would be potentially
detected as "user modified", we no longer use this function ourselves,
and BuildKit (which uses this function) only consumes the Content field,
and discards the Hash; https://github.com/moby/buildkit/blob/v0.20.0/executor/oci/resolvconf.go#L99-L103

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 12:26:30 +01:00
Sebastiaan van Stijn
03aeedcca9 libnetwork/resolvconf: update tests to use more correct values
The tests were depending on the implementation ignoring invalid
nameservers, as these should always be an IP-address, not a hostname.

Update the tests to use correct values, instead of codifying the
bad behavior.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 12:23:03 +01:00
Akihiro Suda
41fe41382e Merge pull request #49559 from thaJeztah/testutil_remove_isErrNotFoundSwarmClassic
testutil: remove isErrNotFoundSwarmClassic
2025-03-04 17:45:15 +09:00
Sebastiaan van Stijn
c34f8bbba3 integration/volume: setupTestVolume: minor cleanups and fixes
- rename the "client" argument to "apiClient" to prevent shadowing the client import.
- remove intermediate "mount" var, which shadowed an import
- remove debug logs for stdOut/stdErr
- update the defer to use the container test-utils package to fix unhandled error warnings.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 01:21:12 +01:00
Sebastiaan van Stijn
28bf578a40 integration/volume: TestRunMountImage: use test-util for container cleanup
update the defer to use the container test-utils package to fix unhandled
error warnings.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 01:18:19 +01:00
Sebastiaan van Stijn
e41eaf2c8d integration/volume: TestRunMountVolumeSubdir: remove some logs
Both stdout and stderr were already asserted further down, so any failure
would be printed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-04 01:17:44 +01:00
Sebastiaan van Stijn
2b9b239db0 Merge pull request #49570 from vvoland/golangci-is-alias
golangci-lint: enforce "is" alias for gotest.tools/v3/assert/cmp
2025-03-04 00:53:40 +01:00
Sebastiaan van Stijn
f1bec97dfe registry: use literal for empty slice
slightly more idiomatic

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 20:03:10 +01:00
Sebastiaan van Stijn
7b4e21e5d0 registry: fix typo in godoc
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 20:03:10 +01:00
Sebastiaan van Stijn
be9c4dd3c5 registry: TestNewIndexInfo: add more test-cases
- Add test-cases for IPv6 refs
- Add test-cases for validating the insecure-registries passed in the test

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 20:03:03 +01:00
Sebastiaan van Stijn
949afd933b registry: TestNewIndexInfo: assert all fields
Using DeepEquals showed that the test was missing differences between
nil-mirrors and empty-slice, in addition to mirrors being normalized
(the test only checked for the length).

While we should consider if we need an explicit empty slice (or if a
nil value would be appropriate), at least we now have a test to verify
the behavior.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 20:02:05 +01:00
Sebastiaan van Stijn
310d6d2fa5 registry: TestNewIndexInfo: use sub-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 20:00:56 +01:00
Sebastiaan van Stijn
50d17676e4 registry: TestParseRepositoryInfo: add test-cases for IPv6 refs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 20:00:51 +01:00
Sebastiaan van Stijn
328b808765 registry: TestParseRepositoryInfo: assert all index-info fields
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 19:56:54 +01:00
Sebastiaan van Stijn
d9634c3b28 registry: TestParseRepositoryInfo: use sub-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 19:38:54 +01:00
Sebastiaan van Stijn
e2a5220ec3 registry: remove makeServiceConfig test-utility
It was a very thin wrapper around newServiceConfig, and didn't save
any code needed; possibly even the reverse, as it was abstracting
what it did under the hood.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 19:38:49 +01:00
Paweł Gronowski
52419cf933 golangci-lint: enforce "is" alias for gotest.tools/v3/assert/cmp
We already have been following this convention - add a linter rule that
will help us follow that convention in future changes.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-03 19:11:49 +01:00
Paweł Gronowski
1c63f3983b volume/service: adjust "gotest.tools/v3/assert/cmp" import alias
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-03 19:11:46 +01:00
Paweł Gronowski
9766a446ae integration/network: adjust "gotest.tools/v3/assert/cmp" import alias
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-03 19:11:44 +01:00
Paweł Gronowski
c16fcdfc4b integration/image: adjust "gotest.tools/v3/assert/cmp" import alias
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-03 19:11:43 +01:00
Paweł Gronowski
6abe6a910a integration/container: adjust "gotest.tools/v3/assert/cmp" import alias
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-03 19:11:42 +01:00
Paweł Gronowski
22069f2431 integration-cli: adjust "gotest.tools/v3/assert/cmp" import alias
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-03 19:11:40 +01:00
Paweł Gronowski
605f02a59b distribution: adjust "gotest.tools/v3/assert/cmp" import alias
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-03 19:11:39 +01:00
Paweł Gronowski
75b86c47d9 daemon/logger/loggerutils: adjust "gotest.tools/v3/assert/cmp" import alias
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-03-03 19:11:37 +01:00
Sebastiaan van Stijn
59e6d1d214 registry: TestLoadInsecureRegistries: don't mutate emptyServiceConfig
This was not revealed in our tests, which only checked for the length
of the Mirror-slice, but when testing with DeepEquals, tests were failing
when all tests were run (but succeeded on individual tests). The problem
here is that some code can mutate the list of Mirrors and set it to `nil`
or an empty slice, resulting in other tests to fail.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 19:08:25 +01:00
Sebastiaan van Stijn
07be327aaa Merge pull request #49568 from thaJeztah/dismantle_ParseRepositoryInfo
registry: refactor to allow splitting out logic for CLI
2025-03-03 15:53:49 +01:00
Sebastiaan van Stijn
960a39bf2c Merge pull request #49567 from thaJeztah/deprecate_repositoryinfo_official
registry: deprecate RepositoryInfo.Official field
2025-03-03 15:52:43 +01:00
Sebastiaan van Stijn
b8b2400a5b Merge pull request #49512 from thaJeztah/portallocator_unexport
libnet/portallocator: un-export errors that were not used as sentinel  errors
2025-03-03 12:38:43 +01:00
Sebastiaan van Stijn
4c96df6550 Merge pull request #49549 from thaJeztah/cleanup_cluster_init
daemon/cluster: some cleanups in initialisation
2025-03-03 12:38:11 +01:00
Sebastiaan van Stijn
ca114a1851 Merge pull request #49544 from thaJeztah/fix_windows_errors
fix some errors for windows containers
2025-03-03 12:33:31 +01:00
Sebastiaan van Stijn
43f636a4e5 Merge pull request #49558 from thaJeztah/testutil_redundant_check
testutil/environment: Execution.Clean: remove redundant condition
2025-03-03 12:31:46 +01:00
Sebastiaan van Stijn
849f344ecc registry: split normalizing index name from validating
ValidateIndexName is used by the docker daemon CLI to validate options
passed through CLI flags and daemon.json. However, it also handled
normalizing the registry name ("index.docker.io" -> "docker.io").

This patch splits the normalization code to a separate function. It
is currently not exported, but could be considered in the future;
if we do so, we may want to look for a better place for that function
to not have it in the same package as the registry code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 10:16:44 +01:00
Sebastiaan van Stijn
fee40a9333 registry: create emptyServiceConfig without parsing
emptyServiceConfig is a default service-config for situations where
no config-file is available (e.g. when used in the CLI). If won't
have mirrors configured, but does have the default insecure registry
CIDRs for loopback interfaces configured.

Before this patch, this config was constructeed using the same code
that handled constructing the config with a config present, but this
involved parsing CIDR masks, and much more.

With this patch, the service config is constructed as a literal, making
it more transparent that it does not depend on any config or state.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 10:16:43 +01:00
Sebastiaan van Stijn
a3583b4b58 registry: newRepositoryInfo only check for official images for Docker Hub
RepositoryInfo.Official indicates whether the image repository
is an official (docker library official images) repository.

We only need to check this if the image-repository is on Docker Hub.

This patch renames the variable to make it more transparent that this
boolean is for the repository, and not to be confused for IndexInfo.Official,
which indicates if the _registry_ is the "Official" (Docker Hub) registry.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 10:16:43 +01:00
Sebastiaan van Stijn
08654b0b30 registry: deprecate RepositoryInfo.Official field
This field indicates whether a repository is an official image (Docker
Library / Docker Official Images). This information is deducted from the
image reference, and not used anywhere, other than in tests.

The `RepositoryInfo` and `IndexInfo` types were originally introduced in
568f86eb18, with their fields documented in
4fcb9ac40c.

At the time, the `Official` field was only used for `docker push` to produce
a custom error message if someone would attempt to push an official image
to docker hub (assuming nobody would be able to do so);
6870bde584/api/client/commands.go (L1184-L1194)

Before that commit, the condition for this error message was based on the
given image reference directly; b370acd679
b370acd679/commands.go (L421-L428)

This patch deprecates the field, because it's not used, and removes
tests related to it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-03-03 10:12:17 +01:00
Akihiro Suda
d86dd75948 Merge pull request #49563 from thaJeztah/graphdriver_noshadow
daemon/graphdriver: rename vars that shadowed
2025-03-03 10:51:36 +09:00
Akihiro Suda
a626620286 Merge pull request #49564 from thaJeztah/bump_containerd_2.0.3
vendor: github.com/containerd/containerd v2.0.3
2025-03-03 10:51:14 +09:00
Sebastiaan van Stijn
dbc9d56820 vendor: github.com/containerd/containerd v2.0.3
Relevant changes:

- Update remote content to break up writes to avoid grpc message size limits
- Move CDI device spec out of the OCI package
- Remove deprecated WithCDIDevices in oci spec opts

full diff: https://github.com/containerd/containerd/compare/v2.0.2...v2.0.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-28 22:11:49 +01:00
Sebastiaan van Stijn
15895d8ead daemon/graphdriver: rename vars that shadowed
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-28 21:36:09 +01:00
Sebastiaan van Stijn
41f781fab3 Merge pull request #49551 from thaJeztah/libcontainerd_less_stubbing
libcontainerd/local: remove unused code and arguments
2025-02-28 16:25:25 +01:00
Sebastiaan van Stijn
aa9817b0c5 testutil: remove isErrNotFoundSwarmClassic
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-27 22:03:08 +01:00
Sebastiaan van Stijn
0ab7d41f9e testutil/environment: Execution.Clean: remove redundant condition
It's either "not windows" or "windows" (and something else), so the second
condition doesn't have to check if it's windows.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-27 21:59:05 +01:00
Brian Goff
7194b508b6 Merge pull request #48638 from robmry/iptables-nft
Use iptables-nft in the dev container / CI
2025-02-27 12:03:14 -08:00
Sebastiaan van Stijn
ea3bb90773 Merge pull request #49547 from robmry/test_docker_ingress_jump
Check swarm's jump to DOCKER-INGRESS
2025-02-27 20:26:29 +01:00
Sebastiaan van Stijn
320db9d55d Merge pull request #49546 from thaJeztah/archiver_noshadow
builder/dockerfile: remove intermediate var that shadowed
2025-02-26 20:48:46 +01:00
Sebastiaan van Stijn
c1fceb0167 Merge pull request #49550 from thaJeztah/bump_docker_cli
Dockerfile: update docker CLI to v28.0.1, docker compose to v2.33.1
2025-02-26 20:45:40 +01:00
Sebastiaan van Stijn
b301c34b92 libcontainerd/local: remove arg-names for stubs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 19:00:20 +01:00
Sebastiaan van Stijn
12f89cc19b libcontainerd/local: NewClient: remove unused cli, stateDir, ns args
The "local" client does not use containerd, but implements the same interface,
many args are not used though, so remove these to make it more clear what's
actually in use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 19:00:20 +01:00
Sebastiaan van Stijn
620f26e1e3 libcontainerd/local: client.createWindows: remove unused runtimeOptions
The "local" client does not use containerd, but implements the same interface,
many args are not used though, so remove these to make it more clear what's
actually in use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 19:00:20 +01:00
Sebastiaan van Stijn
9c4e10126e libcontainerd/local: client.NewContainer: use early return
Also remove an intermediate var, and remove a "WithError" in favor of
adding the error field to the "WithFields".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 19:00:20 +01:00
Sebastiaan van Stijn
7c1a2301f0 libcontainerd/local: client.extractResourcesFromSpec: use early return
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 19:00:20 +01:00
Sebastiaan van Stijn
fc462d699a Dockerfile: update compose to v2.33.1
Update the compose cli plugin used in the dev-container

full diff: https://github.com/docker/compose/compare/v2.32.4...v2.33,1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 15:50:49 +01:00
Sebastiaan van Stijn
855563fc43 Dockerfile: update docker CLI to v28.0.1
Update the Docker CLI used in the dev-container

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 15:47:49 +01:00
Rob Murray
ab7305c85a Check swarm's jump to DOCKER-INGRESS
Related to commit 558da63 (Jump to DOCKER-INGRESS from
DOCKER-FORWARD).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-26 14:27:57 +00:00
Rob Murray
be14d9148c Make integration/service/network_test.go Linux-only
All the tests in it had skips for Windows. The move makes it possible
to add a test that uses L3Segment.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-26 14:27:57 +00:00
Sebastiaan van Stijn
cfc562c358 daemon/cluster: create "state" and "runtime-dir" closer to where used
Don't create these paths until starting the cluster; they're not used
before this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 15:25:00 +01:00
Sebastiaan van Stijn
ef4f4d845d daemon/cluster: rename Cluster.root to Cluster.stateDir
This matches the name used by Swarm in swarmnode.Config. While updating,
also remove code from Cluster.Start that replicated the logic to construct
the path, in favor of using the `stateDir` field.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 15:25:00 +01:00
Sebastiaan van Stijn
4d3d4bbeeb daemon/cluster: remove Config.WatchStream and move to constructor
The WatchStream field was set as configuration option in cmd/dockerd,
but not configurable. Move creating the stream to the constructor,
and remove the configuration option. This field was introduced in
59d45c384a, at which time the cmd/dockerd
code needed direct access to the stream, but a later refactor in
05346355db introduced an accessor
(GetWatchStream) for this.

The cluster.Config struct is only used internally, it's unlikely
for any external project to use this, so skipping deprecation.

With this change, the cmd/dockerd package no longer has a direct
import of swarmkit.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-26 15:24:55 +01:00
Sebastiaan van Stijn
bbd0a17ccc Merge pull request #49538 from robmry/docker_ingress
Jump to DOCKER-INGRESS from DOCKER-FORWARD
2025-02-26 10:52:05 +01:00
Sebastiaan van Stijn
cdbb62394c builder/dockerfile: remove intermediate var that shadowed
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-25 20:23:19 +01:00
Rob Murray
8ae4858af4 Merge pull request #49545 from robmry/revert_check-config_ipset
Revert "contrib/check-config: add ipset related flags"
2025-02-25 18:46:57 +00:00
Rob Murray
18143632f7 Revert "contrib/check-config: add ipset related flags"
This reverts commit ccdfac5328.

Since commit 76417bf, the kernel ip_set module (and friends) are
not required.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-25 17:20:31 +00:00
Rob Murray
558da63444 Jump to DOCKER-INGRESS from DOCKER-FORWARD
A jump to DOCKER-INGRESS chain is only created when Swarm needs
it. That's always after jumps to DOCKER-USER and DOCKER-FORWARD
have been inserted at the top of the FORWARD chain. The
DOCKER-INGRESS rule needs to be between those two other jumps.

Placing the jump to DOCKER-INGRESS at the top of the DOCKER-FORWARD
chain puts it in the right place, without needing to shuffle any
other rules around when it's added.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-25 17:17:36 +00:00
Sebastiaan van Stijn
f92fdfecbf Merge pull request #49530 from robmry/disable_ip_set
Drop the use of ipset
2025-02-25 17:55:31 +01:00
Sebastiaan van Stijn
fdd534d2ca libcontainerd: windows: return errdefs type for pausing
Noticed this log in CI on Windows,  which wasn't clear if it was an error
in Windows or in Docker;

    2025-02-25T03:21:35.9273942Z [Error] Handler for POST /v1.48/containers/1713bc845f9bde79aa0017c16613fbfc8810b3272b31dbb2535d3fb1a3550f9c/pause returned error: cannot pause container 1713bc845f9bde79aa0017c16613fbfc8810b3272b31dbb2535d3fb1a3550f9c: Unimplemented: not implemented

Looks like it's a feature that's not implemented when using process-isolation,
so updating the error-message to make it more identifiable as an error
produced by us.

I kept the type to be a "not implemented", which will be converted to a
501 HTTP status (so still logged as error); alternatively, we could make
this a "invalid parameter".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-25 17:53:25 +01:00
Sebastiaan van Stijn
60782e6d39 container: fix some errors on Windows
While going through some logs from CI, I noticed this log-entry on Windows,
produced as part of a test;

    2025-02-25T03:23:17.6584227Z [Error] Handler for POST /v1.48/containers/b47b1e632188426d6d42a4be04f9a3cc1eca40cfed9536d277011052af0b04f5/update returned error: Cannot update container b47b1e632188426d6d42a4be04f9a3cc1eca40cfed9536d277011052af0b04f5: Restart policy cannot be updated because AutoRemove is enabled for the container

While updating is an error for the user, it's not an error in the daemon,
so we should return the correct error-type (and avoid logging it as an
error in daemon logs).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-25 17:53:25 +01:00
Paweł Gronowski
88bc9a3d0f Merge pull request #49535 from vvoland/c8d-fixcontentsize
c8d/manifests: Fix Content size including missing content
2025-02-25 15:54:42 +00:00
Rob Murray
76417bf763 Don't use ipset
Commit 0546d90 introduced the use of ipset to reduce the number
of rules that need to be processed per-packet, and make the code
a bit simpler.

But, docker's used on embedded kernels compiled without support
for ipset, so the change is too disruptive.

Replace the two ipset rules with a new chain that writes out the
rule's actions long-hand. So ..

This rule:
  -A FORWARD -m set --match-set docker-ext-bridges-v4 dst \
    -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
Is transformed into a per-bridge rule in new chain DOCKER-CT:
  -A DOCKER-FORWARD -j DOCKER-CT
  -A DOCKER-CT -o docker0 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
  -A DOCKER-CT -o bridge1 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT

And:
  -A FORWARD -m set --match-set docker-ext-bridges-v4 dst -j DOCKER
Is transformed into a per-bridge rule in new chain DOCKER-BRIDGE:
  -A DOCKER-FORWARD -j DOCKER-BRIDGE
  -A DOCKER-BRIDGE -o docker0 -j DOCKER
  -A DOCKER-BRIDGE -o bridge1 -j DOCKER

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-25 15:24:25 +00:00
Paweł Gronowski
c35159ed7d c8d/manifests: Fix Content size including missing content
Content size should only include size of content that is present in the
local store.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-25 15:14:51 +01:00
Sebastiaan van Stijn
05104991bc Merge pull request #49533 from vvoland/c8d-inspectlist-indeximg
c8d/list&inspect: Better handle images without any platform blobs available locally
2025-02-25 15:11:55 +01:00
Rob Murray
0274c630c9 Merge pull request #49518 from robmry/docker_forward_chain
Add chain DOCKER-FORWARD
2025-02-25 11:25:55 +00:00
Rob Murray
f344ab14b3 Merge pull request #49525 from robmry/startup_ip6_disabled
Fix daemon startup on a no-IPv6 host
2025-02-24 20:51:10 +00:00
Rob Murray
cd0ceff232 Merge pull request #49521 from robmry/swarm_net_from_config
Fix --config-from creation of swarm networks
2025-02-24 20:50:37 +00:00
Rob Murray
468c2c814d Fix swarm network creation from a config-only network
Creating a swarm network from a config-only network failed
because the new EnableIPv4 wasn't validated/propagated
correctly.

So:
- Always initialise EnableIPv4 to true, including for a config
  only network, and on load from the store.
- Treat enableIPv4=true as the no-overridden state when checking
  params for a config-from network.
- Propagate settings from the config 'Network' objects attributes
  to its generic options, because the network driver only sees
  generic options.
  - This was happening already for Network.internal, after the
    config-only network options were processed. Move that to
    'applyConfigurationTo'.
  - Add enableIPv4/enableIpv6 - enableIPv6 will normaly be present
    anyway. But, for a network created pre-28.x and restored from
    the store, there was no entry for 'netlabel.EnableIpv4'.
- Extend TestSwarmScopedNetFromConfig to start a service and
  check it's ok.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-24 17:48:23 +00:00
Rob Murray
8e6cc4ac48 Fix swarm net validation for config-from networks
For swarm networks, Controller.NewNetwork is called to validate
network config ... nothing gets created, but ManagerRedirectError
is returned if the config is ok - then swarm does its own thing.

So, for a --config-from network, merge config before checking
whether it'll have IPv4 enabled.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-24 17:48:23 +00:00
Rob Murray
8cc4d1d4a2 Fix daemon startup on a no-IPv6 host
With ip6tables enabled (by default), the daemon should start on a
host with IPv6 disabled - then error if IPv6 network creation is
attempted.

That regressed in commit 255fff4 - so, only try to set up network
isolation rules for a network if it's IPv6-enabled.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-24 17:41:44 +00:00
Rob Murray
341cafa611 Test with a drop rule appended to filter-FORWARD
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-24 17:09:09 +00:00
Rob Murray
984a610a21 Add chain DOCKER-FORWARD
In 28.0.0, Docker appended to the FORWARD chain - breaking other
applications that had appended their own rules that needed to execute
after Docker's rules.

Move most of Docker's rules out of the filter-FORWARD chain into a
new DOCKER-FORWARD chain, so that Docker can append to DOCKER-FORWARD
without affecting the order of rules in the FORWARD chain.

After daemon startup inserts jumps to DOCKER-USER and DOCKER-FORWARD,
the bridge driver will not touch the FORWARD chain again. DOCKER-INGRESS
is still added to the FORWARD chain, if used, as it was in 27.x and
earlier.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-24 17:09:09 +00:00
Paweł Gronowski
21582b84fb c8d/list: Fix empty Manifests for some images
Fix empty `Manifests` field for multi-platform images that have no
platform blobs available locally.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-24 16:52:08 +01:00
Paweł Gronowski
6b1b170708 c8d/inspect: Fix image not found error for index-only image
Fix not being able to inspect images that are OCI-index only (like
`tianon/empty`) or a real multi-platform image which has no platform
blobs available locally.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-24 16:52:05 +01:00
Sebastiaan van Stijn
5cf20fe12e Merge pull request #49531 from thaJeztah/bump_cdi
vendor: tags.cncf.io/container-device-interface v0.8.1
2025-02-24 15:37:33 +01:00
Sebastiaan van Stijn
adb2ba0eab Merge pull request #49522 from robmry/doc_default_bridge
Mark default-bridge-only opts in --help and manpage
2025-02-24 15:30:33 +01:00
Rob Murray
33244704ef Merge pull request #49524 from robmry/missing_ip_set_errors
Better error message for missing ip_set kernel modules
2025-02-24 14:29:35 +00:00
Sebastiaan van Stijn
5ced8fd377 vendor: tags.cncf.io/container-device-interface v0.8.1
- pkg/cdi: don't crash if we fail to create fsnotify watch

full diff: https://github.com/cncf-tags/container-device-interface/compare/v0.8.0...v0.8.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-24 14:00:55 +01:00
Rob Murray
a92d20bcc4 Better error message for missing ip_set kernel modules
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-24 12:18:36 +00:00
Sebastiaan van Stijn
0de01f700d Merge pull request #49520 from robmry/inspect_gw6_not_cidr
Fix network inspect IPv6 gateway address format
2025-02-24 11:53:37 +01:00
Paweł Gronowski
a5008d4a41 Merge pull request #49526 from akerouanton/fix-setsockopt-i386
libnet/d/bridge: fix compilation on i386
2025-02-24 09:26:56 +00:00
Albin Kerouanton
73f2a5336d libnet/d/bridge: fix compilation on i386
On i386, Linux doesn't provide direct socket syscall but instead
multiplexes them through the socketcall syscall (see `man 2 socketcall`).
This commit fixes compilation for i386 by wrapping the offending syscall
in a new function that uses the socketcall syscall on i386, and
the `setsockopt` syscall on other archs.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-02-23 12:01:59 +01:00
Rob Murray
013c43fb56 Mark default-bridge-only opts in --help and manpage
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-22 20:21:23 +00:00
Rob Murray
3cf4ff971d Fix network inspect IPv6 gateway address format
When an IPv6 network is first created with no specific IPAM config,
network inspect adds a CIDR range to the gateway address. After the
daemon has been restarted, it's just a plain address.

Once the daaemon's been restated, "info" becomes "config", and the
address is reported correctly from "config".

Make the IPv6 code to report the gateway from "info" use net.IPNet.IP
instead of the whole net.IPNet - like the IPv4 code.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-22 12:24:57 +00:00
Sebastiaan van Stijn
a2a6bf51fa Merge pull request #49514 from AkihiroSuda/fix-49499
Fix v28 regression `protocol "tcp" is not supported by the RootlessKit port driver "slirp4netns"`
2025-02-21 20:47:14 +01:00
Albin Kerouanton
459686bbea Merge pull request #49510 from neersighted/check-config_ipset
contrib/check-config: add ipset related flags
2025-02-21 10:15:42 +01:00
Akihiro Suda
501ce33bab Fix v28 regression protocol "tcp" is not supported by the RootlessKit port driver "slirp4netns"
`DOCKERD_ROOTLESS_ROOTLESSKIT_PORT_DRIVER=slirp4netns` was broken
since f1e0746c08 (PR 48132, v28).

Fix issue 49499

ref: https://github.com/rootless-containers/rootlesskit/blob/v2.3.2/cmd/rootlesskit-docker-proxy/main.go#L196-L204
(used until Docker v27)

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-02-21 13:25:23 +09:00
Sebastiaan van Stijn
f0f008b87f Merge pull request #49507 from akerouanton/fix-restart-port-already-in-use
daemon: handleContainerExit: ignore networking errors
2025-02-21 00:07:08 +01:00
Sebastiaan van Stijn
c37690b98e libnet/portallocator: un-export errors that were not used as sentinel errors
The `ErrPortAlreadyAllocated` error was introduced in ffd68badc0,
and at the time used as sentinel error in the bridge driver. It was later
integrated into libnetwork ([libnetwork@672ced7]), and brought back when
libnetwork was integrated in v1.7.0; 272f8cd4bc
After libnetwork was integrated, the error was unused as sentinel error,
except for locally inside the package as part of a test;

    git rev-parse --verify HEAD
    496bc46c88

    git grep '\.ErrPortAlreadyAllocated'

Which is still the case Today;

    git describe --tags --match="v[0-9]*" HEAD
    v28.0.0
    git rev-parse --verify HEAD
    af898abe44
    git grep '\.ErrPortAlreadyAllocated'

Same for the `ErrAllPortsAllocated` (added in 739d124480)
and `ErrUnknownProtocol` (added in 303ed3c830)
errors, which were never used as sentinel errors, and still aren't;

    git grep '\.ErrAllPortsAllocated'
    git grep '\.ErrUnknownProtocol'
    vendor/github.com/moby/buildkit/client/llb/source.go:   if errors.Is(err, gitutil.ErrUnknownProtocol) {

This patch;

- un-exports these errors as they are not used as sentinel errors
- strips down the `ErrPortAlreadyAllocated`, removing the methods that
  were added, but never used.
- removes the `newErrPortAlreadyAllocated` constructor
- renames `ErrPortAlreadyAllocated` to `alreadyAllocatedErr` to follow
  go conventions.

[libnetwork@672ced7]: c0474b6438

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-20 23:58:44 +01:00
Bjorn Neergaard
ccdfac5328 contrib/check-config: add ipset related flags
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2025-02-20 13:28:15 -07:00
Albin Kerouanton
ac8b4e3e75 daemon: handleContainerExit: ignore networking errors
Prior to commit fe856b9, containers' network sandbox and interfaces were
created before the containerd task. Now, it's created after.

If this step fails, the containerd task is forcefully deleted, and an
event is sent to the c8d event monitor, which triggers `handleContainerExit`.
Then this method tries to restart the faulty container.

This leads to containers with a published port already in use to be
stuck in a tight restart loop (if they're started with
`--restart=always`) until the port is available. This is needlessly
spamming the daemon logs.

Prior to that commit, a published port already in use wouldn't trigger
the restart process.

This commit adds a check to `handleContainerExit` to ignore exit events
if the latest container error is related to networking setup.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-02-20 18:03:20 +01:00
Paweł Gronowski
af898abe44 Merge pull request #49495 from vvoland/update-buildkit
vendor: github.com/moby/buildkit v0.20.0
2025-02-19 21:53:46 +00:00
Paweł Gronowski
d67f035d31 vendor: github.com/moby/buildkit v0.20.0
full diff: https://github.com/moby/buildkit/compare/v0.20.0-rc3...v0.20.0

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-19 21:14:36 +01:00
Paweł Gronowski
00ab386b5a Merge pull request #49491 from vvoland/update-buildkit
vendor: github.com/moby/buildkit v0.20.0-rc3
2025-02-18 22:00:10 +00:00
CrazyMax
1fde8c4615 builder-next: fix cdi manager
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-18 21:48:01 +01:00
Paweł Gronowski
cde9f0752e vendor: github.com/moby/buildkit v0.20.0-rc3
full diff: https://github.com/moby/buildkit/compare/v0.20.0-rc2...v0.20.0-rc3

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-18 21:47:59 +01:00
Paweł Gronowski
89e1429b65 Merge pull request #49490 from thaJeztah/dockerfile_linting
Dockerfile: fix linting warnings
2025-02-18 17:49:09 +00:00
Sebastiaan van Stijn
b2b55903d0 Dockerfile: fix linting warnings
The 'as' keyword should match the case of the 'from' keyword
    FromAsCasing: 'as' and 'FROM' keywords' casing do not match
    More info: https://docs.docker.com/go/dockerfile/rule/from-as-casing/

    Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior
    RedundantTargetPlatform: Setting platform to predefined $TARGETPLATFORM in FROM is redundant as this is the default behavior
    More info: https://docs.docker.com/go/dockerfile/rule/redundant-target-platform/

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-18 18:05:03 +01:00
Rob Murray
cfc049c938 Use iptables-nft in the dev container / CI
Replaces iptables-legacy.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-18 16:14:48 +00:00
Sebastiaan van Stijn
62bc597990 Merge pull request #49480 from thaJeztah/docs_api_1.48
docs/api: add documentation for API v1.48
2025-02-18 13:57:08 +01:00
Paweł Gronowski
670cd81423 Merge pull request #49485 from vvoland/c8d-list-panic
c8d/list: Fix panic when listing images
2025-02-18 12:48:26 +00:00
Sebastiaan van Stijn
a3628f3f8e docs/api: add documentation for API v1.48
API version used by the v28.0.0 release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-18 13:35:34 +01:00
Sebastiaan van Stijn
5eab938af8 Merge pull request #49477 from thaJeztah/swagger_container_examples
api/swagger: remove custom example from /containers/json endpoint
2025-02-18 13:33:06 +01:00
Sebastiaan van Stijn
794cec1c1f Merge pull request #49478 from thaJeztah/swagger_container_examples_step2
api/swagger: remove custom example from /containers/{id}/json endpoint
2025-02-18 12:47:02 +01:00
Paweł Gronowski
9eccc20a17 c8d/list: Fix panic when listing images
imageSummary erroneously returned a nil multi-platform summary in case
of a multi-platform image, which the OCI index is available locally, but
none of its platform manifest is.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-18 12:23:50 +01:00
Paweł Gronowski
4e97729f14 c8d/list: Test with SharedSize = true
For additional coverage

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-18 12:23:47 +01:00
Sebastiaan van Stijn
322eddfb41 api/swagger: remove custom example from /containers/{id}/json endpoint
Create a ContainerInspectResponse definition and Use the example fields
as defined in the definition; add additional examples in that definition
where missing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-18 11:58:10 +01:00
Sebastiaan van Stijn
60539d0956 api/swagger: remove custom example from /containers/json endpoint
Use the example fields as defined in the ContainerSummary definition,
and add additional examples in that definition where missing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-18 11:45:57 +01:00
Sebastiaan van Stijn
89291c57f2 Merge pull request #49484 from thaJeztah/fix_fatcontext_linting
golangci-lint: ignore "nested context" (fatcontext) in tests
2025-02-18 10:55:36 +01:00
Sebastiaan van Stijn
35e615167b Merge pull request #49479 from thaJeztah/swagger_exec_nits
api/swagger: inline Exec example values
2025-02-18 10:53:26 +01:00
Sebastiaan van Stijn
119b52f302 golangci-lint: ignore "nested context" (fatcontext) in tests
Commit 15fbd67407 updated golangci-lint,
which came with an updated version of the "fatcontext" linter, causing
linting to fail.

We use these to set up spans for our tests; suppress these through the
golangci-lint config (instead of linline "//nolint" comments) so that
we can revisit this approach and see if there's a more idiomatic way.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-18 10:20:00 +01:00
Akihiro Suda
28dc5a82b3 Merge pull request #49481 from thaJeztah/bump_golangci_lint
Dockerfile: update golangci-lint to v1.64.5
2025-02-18 17:14:28 +09:00
Sebastiaan van Stijn
15fbd67407 Dockerfile: update golangci-lint to v1.64.5
Adds go1.24 support

full diff: https://github.com/golangci/golangci-lint/compare/v1.63.4...v1.64.5
changelog: https://golangci-lint.run/product/changelog/#v1645

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-17 22:43:18 +01:00
Sebastiaan van Stijn
7b6c3ebe7b api/swagger: inline Exec example values
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-17 21:55:14 +01:00
Sebastiaan van Stijn
57d4d23825 Merge pull request #49468 from thaJeztah/update_branch_status
project: update status of branches
2025-02-17 11:52:00 +01:00
Sebastiaan van Stijn
8b2f6fba4a Merge pull request #49471 from thaJeztah/container_cleanups
container: Container.StopSignal: fix handling of invalid signals and cleanup tests
2025-02-17 11:39:15 +01:00
Paweł Gronowski
54c43a7c93 Merge pull request #49472 from thaJeztah/splunk_nits
daemon/logger: assorted minor (linting) fixes and cleanups
2025-02-17 10:34:47 +00:00
Sebastiaan van Stijn
2fc90096bf project: update status of branches
- Mirantis now ships 25.0 for MCR (23.0 reaching end of support)
- Microsoft packages 27.x
- 26.1 is no longer maintained
- Other branches no longer maintained

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-17 11:33:30 +01:00
Sebastiaan van Stijn
bd92f2bb92 daemon/logger/splunk: New(): combine switches for format validation
The format was validated twice; first just to validate, then to construct
the correct format-wrapper, or error for an unknown format.

This patch combines both switches to a single one.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 20:52:49 +01:00
Sebastiaan van Stijn
eac39ffdb8 daemon/logger/splunk: remove some intermediate variables
Remove intermediate variables or move them closer to where they're used,
as this function has various early returns on errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 20:44:11 +01:00
Sebastiaan van Stijn
9bb3900c30 daemon/logger: Info.ExtraAttributes: make env-var handling conditional
- Move some variables inside the "if" branch to make it clear they're only
  used locally, and not outside of the branch.
- Skip handling "env" and "env-regex" options if there are no env-vars
  to handle.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 20:04:08 +01:00
Sebastiaan van Stijn
cbbff10b01 daemon/logger: use consistent name for "extra attributes"
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 19:44:31 +01:00
Sebastiaan van Stijn
ba559c4f12 daemon/logger/fluentd: fix minor (linting) issues
- Rename variables that collided with imports
- Make capturing interval.Milliseconds conditional as it would trip some
  linters for using a potential "zero" value.
- Use WithFields instead of chainging multiple "WithField" calls for logging.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 19:43:31 +01:00
Sebastiaan van Stijn
b9e7e82b66 daemon/logger/splunk: plunkLogger.postMessages(): improve logs
- No need to use `fmt.Errorf` to format the error message
- Use structured logs, and include the message that failed to be sent
  in a `message` field.
- When failing to marshal the message, log an error outlining what happened
  instead of logging the bare error.
- Move the `messagesLen` variable closer to where it's used, putting the
  context handling first as a reminder that we may want to pass a context
  through.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 19:42:58 +01:00
Sebastiaan van Stijn
2f82cbb5f8 daemon/logger/splunk: suppress some unhandled errors
Also add a commend based on [`ensureReaderClosed`][1] to outline why we're
copying.

[1]: 5cc3f1dab8/client/request.go (L313-L325)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 19:42:58 +01:00
Sebastiaan van Stijn
f049d0c66b daemon/logger/splunk: don't defer in a loop
This is mostly to silences some linters, as we're returning immediately
after, so no looping would happen, but we don't need a defer here either
for the same reason, so let's just remove it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 19:42:57 +01:00
Sebastiaan van Stijn
0d938b6bb3 daemon/logger/splunk: rename var that shadowed import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 19:42:57 +01:00
Sebastiaan van Stijn
529a56d31a container: Container.StopSignal: fix handling of invalid signals
Commit 0e50d946a2 introduced a feature to
allow a custom stop-signal to be set. As part of this, existing code to
parse the signal was extracted to `signal.ParseSignal()`, which accepts
a string either containing a numeric value or a named signal.

When failing to parse the given signal, it returns an error and a magic
"-1" signal. The changes in 0e50d946a2 used
the error when creating a container, but for existing container configs,
it would ignore the error and instead check if the signal was "0", in
which case it would fall back to use the default stop-signal (SIGTERM).

Given that  `signal.ParseSignal()` returns "-1" (not "0") for invalid
signals, this would result in the failure going undetected and "-1"
being used instead of the intended default (SIGTERM).

In practice, this issues would unlikely be encountered, as custom signals
are validated when creating the container, but it would be possible for
an image to contain an invalid signal, which would be used by the container
as default.

This patch updates the logic to only use the custom value if no error is
produced and a non-zero, positive signal is returned.

A test-case was added that would fail before this patch:

    go test -v -run TestContainerStopSignal
    === RUN   TestContainerStopSignal
        container_test.go:34: assertion failed: signal -1 (s syscall.Signal) != terminated (defaultStopSignal syscall.Signal)
    --- FAIL: TestContainerStopSignal (0.00s)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 18:55:03 +01:00
Sebastiaan van Stijn
ef0fe1ac00 container: define defaultStopSignal as a syscall.Signal
"SIGTERM" is defined both for Windows and Linux, so we can define the
signal to use as a syscall.Signal, instead of parsing it from a string
whenever we need to use the default.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 18:29:35 +01:00
Sebastiaan van Stijn
0a4c4c9e82 container: some cleanups in view tests
- use t.TempDir() instead of TestMain creating a directory to make
  tests self-contained.
- fix some unhandled errors, and missing assertions for error-types
- assert with gotest.tools, but kept the Benchmark tests as-is for now,
  to make sure gotest.tools doesn't impact the results.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 16:43:53 +01:00
Sebastiaan van Stijn
49f2320bc7 container: some cleanups in tests
- use t.TempDir()
- use t.Name() instead of hard-coding name
- assert with gotest.tools
- fix some unhandled errors

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 16:43:53 +01:00
Sebastiaan van Stijn
07aa4d96ea container: TestReplaceAndAppendEnvVars: assert with gotest.tools
Assert the actual results match the expected one, which should make the
test more complete, and reduces some noise by removing a `t.Log`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 16:43:52 +01:00
Sebastiaan van Stijn
0914e97df2 container: rename test file
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-15 16:43:52 +01:00
Sebastiaan van Stijn
5cc3f1dab8 Merge pull request #49470 from vvoland/c8d-pull-panic
c8d/progress: Fix panic when pulling some images
2025-02-14 19:15:17 +01:00
Paweł Gronowski
a200675420 Merge pull request #49469 from jsternberg/fix-container-image-manifest-view
container: ensure image manifest is deep copied from the container into the snapshot
2025-02-14 17:37:53 +00:00
Paweł Gronowski
9bcac6d573 c8d/progress: Fix panic when pulling some images
Pulling some images that share the same content blob but have different chain
IDs caused a panic:

```
panic: runtime error: slice bounds out of range [1:0]

goroutine 318661 [running]:
github.com/docker/docker/daemon/containerd.(*pullProgress).UpdateProgress(0x400fd02d70, {0xaaaada2fda38, 0x400fd02e10}, 0x4019d38810, {0xaaaada2d1640, 0x4018c94600}, {0x0?, 0x0?, 0xaaaadb7c7200?})
	/root/build-deb/engine/daemon/containerd/progress.go:232 +0xd84
github.com/docker/docker/daemon/containerd.(*jobs).showProgress.func1()
	/root/build-deb/engine/daemon/containerd/progress.go:55 +0x144
created by github.com/docker/docker/daemon/containerd.(*jobs).showProgress in goroutine 318659
	/root/build-deb/engine/daemon/containerd/progress.go:48 +0x128
```

The panic was caused by attempting to remove the same committed
layer multiple times from the `p.layers` slice.

This occurred because, in such images, multiple snapshots matched the
same layer by digest rather than by the full layer chain and layer removal
was done by index, leading to repeated deletions at the same index.

This commit:
- Selects a specific snapshot to ensure only one removal per layer.
- Changes snapshot matching to compare the full layer chain instead of
  just the layer digest.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-14 17:52:02 +01:00
Sebastiaan van Stijn
9b32baf9db Merge pull request #49467 from robmry/no_iptables_rules_when_disabled
Don't create iptables rules when iptables is disabled
2025-02-14 17:31:53 +01:00
Sebastiaan van Stijn
5af7c47f0e Merge pull request #49420 from thaJeztah/client_remove_serverResponse
client: remove serverResponse and use http.Response directly
2025-02-14 16:40:38 +01:00
Jonathan A. Sternberg
acc4d45278 container: ensure image manifest is deep copied from the container into the snapshot
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-02-14 09:29:50 -06:00
Sebastiaan van Stijn
46c60aa239 Merge pull request #49462 from tonistiigi/buildkit-v0.20.0-rc2
vendor: update buildkit to v0.20.0-rc2
2025-02-14 16:09:41 +01:00
Sebastiaan van Stijn
f106ec122b Merge pull request #49466 from vvoland/client-funcopts
client: Change `ImageHistory`, `ImageLoad` and `ImageSave` to use variadic functional options
2025-02-14 16:09:06 +01:00
Sebastiaan van Stijn
bd409fc882 Merge pull request #49418 from thaJeztah/daemon_structured_logs
daemon: use structured logs for printing reloaded config, move to cli
2025-02-14 15:41:48 +01:00
Paweł Gronowski
903ba2f487 client: Move opts to separate files
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-14 14:45:08 +01:00
Paweł Gronowski
b9319f64ed client: Change ImageSave to use functional options
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-14 14:25:39 +01:00
Paweł Gronowski
ae4c688fd8 client: Change ImageLoad to use functional options
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-14 14:25:37 +01:00
Paweł Gronowski
85808a6abf client: Change ImageHistory to use functional options
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-14 13:55:30 +01:00
Rob Murray
5719e8edf9 Don't create iptables rules when iptables is disabled
New iptables rules were added by:
- commit 27adcd5 (libnet/d/bridge: port mappings: drop direct-access
  when gw_mode=nat)
- commit d216084 (libnet/d/bridge: drop remote connections to port
  mapped on lo)

But they're added even when iptables=false or ip6tables=false in daemon
config.

So, group those rules with the other per-port rules, behind a config
check.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-14 12:55:12 +00:00
Paweł Gronowski
068aa86c23 client: Group deprecated functions into ImageAPIClientDeprecated
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-14 13:55:07 +01:00
Sebastiaan van Stijn
47ca352b0d vendor: github.com/opencontainers/runc v1.2.5, cyphar/filepath-securejoin v0.4.1
Changes in runc code are not impacting code we use;

- libcontainer/utils.MkdirAllInRootOpen is not used
- libcontainer/utils.MkdirAllInRoot is not used

Similarly, while filepath-securejoin is imported, the functions using it
in runc (cgroups.FindCgroupMountpoint, are not used in our codebase, so
these changes don't affect our code; `tryDefaultPath` uses securejoin,
which is used by `FindCgroupMountpoint`, but not used in our codebase.

diffs:

- https://github.com/opencontainers/runc/compare/v1.2.4...v1.2.5
- https://github.com/cyphar/filepath-securejoin/compare/v0.3.5...v0.4.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-14 13:04:45 +01:00
Sebastiaan van Stijn
eed190460f Merge pull request #49464 from thaJeztah/bump_runc_binary_1.2.5
Dockerfile: update runc binary to v1.2.5
2025-02-14 12:25:31 +01:00
Sebastiaan van Stijn
d1c6550f71 daemon: use structured logs for printing reloaded config, move to cli
- Move logging out of config.Reload and daemon.Reload itself, as it was not
  the right place to know whether it was a "signal" that triggered the reload.
- Use Daemon.Config() to get the new config after reloading. This returns an
  immutable copy of the daemon's config, so we can redact fields without having
  to use an ad-hoc struct to shadow the underlying fields.
- Use structured logs for logging config reload events.

Before this (plain text):

    INFO[2025-02-08T12:13:53.389649297Z] Got signal to reload configuration, reloading from: /etc/docker/daemon.json
    INFO[2025-02-08T12:30:34.857691260Z] Reloaded configuration: {"pidfile":"/var/run/docker.pid","data-root":"/var/lib/docker","exec-root":"/var/run/docker","group":"docker","max-concurrent-downloads":3,"max-concurrent-uploads":5,"max-download-attempts":5,"shutdown-timeout":15,"hosts":["unix:///var/run/docker.sock"],"log-level":"info","log-format":"text","swarm-default-advertise-addr":"","swarm-raft-heartbeat-tick":0,"swarm-raft-election-tick":0,"metrics-addr":"","host-gateway-ips":[""],"log-driver":"json-file","mtu":1500,"ip":"0.0.0.0","icc":true,"iptables":true,"ip6tables":true,"ip-forward":true,"ip-masq":true,"userland-proxy":true,"userland-proxy-path":"/usr/local/bin/docker-proxy","default-address-pools":{"Values":null},"network-control-plane-mtu":1500,"experimental":false,"containerd":"/var/run/docker/containerd/containerd.sock","features":{"containerd-snapshotter":false},"builder":{"GC":{},"Entitlements":{}},"containerd-namespace":"moby","containerd-plugin-namespace":"plugins.moby","default-runtime":"runc","runtimes":{"crun":{"path":"/usr/local/bin/crun"}},"seccomp-profile":"builtin","default-shm-size":67108864,"default-ipc-mode":"private","default-cgroupns-mode":"private","resolv-conf":"/etc/resolv.conf","proxies":{}}

Before this (JSON logs):

    {"level":"info","msg":"Reloaded configuration: {\"pidfile\":\"/var/run/docker.pid\",\"data-root\":\"/var/lib/docker\",\"exec-root\":\"/var/run/docker\",\"group\":\"docker\",\"max-concurrent-downloads\":3,\"max-concurrent-uploads\":5,\"max-download-attempts\":5,\"shutdown-timeout\":15,\"hosts\":[\"unix:///var/run/docker.sock\"],\"log-level\":\"info\",\"log-format\":\"json\",\"swarm-default-advertise-addr\":\"\",\"swarm-raft-heartbeat-tick\":0,\"swarm-raft-election-tick\":0,\"metrics-addr\":\"\",\"host-gateway-ips\":[\"\"],\"log-driver\":\"json-file\",\"mtu\":1500,\"ip\":\"0.0.0.0\",\"icc\":true,\"iptables\":true,\"ip6tables\":true,\"ip-forward\":true,\"ip-masq\":true,\"userland-proxy\":true,\"userland-proxy-path\":\"/usr/local/bin/docker-proxy\",\"default-address-pools\":{\"Values\":null},\"network-control-plane-mtu\":1500,\"experimental\":false,\"containerd\":\"/var/run/docker/containerd/containerd.sock\",\"features\":{\"containerd-snapshotter\":false},\"builder\":{\"GC\":{},\"Entitlements\":{}},\"containerd-namespace\":\"moby\",\"containerd-plugin-namespace\":\"plugins.moby\",\"default-runtime\":\"runc\",\"runtimes\":{\"crun\":{\"path\":\"/usr/local/bin/crun\"}},\"seccomp-profile\":\"builtin\",\"default-shm-size\":67108864,\"default-ipc-mode\":\"private\",\"default-cgroupns-mode\":\"private\",\"resolv-conf\":\"/etc/resolv.conf\",\"proxies\":{}}","time":"2025-02-08T12:24:38.600761054Z"}

After this (plain text):

    INFO[2025-02-08T12:30:34.835953594Z] Got signal to reload configuration            config-file=/etc/docker/daemon.json
    INFO[2025-02-08T12:30:34.857614135Z] Reloaded configuration                        config="{\"pidfile\":\"/var/run/docker.pid\",\"data-root\":\"/var/lib/docker\",\"exec-root\":\"/var/run/docker\",\"group\":\"docker\",\"max-concurrent-downloads\":3,\"max-concurrent-uploads\":5,\"max-download-attempts\":5,\"shutdown-timeout\":15,\"hosts\":[\"unix:///var/run/docker.sock\"],\"log-level\":\"info\",\"log-format\":\"text\",\"swarm-default-advertise-addr\":\"\",\"swarm-raft-heartbeat-tick\":0,\"swarm-raft-election-tick\":0,\"metrics-addr\":\"\",\"host-gateway-ips\":[\"\"],\"log-driver\":\"json-file\",\"mtu\":1500,\"ip\":\"0.0.0.0\",\"icc\":true,\"iptables\":true,\"ip6tables\":true,\"ip-forward\":true,\"ip-masq\":true,\"userland-proxy\":true,\"userland-proxy-path\":\"/usr/local/bin/docker-proxy\",\"default-address-pools\":{\"Values\":null},\"network-control-plane-mtu\":1500,\"experimental\":false,\"containerd\":\"/var/run/docker/containerd/containerd.sock\",\"features\":{\"containerd-snapshotter\":false},\"builder\":{\"GC\":{},\"Entitlements\":{}},\"containerd-namespace\":\"moby\",\"containerd-plugin-namespace\":\"plugins.moby\",\"default-runtime\":\"runc\",\"runtimes\":{\"crun\":{\"path\":\"/usr/local/bin/crun\"}},\"seccomp-profile\":\"builtin\",\"default-shm-size\":67108864,\"default-ipc-mode\":\"private\",\"default-cgroupns-mode\":\"private\",\"resolv-conf\":\"/etc/resolv.conf\",\"proxies\":{}}"

After this (JSON logs):

    {"config-file":"/etc/docker/daemon.json","level":"info","msg":"Got signal to reload configuration","time":"2025-02-08T12:24:38.589955637Z"}
    {"config":"{\"pidfile\":\"/var/run/docker.pid\",\"data-root\":\"/var/lib/docker\",\"exec-root\":\"/var/run/docker\",\"group\":\"docker\",\"max-concurrent-downloads\":3,\"max-concurrent-uploads\":5,\"max-download-attempts\":5,\"shutdown-timeout\":15,\"hosts\":[\"unix:///var/run/docker.sock\"],\"log-level\":\"info\",\"log-format\":\"json\",\"swarm-default-advertise-addr\":\"\",\"swarm-raft-heartbeat-tick\":0,\"swarm-raft-election-tick\":0,\"metrics-addr\":\"\",\"host-gateway-ips\":[\"\"],\"log-driver\":\"json-file\",\"mtu\":1500,\"ip\":\"0.0.0.0\",\"icc\":true,\"iptables\":true,\"ip6tables\":true,\"ip-forward\":true,\"ip-masq\":true,\"userland-proxy\":true,\"userland-proxy-path\":\"/usr/local/bin/docker-proxy\",\"default-address-pools\":{\"Values\":null},\"network-control-plane-mtu\":1500,\"experimental\":false,\"containerd\":\"/var/run/docker/containerd/containerd.sock\",\"features\":{\"containerd-snapshotter\":false},\"builder\":{\"GC\":{},\"Entitlements\":{}},\"containerd-namespace\":\"moby\",\"containerd-plugin-namespace\":\"plugins.moby\",\"default-runtime\":\"runc\",\"runtimes\":{\"crun\":{\"path\":\"/usr/local/bin/crun\"}},\"seccomp-profile\":\"builtin\",\"default-shm-size\":67108864,\"default-ipc-mode\":\"private\",\"default-cgroupns-mode\":\"private\",\"resolv-conf\":\"/etc/resolv.conf\",\"proxies\":{}}","level":"info","msg":"Reloaded configuration","time":"2025-02-08T12:24:38.600736179Z"}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-14 12:22:10 +01:00
Paweł Gronowski
40cdab0a3a Merge pull request #49419 from thaJeztah/fix_linting_step2
golangci-lint: enable more linters
2025-02-14 09:55:29 +00:00
Sebastiaan van Stijn
838ae09a23 Dockerfile: update runc binary to v1.2.5
This is the fifth patch release in the 1.2.z series of runc. It primarily fixes
an issue caused by an upstream systemd bug.

* There was a regression in systemd v230 which made the way we define
  device rule restrictions require a systemctl daemon-reload for our
  transient units. This caused issues for workloads using NVIDIA GPUs.
  Workaround the upstream regression by re-arranging how the unit properties
  are defined.
* Dependency github.com/cyphar/filepath-securejoin is updated to v0.4.1,
  to allow projects that vendor runc to bump it as well.
* CI: fixed criu-dev compilation.
* Dependency golang.org/x/net is updated to 0.33.0.

full diff: https://github.com/opencontainers/runc/compare/v1.2.4...v1.2.5
release notes: https://github.com/opencontainers/runc/releases/tag/v1.2.5

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-14 10:22:57 +01:00
Tonis Tiigi
707d8d80b9 vendor: update buildkit to v0.20.0-rc2
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-02-13 19:17:43 -08:00
Sebastiaan van Stijn
c9f8758570 golangci-lint: enable reassign linter
Detects reassigning a top-level variable in another package.
https://github.com/curioswitch/go-reassign

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:08 +01:00
Sebastiaan van Stijn
04ae510a1e golangci-lint: enable gocheckcompilerdirectives linter
Detects invalid go compiler directive comments (//go:);
https://github.com/leighmcculloch/gocheckcompilerdirectives

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:08 +01:00
Sebastiaan van Stijn
179e621019 golangci-lint: enable exhaustive linter
Checks exhaustiveness of enum switch statements in Go source code;
https://github.com/nishanths/exhaustive

For now allowing "default" to satisfy this, but left TODOs in various
places to make switches actually exhaustive so that we can detect missing
cases when new options are added.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:08 +01:00
Sebastiaan van Stijn
1f9ada6668 golangci-lint: enable errchkjson linter
Detects unsupported types passed to json encoding functions and reports
if checks for the returned error can be omitted;
https://github.com/breml/errchkjson

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:07 +01:00
Sebastiaan van Stijn
8b2439a383 golangci-lint: enable durationcheck linter
detect cases where two time.Duration values are being multiplied in
possibly erroneous ways;
https://github.com/charithe/durationcheck

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:07 +01:00
Sebastiaan van Stijn
d62e499bfe golangci-lint: enable dogsled linter
Checks assignments with too many blank identifiers;
https://github.com/alexkohler/dogsled

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:07 +01:00
Sebastiaan van Stijn
75fc4de8c3 golangci-lint: enable asasalint linter
Detects "[]any" used as argument for variadic "func(...any)";
https://github.com/alingse/asasalint

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:07 +01:00
Sebastiaan van Stijn
7218a64e87 golangci-lint: enable wastedassign linter
Detects wasted assignment statements; https://github.com/sanposhiho/wastedassign

For now, ignoring wasted asigns to `ctx` as there were too many hits in
libnetwork in functions that set up spans;

    libnetwork/drivers/bridge/bridge_linux.go:1319:2: assigned to ctx, but never used afterwards (wastedassign)
        ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.bridge.linkUp", trace.WithAttributes(
        ^
    libnetwork/drivers/bridge/bridge_linux.go:1448:2: assigned to ctx, but never used afterwards (wastedassign)
        ctx, span := otel.Tracer("").Start(ctx, "libnetwork.drivers.bridge.Join", trace.WithAttributes(
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:07 +01:00
Sebastiaan van Stijn
55b047e49c golangci-lint: enable fatcontext linter
Detects nested contexts in loops and function literals;
https://github.com/Crocmagnon/fatcontext

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:06 +01:00
Sebastiaan van Stijn
a97d6fe84f golangci-lint: enable nosprintfhostport linter (again)
Looks like we had it enabled at some point, given that there's various
"nolint" comments; https://github.com/stbenjam/no-sprintf-host-port

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:06 +01:00
Sebastiaan van Stijn
fc09a52d85 golangci-lint: enable spancheck linter
Detects mistakes with OpenTelemetry/Census spans;
https://github.com/jjti/go-spancheck

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:06 +01:00
Sebastiaan van Stijn
a0ef452f0c golangci-lint: enable mirror linter
Detects wrong mirror patterns of bytes/strings usage; https://github.com/butuzov/mirror

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:06 +01:00
Sebastiaan van Stijn
0de3c1b7e3 golangci-lint: enable makezero linter
Finds slice declarations with non-zero initial length;
https://github.com/ashanbrown/makezero

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:05 +01:00
Sebastiaan van Stijn
e6e68278f6 golangci-lint: enable iface linter (with default settings)
This linter has various other options for "correct" use of interfaces,
but those are too disruptive, so only enabling it with the default
settings, which detects duplicate interface definitions withing a
package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:05 +01:00
Sebastiaan van Stijn
c8ee8c6302 golangci-lint: enable nilnesserr linter
New linter that detects returning nil errors. It combines the features
of nilness and nilerr: https://github.com/alingse/nilnesserr

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:05 +01:00
Sebastiaan van Stijn
081fac187e golangci-lint: enable exptostd linter
New linter that detects functions from golang.org/x/exp/ that can be
replaced by std functions: https://github.com/ldez/exptostd

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-13 23:59:02 +01:00
Sebastiaan van Stijn
6ee1558852 Merge pull request #49417 from thaJeztah/fix_linting_step1
Fix linting issues to allow enabling more linters
2025-02-13 23:58:24 +01:00
Sebastiaan van Stijn
71e025c560 Merge pull request #49454 from thaJeztah/bump_dns
vendor: github.com/miekg/dns v1.1.61
2025-02-13 23:36:35 +01:00
Sebastiaan van Stijn
3b8eb1ec2a Merge pull request #49407 from jsternberg/containers-platform-json
API: add Platform (OS and Architecture) to /containers/json
2025-02-13 23:35:55 +01:00
Jonathan A. Sternberg
927e07e46e API: add Platform (OS and Architecture) to /containers/json
Adds platform information to containers (for `docker ps`).

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-02-13 14:52:21 -06:00
Sebastiaan van Stijn
c53c553880 Merge pull request #49456 from thaJeztah/bump_netlink
vendor: github.com/vishvananda/netlink 655392bc778a
2025-02-13 20:45:07 +01:00
Sebastiaan van Stijn
eb078a82f9 Merge pull request #49452 from tonistiigi/vendor-buildkit-v0.20.0-rc1
vendor: update buildkit to v0.20.0-rc1
2025-02-13 20:36:37 +01:00
Sebastiaan van Stijn
47ee8a0485 Merge pull request #49351 from LaurentGoderre/hostconfig-warnings
Add experimental feature warning for image mount
2025-02-13 13:39:07 +01:00
Tonis Tiigi
e364e28ec8 vendor: update buildkit to v0.20.0-rc1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-02-12 11:00:04 -08:00
Sebastiaan van Stijn
d47eb241bf vendor: github.com/vishvananda/netlink 655392bc778a
full diff: 084abd93d3...655392bc77

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-12 16:14:20 +01:00
Laurent Goderre
47ff7969b4 Add experimental feature warning for image mount
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-02-12 09:59:59 -05:00
Laurent Goderre
3e51818c5c Add ability to return warnings from host config
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-02-12 09:48:23 -05:00
Sebastiaan van Stijn
c5b226e377 vendor: github.com/miekg/dns v1.1.61
not the latest-latest version, but v1.1.58 is used elsewhere, and I saw
some fixes in v1.1.59 and v1.1.60, and v1.1.61 was docs-only changes.

- Allow use of fs.FS for $INCLUDE and wrap errors
- Add NXT record
- Add ISDN record
- Fix counting of escape sequences when splitting TXT string
- IsDomainName: check for escape as last character
- Add a hook to catch invalid messages
- Fix possible out-of-bounds read in endingToTxtSlice

full diff: https://github.com/miekg/dns/compare/v1.1.57...v1.1.61

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-12 13:20:26 +01:00
Sebastiaan van Stijn
b570831cc3 Merge pull request #49450 from thaJeztah/bump_pflag
vendor: github.com/spf13/pflag v1.0.6
2025-02-11 17:49:21 +01:00
Sebastiaan van Stijn
aa1805eab2 Merge pull request #49448 from thaJeztah/bump_grpc
vendor: google.golang.org/grpc v1.69.4
2025-02-11 17:48:55 +01:00
Sebastiaan van Stijn
7085d741c2 Merge pull request #49449 from thaJeztah/bump_cni
vendor: github.com/containerd/go-cni v1.1.12
2025-02-11 17:48:12 +01:00
Sebastiaan van Stijn
c6a5d1274f Merge pull request #49447 from thaJeztah/jsonmessage_fix_deprecation
Fix deprecation of "error" and "progress" fields in streaming responses
2025-02-11 17:47:04 +01:00
Sebastiaan van Stijn
56a6383883 api: deprecation of "error" and "progress" fields in streaming responses
- error (ErrorMessage) was deprecated in 3043c26419
  which was part of docker v0.6.0 / API v1.4
- progress (ProgressMessage) was deprecated in 597e0e69b4
  which was part of docker v0.7.1 / API v1.8

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-11 16:29:10 +01:00
Sebastiaan van Stijn
e36fb45eec vendor: github.com/spf13/pflag v1.0.6
- Add exported functions to preserve pkg/flag compatibility
- Add IPNetSlice and unit tests

full diff: https://github.com/spf13/pflag/compare/v1.0.5...v1.0.6

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-11 15:45:03 +01:00
Sebastiaan van Stijn
bd13fc37b0 pkg/jsonmessage: JSONMessage: fix deprecation of ProgressMessage, ErrorMessage
- ErrorMessage was deprecated in 3043c26419
  which was part of docker v0.6.0 / API v1.4
- ProgressMessage was deprecated in 597e0e69b4
  which was part of docker v0.7.1 / API v1.8

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-11 15:40:37 +01:00
Sebastiaan van Stijn
66910da5a3 vendor: github.com/containerd/go-cni v1.1.12
full diff: https://github.com/containerd/go-cni/compare/v1.1.11...v1.1.12

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-11 15:36:12 +01:00
Sebastiaan van Stijn
3d72df0e89 vendor: google.golang.org/grpc v1.69.4
full diff: https://github.com/grpc/grpc-go/compare/v1.68.1...v1.69.4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-11 15:30:34 +01:00
Sebastiaan van Stijn
66a2e2d16f Merge pull request #49446 from thaJeztah/deprecate_idresponse
api/types: deprecate IDResponse
2025-02-11 15:26:40 +01:00
Rob Murray
f216d6889c Merge pull request #49443 from robmry/restore_iptables_rules
Restore new iptables rules on firewalld reload
2025-02-11 14:19:24 +00:00
Sebastiaan van Stijn
72c91e378d client: remove serverResponse and use http.Response directly
Looking in history to learn why this struct existed, shows that this type
was mostly the result of tech-debt accumulating over time;

- originally ([moby@1aa7f13]) most of the request handling was internal;
  the [`call()` function][1] would make a request, read the `response.Body`,
  and return it as a `[]byte` (or an error if one happened).
- some features needed the statuscode, so [moby@a4bcf7e] added an extra
  output variable to return the `response.StatusCode`.
- some new features required streaming, so [moby@fdd8d4b] changed the
  function to return the `response.Body` as a `io.ReadCloser`, instead
  of a `[]byte`.
- some features needed access to the content-type header, so a new
  `clientRequest` method was introduced in [moby@6b2eeaf] to read the
  `Content-Type` header from `response.Headers` and return it as a string.
- of course, `Content-Type` may not be the only header needed, so [moby@0cdc3b7]
  changed the signature to return `response.Headers` as a whole as a
  `http.Header`
- things became a bit unwieldy now, with the function having four (4) output
  variables, so [moby@126529c] chose to refactor this code, introducing a
  `serverResponse` struct to wrap them all, not realizing that all these
  values were effectively deconstructed from the `url.Response`, so now
  re-assembling them into our own "URL response", only preserving a subset
  of the information available.
- now that we had a custom struct, it was possible to add more information
  to it without changing the signature. When there was a need to know the
  URL of the request that initiated the response, [moby@27ef09a] introduced
  a `reqURL` field to hold the `request.URL` which notably also is available
  in `response.Request.URL`.

In short;

- The original implementation tried to (pre-maturely) abstract the underlying
  response to provide a simplified interface.
- While initially not needed, abstracting caused relevant information from
  the response (and request) to be unavailable to callers.
- As a result, we ended up in a situation where we are deconstructing the
  original `url.Response`, only to re-assemble it into our own, custom struct
  (`serverResponsee`) with only a subset of the information preserved.

This patch removes the `serverResponse` struct, instead returning the
`url.Response` as-is, so that all information is preserved, allowing callers
to use the information they need.

There is one follow-up change to consider; commit [moby@589df17] introduced
a `ensureReaderClosed` utility. Before that commit, the response body would
be closed in a more idiomatic way through a [`defer serverResp.body.Close()`][2].
A later change in [docker/engine-api@5dd6452] added an optimization to that
utility, draining the response to allow connections to be reused. While
skipping that utility (and not draining the response) would not be a critical
issue, it may be easy to overlook that utility, and to close the response
body in the "idiomatic" way, resulting in a possible performance regression.

We need to check if that optimization is still relevant or if later changes
in Go itself already take care of this; we should also look if context
cancellation is handled correctly for these. If it's still relevant, we could

- Wrap the the `url.Response` in a custom struct ("drainCloser") to provide
  a `Close()` function handling the draining and closing; this would re-
  introduce a custom type to be returned, so perhaps not what we want.
- Wrap the `url.Response.Body` in the response returned (so, calling)
  `response.Body.Close()` would call the wrapped closer.
- Change the signature of `Client.sendRequest()` (and related) to return
  a `close()` func to handle this; doing so would more strongly encourage
  callers to close the response body.

[1]: 1aa7f1392d/commands.go (L1008-L1027)
[2]: 589df17a1a/api/client/ps.go (L84-L89)
[moby@1aa7f13]: 1aa7f1392d
[moby@a4bcf7e]: a4bcf7e1ac
[moby@fdd8d4b]: fdd8d4b7d9
[moby@6b2eeaf]: 6b2eeaf896
[moby@0cdc3b7]: 0cdc3b7539
[moby@126529c]: 126529c6d0
[moby@27ef09a]: 27ef09a46f
[moby@589df17]: 589df17a1a
[docker/engine-api@5dd6452]: 5dd6452d4d

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-11 13:20:27 +01:00
Sebastiaan van Stijn
b99b5422b0 api/types: deprecate IDResponse
Deprecate `api/type.IDResponse` in favor of `container.CommitResponse` and
`container.ExecCreateResponse`, which are currently an alias, but may become
distinct types in a future release. This type  will be removed in the next
release.

updates 0df3a0047a
updates 9a20edf7b6

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-11 13:02:41 +01:00
Rob Murray
96dc9cb693 Don't log a warning when an IP address is already in an ipset
It's situation-normal when firewalld is reloaded.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-11 11:59:41 +00:00
Rob Murray
b23b8f1567 Restore more iptables rules on firewalld reload
In the bridge network driver, filterPortMappedOnLoopback and
filterDirectAccess each set up some per-port iptables rules - but
they're not called by setPerPortIptables.

So, make sure they're called when firewalld is reloaded.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-11 11:59:41 +00:00
Sebastiaan van Stijn
6856bdd5a6 Merge pull request #49444 from thaJeztah/commit_and_exect_response
api/types/container: introduce CommitResponse, ExecCreateResponse types
2025-02-11 12:53:09 +01:00
Sebastiaan van Stijn
13ffbd6cc4 Merge pull request #49442 from thaJeztah/api_rename_container_responses
api/types/container: rename ContainerUpdateOKBody to UpdateResponse, ContainerTopOKBody to TopResponse
2025-02-11 12:52:17 +01:00
Sebastiaan van Stijn
9a20edf7b6 api/types/container: introduce ExecCreateResponse type
Introduce a container.ExecCreateResponse type as alias for IDResponse to allow
consumers to use ContainerCommit without having to import the "types" package,
and allows us to differentiate the response for container commit separate from
other endpoints currently using IDResponse.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-10 21:14:11 +01:00
Sebastiaan van Stijn
0df3a0047a api/types/container: introduce CommitResponse type
Move api/types.IDResponse to a "common" package (to prevent cyclic import
issues), and introduce a container.CommitResponse type as alias. This allows
consumers to use ContainerCommit without having to import the "types" package,
and allows us to differentiate the response for container commit separate from
other endpoints currently using IDResponse.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-10 21:14:03 +01:00
Sebastiaan van Stijn
be1ac5d8e5 api/types/container: rename ContainerTopOKBody to TopResponse
Deprecate ContainerTopOKBody, but keep an alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-10 18:58:31 +01:00
Sebastiaan van Stijn
f4dc38cd36 api/types/container: rename ContainerUpdateOKBody to UpdateResponse
Deprecate ContainerUpdateOKBody, but keep an alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-10 18:35:35 +01:00
Brian Goff
8ca7679631 Merge pull request #49415 from NathanBaulch/traceopts
client: custom trace options
2025-02-10 07:54:26 -08:00
Paweł Gronowski
2e16c5d1fb Merge pull request #49411 from thaJeztah/vendor_compute
vendor: cloud.google.com/go/compute/metadata v0.5.2
2025-02-10 13:30:59 +00:00
Paweł Gronowski
e7ef1b39d0 Merge pull request #49409 from thaJeztah/configureMaxThreads_no_args
daemon: configureMaxThreads: remove unused arg
2025-02-10 13:30:06 +00:00
Paweł Gronowski
9ce063f9c5 Merge pull request #49421 from thaJeztah/bump_gotest_tools
vendor: gotest.tools/v3 v3.5.2
2025-02-10 13:29:19 +00:00
Paweł Gronowski
78533fb2ec Merge pull request #49424 from thaJeztah/bump_gotestsum
Dockerfile: bump gotest.tools/gotestsum v1.12.0
2025-02-10 13:28:37 +00:00
Paweł Gronowski
ac0033f681 Merge pull request #49425 from thaJeztah/bump_buildx
Dockerfile: update buildx v0.20.1
2025-02-10 10:35:24 +00:00
Paweł Gronowski
50d06ff6b3 Merge pull request #49426 from thaJeztah/bump_cli
Dockerfile: update docker CLI to v28.0.0-rc.1
2025-02-10 10:34:47 +00:00
Paweł Gronowski
34404ecfaf Merge pull request #49422 from thaJeztah/fix_deprecation_comment
client: fix deprecation comment for ImageInspectWithRaw
2025-02-10 10:33:45 +00:00
Sebastiaan van Stijn
6cd0fb2c0c Merge pull request #49423 from thaJeztah/update_authors
update authors and mailmap
2025-02-10 09:34:49 +01:00
Sebastiaan van Stijn
85ff36de26 Dockerfile: update docker CLI to v28.0.0-rc.1
Update the Docker CLI used in the dev-container

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 17:17:37 +01:00
Sebastiaan van Stijn
cc6754f3fa Dockerfile: update buildx v0.20.1
Update the buildx cli plugin used in the dev-container

full diff: https://github.com/docker/buildx/compare/v0.20.0...v0.20.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 17:15:05 +01:00
Sebastiaan van Stijn
b90a2bac7d Dockerfile: bump gotest.tools/gotestsum v1.12.0
full diff: https://github.com/gotestyourself/gotestsum/compare/v1.8.2...v1.12.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 16:39:31 +01:00
Sebastiaan van Stijn
c786cdf124 update authors and mailmap
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 14:55:24 +01:00
Sebastiaan van Stijn
b4af9341af client: fix deprecation comment for ImageInspectWithRaw
The comment was not formatted correctly as it was not the last line,
resulting in some editors / linters not detecting the deprecation.

Updates 639a1214fa

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 14:03:29 +01:00
Sebastiaan van Stijn
6ba4e78066 vendor: gotest.tools/v3 v3.5.2
- un-deprecates `assert.ErrorType`, `cmp.ErrorType`
- assert: ensure message is always displayed and fix under bazel
- poll: Continue(): use format.Message for formatting
- fix TestFromDirSymlink on Windows due to missing drive-letter
- fix various linting issues and minor bugs

full diff: https://github.com/gotestyourself/gotest.tools/compare/v3.5.1...v3.5.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:33:43 +01:00
Sebastiaan van Stijn
43532eb1e1 daemon: Daemon.Containers: make switches exhaustive (exhaustive)
daemon/list.go:126:3: missing cases in switch of type daemon.iterationAction: daemon.includeContainer (exhaustive)
            switch includeContainerInList(currentContainer, filter) {
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:53 +01:00
Sebastiaan van Stijn
10ebdbbb92 daemon: Daemon.ProcessEvent: make switches exhaustive (exhaustive)
Adding a `default` statement so that disabling the "default-signifies-exhaustive"
linter option will  make it show up.

    daemon/monitor.go:158:2: missing cases in switch of type types.EventType: types.EventUnknown, types.EventCreate, types.EventExecAdded, types.EventExecStarted (exhaustive)
        switch e {
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:52 +01:00
Sebastiaan van Stijn
f448d5ae3b daemon/events: make switches exhaustive (exhaustive)
Adding a `default` statement so that disabling the "default-signifies-exhaustive"
linter option will  make it show up.

    daemon/events/events.go:95:2: missing cases in switch of type events.Type: events.BuilderEventType, events.ConfigEventType, events.DaemonEventType, events.NetworkEventType, events.NodeEventType, events.PluginEventType, events.SecretEventType, events.ServiceEventType, events.VolumeEventType (exhaustive)
        switch eventType {
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:52 +01:00
Sebastiaan van Stijn
d9cf097402 daemon/cluster/executor/container: make switches exhaustive (exhaustive)
Adding a `default` statement so that disabling the "default-signifies-exhaustive"
linter option will  make it show up.

    daemon/cluster/executor/container/adapter.go:351:3: missing cases in switch of type api.Mount_MountType: api.MountTypeVolume, api.MountTypeTmpfs, api.MountTypeNamedPipe, api.MountTypeCluster (exhaustive)
            switch mount.Type {
            ^
    daemon/cluster/executor/container/adapter.go:540:4: missing cases in switch of type api.LogStream: api.LogStreamUnknown (exhaustive)
                switch stream {
                ^
    daemon/cluster/executor/container/container.go:715:3: missing cases in switch of type api.Privileges_SeccompOpts_SeccompMode: api.Privileges_SeccompOpts_DEFAULT (exhaustive)
            switch seccomp.Mode {
            ^
    daemon/cluster/executor/container/controller.go:257:4: missing cases in switch of type events.Action: events.ActionCreate, events.ActionStart, events.ActionRestart, events.ActionStop, events.ActionCheckpoint, events.ActionPause, events.ActionUnPause, events.ActionAttach, events.ActionDetach, events.ActionResize, events.ActionUpdate, events.ActionRename, events.ActionKill, events.ActionOOM, events.ActionRemove, events.ActionCommit, events.ActionTop, events.ActionCopy, events.ActionArchivePath, events.ActionExtractToDir, events.ActionExport, events.ActionImport, events.ActionSave, events.ActionLoad, events.ActionTag, events.ActionUnTag, events.ActionPush, events.ActionPull, events.ActionPrune, events.ActionDelete, events.ActionEnable, events.ActionDisable, events.ActionConnect, events.ActionDisconnect, events.ActionReload, events.ActionMount, events.ActionUnmount, events.ActionExecCreate, events.ActionExecStart, events.ActionExecDie, events.ActionExecDetach, events.ActionHealthStatus, events.ActionHealthStatusRunning (exhaustive)
                switch event.Action {
                ^
    daemon/cluster/executor/container/controller.go:480:4: missing cases in switch of type events.Action: events.ActionCreate, events.ActionStart, events.ActionRestart, events.ActionStop, events.ActionCheckpoint, events.ActionPause, events.ActionUnPause, events.ActionAttach, events.ActionDetach, events.ActionResize, events.ActionUpdate, events.ActionRename, events.ActionKill, events.ActionDie, events.ActionOOM, events.ActionDestroy, events.ActionRemove, events.ActionCommit, events.ActionTop, events.ActionCopy, events.ActionArchivePath, events.ActionExtractToDir, events.ActionExport, events.ActionImport, events.ActionSave, events.ActionLoad, events.ActionTag, events.ActionUnTag, events.ActionPush, events.ActionPull, events.ActionPrune, events.ActionDelete, events.ActionEnable, events.ActionDisable, events.ActionConnect, events.ActionDisconnect, events.ActionReload, events.ActionMount, events.ActionUnmount, events.ActionExecCreate, events.ActionExecStart, events.ActionExecDie, events.ActionExecDetach, events.ActionHealthStatus, events.ActionHealthStatusRunning, events.ActionHealthStatusHealthy, events.ActionHealthStatusUnhealthy (exhaustive)
                switch event.Action {
                ^
    daemon/cluster/executor/container/controller.go:723:4: missing cases in switch of type events.Action: events.ActionCreate, events.ActionStart, events.ActionRestart, events.ActionStop, events.ActionCheckpoint, events.ActionPause, events.ActionUnPause, events.ActionAttach, events.ActionDetach, events.ActionResize, events.ActionUpdate, events.ActionRename, events.ActionKill, events.ActionDie, events.ActionOOM, events.ActionDestroy, events.ActionRemove, events.ActionCommit, events.ActionTop, events.ActionCopy, events.ActionArchivePath, events.ActionExtractToDir, events.ActionExport, events.ActionImport, events.ActionSave, events.ActionLoad, events.ActionTag, events.ActionUnTag, events.ActionPush, events.ActionPull, events.ActionPrune, events.ActionDelete, events.ActionEnable, events.ActionDisable, events.ActionConnect, events.ActionDisconnect, events.ActionReload, events.ActionMount, events.ActionUnmount, events.ActionExecCreate, events.ActionExecStart, events.ActionExecDie, events.ActionExecDetach, events.ActionHealthStatus, events.ActionHealthStatusRunning, events.ActionHealthStatusHealthy (exhaustive)
                switch event.Action {
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:52 +01:00
Sebastiaan van Stijn
bf3b4d4986 daemon/cluster/convert: make switches exhaustive (exhaustive)
Adding a `default` statement so that disabling the "default-signifies-exhaustive"
linter option will  make it show up.

    daemon/cluster/convert/service.go:59:3: missing cases in switch of type api.UpdateStatus_UpdateState: api.UpdateStatus_UNKNOWN (exhaustive)
            switch s.UpdateStatus.State {
            ^
    daemon/cluster/convert/volume.go:304:2: missing cases in switch of type api.VolumeSpec_VolumeAvailability: api.VolumeAvailabilityDrain (exhaustive)
        switch availability {
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:52 +01:00
Sebastiaan van Stijn
4d8dfc1409 daemon/cluster: make switches exhaustive (exhaustive)
Adding a `default` statement so that disabling the "default-signifies-exhaustive"
linter option will  make it show up.

    daemon/cluster/services.go:560:5: missing cases in switch of type api.LogStream: api.LogStreamUnknown (exhaustive)
                    switch msg.Stream {
                    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:52 +01:00
Sebastiaan van Stijn
6929a3fd22 libnetwork/networkdb: make switches exhaustive (exhaustive)
Adding a `default` statement so that disabling the "default-signifies-exhaustive"
linter option will  make it show up.

    libnetwork/networkdb/delegate.go:49:2: missing cases in switch of type networkdb.NodeEvent_Type: networkdb.NodeEventTypeInvalid (exhaustive)
        switch nEvent.Type {
        ^
    libnetwork/networkdb/delegate.go:223:2: missing cases in switch of type networkdb.TableEvent_Type: networkdb.TableEventTypeInvalid (exhaustive)
        switch tEvent.Type {
        ^
    libnetwork/networkdb/nodemgmt.go:51:2: missing cases in switch of type networkdb.nodeState: networkdb.nodeNotFound (exhaustive)
        switch newState {
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:51 +01:00
Sebastiaan van Stijn
827f84d3ef volume/mounts: parseMountSpec: make switch exhaustive (exhaustive)
Adding a `default` statement so that disabling the "default-signifies-exhaustive"
linter option will  make it show up.

    volume/mounts/linux_parser.go:353:2: missing cases in switch of type mount.Type: mount.TypeNamedPipe, mount.TypeCluster (exhaustive)
        switch cfg.Type {
        ^
    volume/mounts/windows_parser.go:392:2: missing cases in switch of type mount.Type: mount.TypeTmpfs, mount.TypeCluster, mount.TypeImage (exhaustive)
        switch cfg.Type {
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:51 +01:00
Sebastiaan van Stijn
0ee343222b daemon: eventTimestamp: make switch exhaustive (exhaustive)
Adding a `default` statement, and not an explicit "WatchActionKindUnknown",
so that disabling the "default-signifies-exhaustive" linter option will
make it show up.

    daemon/events.go:273:2: missing cases in switch of type api.WatchActionKind: api.WatchActionKindUnknown (exhaustive)
        switch action {
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:51 +01:00
Sebastiaan van Stijn
b343d235a0 container: State.conditionAlreadyMet: make switch exhaustive (exhaustive)
Adding a `default` statement, and not an explicit "WaitConditionNextExit",
so that disabling the "default-signifies-exhaustive" linter option will
make it show up.

    container/state.go:237:2: missing cases in switch of type container.WaitCondition: container.WaitConditionNextExit (exhaustive)
        switch condition {
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:51 +01:00
Sebastiaan van Stijn
8a35300b4a integration/internal/swarm: make switch excaustive (exhaustive)
integration/internal/swarm/states.go:62:4: missing cases in switch of type swarm.TaskState: swarm.TaskStateNew, swarm.TaskStateAllocated, swarm.TaskStatePending, swarm.TaskStateAssigned, swarm.TaskStateAccepted, swarm.TaskStatePreparing, swarm.TaskStateReady, swarm.TaskStateStarting, swarm.TaskStateComplete, swarm.TaskStateShutdown, swarm.TaskStateRejected, swarm.TaskStateRemove, swarm.TaskStateOrphaned (exhaustive)
                switch task.Status.State {
                ^
    integration/internal/swarm/states.go:121:4: missing cases in switch of type swarm.TaskState: swarm.TaskStateNew, swarm.TaskStateAllocated, swarm.TaskStatePending, swarm.TaskStateAssigned, swarm.TaskStateAccepted, swarm.TaskStatePreparing, swarm.TaskStateReady, swarm.TaskStateStarting, swarm.TaskStateShutdown, swarm.TaskStateFailed, swarm.TaskStateRejected, swarm.TaskStateRemove, swarm.TaskStateOrphaned (exhaustive)
                switch task.Status.State {
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:51 +01:00
Sebastiaan van Stijn
66ab2e9e77 plugin/executor/containerd: Executor.ProcessEvent: make switch excaustive (exhaustive)
plugin/executor/containerd/containerd.go:164:2: missing cases in switch of type types.EventType: types.EventUnknown, types.EventOOM, types.EventCreate, types.EventStart, types.EventExecAdded, types.EventExecStarted, types.EventPaused, types.EventResumed (exhaustive)
        switch et {
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:50 +01:00
Sebastiaan van Stijn
1a047bbe8b libnetwork: ignore unchecked json (Un)Marshal errors (errchkjson)
These need revisiting, similar to similar code in libnetwork/drivers/bridge.
There was already a TODO in place for this, so ignoring these for now.

    libnetwork/endpoint.go:148:11: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
        ib, _ := json.Marshal(epMap["ep_iface"])
                 ^
    libnetwork/endpoint.go:151:11: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
        jb, _ := json.Marshal(epMap["joinInfo"])
                 ^
    libnetwork/endpoint.go:154:11: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
        tb, _ := json.Marshal(epMap["exposed_ports"])
                 ^
    libnetwork/endpoint.go:159:11: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
        cb, _ := json.Marshal(epMap["sandbox"])
                 ^
    libnetwork/endpoint.go:237:12: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
        sal, _ := json.Marshal(epMap["svcAliases"])
                  ^
    libnetwork/endpoint.go:242:11: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
        pc, _ := json.Marshal(epMap["ingressPorts"])
                 ^
    libnetwork/endpoint.go:247:11: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
        ma, _ := json.Marshal(epMap["myAliases"])
                 ^
    libnetwork/endpoint.go:252:11: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
        dn, _ := json.Marshal(epMap["dnsNames"])
                 ^
    libnetwork/endpoint_info.go:123:11: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
        rb, _ := json.Marshal(epMap["routes"])
                 ^
    libnetwork/endpoint_info.go:490:12: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
            tb, _ := json.Marshal(v)
                     ^
    libnetwork/network.go:161:11: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
            b, _ := json.Marshal(v)
                    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:50 +01:00
Sebastiaan van Stijn
63deb55263 libnetwork/drivers/bridge: bridgeEndpoint.UnmarshalJSON: fix unhandled errors (errchkjson)
Log errors, but continue, to keep the existing behavior, but add a TODO
to revisit the logic.

    libnetwork/drivers/bridge/bridge_store.go:316:10: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
        d, _ := json.Marshal(epMap["ContainerConfig"])
                ^
    libnetwork/drivers/bridge/bridge_store.go:320:9: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
        d, _ = json.Marshal(epMap["ExternalConnConfig"])
               ^
    libnetwork/drivers/bridge/bridge_store.go:324:9: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
        d, _ = json.Marshal(epMap["PortMapping"])
               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:50 +01:00
Sebastiaan van Stijn
ccbcce2169 daemon/logger/templates: ignore unchecked error (errchkjson)
daemon/logger/templates/templates.go:17:3: Error return value of `(*encoding/json.Encoder).Encode` is not checked: unsafe type `interface{}` found (errchkjson)
            enc.Encode(v)
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:50 +01:00
Sebastiaan van Stijn
32153dee9f daemon: Daemon.Reload: fix unhandled errors printing config (errchkjson)
Print a warning when failing to marshal the JSON for printing

    daemon/reload.go:118:19: Error return value of `encoding/json.Marshal` is not checked: unsafe type `net.IP` found (errchkjson)
        jsonString, _ := json.Marshal(&struct {
                         ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:50 +01:00
Sebastiaan van Stijn
664558f916 daemon/cluster/convert: tmpfsOptionsToGRPC: ignore unchecked error (errchkjson)
The function describes that errors are OK to ignore, so we can suppress
the linter warning.

    daemon/cluster/convert/container.go:582:18: Error return value of `encoding/json.Marshal` is not checked (errchkjson)
        jsonBytes, _ := json.Marshal(options)
                        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:49 +01:00
Sebastiaan van Stijn
4a7f891fc3 integration/plugin: fix unhandled errors in tests (errchkjson)
integration/plugin/logging/cmd/discard/driver.go:84:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(w).Encode(&res)
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:49 +01:00
Sebastiaan van Stijn
196a66a643 integration-cli: fix unhandled errors in tests (errchkjson)
integration-cli/docker_cli_external_volume_driver_test.go:116:4: Error return value of `(*encoding/json.Encoder).Encode` is not checked: unsafe type `interface{}` found (errchkjson)
                json.NewEncoder(w).Encode(&data)
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:49 +01:00
Sebastiaan van Stijn
26d30159f7 libnetwork/driverapi: ignore unchecked error (for now) (errchkjson)
libnetwork/driverapi/ipamdata.go:52:11: Error return value of `encoding/json.Marshal` is not checked: unsafe type `interface{}` found (errchkjson)
            b, _ := json.Marshal(v)
                    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:49 +01:00
Sebastiaan van Stijn
b87c9fb3f4 libnetwork/diagnostic: ignore unchecked error (errchkjson)
libnetwork/diagnostic/server.go:234:19: Error return value of `encoding/json.MarshalIndent` is not checked: unsafe type `github.com/docker/docker/libnetwork/diagnostic.StringInterface` found (errchkjson)
                    response, _ = json.MarshalIndent(FailCommand(err), "", "  ")
                                  ^
    libnetwork/diagnostic/server.go:239:19: Error return value of `encoding/json.Marshal` is not checked: unsafe type `github.com/docker/docker/libnetwork/diagnostic.StringInterface` found (errchkjson)
                    response, _ = json.Marshal(FailCommand(err))
                                  ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:49 +01:00
Sebastiaan van Stijn
7dbceec8aa api/server/router/volume: fix unhandled errors in tests (errchkjson)
Also fixing some minor other linting issues.

    api/server/router/volume/volume_routes_test.go:193:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        e.Encode(volumeCreate)
        ^
    api/server/router/volume/volume_routes_test.go:231:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(&buf).Encode(volumeCreate)
        ^
    api/server/router/volume/volume_routes_test.go:260:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(&buf).Encode(volumeCreate)
        ^
    api/server/router/volume/volume_routes_test.go:292:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(&buf).Encode(volumeCreate)
        ^
    api/server/router/volume/volume_routes_test.go:339:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(&buf).Encode(volumeUpdate)
        ^
    api/server/router/volume/volume_routes_test.go:366:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(&buf).Encode(volumeUpdate)
        ^
    api/server/router/volume/volume_routes_test.go:396:2: Error return value of `(*encoding/json.Encoder).Encode` is not checked (errchkjson)
        json.NewEncoder(&buf).Encode(volumeUpdate)
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:49 +01:00
Sebastiaan van Stijn
07e2fc83ae pkg/plugins: fix "Multiplication of durations" (durationcheck)
Change some variables to a time.Duration to reduce conversions between
integers and durations, which also makes the code slightly more transparent.

    pkg/plugins/client_test.go:109:9: Multiplication of durations: `tc.expTimeOff * time.Second` (durationcheck)
                s := tc.expTimeOff * time.Second
                     ^
    pkg/plugins/client_test.go:132:9: Multiplication of durations: `tc.timeOff * time.Second` (durationcheck)
                s := tc.timeOff * time.Second
                     ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:48 +01:00
Sebastiaan van Stijn
1ffbcb566b pkg/jsonmessage: fix "Multiplication of durations" (durationcheck)
pkg/jsonmessage/jsonmessage.go:111:10: Multiplication of durations: `(left / time.Second) * time.Second` (durationcheck)
            left = (left / time.Second) * time.Second
                   ^

This code was rounding down time remaining to the nearest second;

- Use go's time.Duration.Round() instead
- Make the calculation conditional, as it was only used if there's enough
  space available to print
- Move the declaration of the timeLeftBox var closer to where used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:48 +01:00
Sebastiaan van Stijn
eac45daf06 runconfig: fix declaration has 3 blank identifiers (dogsled)
runconfig/config_test.go:114:2: declaration has 3 blank identifiers (dogsled)
        _, _, _, err = decodeContainerConfig(bytes.NewReader(requestJSON), sysinfo.New())
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:48 +01:00
Sebastiaan van Stijn
09c5a01346 pks/plugins/pluginrpc-gen: fix unused value assign (wastedassign)
pkg/plugins/pluginrpc-gen/parser_test.go:80:2: assigned to arg, but reassigned without using the value (wastedassign)
        arg = f.Args[0]
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:48 +01:00
Sebastiaan van Stijn
a4dba91424 daemon/containerd: fix unused value assign (wastedassign)
daemon/containerd/image_exporter.go:406:2: assigned to msg, but reassigned without using the value (wastedassign)
        msg := ""
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:48 +01:00
Sebastiaan van Stijn
f1d7bd60ab integration/image: TestRemoveByDigest fixed unused values (wastedassign)
Add some assertions, and removed a log, instead using it as message
if the assertion fails.

    integration/image/remove_test.go:88:2: assigned to inspect, but reassigned without using the value (wastedassign)
        inspect, err = client.ImageInspect(ctx, "busybox")
        ^
    integration/image/remove_test.go:91:2: assigned to inspect, but never used afterwards (wastedassign)
        inspect, err = client.ImageInspect(ctx, "test-remove-by-digest")
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:47 +01:00
Sebastiaan van Stijn
9f8eafc101 plugin: withFetchProgress work around "nested context in loop (fatcontext)"
This needs a better solution, but this allows enabling the "fatcontext"
linter.

    plugin/fetch_linux.go:250:6: nested context in loop (fatcontext)
                        ctx = context.Background()
                        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:47 +01:00
Sebastiaan van Stijn
e9c90834fa opts: host:port should be constructed with net.JoinHostPort (nosprintfhostport)
opts/hosts_test.go:110:30: host:port in url should be constructed with net.JoinHostPort and not directly with fmt.Sprintf (nosprintfhostport)
            "tcp://:5555":             fmt.Sprintf("tcp://%s:5555", DefaultHTTPHost),
                                       ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:47 +01:00
Sebastiaan van Stijn
0bf8c8b99e pkg/tailfile: avoid allocations with (*os.File).WriteString (mirror)
pkg/tailfile/tailfile_test.go:149:16: avoid allocations with (*os.File).WriteString (mirror)
            if _, err := f.Write([]byte("tailfile pretty interesting line\n")); err != nil {
                         ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:47 +01:00
Sebastiaan van Stijn
4e6c91cc56 pkg/pools: avoid allocations with (*bufio.Writer).WriteString (mirror)
pkg/pools/pools_test.go:100:18: avoid allocations with (*bufio.Writer).WriteString (mirror)
        written, err := writer.Write([]byte("foobar"))
                        ^
    pkg/pools/pools_test.go:112:14: avoid allocations with (*bufio.Writer).WriteString (mirror)
        if _, err = writer.Write([]byte("barfoo")); err != nil {
                    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:47 +01:00
Sebastiaan van Stijn
f0a233bdc3 pkg/archive: avoid allocations with strings.Compare (mirror)
pkg/archive/changes_linux.go:146:10: avoid allocations with strings.Compare (mirror)
            switch bytes.Compare([]byte(ni1.name), []byte(ni2.name)) {
                   ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:47 +01:00
Sebastiaan van Stijn
17f32e8822 libnetwork/internal/resolvconf: avoid allocations with bytes.NewBufferString (mirror)
libnetwork/internal/resolvconf/resolvconf_test.go:63:21: avoid allocations with bytes.NewBufferString (mirror)
                rc, err := Parse(bytes.NewBuffer([]byte("options "+tc.options)), "")
                                 ^
    libnetwork/internal/resolvconf/resolvconf_test.go:106:19: avoid allocations with bytes.NewBufferString (mirror)
        rc, err := Parse(bytes.NewBuffer([]byte("nameserver 1.2.3.4")), "")
                         ^
    libnetwork/internal/resolvconf/resolvconf_test.go:214:21: avoid allocations with bytes.NewBufferString (mirror)
                rc, err := Parse(bytes.NewBuffer([]byte(input)), "")
                                 ^
    libnetwork/internal/resolvconf/resolvconf_test.go:311:21: avoid allocations with bytes.NewBufferString (mirror)
                rc, err := Parse(bytes.NewBuffer([]byte(tc.input)), "/etc/resolv.conf")
                                 ^
    libnetwork/internal/resolvconf/resolvconf_test.go:418:21: avoid allocations with bytes.NewBufferString (mirror)
                rc, err := Parse(bytes.NewBuffer([]byte(tc.input)), "/etc/resolv.conf")
                                 ^
    libnetwork/internal/resolvconf/resolvconf_test.go:492:21: avoid allocations with bytes.NewBufferString (mirror)
                rc, err := Parse(bytes.NewBuffer([]byte(content)), "/etc/resolv.conf")
                                 ^
    libnetwork/internal/resolvconf/resolvconf_test.go:535:19: avoid allocations with bytes.NewBufferString (mirror)
        rc, err := Parse(bytes.NewBuffer([]byte("nameserver 1.2.3.4.5")), "")
                         ^
    libnetwork/internal/resolvconf/resolvconf_test.go:548:19: avoid allocations with bytes.NewBufferString (mirror)
        rc, err := Parse(bytes.NewBuffer([]byte("nameserver 127.0.0.53")), "/etc/resolv.conf")
                         ^
    libnetwork/internal/resolvconf/resolvconf_test.go:569:19: avoid allocations with bytes.NewBufferString (mirror)
        rc, err := Parse(bytes.NewBuffer([]byte(input)), "/etc/resolv.conf")
                         ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:46 +01:00
Sebastiaan van Stijn
0c8d086ed3 libnetwork: avoid allocations with regexp.Match (mirror)
libnetwork/drivers/bridge/bridge_linux_test.go:978:17: avoid allocations with regexp.Match (mirror)
            matched, _ := regexp.MatchString(regex, string(out[:]))
                          ^
    libnetwork/drivers/bridge/bridge_linux_test.go:1004:17: avoid allocations with regexp.Match (mirror)
            matched, _ := regexp.MatchString(regex, string(out[:]))
                          ^
    libnetwork/drivers/bridge/bridge_linux_test.go:1032:18: avoid allocations with regexp.Match (mirror)
                matched, _ := regexp.MatchString(regex, string(out[:]))
                              ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:46 +01:00
Sebastiaan van Stijn
6ff3dfd88a integration-cli: avoid allocations with (*os.File).WriteString (mirror)
integration-cli/docker_cli_attach_unix_test.go:107:3: avoid allocations with (*os.File).WriteString (mirror)
            cpty.Write([]byte("\n"))
            ^
    integration-cli/docker_cli_attach_unix_test.go:144:11: avoid allocations with (*os.File).WriteString (mirror)
        _, err = cpty.Write([]byte("hello\n"))
                 ^
    integration-cli/docker_cli_exec_test.go:422:16: avoid allocations with (*os.File).WriteString (mirror)
            if _, err := f.Write([]byte("success2\n")); err != nil {
                         ^
    integration-cli/docker_cli_exec_unix_test.go:57:11: avoid allocations with (*os.File).WriteString (mirror)
        _, err = p.Write([]byte("cat /foo && exit\n"))
                 ^
    integration-cli/docker_cli_run_test.go:4092:15: avoid allocations with (*os.File).WriteString (mirror)
        if _, err := tmpFile.Write([]byte(data)); err != nil {
                     ^
    integration-cli/docker_cli_run_unix_test.go:110:11: avoid allocations with (*os.File).WriteString (mirror)
        _, err = cpty.Write([]byte("hello\n"))
                 ^
    integration-cli/docker_cli_run_unix_test.go:169:15: avoid allocations with (*os.File).WriteString (mirror)
        if _, err := cpty.Write([]byte("hello\n")); err != nil {
                     ^
    integration-cli/docker_cli_run_unix_test.go:283:15: avoid allocations with (*os.File).WriteString (mirror)
        if _, err := cpty.Write([]byte("hello\n")); err != nil {
                     ^
    integration-cli/docker_cli_run_unix_test.go:364:15: avoid allocations with (*os.File).WriteString (mirror)
        if _, err := cpty.Write([]byte("hello\n")); err != nil {
                     ^
    integration-cli/docker_cli_run_unix_test.go:438:15: avoid allocations with (*os.File).WriteString (mirror)
        if _, err := cpty.Write([]byte("\n")); err != nil {
                     ^
    integration-cli/docker_cli_run_unix_test.go:880:15: avoid allocations with (*os.File).WriteString (mirror)
        if _, err := tmpFile.Write([]byte(jsonData)); err != nil {
                     ^
    integration-cli/docker_cli_run_unix_test.go:915:15: avoid allocations with (*os.File).WriteString (mirror)
        if _, err := tmpFile.Write([]byte(jsonData)); err != nil {
                     ^
    integration-cli/docker_cli_run_unix_test.go:952:15: avoid allocations with (*os.File).WriteString (mirror)
        if _, err := tmpFile.Write([]byte(jsonData)); err != nil {
                     ^
    integration-cli/docker_cli_run_unix_test.go:1418:11: avoid allocations with (*os.File).WriteString (mirror)
        _, err = tmpFile.Write([]byte(jsonData))
                 ^
    integration-cli/docker_cli_run_unix_test.go:1445:11: avoid allocations with (*os.File).WriteString (mirror)
        _, err = tmpFile.Write([]byte(jsonData))
                 ^
    integration-cli/docker_cli_run_unix_test.go:1483:11: avoid allocations with (*os.File).WriteString (mirror)
        _, err = tmpFile.Write([]byte(jsonData))
                 ^
    integration-cli/docker_cli_run_unix_test.go:1517:11: avoid allocations with (*os.File).WriteString (mirror)
        _, err = tmpFile.Write([]byte(jsonData))
                 ^
    integration-cli/docker_cli_update_unix_test.go:235:11: avoid allocations with (*os.File).WriteString (mirror)
        _, err = cpty.Write([]byte("exit\n"))
                 ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:46 +01:00
Sebastiaan van Stijn
405ce2ef15 distribution/xfer: avoid allocations with bytes.NewBufferString (mirror)
distribution/xfer/download_test.go:196:22: avoid allocations with bytes.NewBufferString (mirror)
        return io.NopCloser(bytes.NewBuffer([]byte(d.id + d.id + d.id + d.id + d.id)))
                            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:46 +01:00
Sebastiaan van Stijn
d50492a70d container/stream: avoid allocations with (*bytes.Buffer).WriteString (mirror)
container/stream/unbuffered_test.go:139:3: avoid allocations with (*bytes.Buffer).WriteString (mirror)
            buf.Write([]byte(testLine + "\n"))
            ^
    container/stream/unbuffered_test.go:142:2: avoid allocations with (*bytes.Buffer).WriteString (mirror)
        buf.Write([]byte(testLine))
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:46 +01:00
Sebastiaan van Stijn
dbf2cdd06c integration/networking: fix append to non-zero initialized length (makezero)
integration/networking/bridge_linux_test.go:1233:17: append to slice `wantProxies` with non-zero initialized length (makezero)
            wantProxies = append(wantProxies, makeExpStr(e.proto, e.hostIP, e.hostPort, ctrIP, e.ctrPort))
                          ^
    integration/networking/bridge_linux_test.go:1254:16: append to slice `gotProxies` with non-zero initialized length (makezero)
            gotProxies = append(gotProxies, makeExpStr(proto, hostIP, hostPort, ctrIP, ctrPort))
                         ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:45 +01:00
Sebastiaan van Stijn
dd8ee9eeb1 libnetwork/cnmallocator: fix append to non-zero initialized length (makezero)
libnetwork/cnmallocator/networkallocator.go:876:17: append to slice `ipamConfigs` with non-zero initialized length (makezero)
            ipamConfigs = append(ipamConfigs, &api.IPAMConfig{Family: api.IPAMConfig_IPV4})
                          ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:45 +01:00
Sebastiaan van Stijn
8e9fce7970 libnetwork/bitmap: fix append to non-zero initialized length (makezero)
Changing to use binary.LittleEndian.AppendUint64, which does not require
the slice to have an initial size, and makes the code slightly more
straightforward.

    libnetwork/bitmap/sequence.go:296:7: append to slice `ba` with non-zero initialized length (makezero)
        ba = append(ba, bm...)
             ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:45 +01:00
Sebastiaan van Stijn
f9890d97d1 libnet: kvstore/boltdb: fix append to non-zero initialized length (makezero)
Changing to use binary.LittleEndian.AppendUint64, which does not require
the slice to have an initial size, and makes the code slightly more
straightforward.

    libnetwork/internal/kvstore/boltdb/boltdb.go:79:11: append to slice `dbval` with non-zero initialized length (makezero)
            dbval = append(dbval, value...)
                    ^
    libnetwork/internal/kvstore/boltdb/boltdb.go:228:11: append to slice `dbval` with non-zero initialized length (makezero)
            dbval = append(dbval, value...)
                    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:45 +01:00
Sebastiaan van Stijn
1f7d497a99 errdefs: remove duplicate "causer" interface definition (iface)
errdefs/helpers_test.go:11:6: identical: interface causal contains identical methods or type constraints from another interface, causing redundancy (iface)
    type causal interface {
         ^
    errdefs/is.go:8:6: identical: interface causer contains identical methods or type constraints from another interface, causing redundancy (iface)
    type causer interface {
         ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-09 13:22:45 +01:00
Akihiro Suda
7adac77d6b Merge pull request #49416 from thaJeztah/bump_golangci_lint
Dockerfile: update golangci-lint to v1.63.4
2025-02-09 18:37:37 +09:00
Nathan Baulch
1784026740 client: custom trace options
Signed-off-by: Nathan Baulch <nathan.baulch@gmail.com>
2025-02-08 18:04:18 +11:00
Sebastiaan van Stijn
cab2157182 Dockerfile: update golangci-lint to v1.63.4
full diff: https://github.com/golangci/golangci-lint/compare/v1.62.0...v1.63.4
Changelog: https://golangci-lint.run/product/changelog/#v1634

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-07 13:45:21 +01:00
Sebastiaan van Stijn
f34a1aafe9 vendor: cloud.google.com/go/compute/metadata v0.5.2
- compute/metadata: Check error chain for retryable error
- compute/metadata: Close Response Body for failed request

full diff: https://github.com/googleapis/google-cloud-go/compare/compute/metadata/v0.5.0...compute/metadata/v0.5.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-07 13:31:37 +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
Paweł Gronowski
6c3797923d Merge pull request #49155 from akerouanton/custom-ifname
libnet: add support for custom interface names
2025-02-06 18:09:49 +00:00
Paweł Gronowski
3c9702983c Merge pull request #49406 from vvoland/gomodule-fix
add //go:build directives to prevent downgrading to go1.16 language
2025-02-06 18:04:41 +00:00
Paweł Gronowski
9e77d05967 add //go:build directives to prevent downgrading to go1.16 language
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-06 18:16:59 +01:00
Paweł Gronowski
19d72fd0a2 Merge pull request #49405 from thaJeztah/undeprecate_windows_users
pkg/idtools: un-deprecate Windows consts for now
2025-02-06 17:01:41 +00:00
Sebastiaan van Stijn
192431cb35 pkg/idtools: un-deprecate Windows consts for now
These consts were deprecated in 9c368a93b6, but are
used externally and lack a canonical location. These sids are "special", as they
are available by default in Windows containers, but we need to;

- Reference official documentation / specification for that.
- Add names (not just the sid)
- Consider finding a canonical location for these consts, which could be as part
  of the OCI specs, or hcsshim (or otherwise).

Lacking a good place for these, let's un-deprecate them for the time being until
we decided what's the best location for these.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-06 17:30:35 +01:00
Albin Kerouanton
5a703c2eda libnet/osl: scan ns ifaces to generate ifname
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-02-06 17:01:15 +01:00
Albin Kerouanton
78b0475605 libnet/osl: AddInterface: un-alias props into local vars
At first glance, it seemed like the Namespace lock was held to make
local copies of Namespace properties, but all those properties all safe
to access concurrently. So, un-alias those props and reduce the scope
of the mutex lock.

This helps understanding where locking is really needed.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-02-06 17:01:12 +01:00
Albin Kerouanton
56a7817b2d libnet: add support for custom interface names
To support this, a new netlabel is added: `com.docker.network.endpoint.ifname`.

It gives the ability to specify the interface name to be set by
netdrivers when the interface is added / moved into the container's
network namespace.

All builtin netdrivers support it.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-02-06 17:00:29 +01:00
Albin Kerouanton
6a8360012c libnet/osl: distinguish dstName & dstPrefix
Before this commit, `Interface.dstName` was used to store the dest
ifname prefix, and then the final ifname.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-02-06 17:00:29 +01:00
Paweł Gronowski
f353b56f49 Merge pull request #49392 from robmry/wait_for_mcast_route
Wait for a route to ff02::1 before sending NAs
2025-02-06 15:47:53 +00:00
Paweł Gronowski
6f246f4761 Merge pull request #49036 from stevapple/patch-1
Use `getsubids` tool for subid validation if possible
2025-02-06 14:51:04 +00:00
Paweł Gronowski
729f5bd967 Merge pull request #49040 from thaJeztah/buildkit_init_timeout_suggestions
cmd/dockerd: refactor buildkit init in daemon startup
2025-02-06 14:50:41 +00:00
Paweł Gronowski
b32f2a2d5e Merge pull request #48264 from vvoland/c8d-inspect-manifests
c8d/inspect: Add `Manifests` field
2025-02-06 14:09:05 +00:00
Sebastiaan van Stijn
2e9e7989f8 cmd/dockerd: initBuildkit: return close-func
Make it more explicit that callers must call close

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-06 13:56:04 +01:00
Brian Goff
2dc03f934f cmd/dockerd: refactor buildkit init in daemon startup
- Move the "Daemon has completed initialization" log to where it has
  actually completed initialization.
- Move buildkit init to its own function.
- Move the builder options to a separate struct, and change initBuildkit
  to return it instead of passing the router-options and manipulate it.

Co-authored-by: Brian Goff <cpuguy83@gmail.com>
Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-06 13:53:29 +01:00
YR Chen
9509f27e28 rootless: use getsubids tool for validation if possible
Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: YR Chen <stevapple@icloud.com>
2025-02-06 13:46:58 +01:00
Paweł Gronowski
a096045678 all: Replace deprecated ImageInspectWithRaw usage
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-06 13:31:48 +01:00
Paweł Gronowski
3d37537f75 c8d/inspect: Add Manifests field
Add `Manifests` field to image inspect (`/images/{name}/json`) response.
This is the same as in `/images/json`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-06 13:30:24 +01:00
Paweł Gronowski
639a1214fa client/image-inspect: Introduce client opts
Deprecate ImageInspectWithRaw and add a simpler ImageInspect function
which takes optional options.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-06 13:30:22 +01:00
Paweł Gronowski
6664f1220a c8d/inspect: Avoid interim images.Image conversion
Don't use the `GetImage` call which returns a "best-effort" view of the
image that is compatible with the old images.Image response.

Instead, use the multi-platform view of the image to construct the
inspect response.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-06 13:30:21 +01:00
Paweł Gronowski
bdb6a7abdc c8d/list: multiPlatformSummary
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-06 13:30:18 +01:00
Paweł Gronowski
02563f2805 Merge pull request #48798 from LaurentGoderre/implement-30449-image-mount
Implement mount from image
2025-02-05 18:04:22 +00:00
Sebastiaan van Stijn
779bdc4fab Merge pull request #49393 from vvoland/update-go
update to go1.23.6
2025-02-05 16:43:24 +01:00
Rob Murray
997a6e167e Merge pull request #49372 from robmry/remote_driver_skip_gw_alloc
Implement GwAllocChecker for the remote network driver
2025-02-05 11:30:33 +00:00
Rob Murray
d4fa252cd3 Wait for a route to ff02::1 before sending NAs
Commit aa3a23d (Temporary debug for unsolicited NA) added code to
check for a route from ::1 to ff02::1 if a neighbour advertisement
send failed ... hoping to show that the route appeared fairly quickly
after the first attempt.

The failure didn't happen in CI, perhaps other changes in that PR
changed the timing enough for it not to be an issue. Or, perhaps the
change in commit 9a6e96f (Before sending ARPs/NAs, check the bridge is
ready) was enough to solve the issue.

But, in case it's a timing issue we're just no longer seeing on the CI
hosts - check the route exists before trying to send an NA, and wait
for a short time if not.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-05 10:56:49 +00:00
Paweł Gronowski
62a747f5e4 Merge pull request #49390 from thaJeztah/implement_unwrapper
implement missing "Unwrapper" interface on errors that implemented "Causer" interface
2025-02-05 09:49:26 +00:00
Paweł Gronowski
6ee81dc3eb Merge pull request #49262 from robmry/gw_mode_isolated
Add gateway mode "isolated"
2025-02-05 09:29:20 +00:00
Laurent Goderre
1126d477fd Add live-restore tests for mount image
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-02-04 21:32:04 -05:00
Laurent Goderre
90aea3b85f Add image subpath mounting functionality
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-02-04 21:32:04 -05:00
Sebastiaan van Stijn
63ea5dc10e Merge pull request #49388 from thaJeztah/client_unify_interfaces
client: deprecate CommonAPIClient interface, add HijackDialer, SwarmManagementAPIClient interfaces
2025-02-04 22:50:24 +01:00
Sebastiaan van Stijn
2277b35061 Merge pull request #49389 from thaJeztah/client_deprecate_ErrorConnectionFailed
client: deprecate ErrorConnectionFailed helper
2025-02-04 22:48:32 +01:00
Paweł Gronowski
126d4bc65b Merge pull request #49391 from thaJeztah/errdefs_godoc
errdefs: touch-up godoc for helpers
2025-02-04 19:41:15 +00:00
Rob Murray
634951457d Implement GwAllocChecker for the remote network driver
Commit 38e76eb (Ask network drivers if they'll use a gateway
address) added an optional driver interface "GwAllocChecker"
to give the driver a chance to say whether, given network
config options, it would use a gateway address if one was
reserved for it in IPAM.

So, implement support for that in the remote network driver.
The driver itself implements the interface, but only tries
to make an HTTP request to the driver plugin if the plugin
has reported support for it in response to an initial
capabilities request.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-02-04 19:35:20 +00:00
Paweł Gronowski
12756071f1 update to go1.23.6
This minor release include 1 security fix following the security policy:

- crypto/elliptic: timing sidechannel for P-256 on ppc64le

  Due to the usage of a variable time instruction in the assembly implementation
  of an internal function, a small number of bits of secret scalars are leaked on
  the ppc64le architecture. Due to the way this function is used, we do not
  believe this leakage is enough to allow recovery of the private key when P-256
  is used in any well known protocols.

This is CVE-2025-22866 and Go issue https://go.dev/issue/71383.

View the release notes for more information:
https://go.dev/doc/devel/release#go1.23.6

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-02-04 20:27:27 +01:00
Sebastiaan van Stijn
294df1c447 volumes/service: OpErr: implement go1.13 unwrapper
This error implemented the Causer interface, but did not implement
the go1.13 unwrapper, which could prevent errors from being matched.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 18:10:51 +01:00
Sebastiaan van Stijn
db68c99d4b distribution: fallbackError, notFoundError implement go1.13 unwrapper
These errors implemented the Causer interface, but did not implement
the go1.13 unwrapper, which could prevent errors from being matched.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 18:08:35 +01:00
Sebastiaan van Stijn
b96b14d078 cluster/executor/container: exitError: implement go1.13 unwrapper
This error implemented the Causer interface, but did not implement
the go1.13 unwrapper, which could prevent errors from being matched.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 17:47:10 +01:00
Sebastiaan van Stijn
2997c0ddc0 client: deprecate CommonAPIClient interface
The CommonAPIClient was used to define all the stable interfaces,
and combined with the experimental ones through APIClient. In theory,
this would allow someone to make sure they only depended on non-experimental
methods or to implement an alternative client that only implements the
stable methods.

While there are users currently using this interface, all those uses
depend on the actual client implementation, not a custom one, so they
should be able to switch to use APIClient instead. In the meantime,
start with deprecating, but keeping the interface the same for now,
scheduling it to become an alias, and removed in a future release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 17:21:31 +01:00
Sebastiaan van Stijn
846b2272e6 client: deprecate ErrorConnectionFailed helper
This function was only used internally, and will be removed in the next release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 17:16:52 +01:00
Sebastiaan van Stijn
e93ff742e8 client: doRequest: use errors.As for error-detection
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 17:09:59 +01:00
Sebastiaan van Stijn
3725998e7d client: define interface for all Swarm-specific methods
Introduce a SwarmManagementAPIClient interface that captures
all swarm-specific methods on the API client.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 16:56:08 +01:00
Sebastiaan van Stijn
a57d737a86 client: define separate interface for HijackDialer
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 16:44:12 +01:00
Sebastiaan van Stijn
902c06fdf0 client: make setupHijackConn a regular function
pass the dialer as argument

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 16:39:44 +01:00
Sebastiaan van Stijn
e6dabfa3b1 client: move resetting mediaType for hijack to where applicable
The mediaType is only used in a single location; reset it in
that location.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 16:39:44 +01:00
Sebastiaan van Stijn
b0e206b807 client: separate Dialer() implementation from public API
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 16:39:44 +01:00
Sebastiaan van Stijn
fcb924712b integration/internal: JobComplete: require shallower interface
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 16:12:06 +01:00
Sebastiaan van Stijn
0f04532956 errdefs: touch-up godoc for helpers
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-04 15:50:07 +01:00
Sebastiaan van Stijn
e7da72a464 Merge pull request #49381 from thaJeztah/improve_validation
client: normalize and validate empty ID / name arguments to fail early
2025-02-04 15:49:23 +01:00
Paweł Gronowski
250378a715 Merge pull request #49362 from vvoland/pr-changelog-desc
github: Clarify release notes description
2025-02-04 09:16:13 +00:00
Paweł Gronowski
72b835151a Merge pull request #48720 from jsternberg/buildkit-gc-options
builder: wire up new gc types for buildkit prune functionality
2025-02-03 16:55:46 +00:00
Sebastiaan van Stijn
c8f1a41965 Merge pull request #49361 from vvoland/pr-validate-sync
gha/validate-pr: Also run when PR has new commits
2025-02-03 17:11:56 +01:00
Sebastiaan van Stijn
329b2a26f3 client: normalize and validate empty ID / name arguments to fail early
In situations where an empty ID was passed, the client would construct an
invalid API endpoint URL, which either resulted in the "not found" handler
being hit (resulting in a "page not found" error), or even the wrong endpoint
being hit if the client follows redirects.

For example, `/containers/<empty id>/json` (inspect) redirects to `/containers/json`
(docker ps))

Given that empty IDs should never be expected (especially if they're part of
the API URL path), we can validate these and return early.

Its worth noting that a few methods already had an error in place; those
methods were related to the situation mentioned above, where (e.g.) an
"inspect" would redirect to a "list" endpoint. The existing errors, for
convenience, mimicked a "not found" error; this patch changes such errors
to an "Invalid Parameter" instead, which is more correct, but it could be
a breaking change for some edge cases where users parsed the output;

    git grep 'objectNotFoundError{'
    client/config_inspect.go:        return swarm.Config{}, nil, objectNotFoundError{object: "config", id: id}
    client/container_inspect.go:     return container.InspectResponse{}, nil, objectNotFoundError{object: "container", id: containerID}
    client/container_inspect.go:     return container.InspectResponse{}, objectNotFoundError{object: "container", id: containerID}
    client/distribution_inspect.go:  return distributionInspect, objectNotFoundError{object: "distribution", id: imageRef}
    client/image_inspect.go:         return image.InspectResponse{}, nil, objectNotFoundError{object: "image", id: imageID}
    client/network_inspect.go:       return network.Inspect{}, nil, objectNotFoundError{object: "network", id: networkID}
    client/node_inspect.go:          return swarm.Node{}, nil, objectNotFoundError{object: "node", id: nodeID}
    client/plugin_inspect.go:        return nil, nil, objectNotFoundError{object: "plugin", id: name}
    client/secret_inspect.go:        return swarm.Secret{}, nil, objectNotFoundError{object: "secret", id: id}
    client/service_inspect.go:       return swarm.Service{}, nil, objectNotFoundError{object: "service", id: serviceID}
    client/task_inspect.go:          return swarm.Task{}, nil, objectNotFoundError{object: "task", id: taskID}
    client/volume_inspect.go:        return volume.Volume{}, nil, objectNotFoundError{object: "volume", id: volumeID}

Two such errors are still left, as "ID or name" would probably be confusing,
but perhaps we can use a more generic error to include those as well (e.g.
"invalid <object> reference: value is empty");

    client/distribution_inspect.go:  return distributionInspect, objectNotFoundError{object: "distribution", id: imageRef}
    client/image_inspect.go:         return image.InspectResponse{}, nil, objectNotFoundError{object: "image", id: imageID}

Before this patch:

    docker container start ""
    Error response from daemon: page not found
    Error: failed to start containers:

    docker container start " "
    Error response from daemon: No such container:
    Error: failed to start containers:

With this patch:

    docker container start ""
    invalid container name or ID: value is empty
    Error: failed to start containers:

    docker container start " "
    invalid container name or ID: value is empty
    Error: failed to start containers:

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-02-03 11:21:51 +01:00
Sebastiaan van Stijn
96ded2a1ba Merge pull request #48850 from JSchltggr/fix-sed-nix-dind
Fix concurrency issue in dind
2025-02-01 23:39:53 +01:00
Sebastiaan van Stijn
bae1ac820e Merge pull request #49375 from LaurentGoderre/fix-typo
Fix typo in API docs
2025-01-31 22:12:52 +01:00
Laurent Goderre
844797348e Implement image mount for the snapshotter
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-01-31 10:34:27 -05:00
Laurent Goderre
8c58934106 Implement mount from image
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-01-31 10:34:27 -05:00
Sebastiaan van Stijn
f88304adf0 Merge pull request #49373 from thaJeztah/client_improve_error_response_handling
client: improve handling of JSON error-responses with incorrect schema
2025-01-31 13:04:39 +01:00
Laurent Goderre
c935a4609d Fix typo in API docs
Signed-off-by: Laurent Goderre <laurent.goderre@docker.com>
2025-01-30 16:57:43 -05:00
Rob Murray
1463c99461 Merge pull request #49364 from robmry/wait_for_bridge_forwarding
Before sending ARPs/NAs, check the bridge is ready
2025-01-30 21:50:01 +00:00
Sebastiaan van Stijn
30e75b8396 client: improve handling of JSON error-responses with incorrect schema
Before this patch, an API response that's valid JSON, but not the right
schema would be silently discarded by the CLI. For example, due to a bug
in Docker Desktop's API proxy, the "normal" (not JSON error) response
would be returned together with a non-200 status code when using an
unsupported API version;

    curl -s -w 'STATUS: %{http_code}\n' --unix-socket /var/run/docker.sock 'http://localhost/v1.99/version'
    {"Platform":{"Name":"Docker Desktop 4.38.0 (181016)"},"Version":"","ApiVersion":"","GitCommit":"","GoVersion":"","Os":"","Arch":""}
    STATUS: 400

Before this patch, this resulted in no output being shown;

    DOCKER_API_VERSION=1.99 docker version
    Client:
     Version:           27.5.1
     API version:       1.99 (downgraded from 1.47)
     Go version:        go1.22.11
     Git commit:        9f9e405
     Built:             Wed Jan 22 13:37:19 2025
     OS/Arch:           darwin/arm64
     Context:           desktop-linux
    Error response from daemon:

With this patch, an error is generated based on the status:

    DOCKER_API_VERSION=1.99 docker version
    Client:
     Version:           27.5.1
     API version:       1.99 (downgraded from 1.47)
     Go version:        go1.22.11
     Git commit:        9f9e405
     Built:             Wed Jan 22 13:37:19 2025
     OS/Arch:           darwin/arm64
     Context:           desktop-linux
    Error response from daemon: API returned a 400 (Bad Request) but provided no error-message

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-30 22:01:13 +01:00
Sebastiaan van Stijn
e82d90384e Merge pull request #49367 from thaJeztah/fix_getNetworkedContainer_errors
daemon: Daemon.getNetworkedContainer: fix errors for invalid network container
2025-01-30 21:40:33 +01:00
Rob Murray
9a6e96fd9c Before sending ARPs/NAs, check the bridge is ready
We don't enable STP on bridges belonging to bridge networks,
but bridge ports still need to transition from "disabled" to
"forwarding", after the veth device comes "up". Until then,
the bridge will just drop packets.

So, if a container's network is a veth device, and its other
end is slaved to a bridge - wait for the bridge port to
be "forwarding".

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-30 20:40:01 +00:00
Sebastiaan van Stijn
a5db4280d8 Merge pull request #49368 from thaJeztah/rmlink_nofuzzy
daemon: Daemon.rmLink: don't fuzzy-match container when using ID
2025-01-30 19:04:44 +01:00
Sebastiaan van Stijn
8860e98d1a Merge pull request #49369 from thaJeztah/daemon_remove_wrappers
daemon: remove Daemon.children(), Daemon.parents() wrappers
2025-01-30 18:04:41 +01:00
Sebastiaan van Stijn
e7f5d73fa5 Merge pull request #49354 from thaJeztah/client_test_coverage
client: improve test-coverage for error-responses
2025-01-30 17:07:00 +01:00
Sebastiaan van Stijn
5b5ad4df2c Merge pull request #49352 from thaJeztah/api_version_prefix
client: WithVersion: strip v-prefix when setting API version
2025-01-30 17:04:31 +01:00
Jonathan A. Sternberg
8e529682af builder: wire up new gc types for buildkit prune functionality
This wires up the new gc types that buildkit exposes in version 0.17.
The previous flag, `KeepBytes`, was renamed to `ReservedBytes` and two
new options, `MaxUsed` and `MinFree` were added.

`MaxUsed` corresponds to the maximum amount of space that buildkit will
use for the build cache and `MinFree` amount of free disk space for the
system to prevent the cache from using that space. This allows greater
configuration of the cache storage usage when used in situations where
docker is not the only service on the system using disk space.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-01-30 09:54:12 -06: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
513fd86710 daemon: Daemon.getNetworkedContainer: fix errors for invalid network container
When failing to resolve the network container, a "not found" error should
not return a 404, but either a "invalid parameter" (400) or "system" (500)
error.

Given that this function is called on container start, not container create,
a 500 (internal server error) is more appropriate, because the API request
(start the container) is valid, but the state of the container isn't.

While working on this, I discovered that no validation happens during container
create; TODO's were added to look into that, but this may be partially
by design (allow a container to be created before the "donor" network
container is created).

Before this patch:

    docker container create --name hello --network=container:nosuchcontainer alpine
    docker container start hello
    Error response from daemon: No such container: nosuchcontainer
    Error: failed to start containers: hello

    # daemon logs:
    DEBU[2025-01-30T11:32:33.595636043Z] error response for POST request               error-response="No such container: nosuchcontainer" method=POST module=api request-url=/v1.47/containers/hello/start status=404 vars="map[name:hello version:1.47]"

    docker container create --name hello2 --network=container:hello2 alpine
    docker container start hello2
    Error response from daemon: cannot join own network
    Error: failed to start containers: hello2

    # daemon logs:
    DEBU[2025-01-30T11:33:19.545287551Z] FIXME: Got an API for which error does not match any expected type!!!  error="cannot join own network" error_type="*errors.errorString" module=api
    DEBU[2025-01-30T11:33:19.545346093Z] error response for POST request               error-response="cannot join own network" method=POST module=api request-url=/v1.47/containers/hello2/start status=500 vars="map[name:hello2 version:1.47]"
    DEBU[2025-01-30T11:33:19.545369968Z] FIXME: Got an API for which error does not match any expected type!!!  error="cannot join own network" error_type="*errors.errorString" module=api
    ERRO[2025-01-30T11:33:19.545375426Z] Handler for POST /v1.47/containers/hello2/start returned error: cannot join own network

With this patch:

    docker container create --name hello --network=container:nosuchcontainer alpine
    docker container start hello
    Error response from daemon: joining network of container: No such container: nosuchcontainer
    Error: failed to start containers: hello

    # daemon logs:
    DEBU[2025-01-30T11:35:50.406462760Z] error response for POST request               error-response="joining network of container: No such container: nosuchcontainer" method=POST module=api request-url=/v1.47/containers/hello/start status=500 vars="map[name:hello version:1.47]"
    ERRO[2025-01-30T11:35:50.406501468Z] Handler for POST /v1.47/containers/hello/start returned error: joining network of container: No such container: nosuchcontainer

    docker container create --name hello2 --network=container:hello2 alpine
    docker container start hello2
    Error response from daemon: cannot join own network namespace
    Error: failed to start containers: hello2

    # daemon logs:
    DEBU[2025-01-30T11:36:15.178475049Z] error response for POST request               error-response="cannot join own network" method=POST module=api request-url=/v1.47/containers/hello2/start status=500 vars="map[name:hello2 version:1.47]"
    ERRO[2025-01-30T11:36:15.178536507Z] Handler for POST /v1.47/containers/hello2/start returned error: cannot join own network

    docker run --name exitedcontainer alpine
    docker run --rm --network=container:exitedcontainer alpine
    docker: Error response from daemon: cannot join network namespace of a non running container: container exitedcontainer is exited.

    # daemon logs:
    DEBU[2025-01-30T12:54:28.040637429Z] error response for POST request               error-response="cannot join network namespace of a non running container: container exitedcontainer is exited" method=POST module=api request-url=/v1.47/containers/hello2/start status=409 vars="map[name:hello2 version:1.47]"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-30 14:18:33 +01:00
Sebastiaan van Stijn
51cb066ec8 daemon: Daemon.rmLink: don't fuzzy-match container when using ID
rmLink already looked up the parent container's ID, so we should not use
daemon.GetContainer to resolve the container, as that performs fuzzy
matching (name, ID-prefix, or ID).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-30 11:39:19 +01:00
Paweł Gronowski
79b0e89628 github: Clarify release notes description
Error out if the release notes section is filled for PRs without the
`impact/` label.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-30 11:00:55 +01:00
Sebastiaan van Stijn
c42005e944 Merge pull request #49356 from thaJeztah/client_reduce_test_deps
client: remove uses of pkg/errors in tests
2025-01-29 23:26:23 +01:00
JSchltggr
c43aa0b6aa Fix concurrency issue in dind
Signed-off-by: JSchltggr <jschltggr@gmail.com>
2025-01-29 19:25:45 +01:00
Paweł Gronowski
7ac0e34dba gha/validate-pr: Also run when PR has new commits
Otherwise, the workflow will won't be rerun even if it was failing
before.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-29 18:26:50 +01:00
Paweł Gronowski
e273a5635a Merge pull request #49355 from thaJeztah/api_types_less_deps
api/types: remove some redundant imports
2025-01-29 15:28:41 +01:00
Sebastiaan van Stijn
dcaf8cb805 Merge pull request #47649 from vvoland/dev-completions
Dockerfile: Use CLI generated completions in the dev shell
2025-01-29 13:03:34 +01:00
Sebastiaan van Stijn
9b5a51a881 api/types/container: remove use of errdefs package in test
It was the only use of errdefs inside api/types, which is the package
that's imported by external users.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-29 12:36:40 +01:00
Sebastiaan van Stijn
02eb72380f client: remove uses of pkg/errors in tests
While there may be reasons to keep pkg/errors in production
code, we don't need them for these tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-29 11:53:16 +01:00
Sebastiaan van Stijn
3f354e8c1b api/types/registry: use stdlib errors package
It was the only use of github.com/pkg/errors inside api/types,
which is the package that's imported by external users.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-29 11:51:29 +01:00
Sebastiaan van Stijn
0ca0ccd37a client: improve test-coverage for error-responses
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-29 11:47:25 +01:00
Rob Murray
9fdcde7618 Add bridge gateway mode "isolated"
It can only be set on a "--internal" network, and the only difference is
that no address is assigned to the bridge. So, there's no route to a
host address.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-29 10:28:55 +00:00
Sebastiaan van Stijn
04f9d3e5fe Merge pull request #49349 from thaJeztah/bridge_clean_errors
libnetwork/drivers/bridge: remove, or internalize errors
2025-01-28 22:33:18 +01:00
Sebastiaan van Stijn
97b50bca2c client: WithVersion: strip v-prefix when setting API version
When overriding the API version through DOCKER_API_VERSION, no validation
happens on the given version. However, some code-paths in the client do
some minor normalizing, and strip the "v" prefix (if present) as part of
[`Client.getAPIPath()`][1].

This resulted in some inconsistent handling of the version that's set. For
example,  [`Client.checkResponseErr()`][2] decides whether or not the API
response is expected to support errors in JSON format (`types.ErrorResponse`),
which would fail because `versions.GreaterThan()` does not strip the prefix,
therefore making the first element "zero" (ranking lower than any valid version).

Net result was "mixed" because of this; for example in the following, half
the output is handled correctly ("downgraded from 1.47"), but the response
is handled as < 1.23 (so printed as-is);

    DOCKER_API_VERSION=v1.23 docker version
    Client: Docker Engine - Community
     Version:           27.5.1
     API version:       v1.23 (downgraded from 1.47)
     Go version:        go1.22.11
     Git commit:        9f9e405
     Built:             Wed Jan 22 13:41:13 2025
     OS/Arch:           linux/amd64
     Context:           default
    Error response from daemon: {"message":"client version 1.23 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version"}

Passing the version without v-prefix corrects this problem;

    DOCKER_API_VERSION=1.23 docker version
    Client: Docker Engine - Community
     Version:           27.5.1
     API version:       1.99 (downgraded from 1.47)
     Go version:        go1.22.11
     Git commit:        9f9e405
     Built:             Wed Jan 22 13:41:13 2025
     OS/Arch:           linux/amd64
     Context:           default
    Error response from daemon: client version 1.99 is too new. Maximum supported API version is 1.47

    DOCKER_API_VERSION=v1.99 docker version
    Client: Docker Engine - Community
     Version:           27.5.1
     API version:       v1.99 (downgraded from 1.47)
     Go version:        go1.22.11
     Git commit:        9f9e405
     Built:             Wed Jan 22 13:41:13 2025
     OS/Arch:           linux/amd64
     Context:           default
    Error response from daemon: {"message":"client version 1.99 is too new. Maximum supported API version is 1.47"}

This patch strips the prefix when setting a custom version, so that
normalization happens consistently. The existing code to strip the
prefix in [`Client.getAPIPath()`][1] is kept for now, in case values
are set through other ways.

[1]: 47dc8d5dd8/client/client.go (L303-L309)
[2]: 47dc8d5dd8/client/request.go (L231-L241)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 21:32:23 +01:00
Sebastiaan van Stijn
bbaa8af8f3 libnetwork/drivers/bridge: un-export errors
These errors implement errdefs interfaces, and are only used internally
for convenience. Un-export their implemetations because the types themselves
are not used as sentinel errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:12:42 +01:00
Sebastiaan van Stijn
3f9698e1f6 libnetwork/drivers/bridge: TestLinkDelete: use gotest.tools
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:12:42 +01:00
Sebastiaan van Stijn
74fd2ec0cf libnetwork/drivers/bridge: TestLinkCreateNoEnableIPv6: use gotest.tools
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:12:37 +01:00
Sebastiaan van Stijn
6e9ba725f8 libnetwork/drivers/bridge: TestLinkCreateTwo: use gotest.tools
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:10:15 +01:00
Sebastiaan van Stijn
bf3323fd40 libnetwork/drivers/bridge: TestLinkCreate: use gotest.tools
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:10:15 +01:00
Sebastiaan van Stijn
7012e3ce14 libnetwork/drivers/bridge: remove NonDefaultBridgeExistError
It was only used in a single place, and a generic errdefs.ErrInvalid; the
type itself was not used as sentinel error other than for a unit test.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:10:15 +01:00
Sebastiaan van Stijn
47f6d4e1bc libnetwork/drivers/bridge: internalize ErrInvalidGateway
It's a generic errdefs.ErrInvalidParameter, and the type itself is not
used as sentinel error anywhere.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:10:14 +01:00
Sebastiaan van Stijn
3a9f4e0146 libnetwork/drivers/bridge: remove ErrInvalidMtu
It's a generic errdefs.ErrInvalidParameter, and the type itself is not
used as sentinel error anywhere.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:10:14 +01:00
Sebastiaan van Stijn
2f42aa0e26 libnetwork/drivers/bridge: remove IPv4AddrNoMatchError
It's a generic error, doesn't implement an errdefs type, and not used as
sentinel error anywhere.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:10:14 +01:00
Sebastiaan van Stijn
0c1b660048 libnetwork/drivers/bridge: remove IPv4AddrAddError
It's a generic error, doesn't implement an errdefs type, and not used as
sentinel error anywhere.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:10:14 +01:00
Sebastiaan van Stijn
dc52ecb1d0 libnetwork/drivers/bridge: remove ErrNoIPAddr
It's a generic error, doesn't implement an errdefs type, and not used as
sentinel error anywhere.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:10:14 +01:00
Sebastiaan van Stijn
77261b5e42 libnetwork/drivers/bridge: remove "InternalError()" method from errors
The `InternalError()` method was added in [moby/libnetwork@50964c9] to
classify the error. However, the same commit defined interfaces for error
types (in the types package). The [InternalError] interface defined did
not match, as it defines a `Internal()` method instead of `InternalError()`.

In short; these errors were never matching any interface, and the actual
error implementations themselves were also never used as a sentinel error,
so we can safely remove these methods.

[moby/libnetwork@50964c9]: 50964c9948
[InternalError]: 50964c9948/types/types.go (L233-L237)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:10:13 +01:00
Sebastiaan van Stijn
2766298f49 libnetwork/drivers/bridge: remove unused errors
This removes the following errors, which were not used anywhere;

- ErrConfigExists
- ErrInvalidNetworkConfig
- ErrInvalidEndpointConfig
- ErrNetworkExists
- ErrIfaceName
- ErrUnsupportedAddressType
- NonDefaultBridgeNeedsIPError
- IPv6AddrNoMatchError

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:10:13 +01:00
Sebastiaan van Stijn
59c2d2a4b3 libnetwork/drivers/bridge: remove ErrInvalidDriverConfig
It's a generic error, doesn't implement an errdefs type, is poorly formatted,
and not used as sentinel error anywhere. Let's remove it, and update the error
produced to be slightly more informative (include the invalid type). Worth
noting that there's no need to include the name of the driver in the error,
because the only uses of the error (in `registerNetworkDrivers`) already
decorates it; 5fd7ed2937/libnetwork/drivers_linux.go (L34-L36)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 19:10:11 +01:00
Sebastiaan van Stijn
47dc8d5dd8 Merge pull request #49325 from akerouanton/fix-45610-v2
libnet/d/bridge: drop connections to lo mappings, and direct remote connections
2025-01-28 16:38:29 +01:00
Sebastiaan van Stijn
beb5fa6acc Merge pull request #49350 from thaJeztah/windows_clean_errors
libnetwork/drivers/windows: remove ErrUnsupportedAddressType
2025-01-28 16:30:49 +01:00
Sebastiaan van Stijn
1c22f5d3d7 Merge pull request #49347 from thaJeztah/libnetwork_options_gotest
libnetwork/options: rewrite tests with gotest.tools
2025-01-28 16:28:45 +01:00
Sebastiaan van Stijn
6bb9f581a5 libnetwork/drivers/windows: remove ErrUnsupportedAddressType
It was only used in a single place, and did not implement an errdef;
the type itself was not used as sentinel error.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 15:14:27 +01:00
Paweł Gronowski
54a969d1a4 Dockerfile: Use CLI generated completions in the dev shell
Use Cobra-generated completion scripts for the CLI inside the dev
container shell.

Remove `DOCKER_BASH_COMPLETION_PATH`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-28 14:28:20 +01:00
Sebastiaan van Stijn
510e6f4f8a libnetwork/options: rewrite tests with gotest.tools
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-28 12:27:44 +01:00
Sebastiaan van Stijn
5fd7ed2937 Merge pull request #49342 from robmry/debug_flaky_unsol_na
Debug flaky unsolicited Neighbour Advertisements
2025-01-28 12:14:38 +01:00
Albin Kerouanton
ac23dddac0 Merge pull request #49302 from robmry/create_veth_in_container
Create bridge veth in container netns
2025-01-28 11:47:33 +01:00
Sebastiaan van Stijn
f760738a15 Merge pull request #49336 from thaJeztah/no_strslice
remove redundant uses of api/types/strslice.StrSlice
2025-01-27 21:33:11 +01:00
Albin Kerouanton
a42b601c31 Merge pull request #49343 from thaJeztah/cluster_cleanup_networkattachment
daemon/cluster/executor: simplify handling of Network Attachments
2025-01-27 18:47:29 +01:00
Sebastiaan van Stijn
af9ffb64cd builder/dockerfile: more consistently put "expected" on the right
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 18:46:48 +01:00
Sebastiaan van Stijn
86a8bfdce4 remove redundant uses of api/types/strslice.StrSlice
The only real purpose of strslice.StrSlice is to provide a custom
json.Unmarshaler implementation for API responses. For all other purposes,
it's a regular string-slice.

This patch removes uses of this type in cases where the custom json.Unmarshaler
is irrelevant; in most cases this was in tests, where results were tested
using "DeepEquals"; for those tests, the type-assertion did not add real
value, so we can cast the values to a []string instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 18:46:48 +01:00
Albin Kerouanton
d216084185 libnet/d/bridge: drop remote connections to port mapped on lo
Traditionally when Linux receives remote packets with daddr set to a
loopback address, it reject them as 'martians'. However, when a NAT rule
is applied through iptables this doesn't happen. Our current DNAT rule
used to map host ports to containers is applied unconditionally, even
for such 'martian' packets.

This means a neighbor host (ie. a host connected to the same L2
segment) can send packets to a port mapped on a loopback address. The
purpose of publishing on a loopback address is to make ports
inaccessible to remote hosts -- lack of proper filtering defeats that.

This commit adds an iptables rule to the raw-PREROUTING chain to drop
packets with a loopback dest address and coming from any interface other
than lo.

To accomodate WSL2 mirrored mode, another rule is inserted beforehand to
specifically accept packets coming from the loopback0 interface.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-01-27 18:41:20 +01:00
Albin Kerouanton
27adcd596b libnet/d/bridge: port mappings: drop direct-access when gw_mode=nat
When a NAT-based port mapping is created, the daemon adds a DNAT rule in
nat-DOCKER to replace the dest addr with the container IP. However, the
daemon never sets up rules to filter packets destined directly to the
container port. This allows a rogue neighbor (ie. a host that shares a
L2 segment with the host) to send packets directly to the container on
its container-side exposed port.

For instance, if container port 5000 is mapped to host port 6000, a
neighbor could send packets directly to the container on its port 5000.

Since nat-DOCKER mangles the dest addr, and the nat table forbids DROP
rules, this change adds a new rule in the raw-PREROUTING chain to filter
ingress connections targeting the container's IP address.

This filtering is only done when gw_mode=nat. For the unprotected
variant, no filtering is done.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-01-27 18:41:20 +01:00
Albin Kerouanton
8474153e13 integration: accessing mappings from another docker network
Commit fc7caf96d reverted 433b1f9b1 as it was introducing a regression,
ie. containers couldn't reach ports published on the host using their
gateway's IP address or the host IP address.

These scenarios are now tested.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-01-27 18:41:20 +01:00
Albin Kerouanton
a7e6d0a8a3 libnet/d/bridge: releasePortBindings: append directly into 'errs'
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-01-27 18:41:15 +01:00
Rob Murray
c2a51054b5 Merge pull request #49338 from thaJeztah/integration_rm_assertAttachedStream
integration: remove assertAttachedStream, check both STDERR and STDOUT
2025-01-27 16:01:45 +00:00
Rob Murray
4f2e128378 Merge pull request #49337 from thaJeztah/simplify_health_getshell
daemon: health: getShell: simplify logic (LCOW remnants)
2025-01-27 15:55:56 +00:00
Rob Murray
bd353d4dba Merge pull request #49335 from thaJeztah/daemon_getEntrypointAndArgs_nomethod
daemon: make daemon.getEntrypointAndArgs a regular function
2025-01-27 15:39:01 +00:00
Sebastiaan van Stijn
47414e22ff Merge pull request #49344 from thaJeztah/libnetwork_use_errdefs_step4
libnetwork: remove ErrNoSuchEndpoint, ErrInvalidID, ErrInvalidName
2025-01-27 16:27:10 +01:00
Rob Murray
aa3a23d4f9 Temporary debug for unsolicited NA
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-27 14:56:31 +00:00
Sebastiaan van Stijn
49b1ed6d27 libnetwork: remove ErrInvalidName
It was only returned in a few places, and not used any different than
a "invalid parameter" error, so let's use a standard errdefs.ErrInvalidParameter

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 14:19:19 +01:00
Sebastiaan van Stijn
a98ecc5f79 libnetwork: remove ErrInvalidID
It was only returned in a few places, and not used any different than
a "invalid parameter" error, so let's use a standard errdefs.ErrInvalidParameter

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 14:19:19 +01:00
Sebastiaan van Stijn
548b0b6290 libnetwork: remove ErrNoSuchEndpoint
It was only returned in 1 place, and not used any different than
a "notfound" error, so let's use a standard errdefs.ErrNotFound

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 14:19:08 +01:00
Sebastiaan van Stijn
e2eea37f20 Merge pull request #49339 from thaJeztah/enable_shell_completion
dockerd: enable shell-completion; add (hidden) completion subcommand
2025-01-27 13:20:04 +01:00
Rob Murray
7cc81407aa Add trace/logging in waitForIfUpped
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-27 11:52:21 +00:00
Rob Murray
30601d96b7 Dump daemon logs when TestAdvertiseAddrs fails
This test has failed a couple of times in CI, but can't repro locally.

Let's find out whether there are any clues in the daemon log.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-27 11:52:21 +00:00
Sebastiaan van Stijn
668cb5a688 Merge pull request #49341 from thaJeztah/libnetwork_remove_EndpointByID
libnetwork: remove Network.EndpointByID as it must not be used
2025-01-27 12:42:40 +01:00
Sebastiaan van Stijn
8705018705 daemon/cluster/executor: containerConfig: store Network instead of envelope
The Network field is the only field used from the NetworkAttachment within
this code. Remove the NetworkAttachment envelope, and store the Network
field directly instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 12:30:32 +01:00
Sebastiaan van Stijn
90323ae123 daemon/cluster/executor: networkCreateRequest: not a method
This method was called in a loop, iterating over the container config's
network-attachments. It was defined as a method, but only to lookup
the same attachment we just iterated over existed, and to obtain a copy.
As there were no goroutines involved, dereferencing should not be an issue
and with Go 1.22+, dereferencing loop vars is no longer needed at all,
so we can change this method to a regular constructor; also removing the
redundant error-return in the process.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 12:30:32 +01:00
Sebastiaan van Stijn
f5f4a062a5 daemon/cluster/executor: networkCreateRequest: slight DRY cleanup
All of this function only referenced the Network field in the attachment;
use an intermediate variable to make the code less repetitive.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 12:30:32 +01:00
Sebastiaan van Stijn
16770340ea daemon/cluster/executor: networkCreateRequest don't shadow config
c is used as name for the containerConfig receiver; remove the intermediate
variable so that we don't shadow it. There's no bug here, because a new
variable is created; just to prevent confusion and to make linters happier.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 12:30:31 +01:00
Paweł Gronowski
c677454794 Merge pull request #49340 from thaJeztah/bump_gomd2man
man: vendor github.com/cpuguy83/go-md2man/v2 v2.0.6
2025-01-27 11:05:50 +01:00
Sebastiaan van Stijn
cef6fd2fa2 libnetwork: remove Network.EndpointByID as it must not be used
commit 80c44b4b2e removed uses of this
method and added a comment that it should never be used;

> EndpointByID should *never* be called as it's going to create a 2nd instance
> of an Endpoint. The first one lives in the Sandbox the endpoint is attached to.
> Instead, the endpoint should be retrieved by calling [Sandbox.Endpoints()].

Given that the only use of this method is in tests, we can remove if altogether.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-27 10:49:40 +01:00
Sebastiaan van Stijn
56547a3dcf Merge pull request #49332 from thaJeztah/libnetwork_use_errdefs_step3
libnetwork: use gotest.tools for errdefs assertions in various tests
2025-01-27 10:39:46 +01:00
Sebastiaan van Stijn
4e6535fd3e man: vendor github.com/cpuguy83/go-md2man/v2 v2.0.6
full diff: https://github.com/cpuguy83/go-md2man/compare/v2.0.5...v2.0.6

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:40:10 +01:00
Sebastiaan van Stijn
5c1fe287fc libnetwork: remove UnknownNetworkError
It was only returned in 2 places, and not used any different than
a "notfound" error, so let's use a standard errdefs.NotFound

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:35:22 +01:00
Sebastiaan van Stijn
8f4c98e1eb libnetwork: TestControllerGetSandbox: use errdefs for error asserts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:35:22 +01:00
Sebastiaan van Stijn
d34ca256b8 libnetwork: TestNetworkConfig: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:35:22 +01:00
Sebastiaan van Stijn
c6f0fe5fc0 libnetwork: parallelTester.Do: use errdefs for error assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:35:22 +01:00
Sebastiaan van Stijn
11a6cb5fac libnetwork: TestEndpointJoin: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:35:21 +01:00
Sebastiaan van Stijn
ea7d17376e libnetwork: TestInvalidRemoteDriver: use gotest.tools for error assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:35:21 +01:00
Sebastiaan van Stijn
01c87cc809 libnetwork: TestContainerInvalidLeave: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:35:21 +01:00
Sebastiaan van Stijn
9472c860de libnetwork: TestEndpointMultipleJoins: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:35:21 +01:00
Sebastiaan van Stijn
ab9d250876 libnetwork: TestEndpointDeleteWithActiveContainer: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:35:21 +01:00
Sebastiaan van Stijn
56debcfc1c libnetwork: TestNetworkQuery: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:35:20 +01:00
Sebastiaan van Stijn
874fb4d2f4 libnetwork: TestControllerQuery: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:35:13 +01:00
Sebastiaan van Stijn
53bf2e8960 libnetwork: TestUnknownEndpoint: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:17:43 +01:00
Sebastiaan van Stijn
895ee1214a libnetwork: TestDuplicateEndpoint: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:17:43 +01:00
Sebastiaan van Stijn
678a8a27f5 libnetwork: TestUnknownNetwork: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:17:42 +01:00
Sebastiaan van Stijn
9304d98757 libnetwork: TestDeleteNetworkWithActiveEndpoints: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:17:42 +01:00
Sebastiaan van Stijn
01b0fe1172 libnetwork: TestNetworkName: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:17:42 +01:00
Sebastiaan van Stijn
24df497674 libnetwork: TestNilRemoteDriver: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:17:42 +01:00
Sebastiaan van Stijn
532d36c251 libnetwork: TestUnknownDriver: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:17:42 +01:00
Sebastiaan van Stijn
400ad04c74 libnetwork: TestNull: use gotest.tools for errdefs assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 21:17:39 +01:00
Sebastiaan van Stijn
3bb40af036 dockerd: enable shell-completion; add (hidden) completion subcommand
This required a minor hack to accommodate Cobra's logic (and a TODO was
added to see if we can improve that logic in upstream). Some changes also
had to be made to our "Usage" template, as our custom template did not
take into account subcommands and long descriptions for commands. We
should review these templates, as some additional features were added
in upstream Cobra that we currently may not be using.

With this patch:

instructions for the (hidden) completion subcommand:

    docker completion --help

    Usage:  docker completion COMMAND

    Generate the autocompletion script for docker for the specified shell.
    See each sub-command's help for details on how to use the generated script.

    Commands:
      bash        Generate the autocompletion script for bash
      fish        Generate the autocompletion script for fish
      powershell  Generate the autocompletion script for powershell
      zsh         Generate the autocompletion script for zsh

    Run 'docker completion COMMAND --help' for more information on a command.

and instructions for installing:

    dockerd completion bash --help

    Usage:	dockerd completion bash

    Generate the autocompletion script for the bash shell.

    This script depends on the 'bash-completion' package.
    If it is not installed already, you can install it via your OS's package manager.

    To load completions in your current shell session:

        source <(dockerd completion bash)

    To load completions for every new session, execute once:

    #### Linux:

        dockerd completion bash > /etc/bash_completion.d/dockerd

    #### macOS:

        dockerd completion bash > $(brew --prefix)/etc/bash_completion.d/dockerd

    You will need to start a new shell for this setup to take effect.

    Options:
          --help              Print usage
          --no-descriptions   disable completion descriptions

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 17:12:26 +01:00
Sebastiaan van Stijn
816f3fa516 integration: remove assertAttachedStream, check both STDERR and STDOUT
This helper was not marked as t.Helper(), and didn't do a great job at
actually asserting the expected output streams. The existing checks
could've been replaced by a io.Readall to do a fuzzy check for the
response, but let's abstract away what it's doing, and properly check
both STDOUT and STDERR.

    make BIND_DIR=. TEST_FILTER='TestTemplated' DOCKER_GRAPHDRIVER=vfs test-integration
    ...
    INFO: Testing against a local daemon
    === RUN   TestTemplatedConfig
    --- PASS: TestTemplatedConfig (11.73s)
    PASS
    INFO: Testing against a local daemon
    === RUN   TestTemplatedSecret
    --- PASS: TestTemplatedSecret (11.04s)
    PASS

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 16:12:58 +01:00
Sebastiaan van Stijn
2197549e4f daemon: health: getShell: simplify logic (LCOW remnants)
This function had some LCOW remnants, where the assumption was made
the only on Windows, the image's OS could potentially not match the
host's OS (see 3e6a13ccb8).

While we currently are not able to run a Windows image on Linux (or
vice versa), this function doesn't have to take into account;

- If a shell is configured; use whatever is configured
- otherwise, use "cmd.exe" for Windows images, and "/bin/sh" otherwise
  (likely Linux, but the existing code did not account for other platforms).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 15:27:46 +01:00
Sebastiaan van Stijn
d3c0825439 daemon: make daemon.getEntrypointAndArgs a regular function
It was not using the daemon, so can be a regular function. While at it,
also changed the parameter type to accept a regular string-slice, as
we don't need strslice.StrSlice's json.Unmarshaler implementation, and
reversed the logic for the early return.

Finally, for uses where the entrypoint was always nil, this patch removes
the use of this utility altogether.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-26 14:37:08 +01:00
Rob Murray
65120d586b Create bridge veth in container netns
Since commit 933fcc9 (Re-remove the SetKey OCI prestart hook),
the network namespace will be set up before endpoints are
created in most cases, apart from build containers.

So, when possible, create the veth with one end in that netns
to save moving it in later. On my host, that saves about 20ms
for each bridge network a container is connected to.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-24 18:43:51 +00:00
Sebastiaan van Stijn
433e9a50ce Merge pull request #48828 from vbatts/cgroups-rw
daemon/&container/: enable `--security-opt writable-cgroups=true|false` as an option
2025-01-23 20:41:08 +01:00
Rob Murray
b3b9e990ee Get netns before calling moveLink
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-23 14:53:52 +00:00
Rob Murray
357fb9d58d Add trace/logging in waitForIfUpped
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-23 14:53:52 +00:00
Rob Murray
441579aaf1 Merge pull request #48809 from robmry/v6only/not_experimental
IPv6 only: not experimental
2025-01-23 11:36:31 +00:00
Sebastiaan van Stijn
f2804e04b2 Merge pull request #49329 from thaJeztah/libnetwork_use_errdefs_step2
libnetwork: rewrite some tests to use gotest.tools
2025-01-23 11:30:03 +01:00
Sebastiaan van Stijn
c8a456a5a2 Merge pull request #49327 from thaJeztah/libnetwork_type_conversions
libnetwork: remove some redundant type-conversions
2025-01-23 11:28:18 +01:00
Sebastiaan van Stijn
203d6530d0 libnetwork: use gotest.tools assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 22:20:43 +01:00
Sebastiaan van Stijn
a39bee9b71 libnetwork: suppress some unhandled errors in tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 22:06:40 +01:00
Sebastiaan van Stijn
376ff6add6 libnetwork: use assert.Check in defers
Prefering Check here over NilError so that all defers
wil be executed, instead of potentially failing on the
first one.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 22:06:40 +01:00
Sebastiaan van Stijn
71c9a45672 libnetwork: use assert.NilError (step 2)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 22:06:38 +01:00
Sebastiaan van Stijn
231012996f libnetwork: use assert.NilError (step 1)
First step; this is just a find and replace

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 22:05:58 +01:00
Rob Murray
6bb69a21bf EnableIPv4:false is no longer --experimental
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-22 18:56:41 +00:00
Rob Murray
94444587d4 Merge pull request #48808 from robmry/v6only/gratuitous_arp
IPv6 only: use random MAC addresses
2025-01-22 18:52:21 +00:00
Rob Murray
9a37ae3657 Test unsolicited ARP/NA on interface creation
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-22 16:59:27 +00:00
Rob Murray
bc130f367d bridge/macvlan endpoints always use a random MAC address
Now a gratuitous/unsolicted ARP is sent, there's no need to
use an IPv4-based MAC address to preserve arp-cache mappings
between an endpoint's IP addresses and its MAC addresses.

Because a random MAC address is used for the default bridge,
it no longer makes sense to derive container IPv6 addresses
from the MAC address. This "postIPv6" behaviour was needed
before IPv6 addresses could be configured, but not now. So,
IPv6 addresses will now be IPAM-allocated on the default
bridge network, just as they are for user-defined bridges.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-22 16:59:27 +00:00
Cory Snider
a900e0b5bb libn/netutils: put more entropy into random MACs
With randomly-generated MAC addresses going into wider use in the most
commonly used container network drivers, it is imperative to avoid
address collisions. Increase the number of random bits in randomly-
generated MAC addresses from 32 bits to 46 bits.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2025-01-22 16:59:27 +00:00
Rob Murray
422e056b0f Treat failure to send an initial ARP/NA as an error
If this causes problems, setting nmsgs=0 is a workaround.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-22 16:59:27 +00:00
Rob Murray
522016a842 Configurable count and interval for gratuitous ARP/NA messages
The default is to send 3 messages at 1s intervals.

That can be overridden in "docker network create" using:
  -o com.docker.network.advertise_addr_nmsgs=3
  -o com.docker.network.advertise_addr_ms=1000

Or, in daemon.json for each driver:
  "default-network-opts": {
    "bridge": {
      "com.docker.network.advertise_addr_nmsgs": "3",
      "com.docker.network.advertise_addr_ms": "1000"
    }
  }

The allowed range is 0-3 for the number of messages, and
100-2000ms for the interval. Setting nmsgs to 0 disables the
gratuitous ARP/NA messages.

The default bridge will always use the built-in defaults,
it cannot be configured.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-22 16:59:27 +00:00
Rob Murray
eaa84bc8f4 Send unsolicited ARP/NA requests when bringing up interfaces
Co-authored-by: Cory Snider <csnider@mirantis.com>
Co-authored-by: Rob Murray <rob.murray@docker.com>
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-22 16:59:27 +00:00
Sebastiaan van Stijn
20a05dabf4 Merge pull request #49326 from thaJeztah/libnetwork_use_errdefs_step1
libnetwork: use errdefs and gotest.tools for asserting error-types (step 1)
2025-01-22 15:53:26 +01:00
Sebastiaan van Stijn
3719fff903 Merge pull request #49328 from thaJeztah/bridge_configure
libnetwork/drivers/bridge: driver.configure: move vars close to where used
2025-01-22 15:52:23 +01:00
Sebastiaan van Stijn
2f84e2b208 libnetwork/drivers/bridge: driver.configure: move vars close to where used
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 12:53:37 +01:00
Sebastiaan van Stijn
3955c021ff libnetwork: remove redundant type conversion
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 12:51:39 +01:00
Sebastiaan van Stijn
41d502892d libnetwork/drivers/bridge: remove redundant type conversion
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 12:51:39 +01:00
Sebastiaan van Stijn
6e6cf999ed libnetwork: remove isNotfound test-utility
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 12:45:22 +01:00
Sebastiaan van Stijn
c9c322785c libnetwork: Controller.defaultGwNetwork: use errdefs to check for not-found
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 12:45:22 +01:00
Sebastiaan van Stijn
59722228d7 libnetwork/types: compareIPMask: make error more readable
Both net.IP and net.IPMask implement a stringer interface; use it to print
their value. While updating also removed the naked return.

Before this patch:

    cannot compute host portion ip address because ip and mask are not compatible: (net.IP{0x20, 0x1, 0xd, 0xb8, 0x20, 0x2, 0x20, 0x1, 0xff, 0xff, 0xab, 0xcd, 0xee, 0xab, 0x0, 0xcd}, net.IPMask{0xff, 0xff, 0xff, 0x0})
    cannot compute host portion ip address because ip and mask are not compatible: (net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xad, 0x20, 0x4, 0x5}, net.IPMask{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0x0})
    cannot compute host portion ip address because ip and mask are not compatible: (net.IP{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xad, 0x20, 0x4, 0x5}, net.IPMask{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xff, 0xff, 0xff, 0xff, 0xff, 0x0})

With this patch:

    cannot compute host portion ip address because ip and mask are not compatible: (2001:db8:2002:2001:ffff:abcd:eeab:cd, ffffff00)
    cannot compute host portion ip address because ip and mask are not compatible: (173.32.4.5, 000000000000000000000000ffffff00)
    cannot compute host portion ip address because ip and mask are not compatible: (173.32.4.5, 00000000000000000000ffffffffff00)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 12:45:22 +01:00
Sebastiaan van Stijn
768b152494 libnetwork/types: TestUtilGetBroadcastIP: use gotest.tools, table-tests
Also rename the test to TestGetBroadcastIP, removing "Util" from  the name.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 12:45:22 +01:00
Sebastiaan van Stijn
06ae35afb9 libnetwork/types: TestUtilGetHostPartIP: use gotest.tools, table-tests
Also rename the test to TestGetHostPartIP, removing "Util" from  the name.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 12:45:21 +01:00
Sebastiaan van Stijn
9e11ea9287 libnetwork/types: TestCompareIPMask: use gotest.tools, table-tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 12:45:21 +01:00
Sebastiaan van Stijn
85cd2b7c94 libnetwork/types: TestErrorConstructors: use errdefs for asserting
Rewrite the test using gotest.tools and use  the errdefs helpers to assert
the right errdefs definition.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 12:45:21 +01:00
Sebastiaan van Stijn
afcf1b92a5 libnetwork: TestErrorInterfaces: use errdefs helpers to check error-types
Make sure these errors are properly detected by the errdefs helpers to
implement the right interface / definition.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-22 12:45:18 +01:00
Paweł Gronowski
a5960d4b9c Merge pull request #49297 from thaJeztah/distribution_improve_context_and_pipe_errs
distribution: fix / improve handling of "closed pipe" and context cancellation / timeouts
2025-01-22 12:33:57 +01:00
Paweł Gronowski
db03ac8a68 Merge pull request #49323 from thaJeztah/dco_alpine
gha: update DCO check to alpine 3.21
2025-01-22 12:30:48 +01:00
Paweł Gronowski
de7800bb1a Merge pull request #49298 from thaJeztah/layerstore_logs
layerStore.registerWithDescriptor: improve logs for cleaning up cache
2025-01-22 12:21:33 +01:00
Sebastiaan van Stijn
2b4aa5eb52 gha: update DCO check to alpine 3.21
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-21 18:15:19 +01:00
Paweł Gronowski
df0cb852e7 Merge pull request #48617 from thaJeztah/update_grpc_options
daemon: NewDaemon: align grpc options with containerd's defaults
2025-01-21 17:49:06 +01:00
Sebastiaan van Stijn
f32ec6be05 Merge pull request #49318 from thaJeztah/unify_some_errdefs
libnetwork/types: align error-types with errdefs
2025-01-21 15:17:38 +01:00
Sebastiaan van Stijn
dc0f3c085a Merge pull request #49319 from thaJeztah/libnet_godoc
libnetwork/driverapi: fix GoDoc for UpdateIpamConfig
2025-01-21 15:17:16 +01:00
Sebastiaan van Stijn
9dab00554d libnetwork/driverapi: fix GoDoc for UpdateIpamConfig
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-21 13:14:26 +01:00
Sebastiaan van Stijn
52d2d28148 libnetwork/types: align error-types with errdefs
These types were identical to errdefs definitions; make
them an alias and use errdefs utilities to produce them.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-21 11:48:39 +01:00
Sebastiaan van Stijn
29e2353f80 Merge pull request #49223 from robmry/ipam_with_more_bits
IPAM: handle subnets bigger than "/64"
2025-01-21 11:22:14 +01:00
Paweł Gronowski
81501c6a58 Merge pull request #49316 from thaJeztah/bump_dev_tools
Dockerfile: dev-container: update CLI v27.5.0, buildx v0.20.0, compose v2.32.4
2025-01-21 10:53:51 +01:00
Paweł Gronowski
96419cb52a Merge pull request #49266 from dvdksn/fromimage-tag-clarification
docs: clarify that tag or digest in fromImage is ignored
2025-01-21 10:35:55 +01:00
Sebastiaan van Stijn
836a5fac10 Dockerfile: update compose to v2.32.4
Update the compose cli plugin used in the dev-container

full diff: https://github.com/docker/compose/compare/v2.30.3...v2.32.4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-21 09:41:59 +01:00
Sebastiaan van Stijn
b75a75017d Dockerfile: update buildx to v0.20.0
Update the buildx cli plugin used in the dev-container

full diff: https://github.com/docker/buildx/compare/v0.18.0..v0.20.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-21 09:39:59 +01:00
Sebastiaan van Stijn
1e2a828ed5 Dockerfile: update docker CLI to v27.5.0
Update the Docker CLI used in the dev-container
full diff: https://github.com/docker/cli/compare/v27.3.1...v27.5.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-21 09:35:52 +01:00
Sebastiaan van Stijn
de25f807d6 Merge pull request #49315 from crazy-max/buildkit-0.19.0
vendor: update buildkit to v0.19.0
2025-01-20 22:10:58 +01:00
CrazyMax
c52c68a709 vendor: update buildkit to v0.19.0
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-01-20 20:31:04 +01:00
Sebastiaan van Stijn
500ece5f31 Merge pull request #34143 from thaJeztah/fix-copy-permissions
Fix parsing of user/group during copy operation
2025-01-20 18:10:52 +01:00
Rob Murray
366f2b563d Clarify code/comments in defaultipam.newPoolData
The first address in an IPv6 range was reserved, but that wasn't
clear from comments or the code.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-20 16:48:46 +00:00
Rob Murray
bc93bba099 Use addrset.AddrSet instead of bitmap.Bitmap in IPAM
The default IPAM allocator is unable to represent subnets larger than
64-bits (subnets with a smaller prefix), because it uses a Bitmap
that's limited to 64-bits.

When it's used to represent a 64-bit subnet, the top address can't
be allocated (because bitmap.Bitmap is initialised with the number
of bits it needs to represent in a uint64, so it's one short).

The rest of the daemon doesn't know about these limitations, so
strange things happen when a large IPv6 subnet is used.

No errors are reported, addresses/subnets are just set up incorrectly.
The IPAM code calculates offsets into the bitmap itself, details it
shouldn't need to understand and, because it's working on offsets
into a range it doesn't always notice when it's asked to set a bit
outside the range.

It's unusual to need a big subnet but, for example, it may be useful
for modelling an ISP network, or an ISP's gateway may be in a "/56"
subnet that's outside a 64-bit range used by hosts.

So, use addrset.AddrSet instead of bitmap.Bitmap.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-20 16:48:46 +00:00
Rob Murray
7e247e8b13 Add addrset.AddrSet to track a set of IP addresses
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-20 16:48:46 +00:00
Rob Murray
46e290fec6 Don't increment "unselected" in Bitmap when clearing a 0
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-20 16:48:46 +00:00
Sebastiaan van Stijn
bccd9cc6bc Merge pull request #49313 from vvoland/gha-relbranches
gha: Adjust release branches
2025-01-20 17:39:48 +01:00
Sebastiaan van Stijn
101ff26886 Merge pull request #49311 from thaJeztah/bump_golang_1.23.5
update to go1.23.5 (fix CVE-2024-45341, CVE-2024-45336)
2025-01-20 17:34:22 +01:00
Paweł Gronowski
456c58cd1c Merge pull request #49299 from thaJeztah/build_no_broken_pipe_errs
build: don't print warning when connection was terminated
2025-01-20 17:17:27 +01:00
Paweł Gronowski
5e9ee1a849 gha: Adjust release branches
Adjust all workflows to also run on branches like `27.x`

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-20 16:34:14 +01:00
Albin Kerouanton
0fecf057d2 Merge pull request #49310 from akerouanton/revert-48721
Revert "libnet/d/bridge: port mappings: filter by input iface"
2025-01-20 15:51:00 +01:00
Sebastiaan van Stijn
ae0fda655b update to go1.23.5 (fix CVE-2024-45341, CVE-2024-45336)
go1.23.5 (released 2025-01-16) includes security fixes to the crypto/x509 and
net/http packages, as well as bug fixes to the compiler, the runtime, and the
net package. See the Go 1.23.5 milestone on our issue tracker for details;

- https://github.com/golang/go/issues?q=milestone%3AGo1.23.5+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.23.4...go1.23.5

Hello gophers,

We have just released Go versions 1.23.5 and 1.22.11, minor point releases.

These minor releases include 2 security fixes following the security policy:

- crypto/x509: usage of IPv6 zone IDs can bypass URI name constraints

  A certificate with a URI which has a IPv6 address with a zone ID may
  incorrectly satisfy a URI name constraint that applies to the certificate
  chain.

  Certificates containing URIs are not permitted in the web PKI, so this
  only affects users of private PKIs which make use of URIs.

  Thanks to Juho Forsén of Mattermost for reporting this issue.

  This is CVE-2024-45341 and Go issue https://go.dev/issue/71156.

- net/http: sensitive headers incorrectly sent after cross-domain redirect

  The HTTP client drops sensitive headers after following a cross-domain redirect.
  For example, a request to a.com/ containing an Authorization header which is
  redirected to b.com/ will not send that header to b.com.

  In the event that the client received a subsequent same-domain redirect, however,
  the sensitive headers would be restored. For example, a chain of redirects from
  a.com/, to b.com/1, and finally to b.com/2 would incorrectly send the Authorization
  header to b.com/2.

  Thanks to Kyle Seely for reporting this issue.

  This is CVE-2024-45336 and Go issue https://go.dev/issue/70530.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 15:47:35 +01:00
Albin Kerouanton
fc7caf96d2 Revert "libnet/d/bridge: port mappings: filter by input iface"
This reverts commit 433b1f9b17.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-01-20 14:11:51 +01:00
Sebastiaan van Stijn
f658ea3152 Fix parsing of user/group during copy operation
If a container was started with

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

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

This patch;

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

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 12:45:29 +01:00
Sebastiaan van Stijn
cb4cc87398 Merge pull request #49300 from thaJeztah/links_fixes
daemon/links: assorted bug fixes and cleanup
2025-01-20 12:37:42 +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
76a496a482 daemon/links: fix duplicate env-vars and cleanup range-detection
Rewrite the range-detection logic to prevent duplicate env-vars,
and to avoid looping over the same values multiple times.

Benchmark before / after:

    goos: darwin
    goarch: arm64
    pkg: github.com/docker/docker/daemon/links
    cpu: Apple M1 Pro
    BenchmarkLinkMultipleEnv
    BenchmarkLinkMultipleEnvOld-10       92817     12072 ns/op    8516 B/op     316 allocs/op
    BenchmarkLinkMultipleEnvNew-10      149493      7792 ns/op    6435 B/op     213 allocs/op
    PASS

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 11:52:41 +01:00
Sebastiaan van Stijn
fcdd6f4ad2 daemon/links: fix port-ranges with mixed protocols
The code incorrectly created env-vars for consecutive port numbers with
a different protocol; we should only consider ports to be part of a range
if they have consecutive port-numbers and have the same protocol.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 11:51:17 +01:00
Sebastiaan van Stijn
251c68c647 daemon/links: fix port-sorting with mixed protocols
The intent of this sorting was twofold;

- the "default" port of the container to be the first TCP port (if present)
- consecutive port-mappings with the same protocol to be together so
  that port-ranges would produce an env-var describing the range.

The current sorting would sort TCP ports before UDP (or SCTP) port, but
only if they had the same port-number. This could result in range-detection
incorrectly combining TCP and UDP (or SCTP) ports in the same range.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 11:50:54 +01:00
Sebastiaan van Stijn
3d37d54b8c daemon/links: Link.ToEnv: simplify adding default port env-var
There's no need to loop and sort multiple times; this code picked
the first port after sorting, which we already did in this function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 11:50:00 +01:00
Sebastiaan van Stijn
c508919b7c daemon/links: add BenchmarkLinkMultipleEnv
go test -v -bench ^\QBenchmarkLinkMultipleEnv\E$ -run ^$
    goos: darwin
    goarch: arm64
    pkg: github.com/docker/docker/daemon/links
    cpu: Apple M1 Pro
    BenchmarkLinkMultipleEnv
    BenchmarkLinkMultipleEnv-10    	   92817	     12072 ns/op	    8516 B/op	     316 allocs/op
    PASS

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 11:49:59 +01:00
Sebastiaan van Stijn
3b27e36d67 daemon/links: add EnvVars function
Encapsulate the "create link -> link.ToEnv" process.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 11:49:59 +01:00
Sebastiaan van Stijn
b54053d5da daemon/links: NewLink: simplify map to string conversion
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 11:49:59 +01:00
Sebastiaan van Stijn
53fec9813f daemon: Daemon.setupLinkedContainers: don't fetch linked containers if not used
This function was unconditionally trying to fetch linked container, even
if the container was not using the default bridge (the only network that
supports legacy links).

Also removing the intermediate variable, as daemon.children, through
daemon.linkindex.children already returns a variable with a copy of these
links.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 11:49:59 +01:00
Sebastiaan van Stijn
6160aeb6e2 Merge pull request #49305 from thaJeztah/cleanup_diagnosticserver
Assorted fixes,  improvements, and refactoring of  network diagnostic server
2025-01-20 11:24:34 +01:00
Sebastiaan van Stijn
2c3c0c788c Merge pull request #48800 from AmirBuddy/48797-network-disconnect-double-event
Fix: Duplicate event on network disconnect
2025-01-20 10:55:48 +01:00
Sebastiaan van Stijn
6b14bdb7c7 daemon/config: validate network-diagnostic-port
with this patch:

    dockerd --network-diagnostic-port -1 --validate
    unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: invalid network-diagnostic-port (-1): value must be between 0 and 65535

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 10:10:51 +01:00
Sebastiaan van Stijn
370c7a30e2 libnetwork/diagnostic: rename methods
- EnableDiagnostic -> Enable
- DisableDiagnostic -> Shutdown
- IsDiagnosticEnabled -> Enabled

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 10:10:51 +01:00
Sebastiaan van Stijn
16cc0be0e1 libnetwork/diagnostic: move and improve logs for starting/stoping
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 10:10:50 +01:00
Sebastiaan van Stijn
8f1a49fa8c libnetwork: Controller: remove redundant mutex for diagnosticServer
diagnosticServer is only written to during controller.New, and the
diagnostic server itself already has a mutex on EnableDiagnostic,
DisableDiagnostic, and IsDiagnosticEnabled, which should prevent
issues trying to concurrently change its state.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 10:10:50 +01:00
Sebastiaan van Stijn
e4abcad7ac libnetwork/diagnostic: make EnableDiagnostic, DisableDiagnostic idempotent
Handle situations where the server is already started or stopped internally,
instead of requiring the caller to do this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 10:10:50 +01:00
Sebastiaan van Stijn
e899092b25 libnetwork/diagnostic: make DisableDiagnostic idempotent
Handle situations where the server is already stopped internally, instead
of requiring the caller to do this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 10:10:50 +01:00
Sebastiaan van Stijn
1e6449dfc7 libnetwork/diagnostic: print newline after stackdump log path
The response would not have a trailing newline, which made it difficult
to copy the path. While updating, also include the path of the stackdump
in the daemon log that's produced.

Before this:

    root@fa87ff1bcd00:/go/src/github.com/docker/docker# curl -s http://127.0.0.1:123/stackdump
    OK
    goroutine stacks written to /tmp/goroutine-stacks-2025-01-19T160337Z.logroot@fa87ff1bcd00:/go/src/github.com/docker/docker#

After this:

    root@fa87ff1bcd00:/go/src/github.com/docker/docker# curl -s http://127.0.0.1:123/stackdump
    OK
    goroutine stacks written to /tmp/goroutine-stacks-2025-01-19T160922Z.log
    root@fa87ff1bcd00:/go/src/github.com/docker/docker#

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 10:10:50 +01:00
Sebastiaan van Stijn
8cc0e11823 libnetwork: un-export Controller.DiagnosticServer
It's only accessed internally, so doesn't have to be exported.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-20 10:10:47 +01:00
David Karlsson
bf7a87a15a docs: clarify fromImage vs tag behavior in ImageCreate
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2025-01-20 09:54:52 +01:00
Sebastiaan van Stijn
378e21ede0 Merge pull request #49303 from AkihiroSuda/rootlesskit
Update RootlessKit to v2.3.2
2025-01-20 09:34:10 +01:00
Akihiro Suda
aa565ec1ef Dockerfile: update RootlessKit to v2.3.2
https://github.com/rootless-containers/rootlesskit/releases/tag/v2.3.2

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-01-20 11:25:53 +09:00
Akihiro Suda
f3f9641f5d vendor.mod: github.com/rootless-containers/rootlesskit/v2 v2.3.2
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-01-20 11:25:16 +09:00
Akihiro Suda
912a64e22a vendor.mod: golang.org/x/sys v0.29.0
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2025-01-20 11:24:43 +09:00
Sebastiaan van Stijn
e718b06f99 Merge pull request #49293 from robmry/49240_ignore_br_netfilter_error
Allow users to ignore missing br_netfilter
2025-01-18 16:39:23 +01:00
Sebastiaan van Stijn
e8c6e7ceb0 build: don't print warning when connection was terminated
A terminated connection is not an error on the daemon-side, and expected
if the client disconnects. This patch detects if the error is because of
a broken pipe, and skips the warning in that case.

Before this patch:

    WARN[2025-01-18T12:38:04.115298341Z] could not write error response: write unix /var/run/docker.sock->@: write: broken pipe

After this patch, no warning is logged. This patch also changes the log
format to use structured logs.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-18 16:24:54 +01:00
Sebastiaan van Stijn
52774154c9 distribution: continueOnError: handle context cancellation / timeout
Before this change, it would fail to detect context errors, resulting in
pullEndpoints clobbering the context error and changing it into a fallback
error; 029933578b/distribution/pull.go (L114-L119)

While the context cancellation would still be handled, the error returned
would be wrapped, causing calling code to no longer being able to detect
it as context cancellation;
029933578b/distribution/pull.go (L125)

Context cancellation are now logged as "info" in daemon-logs, as they
are not an error from the daemon's perspective;

Before:

    DEBU[2025-01-18T14:59:10.079259676Z] pulling blob "sha256:8bb55f0677778c3027fcc4253dc452bc9c22de989a696391e739fb1cdbbdb4c2"
    ERRO[2025-01-18T14:59:10.564076135Z] Not continuing with pull after error: context canceled

After:

    DEBU[2025-01-18T15:09:56.743045420Z] pulling blob "sha256:8bb55f0677778c3027fcc4253dc452bc9c22de989a696391e739fb1cdbbdb4c2"
    INFO[2025-01-18T15:09:57.390835628Z] Not continuing with pull after error          error="context canceled"

This package needs a big cleanup for context- and error-handling, as it's
very messy, so these changes are only a short-term workaround.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-18 16:20:49 +01:00
Sebastiaan van Stijn
6b5f14a7bb distribution/utils: WriteDistributionProgress simplify check for broken pipe
The isBrokenPipe utility was added in 3d86b0c79b
to unwrap the error returned to detect if it was a broken pipe error.
`net.OpError` now implements Unwrap(), so we can simplify this check
using `errors.Is`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-18 16:20:49 +01:00
Sebastiaan van Stijn
81a2acdd23 Merge pull request #48696 from thaJeztah/build_log_cancelled
build: log when build is cancelled
2025-01-18 16:20:38 +01:00
Sebastiaan van Stijn
61aa1657f7 layerStore.registerWithDescriptor: improve logs for cleaning up cache
The debug log was slightly confusing, as it seemed the cleaning up failed,
but the log was intended to inform that cleaning up was started because
of an error.

Before this patch:

    DEBU[2025-01-18T12:29:52.717452919Z] Cleaning up layer 472e3e532da3945040a6224ba36d2befcfe250aeb53536868d23e5f617e34226: exit status 1: unpigz: skipping: <stdin>: corrupted -- incomplete deflate data

With this patch:

    DEBU[2025-01-18T13:01:45.307983471Z] Cleaning up cache layer after error           cache-id=c4d9f38bdf6d8fcb69bd130b89d34d1511b42f3644fc49c91e253eda648bd37a error="exit status 1: unpigz: skipping: <stdin>: corrupted -- incomplete deflate data\n"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-18 16:18:08 +01:00
Rob Murray
029933578b Merge pull request #49295 from robmry/ignore_subnet_already_in_ipset
Ignore error when adding a bridge already in the ipset
2025-01-18 12:01:33 +00:00
Rob Murray
e7bd60ee2d Allow users to ignore missing br_netfilter
Since commit 0f8fc31, the bridge driver will try to load kernel
module br_netfilter if the userland proxy is disabled. If it fails,
we're in unknown territory, so it's treated as an error. At the
very least, containers will not be able to access host ports
mapped to other containers in the same network.

Before that, and before commit 5c499fc delayed the module load
until it was needed - it was loaded unconditionally, but errors
were only logged.

So, on systems where the module is not available, or could not be
loaded/configured, no error was reported and things "worked" (as
long as you didn't try to use something that didn't work).

That behaviour has been useful to some. So, make it possible to
ignore the problem by setting env var:
  DOCKER_IGNORE_BR_NETFILTER_ERROR=1

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-18 11:59:04 +00:00
Sebastiaan van Stijn
b28d13040d Merge pull request #49294 from tonistiigi/update-buildkit-v0.19.0-rc3
vendor: update buildkit to v0.19.0-rc3
2025-01-18 01:50:05 +01:00
Sebastiaan van Stijn
f50afd8b0b Merge pull request #49292 from robmry/bridge_startup_error
Recover from default bridge init failure
2025-01-18 01:17:02 +01:00
Tonis Tiigi
66e6a0b7a1 vendor: update buildkit to v0.19.0-rc3
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2025-01-17 14:43:39 -08: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
Rob Murray
22c02219de Bridge: on network delete, make sure it's deleted from store
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-17 21:56:02 +00:00
Rob Murray
feb2dabaa9 Ignore error when adding a bridge already in the ipset
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-17 21:54:41 +00:00
Sebastiaan van Stijn
0fad8324a8 libcontainer/supervisor: monitorDaemon: move options inline again
These were moved in 84965c0752

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-17 22:54:19 +01:00
Sebastiaan van Stijn
29ce3633e5 libcontainerd/supervisor: 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
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
Tõnis Tiigi
7e78f78fb3 Merge pull request #49296 from thompson-shaun/logjam-typo-fix
spelling fix in comments (daemon/logger/loggerutils/queue.go)
2025-01-17 13:40:32 -08:00
Shaun Thompson
80b0570445 spelling fix in comments
Signed-off-by: Shaun Thompson <shaun.thompson@docker.com>
2025-01-17 14:55:54 -05:00
Shaun Thompson
41f4d91cc7 Merge pull request #47748 from cpuguy83/logjam
awslogs: Prevent close from being blocked on log
2025-01-17 13:50:24 -05:00
Shaun Thompson
d9c2474d6a Merge pull request #49286 from thaJeztah/swagger_stats
api: swagger: document StatsResponse
2025-01-17 11:59:45 -05:00
Sebastiaan van Stijn
84bbd3badd Merge pull request #49219 from thaJeztah/daemon_windows_remove_unsupported
daemon: assorted fixes and cleanups for archive endpoints
2025-01-17 17:16:51 +01:00
Sebastiaan van Stijn
f39fdb3c20 Merge pull request #49289 from crazy-max/ci-fix-bake-build
ci(bin-image): fix bake build
2025-01-17 17:11:00 +01:00
Sebastiaan van Stijn
49376caef9 Merge pull request #49290 from crazy-max/gha-arm64
ci: switch from jenkins to gha for arm64 build and tests
2025-01-17 17:07:53 +01:00
Sebastiaan van Stijn
58de8c7dec Merge pull request #48740 from thaJeztah/fix_debug_logs
api/server/middleware: log before, not after the request
2025-01-17 16:59:05 +01:00
Sebastiaan van Stijn
bf49fbff5c Merge pull request #49287 from thaJeztah/stats_merge
api/types/container: merge Stats and StatsResponse
2025-01-17 16:50:32 +01:00
CrazyMax
8c236de735 ci: switch from jenkins to gha for arm64 build and tests
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-01-17 12:05:11 +01:00
Sebastiaan van Stijn
c817ea2159 api/server/middleware: log before, not after the request
commit 1701bce9e0 updated the debug logs
to use structured logs, and to include more information in the logs, such
as the form-data used and the status-code, and combining them into a
single log.

However, for the status-code, we need to wait for the handler to do its
thing and (ahum) this was staring me right in the face, and crossed my
mind, but then I didn't act on it; the handler may take some time to
run, and produce logs, which now means that our nice "handling request"
log will be logged _after_ the request, which is obviously confusing.

This patch splits the log into two;

- a log entry when starting to handle the request
- a log entry if a non-200 status is returned (assuming 200 status
  codes are less interesting to log).

Before this patch:

    DEBU[2024-10-23T15:23:31.677184128Z] handling HEAD request                         method=HEAD module=api request-url=/_ping spanID=8180b03fa17f9783 status=200 traceID=a5dfa9b86445467889274145ad31bb9a vars="map[]"
    DEBU[2024-10-23T15:23:31.712833045Z] resolving                                     host=registry-1.docker.io spanID=97e231483c8d4d9a traceID=3c01e6c2cf19cf82237fdd01c0294fb4
    DEBU[2024-10-23T15:23:31.712883670Z] do request                                    host=registry-1.docker.io request.header.accept="application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, */*" request.header.user-agent="docker/dev go/go1.22.8 git-commit/06c2ba1fa02626e242dc8dfe888f022bcd247c52 kernel/6.10.11-linuxkit os/linux arch/arm64 containerd-client/1.7.22+unknown storage-driver/overlayfs UpstreamClient(Docker-Client/27.3.1 \\(darwin\\))" request.method=HEAD spanID=97e231483c8d4d9a traceID=3c01e6c2cf19cf82237fdd01c0294fb4 url="https://registry-1.docker.io/v2/library/nosuchimage/manifests/latest"
    DEBU[2024-10-23T15:23:32.051728378Z] fetch response received                       host=registry-1.docker.io response.header.content-length=162 response.header.content-type=application/json response.header.date="Wed, 23 Oct 2024 15:23:32 GMT" response.header.docker-distribution-api-version=registry/2.0 response.header.docker-ratelimit-source=94.210.180.92 response.header.strict-transport-security="max-age=31536000" response.header.www-authenticate="Bearer realm=\"https://auth.docker.io/token\",service=\"registry.docker.io\",scope=\"repository:library/nosuchimage:pull\"" response.status="401 Unauthorized" spanID=97e231483c8d4d9a traceID=3c01e6c2cf19cf82237fdd01c0294fb4 url="https://registry-1.docker.io/v2/library/nosuchimage/manifests/latest"
    DEBU[2024-10-23T15:23:32.051830920Z] Unauthorized                                  header="Bearer realm=\"https://auth.docker.io/token\",service=\"registry.docker.io\",scope=\"repository:library/nosuchimage:pull\"" host=registry-1.docker.io spanID=97e231483c8d4d9a traceID=3c01e6c2cf19cf82237fdd01c0294fb4
    DEBU[2024-10-23T15:23:32.051909045Z] do request                                    host=registry-1.docker.io request.header.accept="application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, */*" request.header.user-agent="docker/dev go/go1.22.8 git-commit/06c2ba1fa02626e242dc8dfe888f022bcd247c52 kernel/6.10.11-linuxkit os/linux arch/arm64 containerd-client/1.7.22+unknown storage-driver/overlayfs UpstreamClient(Docker-Client/27.3.1 \\(darwin\\))" request.method=HEAD spanID=97e231483c8d4d9a traceID=3c01e6c2cf19cf82237fdd01c0294fb4 url="https://registry-1.docker.io/v2/library/nosuchimage/manifests/latest"
    DEBU[2024-10-23T15:23:32.544987920Z] fetch response received                       host=registry-1.docker.io response.header.content-length=162 response.header.content-type=application/json response.header.date="Wed, 23 Oct 2024 15:23:32 GMT" response.header.docker-distribution-api-version=registry/2.0 response.header.docker-ratelimit-source=4203339e-74c0-11e4-bea4-0242ac11001b response.header.strict-transport-security="max-age=31536000" response.header.www-authenticate="Bearer realm=\"https://auth.docker.io/token\",service=\"registry.docker.io\",scope=\"repository:library/nosuchimage:pull\",error=\"insufficient_scope\"" response.status="401 Unauthorized" spanID=97e231483c8d4d9a traceID=3c01e6c2cf19cf82237fdd01c0294fb4 url="https://registry-1.docker.io/v2/library/nosuchimage/manifests/latest"
    DEBU[2024-10-23T15:23:32.545112212Z] Unauthorized                                  header="Bearer realm=\"https://auth.docker.io/token\",service=\"registry.docker.io\",scope=\"repository:library/nosuchimage:pull\",error=\"insufficient_scope\"" host=registry-1.docker.io spanID=97e231483c8d4d9a traceID=3c01e6c2cf19cf82237fdd01c0294fb4
    INFO[2024-10-23T15:23:32.545270087Z] trying next host                              error="pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed" host=registry-1.docker.io spanID=97e231483c8d4d9a traceID=3c01e6c2cf19cf82237fdd01c0294fb4
    DEBU[2024-10-23T15:23:32.550666962Z] handling POST request                         error-response="pull access denied for nosuchimage, repository does not exist or may require 'docker login'" method=POST module=api request-url="/v1.47/images/create?fromImage=nosuchimage&tag=latest" spanID=38286e48a07445ef status=404 traceID=3c01e6c2cf19cf82237fdd01c0294fb4 vars="map[version:1.47]"

With this patch applied:

    DEBU[2024-10-23T15:18:18.876346178Z] handling HEAD request                         method=HEAD module=api request-url=/_ping spanID=7fd5eb011140f546 traceID=80ffd75a39de78a1f51ffda89fc4f227 vars="map[]"
    DEBU[2024-10-23T15:18:18.878006428Z] handling POST request                         method=POST module=api request-url="/v1.47/images/create?fromImage=nosuchimage&tag=latest" spanID=40dea95727e38394 traceID=2f901d99f1cf2105e2614d6929d53d3b vars="map[version:1.47]"
    DEBU[2024-10-23T15:18:18.919686136Z] resolving                                     host=registry-1.docker.io spanID=74f65a3accb19ad3 traceID=2f901d99f1cf2105e2614d6929d53d3b
    DEBU[2024-10-23T15:18:18.919748094Z] do request                                    host=registry-1.docker.io request.header.accept="application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, */*" request.header.user-agent="docker/dev go/go1.22.8 git-commit/06c2ba1fa02626e242dc8dfe888f022bcd247c52 kernel/6.10.11-linuxkit os/linux arch/arm64 containerd-client/1.7.22+unknown storage-driver/overlayfs UpstreamClient(Docker-Client/27.3.1 \\(darwin\\))" request.method=HEAD spanID=74f65a3accb19ad3 traceID=2f901d99f1cf2105e2614d6929d53d3b url="https://registry-1.docker.io/v2/library/nosuchimage/manifests/latest"
    DEBU[2024-10-23T15:18:19.258132303Z] fetch response received                       host=registry-1.docker.io response.header.content-length=162 response.header.content-type=application/json response.header.date="Wed, 23 Oct 2024 15:18:19 GMT" response.header.docker-distribution-api-version=registry/2.0 response.header.docker-ratelimit-source=94.210.180.92 response.header.strict-transport-security="max-age=31536000" response.header.www-authenticate="Bearer realm=\"https://auth.docker.io/token\",service=\"registry.docker.io\",scope=\"repository:library/nosuchimage:pull\"" response.status="401 Unauthorized" spanID=74f65a3accb19ad3 traceID=2f901d99f1cf2105e2614d6929d53d3b url="https://registry-1.docker.io/v2/library/nosuchimage/manifests/latest"
    DEBU[2024-10-23T15:18:19.258219803Z] Unauthorized                                  header="Bearer realm=\"https://auth.docker.io/token\",service=\"registry.docker.io\",scope=\"repository:library/nosuchimage:pull\"" host=registry-1.docker.io spanID=74f65a3accb19ad3 traceID=2f901d99f1cf2105e2614d6929d53d3b
    DEBU[2024-10-23T15:18:19.258406886Z] do request                                    host=registry-1.docker.io request.header.accept="application/vnd.docker.distribution.manifest.v2+json, application/vnd.docker.distribution.manifest.list.v2+json, application/vnd.oci.image.manifest.v1+json, application/vnd.oci.image.index.v1+json, */*" request.header.user-agent="docker/dev go/go1.22.8 git-commit/06c2ba1fa02626e242dc8dfe888f022bcd247c52 kernel/6.10.11-linuxkit os/linux arch/arm64 containerd-client/1.7.22+unknown storage-driver/overlayfs UpstreamClient(Docker-Client/27.3.1 \\(darwin\\))" request.method=HEAD spanID=74f65a3accb19ad3 traceID=2f901d99f1cf2105e2614d6929d53d3b url="https://registry-1.docker.io/v2/library/nosuchimage/manifests/latest"
    DEBU[2024-10-23T15:18:19.755911762Z] fetch response received                       host=registry-1.docker.io response.header.content-length=162 response.header.content-type=application/json response.header.date="Wed, 23 Oct 2024 15:18:19 GMT" response.header.docker-distribution-api-version=registry/2.0 response.header.docker-ratelimit-source=4203339e-74c0-11e4-bea4-0242ac11001b response.header.strict-transport-security="max-age=31536000" response.header.www-authenticate="Bearer realm=\"https://auth.docker.io/token\",service=\"registry.docker.io\",scope=\"repository:library/nosuchimage:pull\",error=\"insufficient_scope\"" response.status="401 Unauthorized" spanID=74f65a3accb19ad3 traceID=2f901d99f1cf2105e2614d6929d53d3b url="https://registry-1.docker.io/v2/library/nosuchimage/manifests/latest"
    DEBU[2024-10-23T15:18:19.757501928Z] Unauthorized                                  header="Bearer realm=\"https://auth.docker.io/token\",service=\"registry.docker.io\",scope=\"repository:library/nosuchimage:pull\",error=\"insufficient_scope\"" host=registry-1.docker.io spanID=74f65a3accb19ad3 traceID=2f901d99f1cf2105e2614d6929d53d3b
    INFO[2024-10-23T15:18:19.757689387Z] trying next host                              error="pull access denied, repository does not exist or may require authorization: server message: insufficient_scope: authorization failed" host=registry-1.docker.io spanID=74f65a3accb19ad3 traceID=2f901d99f1cf2105e2614d6929d53d3b
    DEBU[2024-10-23T15:18:19.763826095Z] error response for POST request               error-response="pull access denied for nosuchimage, repository does not exist or may require 'docker login'" method=POST module=api request-url="/v1.47/images/create?fromImage=nosuchimage&tag=latest" spanID=40dea95727e38394 status=404 traceID=2f901d99f1cf2105e2614d6929d53d3b vars="map[version:1.47]"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-17 11:00:17 +01:00
CrazyMax
d86920b9b3 ci(bin-image): fix bake build
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-01-17 09:24:56 +01:00
Tianon Gravi
078c5edcd7 Adjust test to support cgroupv1
This has to be careful to do something non-destructive, which this *should* be.

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

(thanks Go)

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

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

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

Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2025-01-16 15:27:33 -08:00
Tianon Gravi
081b9d97db Update TestCgroupRW with subtests + nil case fix
Signed-off-by: Tianon Gravi <admwiggin@gmail.com>
2025-01-16 12:58:24 -08:00
Vincent Batts
b5b5b7e983 integration/container: test the writable-cgroups security option
Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2025-01-16 12:58:24 -08:00
Vincent Batts
e3cdd59a82 daemon/&container/: enable --security-opt writable-cgroups=true as an option
Fixes #42040
Closes #42043

Rather than making cgroups read-write by default, instead have a flag
for making it possible.

Since these security options are passed through the cli to daemon API,
no changes are needed to docker-cli.

Signed-off-by: Vincent Batts <vbatts@hashbangbash.com>
2025-01-16 12:58:17 -08:00
Sebastiaan van Stijn
b1ea8032fa api: swagger: document StatsResponse
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-16 21:22:21 +01:00
Sebastiaan van Stijn
9ed85f487d daemon: don't discard "invalid parameter" errors for archive endpoints
Commit ebcb7d6b40 removed code that string-
matched errors to return the appropriate error-type. As part of that, it
defaulted to using a "System" (status 500) error.

We need to verify codepaths used by the archive functions, but let's
start with detecting invalid parameter errors, and preserve those.

This patch updates the code backing the following endpoints to return
a 400 (Invalid Parameter) error when present;

- `HEAD /containers/{name:.*}/archive`
- `GET /containers/{name:.*}/archive`
- `PUT /containers/{name:.*}/archive`

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-16 20:58:32 +01:00
Sebastiaan van Stijn
c6d8a93d58 daemon: containerExtractToDir: remove handling for read-only paths on windows
Windows containers do not currently support a read-only rootFS, and a
[validateReadonlyRootfs] (added in 6f7dc65847)
will reject containers created with this option. Similarly, Windows does
not support read-only volume;

Windows originally did not support volumes (47c56e4353).
Support for volumes was added later, but without support for read-only volumes
(see e5261d6e4a). Support for read-only values
was originally planned to be supported after TP4, but later moved to "post TP5"
when support for TP4 was removed in 331c8a86d4.

This patch removes code related to read-only paths on Windows, but keeps
a TODO / comment as a reminder.

[validateReadonlyRootfs]: a052449271/runconfig/hostconfig_windows.go (L56-L62)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-16 20:58:15 +01:00
Sebastiaan van Stijn
ca0158b235 daemon: containerExtractToDir: combine checks for read-only target
Combine the check for read-only volume paths and the container's rootFS
to be read-only into a single check.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-16 20:58:10 +01:00
Sebastiaan van Stijn
0530750d7e daemon: containerExtractToDir: remove named error return
Also move an error check in the branch where it's produced.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-16 20:55:57 +01:00
Sebastiaan van Stijn
9ed662e72e daemon: containerExtractToDir: remove handling for copyUIDGID on windows
This was a no-op on Windows, which currently doesn't support it, so we
can remove this code in the meantime until there's support for this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-16 20:55:53 +01:00
Sebastiaan van Stijn
ca06b222e3 api/types/container: merge Stats and StatsResponse
The StatsResponse type  was a compatibility-wrapper introduced in
d3379946ec to differentiate responses
for  API < 1.21 and API >= 1.21. API versions lower than 1.24 are
deprecated, and we can merge these types again.

The Stats type was not used directly, but deprecating it, and
making it an alias for StatsResponse, which provides a superset
of its fields.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-16 19:47:40 +01:00
Sebastiaan van Stijn
033f97519c Merge pull request #49184 from thaJeztah/drop_kernel_4.10_check
daemon: remove kernel-version check for kernel < 4.0.0
2025-01-16 18:53:34 +01:00
Sebastiaan van Stijn
1153242d3a Merge pull request #49284 from thaJeztah/test_statsresponse
use StatsResponse instead of Stats in tests
2025-01-16 13:44:29 +01:00
Sebastiaan van Stijn
57c597203a Merge pull request #49261 from robmry/ask_driver_if_gw_needed
Ask network drivers if they'll use a gateway address
2025-01-16 13:22:05 +01:00
Sebastiaan van Stijn
16cbb27e4e use StatsResponse instead of Stats in tests
The StatsResponse type  was a compatibility-wrapper introduced in
d3379946ec to differentiate responses
for  API < 1.21 and API >= 1.21. API versions lower than 1.24 are
deprecated, and we should merge StatsResponse and Stats, but let's
start with using the StatsResponse in our tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-15 17:45:10 +01:00
Paweł Gronowski
b1c00b18bd Merge pull request #49283 from robmry/increase_integration_test_timeout
Increase integration test timeout from 5m to 10m
2025-01-15 17:41:14 +01:00
Sebastiaan van Stijn
079b6e6187 Merge pull request #48893 from thaJeztah/logger_cleans
daemon/logger: un-export RingLogger
2025-01-15 16:58:26 +01:00
Rob Murray
390cb4c2f1 Increase integration test timeout from 5m to 10m
Networking tests have been creeping towards the limit for a
while, but they're reliably failing in a upcoming PR that adds
a relatively slow test.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-15 15:44:30 +00:00
Sebastiaan van Stijn
19147b005c Merge pull request #48872 from dmcgowan/update-containerd-2.0
Update to containerd 2.0, buildkit v0.19
2025-01-15 15:08:17 +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
Derek McGowan
a63602472d Use local cleanup method rather than dependency
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-01-14 21:36:58 -08:00
Akihiro Suda
264801efb1 Merge pull request #49281 from thaJeztah/remove_crypto
pkg/ioutils: remove crypto/sha256, crypto/sha512 imports
2025-01-15 12:19:13 +09:00
Akihiro Suda
1cf2cb52ac Merge pull request #49274 from thaJeztah/containerd_2_deps
vendor: containerd 2.0 / buildkit v0.19.0 dependencies
2025-01-15 12:18:14 +09:00
Sebastiaan van Stijn
3db60168e7 pkg/ioutils: remove crypto/sha256, crypto/sha512 imports
commit 572498be56 moved the ioutils.HashData
utility to the libnetwork resolvconf package.

After removing, we saw some tests  in the reference  pacakge failing;

    === Failed
    === FAIL: reference TestLoad (0.00s)
        store_test.go:53: failed to parse reference: unsupported digest algorithm

    === FAIL: reference TestSave (0.00s)
        store_test.go:82: failed to parse reference: unsupported digest algorithm

    === FAIL: reference TestAddDeleteGet (0.00s)
        store_test.go:174: could not parse reference: unsupported digest algorithm

    === FAIL: reference TestInvalidTags (0.00s)
        store_test.go:355: assertion failed: error is not nil: unsupported digest algorithm

Those failures were because those tests depended on a side-effect of the
ioutils package being imported, which (before removal of HashData) imported
crypto/sha256, registering that algorithms, which on its turn was used by
github.com/opencontainers/go-digest to determnin if a given algorithm must
be accepted (see [go-digest#64]).

As a workaround, these imports were added. pkg/ioutils is now imported
in less places, and should not be depended on for this purpose.

Let's remove this workaround; if needed, these imports can be added in
a more relevant location.

This reverts commit 98caf09f0f.

[go-digest#64]: https://github.com/opencontainers/go-digest/pull/64

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-15 00:20:28 +01:00
Sebastiaan van Stijn
a2b1ac7959 Merge pull request #49280 from thaJeztah/update_semconv
testutil: update to semconv v1.26.0
2025-01-14 20:41:16 +01:00
Sebastiaan van Stijn
f68eb9c3cb vendor: github.com/Microsoft/hcsshim v0.12.9
full diff: https://github.com/Microsoft/hcsshim/compare/v0.12.8...v0.12.9

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 20:21:15 +01:00
Sebastiaan van Stijn
488d6972b2 vendor: github.com/stretchr/testify v1.10.0
full diff: https://github.com/stretchr/testify/compare/v1.9.0...v1.10.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 20:21:15 +01:00
Sebastiaan van Stijn
2008799026 vendor: k8s.io/klog/v2 v2.130.1
full diff: https://github.com/kubernetes/klog/compare/v2.90.1...v2.130.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 20:21:14 +01:00
Sebastiaan van Stijn
adec695d36 vendor: github.com/fsnotify/fsnotify v1.7.0
full diff: https://github.com/fsnotify/fsnotify/compare/v1.6.0...v1.7.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 20:21:14 +01:00
Sebastiaan van Stijn
1ef5957089 vendor: github.com/vbatts/tar-split v0.11.6
full diff: https://github.com/vbatts/tar-split/compare/v0.11.5...v0.11.6

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 20:21:14 +01:00
Sebastiaan van Stijn
de86c46158 vendor: github.com/containernetworking/cni v1.2.3
full diff: https://github.com/containernetworking/cni/compare/v1.2.2...v1.2.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 20:21:14 +01:00
Sebastiaan van Stijn
6dd592bd49 vendor: github.com/containerd/go-cni v1.1.11
full diff: https://github.com/containerd/go-cni/compare/v1.1.10...v1.1.11

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 20:21:13 +01:00
Sebastiaan van Stijn
2ea97aec2d vendor: github.com/containerd/ttrpc v1.2.7
full diff: https://github.com/containerd/ttrpc/compare/v1.2.5...v1.2.7

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 20:21:13 +01:00
Sebastiaan van Stijn
cc120c4c05 testutil: update to semconv v1.26.0
update the version to align with BuildKit's [util/tracing/detect], which
was updated to v1.26.0 in 48b237f7af

[util/tracing/detect]:  2b7e859c49/vendor/github.com/moby/buildkit/util/tracing/detect/resource.go (L15)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 19:21:16 +01:00
Sebastiaan van Stijn
6439c46e06 vendor: github.com/containerd/errdefs v1.0.0
no changes in vendored code

full diff: https://github.com/containerd/errdefs/compare/v0.3.0...v1.0.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 17:31:17 +01:00
Sebastiaan van Stijn
f40b92272c vendor: github.com/AdamKorcz/go-118-fuzz-build v0.0.0-20231105174938-2b5cbb29f3e2
full diff: 8075edf89b...2b5cbb29f3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 17:31:17 +01:00
Sebastiaan van Stijn
eb592fecad vendor: github.com/AdaLogics/go-fuzz-headers v0.0.0-20240806141605-e8a1dd7889d6
full diff: e8a1dd7889...e8a1dd7889

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 17:31:16 +01:00
Sebastiaan van Stijn
2b7e859c49 Merge pull request #49276 from thaJeztah/vendor_otel
vendor: otel v0.56.0 / v1.31.0
2025-01-14 17:30:14 +01:00
Sebastiaan van Stijn
04b03cfc0a Merge pull request #49278 from thaJeztah/vendor_pty_v1.1.24
vendor: github.com/creack/pty v1.1.24
2025-01-14 15:26:28 +01:00
Sebastiaan van Stijn
48e6b4e8f7 vendor: otel v0.56.0 / v1.31.0
Reverts otel workaround, added in cca7085464,
as it's no longer needed:

    === Failed
    === FAIL: cmd/dockerd TestOtelMeterLeak (0.64s)
        daemon_test.go:303: Allocations: 3
        daemon_test.go:307: Allocations count decreased. OTEL leak workaround is no longer needed!

We're keeping the test for now, so that we can check for possible
regressions in the OTel dependencies.

Co-authored-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 15:01:34 +01:00
Sebastiaan van Stijn
80d14859a2 Merge pull request #49277 from thaJeztah/bump_aws
vendor: github.com/aws/aws-sdk-go-v2 v1.30.3
2025-01-14 14:34:18 +01:00
Sebastiaan van Stijn
5b1b62058f Merge pull request #49275 from thaJeztah/vendor_grpc
vendor: google.golang.org/grpc v1.68.1, google.golang.org/genproto 324edc3d5d38
2025-01-14 13:58:23 +01:00
Sebastiaan van Stijn
d60f164e21 vendor: github.com/creack/pty v1.1.24
full diff: https://github.com/creack/pty/compare/v1.1.21...v1.1.24

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 13:47:01 +01:00
Sebastiaan van Stijn
a78b84c212 vendor: github.com/aws/aws-sdk-go-v2 v1.30.3
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 13:35:34 +01:00
Albin Kerouanton
6abba374d9 Merge pull request #48721 from akerouanton/45610-filter-by-input-iface
libnet/d/bridge: port mappings: filter by input iface
2025-01-14 13:04:25 +01:00
Sebastiaan van Stijn
d5fe43335f vendor: google.golang.org/grpc v1.68.1, google.golang.org/genproto
full diff: https://github.com/grpc/grpc-go/compare/v1.66.3...v1.68.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 12:25:57 +01:00
Sebastiaan van Stijn
5066658f39 vendor: golang.org/x/oauth2 v0.23.0
full diff: https://github.com/golang/oauth2/compare/v0.22.0...v0.23.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-14 12:25:57 +01:00
Sebastiaan van Stijn
f2854d1e50 Merge pull request #49273 from thaJeztah/update_google_metadata
vendor: cloud.google.com/go/compute/metadata v0.5.0
2025-01-14 12:25:12 +01:00
Sebastiaan van Stijn
81d5487330 vendor: cloud.google.com/go/compute/metadata v0.5.0
Update use of deprecated methods from gcp package

full diff: https://github.com/googleapis/google-cloud-go/compoare/compute/metadata/v0.3.0...compute/metadata/v0.5.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-01-14 11:18:32 +01:00
Sebastiaan van Stijn
b59e5cdbe1 Merge pull request #46114 from akerouanton/remove-fluentd-async-connect
logger/fluentd: remove deprecated fluentd-async-connect option
2025-01-13 19:47:11 +01:00
Sebastiaan van Stijn
22d3a32a20 Merge pull request #49265 from vvoland/export-ctx-cancellation
daemon/export: Stop when context is canceled
2025-01-13 19:41:21 +01:00
Albin Kerouanton
433b1f9b17 libnet/d/bridge: port mappings: filter by input iface
When a NAT-based port mapping is created with a HostIP specified, we
insert a DNAT rule in nat-DOCKER to replace the dest addr with the
container IP. Then, in filter chains, we allow access to the container
port for any packet not coming from the container's network itself (if
hairpinning is disabled), nor from another host bridge.

However we don't set any rule that prevents a rogue neighbor that shares
a L2 segment with the host, but not the one where the port binding is
expected to be published, from sending packets destined to that HostIP.

For instance, if a port binding is created with HostIP == '127.0.0.1',
this port should not be accessible from anything but the lo interface.
That's currently not the case and this provides a false sense of
security.

Since nat-DOCKER mangles the dest addr, and the nat table rejects DROP
rules, this change adds rules into raw-PREROUTING to filter ingress
packets destined to mapped ports based on the input interface, the dest
addr and the dest port.

Interfaces are dynamically resolved when packets hit the host, thanks
to iptables' addrtype extension. This extension does a fib lookup of the
dest addr and checks that it's associated with the interface reached.

Also, when a proxy-based port mapping is created, as is the case when an
IPv6 HostIP is specified but the container is only IPv4-capable, we
don't set any sort of filtering. So the same issue might happen. The
reason is a bit different - in that case, that's just how the kernel
works. But, in order to stay consistent with NAT-based mappings, these
rules are also applied.

The env var `DOCKER_DISABLE_INPUT_IFACE_FILTERING` can be set to any
true-ish value to globally disable this behavior.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-01-13 19:04:25 +01:00
Albin Kerouanton
d088d64ec2 Merge pull request #49267 from akerouanton/newDriver-init-nlh
libnet/d/bridge: init driver.nlh in newDriver
2025-01-13 18:50:07 +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
Albin Kerouanton
d560704c91 libnet/d/bridge: init driver.nlh in newDriver
This field was initialized by `driver.createNetwork` instead of being
initialized by the `newDriver` constructor. That's currently the single
place where it's initialized -- no tests override it, so it seems the
'current' netns is always used.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2025-01-13 17:36:15 +01:00
Paweł Gronowski
5a6a980dad daemon/export: Stop when context is canceled
Close archive when context is done - this makes the cancellation
actually stop the export instead of continuing it regardless if the
client still expects the data.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-13 16:34:41 +01:00
Sebastiaan van Stijn
d7ad7a9534 Merge pull request #49263 from vvoland/imageservice-performwithbasefs
imageService: Remove PerformWithBaseFS
2025-01-13 16:02:45 +01:00
Paweł Gronowski
15df1c9c40 imageService: Remove PerformWithBaseFS
With `RWLayer` it's no longer necessary to define it for each image
service as it became a wrapper for the RWLayer's Mount and Unmount.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-13 14:40:43 +01:00
Rob Murray
2f60d15ddf Internal macvlan networks don't need a gateway address.
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-13 10:31:14 +00:00
Rob Murray
8b13cde274 L3 and internal ipvlans don't need a gateway address
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-13 10:31:14 +00:00
Rob Murray
43f71fb582 Bridge - skip gateway allocation if no gateway is needed
An "--internal" bridge network will never set up a default route
and, with "-o com.docker.network.bridge.inhibit_ipv4", no Gateway
address will be assigned to the bridge.

So, implement the SkipGwAlloc interface in the bridge driver, and
use it to to indicate that no Gateway address is required in this
specific case.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-13 10:28:55 +00:00
Rob Murray
38e76ebea9 Only allocate a gateway if the n/w driver wants one
A gateway address is always reserved before the network driver is
asked to create the network. But, the driver doesn't always need a
gateway address, so the address reservation can be unnecessary.

This means, for example, an "--internal" IPv4 "/31" network cannot
be used as a point-to-point link, because one of its two addresses
is always reserved for a gateway.

So, before allocating a gateway address, ask the network driver if
it will need one (based on options that only the network driver can
interpret). Implement that as an optional interface for network
drivers.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-13 10:28:55 +00:00
Rob Murray
64006f964a Simplify selection of gateway address
When setting up a gateway in IpamInfo, and reserving that address in
IPAM ... the IPAM driver may return its own default gateway. That
gateway address is currently always parsed, but it's only used if the
user did not supply their own gateway address. If the user supplied
an address, it's always reserved and used. Otherwise, the IPAM driver
is asked to select and reserve an address.

The logic to deal with that was a bit confusing - and it's probably
better just to ignore the IPAM driver's gateway if it's not going to
be used.

So, simplify it little.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-13 10:28:55 +00:00
Sebastiaan van Stijn
d9ba13e84d Merge pull request #49259 from laurazard/update-email-laurazard
Update MAINTAINERS file
2025-01-12 14:58:47 +01:00
Laura Brehm
24f09ef13c Update MAINTAINER file email for laurazard
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2025-01-12 13:31:51 +01:00
Sebastiaan van Stijn
6968719093 Merge pull request #49120 from vvoland/c8d-rwlayer
c8d: Implement `RWLayer`
2025-01-11 00:43:21 +01:00
Tianon Gravi
df596e996b Merge pull request #49258 from thaJeztah/ioutils_remove_NewReaderErrWrapper
pkg/ioutils: remove unused NewReaderErrWrapper
2025-01-10 14:44:19 -08:00
Tianon Gravi
4ee19faf05 Merge pull request #49251 from thaJeztah/vendor_containerd_1.7.25
vendor: github.com/containerd/containerd v1.7.25
2025-01-10 14:35:54 -08:00
Sebastiaan van Stijn
e26122c609 pkg/ioutils: remove unused NewReaderErrWrapper
It was added in Docker [v1.3.0] through bd130e72a0,
but never used, and its behavior never documented. There are no publicly
visible external consumers  of this function, so let's remove it.

[v1.3.0]: https://github.com/moby/moby/releases/tag/v1.3.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 20:55:15 +01:00
Sebastiaan van Stijn
d34a5f5d72 Merge pull request #49152 from thaJeztah/pkg_archive_nolookups
pkg/archive: nosysFileInfo: implement tar.FileInfoNames to prevent lookups
2025-01-10 20:02:47 +01:00
Sebastiaan van Stijn
c2617e29ee Merge pull request #49256 from thaJeztah/ioutils_even_cleaner
pkg/ioutils: remove deprecated NopWriter, NopWriteCloser
2025-01-10 18:32:59 +01:00
Sebastiaan van Stijn
2b4db9383c pkg/archive: nosysFileInfo: implement tar.FileInfoNames to prevent lookups
commit e9bbc41dd1 removed our fork of
pkg/archive that was in place to mitigate CVE-2019-14271. As part of that
change, a nosysFileInfo type was added to prevent tar.FileInfoHeader from
looking up user- and group-names.

A proposal was pending in go https://go.dev/issue/50102 to define an
interface for implementing custom lookup functions to be implemented,
and disable go's builtin lookup. That proposal was accepted, and is now
implemented in go1.23.

Thia patch makes the nosysFileInfo implement the tar.FileInfoNames interface
to prevent tar.FileInfoHeader from performing its own lookups. While the
mitigation implemented in e9bbc41dd1 should
already prevent this from happening, implementing the interface does not
cost us much and is complementary to the existing mitigation.

This patch keeps the mitigation added in a316b10dab
in place for any unforeseen other code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 16:14:38 +01:00
Sebastiaan van Stijn
ce8d3d1c78 pkg/ioutils: remove deprecated NopWriteCloser
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 15:40:12 +01:00
Sebastiaan van Stijn
39f1abb1fb pkg/ioutils: remove deprecated NopWriter
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 15:40:12 +01:00
Sebastiaan van Stijn
ecaccdd668 Merge pull request #49254 from thaJeztah/ioutils_more_deprecations
pkg/ioutils: deprecate NopWriter, NopWriteCloser
2025-01-10 15:39:25 +01:00
Sebastiaan van Stijn
deeb349721 Merge pull request #49252 from thaJeztah/bump_containerd_binary_1.7.25
Dockerfile: update containerd to v1.7.25
2025-01-10 14:45:29 +01:00
Sebastiaan van Stijn
3faa170371 pkg/ioutils: deprecate NopWriteCloser
It was only used internally, and has no external consumers; deprecate
it to be removed in the next release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 14:20:11 +01:00
Sebastiaan van Stijn
7fa3c553e7 pkg/ioutils: deprecate NopWriter
It's not used, and users can use io.Discard instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 14:17:28 +01:00
Sebastiaan van Stijn
71253c38f1 Merge pull request #49245 from thaJeztah/ioutils_cleaner
pkg/ioutils: remove or internalize deprecated types and functions
2025-01-10 14:11:04 +01:00
Sebastiaan van Stijn
8dca012cef Merge pull request #49242 from vvoland/pkg-sysinfo-remove-numcpu
pkg/sysinfo: Remove deprecated NumCPU
2025-01-10 13:23:42 +01:00
Sebastiaan van Stijn
ad860173a2 vendor: github.com/containerd/containerd v1.7.25
full diff: https://github.com/containerd/containerd/compare/v1.7.24...v1.7.25

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 13:10:42 +01:00
Sebastiaan van Stijn
c12bfda3cd Dockerfile: update containerd to v1.7.25
release notes: https://github.com/containerd/containerd/releases/tag/v1.7.25
full diff: https://github.com/containerd/containerd/compare/v1.7.24...v1.7.25

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 10:59:32 +01:00
Sebastiaan van Stijn
d80e3410bc vendor: github.com/containerd/containerd/api v1.8.0
full diff: https://github.com/containerd/containerd/compare/api/v1.7.19..api/v1.8.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 10:27:23 +01:00
Paweł Gronowski
d23871469b pkg/sysinfo: Remove deprecated NumCPU
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-10 10:26:04 +01:00
Sebastiaan van Stijn
f54ac482dc Merge pull request #49248 from robmry/fix_unit_tests_for_nftables_host
Fix unit tests for an nftables host
2025-01-10 09:22:38 +01:00
Sebastiaan van Stijn
cdd4a7429f pkg/ioutils: remove errWriteFlusherClosed
It's an alias for io.EOF and not exported, so we don't need it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 09:21:10 +01:00
Sebastiaan van Stijn
034cd27da0 pkg/ioutils: remove deprecated NopFlusher
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 09:21:09 +01:00
Sebastiaan van Stijn
e183df63f9 pkg/ioutils: remove deprecated WriteCounter, NewWriteCounter
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 09:21:09 +01:00
Sebastiaan van Stijn
15ce2914a5 pkg/ioutils: move BytesPipe to container/streams/bytespipe
These types are only used internally in container/streams and have no
external consumers. move them to a subpackage of container/streams.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-10 09:21:09 +01:00
Akihiro Suda
00d1b92d0a Merge pull request #49244 from thaJeztah/ioutils_deprecations
pkg/ioutils: deprecate unused types and functions
2025-01-10 05:26:41 +09:00
Rob Murray
8f9c09edd4 Fix unit tests for an nftables host
On a freshly rebooted Linux host that's configured to use nftables
with the iptables front-end, "make test-unit" fails "TestUserChains"
on the first run - it's ok in subsequent runs.

The unit tests run in moby's dev container.

The first test in TestUserChain runs with ip6tables disabled, so the
bridge driver doesn't try to load the ip6_tables module. Then, because
the module isn't loaded (it wasn't needed by the daemon running on the
nftables host when it started), the test fails because it can't check
what's in the ip6tables filter chain.

The next test in TestUserChain does the same thing, but with ip6tables
enabled. So the module gets loaded by the bridge driver, and everything
works normally after that.

The dev container used to try to load the module on startup, but that
was removed in commit 2af19b6b ("Don't try to modprobe ip6_tables in
the moby dev container"), as part of a change to give the daemon a way
to load modules itself.

Rather that put back the dev container's code to load ip6_tables on
startup (which would mean the daemon's module-loading code not getting
to run on nftables/firewalld hosts) ...

Run the tests in TestUserChains in a different order, with iptables
enabled in the first test will make it happen to work. At least for
now.

It's not ideal, but we'll be switching to nftables soon, so the issue
will go away.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-09 19:07:37 +00:00
Sebastiaan van Stijn
818a180fce pkg/ioutils: deprecate NopFlusher
Apart from being used internally for NewWriteFlusher, it's only used
in a single location outside of this package. Copy the implementation
where it's used, and mark it deprecated.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-09 17:56:34 +01:00
Paweł Gronowski
18f1ecafea c8d/snapshot: Rename variable that collided with import
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-09 17:31:24 +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
daed0bd4d6 container/rwLayer: Remove unused TarStreamer, ApplyDiff, Size and Name
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-09 17:31:18 +01:00
Paweł Gronowski
85de28901d container/rwLayer: Remove Changes
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-09 17:31:17 +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
Sebastiaan van Stijn
383503d382 pkg/ioutils: deprecate WriteCounter, NewWriteCounter
it was moved to pkg/ioutils in c30a55f14d,
and only had a single use at the time in [engine/Env.WriteTo]. That use
was removed in 531f4122bd, which removed
the engine package.

[engine/Env.WriteTo]: c30a55f14d/engine/env.go (L260-L264)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-09 17:23:46 +01:00
Sebastiaan van Stijn
60971a66b4 pkg/ioutils: deprecate BytesPipe, NewBytesPipe, ErrClosed
These types are only used internally in container/streams and have no
external consumers. Deprecate them in preparation of moving them to
a subpackage of container/streams.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-09 17:19:43 +01:00
Sebastiaan van Stijn
45fe68629b Merge pull request #49241 from vvoland/runtime-numcpu
pkg/sysinfo: Deprecate NumCPU
2025-01-09 15:15:41 +01:00
Sebastiaan van Stijn
4938e84c28 Merge pull request #49180 from thaJeztah/improve_cpushares_validation
improve validation of cpu-shares, and migrate TestRunInvalidCPUShares
2025-01-09 15:05:14 +01:00
Sebastiaan van Stijn
957f77e730 Merge pull request #49177 from thaJeztah/daemon_no_pkg_parsers
deprecate pkg/parsers.ParseKeyValueOpt and move internal
2025-01-09 15:04:38 +01:00
Sebastiaan van Stijn
43b6e1af85 Merge pull request #49237 from thaJeztah/pkg_ioutils_unexport_ReadCloserWrapper
pkg/ioutils: un-export ReadCloserWrapper
2025-01-09 14:33:03 +01:00
Paweł Gronowski
3db72b255d pkg/sysinfo: Deprecate NumCPU
Deprecate in favor of `runtime.NumCPU` as the behavior is the same now.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-09 13:39:49 +01:00
Sebastiaan van Stijn
6d24a21643 improve validation of cpu-shares, and migrate TestRunInvalidCPUShares
This test was testing errors produced by runc; both the "maximum" and
"minimum" values originate from the OCI runtime;
d48d9cfefc/libcontainer/cgroups/fs/cpu.go (L66-L83)

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

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

This patch:

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

With this patch:

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-09 13:24:02 +01:00
Sebastiaan van Stijn
400f1ed95c runconfig: TestValidateResources: use subtests
- rewrite to use subtests
- check for actual error returned

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-09 13:23:53 +01:00
Sebastiaan van Stijn
93907c904d runconfig: TestValidateResources: fix duplicate test-case
Make sure we're testing for the right condition.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-09 13:15:15 +01:00
Sebastiaan van Stijn
5b18a7914c deprecate pkg/parsers.ParseKeyValueOpt and move internal
Move the utility to where it's used, and deprecate the implementation
in pkg/parsers.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-09 13:14:09 +01:00
Sebastiaan van Stijn
df0174b6f1 Merge pull request #49238 from thaJeztah/bump_runc_binary_1.2.4
Dockerfile: update runc binary to v1.2.4
2025-01-09 13:11:56 +01:00
Sebastiaan van Stijn
bda51fe476 Merge pull request #48611 from stevvooe/sjd/stable-save-timestamps
image/save: set a stable timestamp for assets
2025-01-08 19:34:06 +01:00
Sebastiaan van Stijn
53287e4ebf Merge pull request #49232 from thaJeztah/link_test_cleanup
daemon/links: use gotest.tools, remove unneeded utility and duplicated test
2025-01-08 19:07:00 +01:00
Sebastiaan van Stijn
aad7bcedd2 Dockerfile: update runc binary to v1.2.4
This is the fourth patch release of the 1.2.z release branch of runc. It
includes a fix for a regression introduced in 1.2.0 related to the
default device list.

- Re-add tun/tap devices to built-in allowed devices lists.

 In runc 1.2.0 we removed these devices from the default allow-list
 (which were added seemingly by accident early in Docker's history) as
 a precaution in order to try to reduce the attack surface of device
 inodes available to most containers. At the time we thought
 that the vast majority of users using tun/tap would already be
 specifying what devices they need (such as by using --device with
 Docker/Podman) as opposed to doing the mknod manually, and thus
 there would've been no user-visible change.

 Unfortunately, it seems that this regressed a noticeable number of
 users (and not all higher-level tools provide easy ways to specify
 devices to allow) and so this change needed to be reverted. Users
 that do not need these devices are recommended to explicitly disable
 them by adding deny rules in their container configuration.

full diff: https://github.com/opencontainers/runc/compare/v1.2.3...v1.2.4
release notes: https://github.com/opencontainers/runc/releases/tag/v1.2.4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 19:06:02 +01:00
Sebastiaan van Stijn
6ad0bfd6e9 Merge pull request #49235 from thaJeztah/processIPAM_clean
libnetwork/drivers/bridge: processIPAM: remove unused arg
2025-01-08 19:00:24 +01:00
Paweł Gronowski
eefb0802c8 Merge pull request #49228 from RTBHOUSE/49227-rwlayer-nil-dereference-fix
Clear RWLayer reference under container lock
2025-01-08 18:59:53 +01:00
Sebastiaan van Stijn
35932cdeec pkg/ioutils: un-export readCloserWrapper
This type was exported in fd35494a25 to be
used in tests in pkg/archive. It's no longer used in pkg/archive since
ba90fd8da0, so we can un-export it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 18:29:44 +01:00
Sebastiaan van Stijn
50212d215b Merge pull request #49014 from thaJeztah/eventlog_context
daemon: ImageService.LogImageEvent: pass through context
2025-01-08 17:53:00 +01:00
Stephen Day
392d33c98c image/save: set a stable timestamp for assets
When saving a docker image with `docker save`, output may have the
current timestamp, resulting in slightly changed content each time the
`save` command gets run. This patch attemtps to stabilize that effort to
clean up some spots where we've missed setting the timestamps.

It's not totally clear that setting these timestamps to 0 is the correct
behavior but it will fix the hash stability problem on output.

Signed-off-by: Stephen Day <stephen.day@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 17:49:25 +01:00
Sebastiaan van Stijn
e324df3f1b image/tarexport: patch MkDirall to accept atime, mtime
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 17:48:29 +01:00
Sebastiaan van Stijn
ca962cecfd image/tarexport: add fork of os.MkdirAll (non-buildable commit)
Fork the os.MkdirAll function, so that we can make changes to add support
for setting atime and mtime. This commit contains a 1:1 fork, but won't
build; code is taken from:
https://cs.opensource.google/go/go/+/refs/tags/go1.23.4:src/os/path.go;l=19-66

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 17:24:42 +01:00
Sebastiaan van Stijn
d127f16d56 Merge pull request #49171 from thaJeztah/move_atomicwriters
pkg/ioutils: move atomic file-writers to a separate (pkg/atomicwriter) package
2025-01-08 17:13:05 +01:00
Sebastiaan van Stijn
ee1a15a970 daemon: ImageService.LogImageEvent: pass through context
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 15:43:17 +01:00
Sebastiaan van Stijn
1b1192f009 Merge pull request #49217 from thaJeztah/runconfig_cleanups
runconfig: cleanup and fix tests, and fix error-types to use correct errdefs
2025-01-08 15:33:07 +01:00
Sebastiaan van Stijn
938bb0171a Merge pull request #49233 from crazy-max/bake-v6
ci: update bake-action to v6
2025-01-08 15:19:12 +01:00
Sebastiaan van Stijn
ea00e72c21 libnetwork/drivers/bridge: processIPAM: remove unused arg
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 15:15:11 +01:00
Sebastiaan van Stijn
eb36b182d3 Merge pull request #49229 from robmry/defgw_labels
Use bridge consts for "DefaultGatewayIPv[46]" aux-addr keys
2025-01-08 15:03:45 +01:00
CrazyMax
f8a973ba4e ci: update bake-action to v6
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2025-01-08 13:43:59 +01:00
Sebastiaan van Stijn
b223a6bcd2 Merge pull request #49187 from thaJeztah/info_generics_again
daemon: remove workaround for  go1.21 compiler bug
2025-01-08 12:34:45 +01:00
Sebastiaan van Stijn
586556eda7 runconfig: return correct error-types and touch-up error messages
Make sure we return a proper errdefs.InvalidParameter for these, and
update some error-messages to fix linting issues.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 12:08:46 +01:00
Sebastiaan van Stijn
fbb421efaa runconfig: cleanup TestDecodeContainerConfig
This test was conditionally testing windows or non-windows fixtures,
but it looks like we can test these cross-platform (at least currently).

Also moved the custom "f" type into the test, and rewrote it to use a
regular test-table with subtests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 12:08:45 +01:00
Sebastiaan van Stijn
c76cab29df runconfig: cleanup TestValidatePrivileged
- Rewrite the test to validate decoding the container config
  as a whole instead of the individial check, which didn't
  provide much coverage.
- Rename to TestDecodeContainerConfigPrivileged
- Move the test to a platform-agnostic file to verify an
  error is produced on Windows, but not on Linux

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 12:08:45 +01:00
Sebastiaan van Stijn
ff64a348cc runconfig: fix and refactor TestDecodeContainerConfigIsolation
This test had some broken test-case where the error would only be asserted
if an error happened, but would be ignored if no error happened, e.g.;

    if err := callDecodeContainerConfigIsolation(t, "invalid"); err != nil {
        if !strings.Contains(err.Error(), `Invalid isolation: "invalid"`) {
            t.Fatal(err)
        }
    }

The test also used a helper function (callDecodeContainerConfigIsolation,
added in 15e35c4470), which had multiple
output variables, but none of those, except for the error, were used.

This patch:

- removes the callDecodeContainerConfigIsolation utility
- rewrites TestDecodeContainerConfigIsolation to use sub-tests
- uses gotest.tools to assert errors

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 12:08:40 +01:00
Sebastiaan van Stijn
7864454792 pkg/ioutils: move atomic file-writers to a separate (pkg/atomicwriter) package
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 10:36:32 +01:00
Sebastiaan van Stijn
641e2fca5b Merge pull request #49198 from thaJeztah/migrate_TestCreateByImageID
integration-cli: migrate TestCreateByImageID to integration suite
2025-01-08 10:28:17 +01:00
Sebastiaan van Stijn
34ab9570ad daemon/links: TestLinkMultipleEnv: assert with gotest.tools, remove TestLinkPortRangeEnv
Simplify the test by testing the result, instead of manually checking
specific values. This makes sure we check the actual results, and don't
miss values, or ignore unexpected values.

TestLinkPortRangeEnv was added in 611a23aa7f
to test for port-ranges to produce the expected env-vars, but used the
same input as TestLinkMultipleEnv. Now that we assert all env-vars produced,
it became a duplicate of TestLinkMultipleEnv, so we can remove that test.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 10:04:56 +01:00
Tadeusz Dudkiewicz
97dc3056c6 Clear RWLayer reference under container lock
Previously the RWLayer reference was cleared without holding the
container lock. This could lead to goroutine panics in various places
that use the container.RWLayer because nil checks introduced in #36242
where not sufficient as the reference could change right before the use.

Fixes #49227

Signed-off-by: Tadeusz Dudkiewicz <tadeusz.dudkiewicz@rtbhouse.com>
2025-01-08 10:01:35 +01:00
Sebastiaan van Stijn
080d8e7d63 daemon/links: TestLinkEnv: assert with gotest.tools
Simplify the test by testing the result, instead of manually checking
specific values. This makes sure we check the actual results, and don't
miss values, or ignore unexpected values.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 09:59:17 +01:00
Sebastiaan van Stijn
702df89d9b daemon/links: TestLinkNaming: assert with gotest.tools
Simplify the test by testing the result, instead of manually checking
specific values. This makes sure we check the actual results, and don't
miss values, or ignore unexpected values.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 09:58:26 +01:00
Sebastiaan van Stijn
51eb0c6a24 daemon/links: TestLinkNew: assert with gotest.tools
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 09:58:22 +01:00
Sebastiaan van Stijn
382fb41563 daemon/links: remove newPortNoError utility
This utility was added in 12b6083c8f as a
replacement for nat.NewPort(), which before that patch would panic on
invalid values, but was changed to return an error.

Given that the utility ignores any error, and these values are fixed values
for the test, let's remove it to simplify constructing the tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-08 09:37:23 +01:00
Sebastiaan van Stijn
6c523afaed Merge pull request #49087 from dmcgowan/split-idtools-internal
Split idtools to an internal package and package to be moved
2025-01-07 22:18:36 +01:00
Derek McGowan
3fa5e7e6a9 Update internal use of idtools to usergroup
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-01-07 11:18:46 -08:00
Derek McGowan
9c368a93b6 Split internal idtools functionality
Separare idtools functionality that is used internally from the
functionlality used by importers. The `pkg/idtools` package is now
much smaller and more generic.

Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-07 11:18:46 -08:00
Sebastiaan van Stijn
8260f985b6 Merge pull request #49226 from thaJeztah/idtools_use_user
pkg/idtools: rewrite to use moby/sys/user
2025-01-07 20:01:11 +01:00
Akihiro Suda
49890db23b Merge pull request #49222 from thaJeztah/internalize_pkg_parsers_step3
pkg/parsers: deprecate ParseUintListMaximum, ParseUintList
2025-01-08 03:41:05 +09:00
Sebastiaan van Stijn
72829b7b5f Merge pull request #49165 from vvoland/image-metrics-move
Centralize daemon metrics
2025-01-07 19:03:59 +01:00
Rob Murray
a4ae38b010 Use bridge consts for "DefaultGatewayIPv[46]" aux-addr keys
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-07 15:51:04 +00:00
Paweł Gronowski
c08f00d821 Merge pull request #49218 from thaJeztah/daemon_clean_syntax
daemon: isOnlineFSOperationPermitted: cleanup confusing syntax
2025-01-07 15:14:35 +01:00
Paweł Gronowski
0f7a43271c daemon/events: Move metrics to internal/metrics
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-07 14:13:10 +01:00
Paweł Gronowski
90e2afd0be daemon: Move direct usages of go-metrics to internal/metrics
Add wrapper for StartTimer inside the internal package

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-07 14:13:08 +01:00
Paweł Gronowski
438f5801e1 daemon/images: Move ImageActions to metrics
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-07 14:13:07 +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
Paweł Gronowski
048fece105 Alias github.com/docker/go-metrics imports
Next commits will introduce a new internal `metrics` package, so alias
the "external" import to avoid confusion.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-01-07 14:13:05 +01:00
Sebastiaan van Stijn
24ad9bef9d pkg/idtools: rewrite to use moby/sys/user
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-07 13:43:24 +01:00
Rob Murray
3c628f7b45 Merge pull request #49224 from thaJeztah/std_errs
libnetwork/osl: Namespace.setSysctls: use stdlib errors
2025-01-07 12:01:38 +00:00
Sebastiaan van Stijn
b2450ff16d Merge pull request #49220 from thaJeztah/touch_up_IsInState
integration/internal/container: IsInState: touch up error-logs
2025-01-07 11:07:20 +01:00
Sebastiaan van Stijn
f4e2cfa209 libnetwork/osl: Namespace.setSysctls: use stdlib errors
This was the only location in this file where pkg/errors was used,
and this function already mixed stdlib errors with pkg/errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-07 11:01:14 +01:00
Rob Murray
9e3e42971a Merge pull request #49150 from robmry/live_restore_fixes
Fix live restore for IPv6-only and multiple gateway endpoints
2025-01-06 20:14:00 +00:00
Sebastiaan van Stijn
064cdf475c pkg/parsers: deprecate ParseUintListMaximum, ParseUintList
These utilities have been moved internal to pkg/sysinfo in
2282279180, and are no longer
used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-06 21:12:36 +01:00
Sebastiaan van Stijn
3ca5ca4dbc Merge pull request #49221 from thaJeztah/internalize_pkg_parsers_step2
pkg/sysinfo: parse cpuset.cpus/mems once and memoize
2025-01-06 21:11:49 +01:00
Rob Murray
39c05177ef Check network connect/disconnect after live-restore
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-06 18:15:07 +00:00
Rob Murray
c2fe1d31e9 Fix live-restore of the osSbox
On live-restore, the Sandbox tries to restore state in the osSbox
by telling it about interface, routes, and gateways that would
have been set up by the previous incarnation of the daemon.

Restoring gateways has been broken since commit 18327745c0 (Allow
separate IPv4/IPv6 gateway endpoints.) ... which didn't properly
deal with searching for the "dstName" of an interface based on its
IPv6 address.

This commit fixes that, and splits the osSbox restore into three
parts:
- Restore the interfaces, including finding the "dstName".
- Restore routes, unchanged, they're just a copy of the sandbox's
  StaticRoutes
- Restore gateway info - if the Sandbox's gateway endpoint has an
  IP address (v4 or v6, depending on which addr family/families it's
  acting as the gateway for), store that. If not, the default route
  is bound to the interface, so store that.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-06 18:11:11 +00:00
Rob Murray
a77ee8b9c0 Mark endpoints as "populated" after live restore
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-06 18:11:11 +00:00
Rob Murray
db1ed280f1 Live-restore gw-priority
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-06 18:11:11 +00:00
Rob Murray
9138195cef Rename Controller.sandboxCleanup to sandboxRestore
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-06 18:11:10 +00:00
Sebastiaan van Stijn
0342576056 Merge pull request #48979 from thaJeztah/execopts_parse
daemon/config: add validation of exec-config options
2025-01-06 18:15:19 +01:00
Sebastiaan van Stijn
1359772433 pkg/sysinfo: parse cpuset.cpus/mems once and memoize
Preserve the result instead of parsing these for each container that
specifies cpuset options,

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-06 17:53:25 +01:00
Sebastiaan van Stijn
120f616d06 Merge pull request #49193 from thaJeztah/internalize_pkg_parsers
pkg/sysinfo: internalize parsing cpusets
2025-01-06 17:51:20 +01:00
Rob Murray
fe7b02d739 Merge pull request #49130 from robmry/48576_connected_default_routes
Only set up an L3-ipvlan's default route when it's the gateway endpoint
2025-01-06 16:36:52 +00:00
Rob Murray
35fcbc1d1a Test a container attached to l3-ipvlan and bridge networks
Check that when a container has endpoints in an l3-ipvlan and
another network type (bridge), there's no longer any clash
betwen the ipvlan's connected default route and the bridge's
default gateway.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-06 15:24:23 +00:00
Rob Murray
81f6e087c1 Treat connected routes to unspecified addrs like default gws
In L3 modes, the ipvlan driver can't set up a default gateway with
a next hop address, because there's no L2 for it to resolve the
gateway IP into a MAC address.

Instead, it sets up a route to 0.0.0.0 or [::] that's connected to
the network's interface. The end result is the same - the container
has a default route.

So, don't set up routes to 0.0.0.0/:: when applying routes when an
endpoint joins a sandbox, set them up when the endpoint is selected
as the container's gateway. And, drop those routes when another
endpoint becomes the gateway.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-06 15:24:23 +00:00
Rob Murray
725defe1e9 Include iface routes to unspecified addrs when looking for default gws
In L3 modes, the ipvlan driver can't set up a default gateway with
a next hop address, because there's no L2 for it to resolve the
gateway IP into a MAC address.

Instead, it sets up a route to 0.0.0.0 or [::] that's connected to
the network's interface. The end result is the same - the container
has a default route.

So, include those routes when searching for endpoints that can act
as a container's default gateway.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-06 15:14:15 +00:00
Rob Murray
0416e31876 Add comments to selectGatewayEndpoint
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-06 15:14:15 +00:00
Sebastiaan van Stijn
1b9c09e10a daemon/logger: un-export RingLogger
It doesn't look like this type was intended for external use; constructing
a RingLogger can be done through the `NewRingLogger()` constructor, which
returns a `Logger` interface (implemented by `RingLogger`).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-06 14:52:03 +01:00
Sebastiaan van Stijn
263c46d755 integration/internal/container: IsInState: touch up error-logs
Before this patch:

    remove_test.go:62: timeout hit after 10s: waiting for container to be one of (exited), currently running

After this patch:

    remove_test.go:62: waiting for container State.Status to be 'exited', currently 'running'

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-06 13:20:16 +01:00
Sebastiaan van Stijn
2282279180 pkg/sysinfo: internalize parsing cpusets
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-06 10:46:42 +01:00
Sebastiaan van Stijn
aa696ffbb1 pkg/sysinfo: touch-up docs for cgroupCpusetInfo.Cpus, Mems
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-06 10:46:42 +01:00
Sebastiaan van Stijn
4597396cb5 pkg/sysinfo: define const for default Max CPUs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-06 10:46:29 +01:00
Sebastiaan van Stijn
799501d172 pkg/sysinfo: rename vars/arguments for clarity
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-06 10:40:09 +01:00
Sebastiaan van Stijn
0d51680f91 pkg/sysinfo: stub out parsing cpusets on non-linux
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-06 10:40:08 +01:00
Akihiro Suda
ca0e6af56c Merge pull request #49215 from thaJeztah/man_remove_nondistributable_artifacts
man: remove --allow-nondistributable-artifacts
2025-01-05 23:54:49 +09:00
Akihiro Suda
f3476518e4 Merge pull request #49216 from thaJeztah/vendor_moby_term
vendor: github.com/moby/term v0.5.2
2025-01-05 23:54:28 +09:00
Sebastiaan van Stijn
b7ed099727 daemon: isOnlineFSOperationPermitted: cleanup confusing syntax
This function was using a confusing syntax because `Isolation.IsDefault()`
and `Isolation.IsHyperV()` don't accept an argument. It's valid (see below),
but just confusing, so let's use a more common approach.

```go
package main

import "fmt"

type NameSayer string

func (f NameSayer) SayMyName() {
	fmt.Println(f)
}

func main() {
	var foo NameSayer = "my name is"
	foo.SayMyName()

	NameSayer("my name is..").SayMyName()

	// Thought SayMyName() would take no arguments? Think again!
	NameSayer.SayMyName("slim shady!")
}
```

While at it, also renamed the `container` argument as it was shadowing
the `container` import.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-04 18:27:26 +01:00
Sebastiaan van Stijn
fb03a3c403 vendor: github.com/moby/term v0.5.2
- update github.com/Azure/go-ansiterm to v0.0.0-20250102033503-faa5f7b0171c
  to fix OSC string terminator parsing.
- add security policy
- update github actions and test against go1.22, go1.23

full diff: https://github.com/moby/term/compare/v0.5.0...v0.5.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-03 22:25:55 +01:00
Sebastiaan van Stijn
a052449271 Merge pull request #49214 from dmcgowan/update-swarm-alpn
Update swarm to latest for server alpn config
2025-01-03 21:29:54 +01:00
Sebastiaan van Stijn
a49984dba7 Merge pull request #49211 from thaJeztah/update_golangci_config
golangci-lint: remove temporary exception for deprecated code
2025-01-03 21:11:02 +01:00
Sebastiaan van Stijn
be39e4f732 man: remove --allow-nondistributable-artifacts
commit 1932091e21 removed support
for the --allow-nondistributable-artifacts, but forgot to remove
this section.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-03 20:58:16 +01:00
Derek McGowan
4f9150cee5 Update swarm to latest for server alpn config
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-01-03 11:36:06 -08:00
Sebastiaan van Stijn
7b95ccc9fe Merge pull request #49210 from thaJeztah/internalize_fd_count
pkg/fileutils: move GetTotalUsedFds internal in daemon
2025-01-03 20:13:25 +01:00
Sebastiaan van Stijn
b7ae70033e Merge pull request #49178 from rumpl/c8d-fix-tar-build
c8d: Use the roundtripper during build
2025-01-03 19:16:46 +01:00
Sebastiaan van Stijn
a51baca00d pkg/fileutils: move GetTotalUsedFds internal in daemon
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-03 18:39:43 +01:00
Sebastiaan van Stijn
ca1cd48ad8 Merge pull request #49208 from thaJeztah/deprecate_GetTotalUsedFds
pkg/fileutils: deprecate GetTotalUsedFds
2025-01-03 18:39:22 +01:00
Sebastiaan van Stijn
ba8279bf1f golangci-lint: remove temporary exception for deprecated code
This was added in f0ce367e1e, but are no longer
used since b677cf93d3, so we can now remove this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-03 17:33:18 +01:00
Sebastiaan van Stijn
e45f20352d pkg/fileutils: deprecate GetTotalUsedFds
This function is only used internally and has no external consumers.
Mark it deprecated to be removed in the next release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-03 17:18:15 +01:00
Sebastiaan van Stijn
68f80d1d01 Merge pull request #49181 from thaJeztah/TestRunInvalidCpuset_create_not_run
integration-cli: TestRunInvalidCpuset.. create instead of run
2025-01-03 16:48:46 +01:00
Sebastiaan van Stijn
0241d0f91a Merge pull request #49199 from thaJeztah/integration_cleanups
integration: minor cleanups  and linting fixes
2025-01-03 16:48:09 +01:00
Sebastiaan van Stijn
0cd495cb44 Merge pull request #49132 from robmry/withresolvconf
Add testutil daemon.WithResolvConf
2025-01-03 15:42:46 +01:00
Rob Murray
a079f62f47 Add testutil daemon.WithResolvConf
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-03 12:37:00 +00:00
Sebastiaan van Stijn
d7f59cec05 daemon/config: add basic validation of exec-opt options
Validate if options are passed in the right format and if the given option
is supported on the current platform.

Before this patch, no validation would happen until the daemon was started,
and unknown options as well as incorrectly formatted options would be silently
ignored on Linux;

    dockerd --exec-opt =value-only --validate
    configuration OK

    dockerd --exec-opt unknown-opt=unknown-value --validate
    configuration OK

    dockerd --exec-opt unknown-opt=unknown-value --validate
    ...
    INFO[2024-11-28T12:07:44.255942174Z] Daemon has completed initialization
    INFO[2024-11-28T12:07:44.361412049Z] API listen on /var/run/docker.sock

With this patch, exec-opts are included in the validation before the daemon
is started/created, and errors are produced when trying to use an option
that's either unknown or not supported by the platform;

    dockerd --exec-opt =value-only --validate
    unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: invalid exec-opt (=value-only): must be formatted 'opt=value'

    dockerd --exec-opt isolation=default --validate
    unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: invalid exec-opt (isolation=default): 'isolation' option is only supported on windows

    dockerd --exec-opt unknown-opt=unknown-value --validate
    unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: invalid exec-opt (unknown-opt=unknown-value): unknown option: 'unknown-opt'

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-03 13:05:35 +01:00
Albin Kerouanton
1917be1672 Merge pull request #49202 from thaJeztah/hcsshim_stringmatch
libnetwork/drivers/windows: fix error-matching for hcsshim "not found"
2025-01-03 10:17:24 +01:00
Sebastiaan van Stijn
ac19b5c8b0 Merge pull request #49156 from vvoland/distribution-http-otel
distribution: Pass `Traceparent` OTEL header
2025-01-03 01:06:50 +01:00
Sebastiaan van Stijn
a646467a66 integration-cli: migrate TestCreateByImageID to integration suite
This test originally added in 4352da7803,
and was a bit involved as it involved building an image, and had some
dubious test-cases, such as  using `wrongimage:<ID of other image>` as
reference, and expecting that to produce a "not found" error. Possibly
this format was supported in the past, but currently it fails equally with
`correctimage:<ID of image>`.

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-03 00:11:53 +01:00
Sebastiaan van Stijn
58125b6df6 Merge pull request #48958 from cpuguy83/autogo_to_the_future
Down with the sickness (AUTO_GOPATH)
2025-01-02 23:55:45 +01:00
Sebastiaan van Stijn
ebb269d885 Merge pull request #48166 from thaJeztah/regex_oncevalue
use lazyregexp to compile regexes on first use
2025-01-02 23:54:51 +01:00
Sebastiaan van Stijn
5b31a5b370 libnetwork/drivers/windows: fix error-matching for hcsshim "not found"
This code has some gnarly string-matching to detect "not found" errors
returned by hcsshim.

Hcsshim at some point changed this error to lowercase;
6d67a30859

It looks like we ran into that problem in integration tests, which was
fixed in c530c9cbb0 when updating hcsshim,
however, it was only fixed in tests, and hiding the actual issue in our
code.

It looks like hcsshim has some utilities to detect error-types, such as the
IsElementNotFoundError function in hcn, which is the newer API that also wraps
the "HNS" service;
d9a4231b9d/hcn/hcnerrors.go (L75-L77)

But unfortunately, the hns API used by us, does not return typed errors, and
returns HNS errors as a untyped formatted string.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 23:15:32 +01:00
Sebastiaan van Stijn
cc4d2b08f2 Merge pull request #49201 from thaJeztah/non_const_formatting
fix non-constant format string (caught by go1.24)
2025-01-02 23:15:22 +01:00
Sebastiaan van Stijn
1f4c9f23c3 libnetwork/drivers/bridge: format errors with '%v' for consistency
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 22:05:38 +01:00
Sebastiaan van Stijn
3b8ba71fe3 libnetwork/drivers/windows: fix non-constant format string
Also updated some existing ones to use `%v` instead of `%s` for consistency.

caught by go1.24

    # github.com/docker/docker/libnetwork/drivers/windows/overlay
    # github.com/docker/docker/libnetwork/drivers/windows/overlay/ov_network_windows.go:206:32: non-constant format string in call to github.com/docker/docker/libnetwork/types.ForbiddenErrorf
    FAIL    github.com/docker/docker/libnetwork/drivers/windows/overlay [build failed]

    # github.com/docker/docker/libnetwork/drivers/windows
    # github.com/docker/docker/libnetwork/drivers/windows/windows.go:449:33: non-constant format string in call to github.com/docker/docker/libnetwork/types.ForbiddenErrorf
    FAIL    github.com/docker/docker/libnetwork/drivers/windows [build failed]

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 22:05:38 +01:00
Sebastiaan van Stijn
8c96e45375 distribution: fix non-constant format string
caught by go1.24

    # github.com/docker/docker/distribution
    # github.com/docker/docker/distribution/pull_v2_windows.go:145:35: non-constant format string in call to (*github.com/docker/docker/vendor/github.com/sirupsen/logrus.Entry).Debugf
    FAIL    github.com/docker/docker/distribution [build failed]

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 22:05:38 +01:00
Sebastiaan van Stijn
e451b698d3 golangci-lint: add forbidigo rules to prevent regex.MustCompile
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:35 +01:00
Sebastiaan van Stijn
86e470fe3a daemon/names: use lazyregexp
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:35 +01:00
Sebastiaan van Stijn
b7c88502fb internal/testutils/networking: use lazyregexp
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:35 +01:00
Sebastiaan van Stijn
ae13510577 daemon/logger/awslogs: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:34 +01:00
Sebastiaan van Stijn
690e00733e volume/mounts: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:34 +01:00
Sebastiaan van Stijn
72ebf2c309 testutil: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:34 +01:00
Sebastiaan van Stijn
b5d90d746b registry: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:34 +01:00
Sebastiaan van Stijn
b6b19059c5 plugin: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:34 +01:00
Sebastiaan van Stijn
0fe953dff0 pkg/idtools: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:33 +01:00
Sebastiaan van Stijn
48d63b99ef opts: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:33 +01:00
Sebastiaan van Stijn
06948b83f3 oci: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:33 +01:00
Sebastiaan van Stijn
98f7c45e7f integration-cli: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:33 +01:00
Sebastiaan van Stijn
bc1dbd9ea6 daemon: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:33 +01:00
Sebastiaan van Stijn
d61a6924d7 client: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:32 +01:00
Sebastiaan van Stijn
0672b3b7f7 builder: use lazyregexp to compile regexes on first use
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:32 +01:00
Sebastiaan van Stijn
43b3aaa62d implement lazyregexp package
Based on the "lazyregexp" package in golang.org/x/mod;
https://cs.opensource.google/go/x/mod/+/refs/tags/v0.19.0:internal/lazyregexp/lazyre.go;l=66-78

This package allows defining regular expressions that should not be
compiled until used, but still providing validation to prevent
invalid regular expressions from producing a panic at runtime.

This is largely a copy of the package from golang.org/x/mod,
with FindAllStringSubmatch and ReplaceAllStringFunc added

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 21:37:11 +01:00
Brian Goff
ce37cb3ea0 Down with the sickness (AUTO_GOPATH)
Go has a nice tool to inspect the currently set (or default) `GOPATH`
with `go env GOPATH`.
We should do that rather than absolutely requiring people to manually
set `GOPATH` or use the `AUTO_GOPATH`.

This doesn't actually remove `AUTO_GOPATH`, people can still use it.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2025-01-02 19:36:52 +00:00
Sebastiaan van Stijn
35cfb6fb76 Merge pull request #49189 from thaJeztah/pkg_sysinfo_cleanup_tests
pkg/sysinfo: cleanup tests
2025-01-02 20:31:12 +01:00
Brian Goff
db6158b1e6 Merge pull request #49195 from thaJeztah/vendor_ansiterm
vendor: github.com/Azure/go-ansiterm faa5f7b0171c, remove workaround for OSC string terminator parsing
2025-01-02 11:12:02 -08:00
Sebastiaan van Stijn
839b0afbc7 integration/container: use is.ErrorType for some tests
It provides more details about the actual error-type obtained
on failures.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 19:43:08 +01:00
Sebastiaan van Stijn
4504ca6bf6 integration/container: rename vars that shadowed imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 19:43:08 +01:00
Sebastiaan van Stijn
6b0085eebd integration/container: use consistent name for api-client
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 19:43:08 +01:00
Sebastiaan van Stijn
fa0b9f9505 integration/container: use consistent alias for test-container pkg
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 19:43:08 +01:00
Sebastiaan van Stijn
5a68f1c524 Merge pull request #49168 from thaJeztah/unconvert
builder/dockerfile: unconvert
2025-01-02 19:41:55 +01:00
Sebastiaan van Stijn
547151abd2 pkg/sysinfo: cleanup tests
- use t.TempDir()
- combine various tests to check if New() sets expected values instead
  of skipping tests when not.
- remove gotest.tools, as it was only used minimally
- replace uses of "path" for filepath operations.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 16:51:42 +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
a948ee657e Merge pull request #49192 from thaJeztah/numcpu_once
daemon: don't repeatedly call NumCPU if not needed
2025-01-02 16:30:20 +01:00
Rob Murray
e44835810b Merge pull request #49196 from robmry/49179_restore_windows_network_labels
Restore labels when re-creating Windows networks
2025-01-02 14:26:03 +00:00
Rob Murray
25009ed5c0 Restore labels when re-creating Windows networks
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-01-02 10:56:01 +00:00
Sebastiaan van Stijn
7bd1b64058 daemon/logger/loggertest: remove workaround for OSC string terminator parsing
This workaround was added in 2ec3e14c0f
to work around a [bug in go-ansiterm][1], which was fixed in [o-ansiterm#35][1].

[1]: https://github.com/Azure/go-ansiterm/issues/34
[2]: https://github.com/Azure/go-ansiterm/pull/35

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 11:00:57 +01:00
Sebastiaan van Stijn
5149401665 vendor: github.com/Azure/go-ansiterm faa5f7b0171c
- Fix OSC string terminator parsing

full diff:  306776ec81...faa5f7b017

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-02 10:56:48 +01:00
Sebastiaan van Stijn
700c91b3bf Merge pull request #49185 from thaJeztah/daemon_info_cleanups
daemon: minor cleanups for getting system info
2025-01-01 18:27:04 +01:00
Sebastiaan van Stijn
ddd885a961 daemon: don't repeatedly call NumCPU if not needed
sysinfo.NumCPU returns the number of CPUs which are currently online,
which involves some syscalls and parsing on Windows.

Change the code to only retrieve this information when needed, and
memoize the result to prevent calling this function multiple times.

Ideally, we'd obtain this information from daemon.RawSysInfo(), but
that uses a sync.Once, which could return outdated information.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-01 18:24:22 +01:00
Sebastiaan van Stijn
6f6c3b9211 Merge pull request #49172 from thaJeztah/internalize_pkg_broadcaster
remove pkg/broadcaster and make it internal to container/streams
2025-01-01 16:12:00 +01:00
Sebastiaan van Stijn
aa7493f953 daemon: minor cleanups for getting system info
- rename variables that shadowed functions
- use strconv.FormatBool instead of fmt.Sprintf to reduce some allocations
- use structured logs for some warnings
- remove some intermediate vars in favor of early returns

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-01 16:10:13 +01:00
Sebastiaan van Stijn
d01dd981c1 Merge pull request #49188 from thaJeztah/go1.24_prep
daemon: adjust tests for changes in go1.24 JSON errors
2025-01-01 16:00:58 +01:00
Sebastiaan van Stijn
0e10cd65f3 Merge pull request #49186 from thaJeztah/daemon_add_missing_gobuild
daemon: add missing "//go:build" directive
2025-01-01 16:00:34 +01:00
Akihiro Suda
1d3d51f1fe Merge pull request #49182 from thaJeztah/pkg_parsers_rename_var
pkg/parsers: rename var that collided with builtin
2025-01-01 22:39:24 +09:00
Akihiro Suda
05a5bdf9be Merge pull request #49176 from thaJeztah/parseSecurityOpt_noshadow
daemon: parseSecurityOpt: rename var that shadowed function
2025-01-01 22:39:06 +09:00
Akihiro Suda
ae1a1869ef Merge pull request #49170 from thaJeztah/internalize_ioutils_OnEOFReader
pkg/ioutils: remove OnEOFReader and move it internal
2025-01-01 22:38:44 +09:00
Sebastiaan van Stijn
1c37a4454b daemon: adjust tests for changes in go1.24 JSON errors
These tests failed because the error message changed in go1.24 through
https://go.dev/cl/606956.

    === Failed
    === FAIL: daemon/config TestDaemonConfigurationFeatures/invalid_config_value (0.00s)
        config_linux_test.go:182: assertion failed: expected error "json: cannot unmarshal string into Go struct field Config.features of type bool", got "json: cannot unmarshal string into Go struct field Config.CommonConfig.features of type bool"

    === FAIL: daemon/config TestDaemonConfigurationFeatures (0.00s)

    === FAIL: daemon/config TestDaemonConfigurationHostGatewayIP/config_not_array (0.00s)
        config_linux_test.go:354: assertion failed: expected error "json: cannot unmarshal string into Go struct field Config.host-gateway-ips of type []netip.Addr", got "json: cannot unmarshal string into Go struct field Config.CommonConfig.DNSConfig.host-gateway-ips of type []netip.Addr"

Relax the tests a bit to accept errors produced by either go1.24 or older.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-01 14:28:35 +01:00
Sebastiaan van Stijn
c5575b5119 daemon: add missing "//go:build" directive
relates to 56eb47c622, which added
the "slices" package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-01 13:42:32 +01:00
Sebastiaan van Stijn
f8524ab041 daemon: remove workaround for go1.21 compiler bug
This reverts commit 6d2c4f87af.

go.dev/issue/64759 should be fixed in go1.21.9 through https://go.dev/cl/574736,
so we can revert the workaround.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-01 13:29:20 +01:00
Sebastiaan van Stijn
8e9213a6b6 daemon: remove kernel-version check for kernel < 4.0.0
This check was in place for CentOS/RHEL 7, which use kernel 3.10. Now
that both reached EOL, and we stopped packaging for those distros, we
can remove this condition.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-01-01 12:42:57 +01:00
Sebastiaan van Stijn
86a2df8be6 pkg/parsers: rename var that collided with builtin
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-31 20:17:21 +01:00
Sebastiaan van Stijn
cfc988e4da integration-cli: TestRunInvalidCpuset.. create instead of run
These tests don't have to run a container, as validation happens
on create.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-31 18:34:42 +01:00
Djordje Lukic
8d5cf1db1e Use the roundtripper during build
The roundtripper is responsible for giving back the build context when
it comes from a tar directly. So we add it to the source manager of the
containerd worker.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2024-12-30 23:39:52 +01:00
Sebastiaan van Stijn
f321120767 daemon: parseSecurityOpt: rename var that shadowed function
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-30 13:59:17 +01:00
Sebastiaan van Stijn
44db31b9cc remove pkg/broadcaster and make it internal to container/streams
This package was only used internally in container/streams and had
no external consumers.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-28 17:30:39 +01:00
Sebastiaan van Stijn
6ab9212168 pkg/ioutils: remove OnEOFReader and move it internal
This type was originally in pkg/transport, but got moved to pkg/ioutils
in 276c640be4.

This type is only used in a single location, and has no external consumers,
so we can move it where it's used and un-export it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-28 16:52:54 +01:00
Sebastiaan van Stijn
f5af46d4d5 Merge pull request #49117 from dmcgowan/archive-remove-pools
Remove use of `pkg/pools` in archive
2024-12-28 15:49:32 +01:00
Derek McGowan
be4eac753f Remove use of bufio in cli import tests
The use of bufio for writing without flushing can lead to an incomplete
writing of the tar and subsequent unexpected EOF when importing.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-12-24 22:01:05 -08:00
Derek McGowan
4c251b6b03 Add pool for archive decompress stream
Cleanup decompress logic and add a pool. The close logic should be
custom defined for each compression type since they have different
close interfaces.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-12-23 17:45:10 -08:00
Derek McGowan
9189a6e0ab Fix chrootarchive test
After the untar errors, the reader must complete in order to fill
the buffer used by the subsequent check.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-12-23 17:45:10 -08:00
Derek McGowan
a93a079cb4 Remove use of pools in archive
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-12-23 17:45:10 -08:00
Sebastiaan van Stijn
8d787e3461 builder/dockerfile: unconvert
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-23 17:14:43 +01:00
Sebastiaan van Stijn
a72026acbb Merge pull request #49162 from thaJeztah/pkg_system_volume_uuid
pkg/system: deprecate MkdirAll and remove custom volume GUID handling
2024-12-23 12:57:00 +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
1e060d3315 daemon/graphdriver/windows: remove uses of deprecated system.MkdirAll
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-21 14:38:23 +01:00
Sebastiaan van Stijn
05ec732667 libcontainerd/supervisor: remove uses of deprecated system.MkdirAll
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-21 14:33:04 +01:00
Sebastiaan van Stijn
84bb6e5afb container: remove uses of deprecated system.MkdirAll
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-21 14:32:25 +01:00
Sebastiaan van Stijn
c02c2a3a79 cmd/dockerd: remove uses of deprecated system.MkdirAll
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-21 14:30:56 +01:00
Sebastiaan van Stijn
e783bb5c69 builder/dockerfile: remove uses of deprecated system.MkdirAll
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-21 14:28:34 +01:00
Sebastiaan van Stijn
bc61b31935 pkg/idtools: remove uses of deprecated system.MkdirAll
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-21 14:28:04 +01:00
Sebastiaan van Stijn
4472e9b7f8 pkg/system: deprecate MkdirAll and remove custom volume GUID handling
commit 86d1223a29 introduced a custom version
of `os.MkdirAll` for Windows to account for situations where the path to
create would start with a Windows volume name (GUID path), for example,
`"\\?\Volume{4c1b02c1-d990-11dc-99ae-806e6f6e6963}\`. At the time that patch
was added we were using [go1.4.2], which did not have special handling
for Windows in [MkdirAll], therefore would recognize such paths as regular
paths, trying to create them, which would fail.

This code was later updated in 46ec4c1ae2
to provide ACL (DACL) support on Windows.

Further updates were made in cfef1b11e5 and
55ceb5047c to allow for an early return when
detecting a volume GUID path, and the code was re-aligned with the latest
(go1.19.2) implementation in f058afc861, which
brought in the platform-specific [fixRootDirectory] handling introduced in
go1.11. While that enhancement detected UNC volume-paths (`\\?c\`, `//?/c:`),
it did not yet support volume GUID paths.

go1.22, through [golang.org/cl/86295] added support for this, and `os.MkdirAll`
now natively detects volume GUID paths, making our own implementation for
this redundant.

This patch:

- Deprecates pkg/system.MkdirAll in favor of os.MkdirAll, which now provides
  the same functionality on go1.22 and up.
- Renames the (non-exported) `mkdirall` function to `mkdirAllWithACL`, and
  synchronises `it` with the [implementation in go1.23.4], bringing in the
  changes from [golang.org/cl/86295] and [golang.org/cl/582499].
- Adds a fast path to `MkdirAllWithACL` if no ACL / SDDL is provided.

It's worth noting that we currently still support go1.22, and that the
implementation changed in go1.23; those changes ([golang.org/cl/581517]
and [golang.org/cl/566556]) were lateral moves, therefore should be
identical to the implementation in go1.22, and we can safely use the
implementation provided by [filepath.VolumeName] on either go1.22 or go1.23.

[go1.4.2]: 86d1223a29/Dockerfile (L77)
[MkdirAll]: https://github.com/golang/go/blob/go1.4.2/src/os/path.go#L19-L60
[fixRootDirectory]: b86e766813
[golang.org/cl/86295]: cd589c8a73
[golang.org/cl/582499]: 5616ab6025
[golang.org/cl/581517]: ad22356ec6
[golang.org/cl/566556]: ceef0633b3
[1]: https://github.com/golang/go/blob/go1.23.4/src/os/path.go#L12-L66
[filepath.VolumeName]: https://pkg.go.dev/path/filepath#VolumeName

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-21 14:19:01 +01:00
Sebastiaan van Stijn
b5d5fef7aa Merge pull request #49158 from akerouanton/netdrivers-store-param
libnet: pass store as an arg to netdrivers
2024-12-20 20:43:14 +01:00
Albin Kerouanton
e5bf6d8ba0 libnet: pass store as an arg to netdrivers
Before that change, we were passing the datastore to network drivers
through a `map[string]interface{}`. Then, each driver that needed the
store would cast the datastore to the correct type.

This was not a good design, as it was not clear which drivers were using
the store and which were not. Not all unit tests were passing the store,
leading to logs about uninitialized store being written.

This change makes the store a parameter of the `RegisterX` functions.
All unit tests are now passing a valid datastore to the drivers. A new
testutil func is added for that purpose.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-12-20 17:51:53 +01:00
Paweł Gronowski
93e9f7f75f distribution: Pass Traceparent OTEL HTTP header
Wrap `http.RoundTripper` used by distribution code (push/pull) with the
`otelhttp.Transport`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-20 15:49:09 +01:00
Paweł Gronowski
ad6929339a Merge pull request #49147 from thaJeztah/fix_gc_default
builder: don't fall back to defaultKeepStorage when set to zero
2024-12-20 12:12:30 +00:00
Akihiro Suda
2c5649784d Merge pull request #49151 from thaJeztah/chrootarchive_reduce_deps
pkg/chrootarchive: use stdlib errors, remove "// import" comments
2024-12-20 18:34:12 +09:00
Sebastiaan van Stijn
ec0dba0020 Merge pull request #49140 from vvoland/c8d-fix-duplicate-containerdimages-import
daemon/c8d: Fix duplicate containerd/images import
2024-12-19 22:58:45 +01:00
Sebastiaan van Stijn
0c02317851 Merge pull request #49032 from thaJeztah/vendor_cgroups
vendor: github.com/containerd/cgroups v3.0.5
2024-12-19 22:38:03 +01:00
Sebastiaan van Stijn
524a63a958 pkg/chrootarchive: remove "// import" comments
These comments were added to prevent users from accidentally
importing using the wrong module name, but they don't have
an effect when working in go modules mode.

Remove the comments in preparation of moving this package
to a separate module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-19 22:27:40 +01:00
Sebastiaan van Stijn
302ca6227f pkg/chrootarchive: use stdlib errors
Remove use of github.com/pkg/errors for this package, in preparation
of it being moved to a separate module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-19 22:26:42 +01:00
Sebastiaan van Stijn
727ab584bb vendor: github.com/containerd/cgroups v3.0.5
full diff: https://github.com/containerd/cgroups/compare/v3.0.3...v3.0.5

notable changes:

- chore: don't log ENOTSUP during parsing PSI files
- Add EOPNOTSUPP to err filter for PSI data
- cg2: Don't read cgroup.procs when deleting threaded cg
- Added cgroup type "domain threaded" and "domain invalid"
- switch to github.com/containerd/log
- go.mod: update to go1.22 as minimum
- deprecate RunningInUserNS()
- dont ignore failure to create cgroup after timeout
- cgroup2: Manager.Delete: handle both "threaded" and "domain threaded"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-19 21:27:44 +01:00
Sebastiaan van Stijn
275bbcd300 builder: don't fall back to defaultKeepStorage when set to zero
commit b08ff81204 updated this code to
only produce an error if an invalid value was set by the user, and to
avoid errors on empty values.

However, the intent of this code was to allow `0` as a valid value for
cases where gc is to be handled through other properties / filters.

This patch only sets the default if no value was set by the user, but
doesn't set the default if a value is set by the user, but zero.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-19 21:23:09 +01:00
Sebastiaan van Stijn
b677cf93d3 Merge pull request #49072 from dmcgowan/decouple-archive-system
Decouple pkg/archive from pkg/system
2024-12-19 20:40:36 +01:00
Sebastiaan van Stijn
1a127ed2d7 Merge pull request #49144 from thaJeztah/docs_api_isolation
docs/api: allow for an empty string for Isolation (api v1.25-v1.47)
2024-12-19 20:33:24 +01:00
Sebastiaan van Stijn
7dfe4f2335 Merge pull request #49146 from thaJeztah/bump_x_net
vendor: golang.org/x/net v0.33.0
2024-12-19 20:14:22 +01:00
Derek McGowan
315891dd2e Remove import comments
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-12-19 10:13:45 -08:00
Derek McGowan
e4236c93d9 Remove unused pkg/system functions
These were previously only used for pkg/archive

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-12-19 10:13:44 -08:00
Derek McGowan
12b2b56fa6 Update archive to use fs.FileInfo over custom stat
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-12-19 10:13:44 -08:00
Derek McGowan
bb3e95dfdc Update archive to use unix.Mknod directly
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-12-19 10:13:44 -08:00
Derek McGowan
35b9525f9a Update archive to use its own xattr funcs
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-12-19 10:13:44 -08:00
Derek McGowan
1b4cbea3a8 Update archive to use time operations directly
Update archive time logic to mirror containerd's

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-12-19 10:13:33 -08:00
Paweł Gronowski
90fef061ec daemon/c8d: Force c8dimages alias for containerd/images
Change all github.com/containerd/containerd/images imports to be
imported as `c8dimages`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-19 18:39:43 +01:00
Paweł Gronowski
8c30e11321 c8d/delete: Consistent method receiver
`imageDeleteConflict` is always returned via a reference, so adjust the
method receiver of `Conflict` to make it consistent with `Error`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-19 18:39:42 +01:00
Paweł Gronowski
1ad78f00b1 daemon/c8d: Fix duplicate containerd/images import
Remove duplicate imports under different aliases

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-19 18:39:40 +01:00
Sebastiaan van Stijn
6bd5840675 vendor: golang.org/x/net v0.33.0
contains a fix for CVE-2024-45338 / https://go.dev/issue/70906,
but it doesn't affect our codebase:

    govulncheck -show=verbose ./...
    Scanning your code and 1260 packages across 211 dependent modules for known vulnerabilities...
    ...
    Vulnerability #1: GO-2024-3333
        Non-linear parsing of case-insensitive content in golang.org/x/net/html
      More info: https://pkg.go.dev/vuln/GO-2024-3333
      Module: golang.org/x/net
        Found in: golang.org/x/net@v0.32.0
        Fixed in: golang.org/x/net@v0.33.0

    Your code is affected by 0 vulnerabilities.
    This scan also found 0 vulnerabilities in packages you import and 1
    vulnerability in modules you require, but your code doesn't appear to call these
    vulnerabilities.

full diff: https://github.com/golang/net/compare/v0.32.0...v0.33.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-19 18:17:33 +01:00
Sebastiaan van Stijn
64ca1c0f92 Merge pull request #49133 from vvoland/c8d-remove-getimagemanifest
image: Remove `GetImageManifest`
2024-12-19 17:42:29 +01:00
Sebastiaan van Stijn
364e4790e1 docs/api: allow for an empty string for Isolation (api v1.25-v1.47)
Backport the changes from 26049febb2
to all versions used in the documentation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-19 17:27:18 +01:00
Sebastiaan van Stijn
fe6acf647e Merge pull request #49122 from XxRoloxX/49033-update-swarmjoin-datapathaddr-examples
docs: Update example section for SwarmJoinRequest
2024-12-19 16:55:13 +01:00
Paweł Gronowski
ce9c1635cd Merge pull request #49138 from vvoland/api-remove-unused-gd-fields
api: Remove unused imageStore and layerStore
2024-12-19 14:52:07 +00:00
Sebastiaan van Stijn
1fd9eb772f Merge pull request #48616 from dgunzy/47452-allow-empty-isolation-string
api: Allow for an empty string for Isolation in Swagger specs
2024-12-19 15:31:15 +01:00
Sebastiaan van Stijn
6f1580399e Merge pull request #49127 from thaJeztah/shaun_curator
add Shaun Thompson as curator
2024-12-19 14:54:38 +01:00
Paweł Gronowski
7e9a5064dc api: Remove unused imageStore and layerStore
Commit 8fb71ce208 moved access to these to
the image service directly, so they are no longer used in the router.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-19 14:50:50 +01:00
Sebastiaan van Stijn
4e3202affb Merge pull request #49125 from akerouanton/move-iptRule-to-ipt-pkg
libnet/d/bridge: move iptRule to iptables pkg
2024-12-19 13:50:42 +01:00
Paweł Gronowski
2dad06f981 Merge pull request #49106 from thaJeztah/ReplaceContainer_noshadow
libcontainer: ReplaceContainer: fix var shadowing import
2024-12-19 12:48:40 +00:00
Albin Kerouanton
f95e4b3d22 Merge pull request #49129 from thaJeztah/migrate_reexec
pkg/reexec: deprecate and migrate to github.com/moby/sys/reexec
2024-12-19 12:42:41 +01:00
Paweł Gronowski
c452af6651 image: Remove unused Details fields
Last usage of these fields was removed by cd11843df8.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-19 12:14:24 +01:00
Paweł Gronowski
d9795da33e image: Remove GetImageManifest
Its only usage was in container creation, which also called `GetImage`
first.
This method is specific to the containerd image service and is largely
the same as `GetImage`, except it returns a manifest descriptor.
Instead, introduce add the descriptor as a new field in `Image.Details`
and set it in the containerd image service implementation of `GetImage`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-19 12:14:22 +01:00
Sebastiaan van Stijn
4f5ec9994c pkg/reexec: deprecate and migrate to github.com/moby/sys/reexec
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-19 10:12:58 +01:00
Sebastiaan van Stijn
40f58b3492 Merge pull request #49062 from dvdksn/builder-gcpolicy-empty-keepbytes
builder: fall back to defaultKeepStorage if keepStorage is unset for GC policy
2024-12-18 19:12:59 +01:00
Sebastiaan van Stijn
93101be4b7 Merge pull request #49128 from robmry/v6only/enable_ext_dns
Enable external DNS if a network has an IPv6 gateway
2024-12-18 16:24:06 +01:00
Sebastiaan van Stijn
7fbbd52b0e add Shaun Thompson as curator
Shaun is managing the runtime and build teams, and will be helping out
on triage, as well as organizing backlogs on GitHub.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-18 14:33:19 +01:00
Rob Murray
b0be1f3af8 Enable external DNS if a network has an IPv6 gateway
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-18 12:22:45 +00:00
Sebastiaan van Stijn
bdfc384352 Merge pull request #49123 from akerouanton/remove-dns-answers-from-otel-spans
[master forward-port] libnet: don't put external DNS answers in OTel spans
2024-12-18 12:30:05 +01:00
Albin Kerouanton
ec8a5b0f4c libnet/d/bridge: move iptRule to iptables pkg
This moves the iptRule struct from the bridge package to the iptables
pkg.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-12-18 11:01:27 +01:00
Albin Kerouanton
1b823fb54e libnet: don't put external DNS answers in OTel spans
When containers make DNS resolution, and the domain name they're trying
to resolve doesn't match any running container, the DNS query is
forwarded to upstream servers. In that case, when we receive a response,
we put it in an OTel spans.

This was useful to debug DNS resolution on GHA, but it leads to
excessive memory usage when DNS resolution happen in a tight loop. So,
keep the OTel event signaling that a response was received, but drop the
answer from the OTel span.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
(cherry picked from commit 173a9f2091)
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-12-18 09:24:44 +01:00
Albin Kerouanton
ca85ba2e82 Merge pull request #49114 from thaJeztah/deprecate_BridgeNfIptables_fields
Deprecate BridgeNfIptables and BridgeNfIp6tables fields
2024-12-18 09:22:36 +01:00
Sebastiaan van Stijn
fab60e2c2c Merge pull request #49121 from thaJeztah/iptables_rm_deprecated
libnetwork/iptables: remove deprecated IPV, Iptables, IP6Tables, Passthrough()
2024-12-18 00:00:55 +01:00
Adam Lamers
1aecca8bbd docs: Update example section for SwarmJoinRequest
- Updated the example section in `swagger.yaml` for the `DataPathAddr` parameter in `SwarmJoinRequest`.
- Updated corresponding example sections in `docs/api/v1.*`

Signed-off-by: Adam Lamers <adam.lamers@wmsdev.pl>
2024-12-17 21:38:03 +01:00
Albin Kerouanton
0d53725a7f Merge pull request #49107 from akerouanton/ipt-split-ProgramChain
libnet/iptables: split ProgramChain and move to bridge driver
2024-12-17 19:15:52 +01:00
Sebastiaan van Stijn
b6594353f8 libnetwork/iptables: remove deprecated Passthrough()
This was deprecated in d688389f4a, and has
no known external users. The deprecation was included in the 27.4.1
release, so we can remove it from master.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-17 18:49:10 +01:00
Sebastiaan van Stijn
d34d092b42 libnetwork/iptables: remove deprecated IPV, Iptables, IP6Tables
This was deprecated in 27deff4da1, and has
no known external users. The deprecation was included in the 27.4.1
release, so we can remove it from master.

This patch removes the deprecated `IPV`, and `Iptables` and `IP6Tables`
consts.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-17 18:49:09 +01:00
Sebastiaan van Stijn
cc1d50a63d Merge pull request #49118 from thaJeztah/reexec_clean
pkg/reexec: some cleaning up in preparation of moving to a separate module
2024-12-17 17:07:05 +01:00
Rob Murray
f237ba0ea7 Merge pull request #48641 from robmry/iptables-combine-outgoing-and-icc-rules
Combine Outgoing and ICC=true iptables rules
2024-12-17 14:44:11 +00:00
Sebastiaan van Stijn
8d3ecc28c1 Merge pull request #49115 from thaJeztah/libnetwork_deprecate_Passthrough
libnetwork/iptables: deprecate Passthrough
2024-12-17 12:48:53 +01:00
Albin Kerouanton
820dea0d2b libnet/d/bridge: hardcode chain names
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-12-17 12:31:35 +01:00
Albin Kerouanton
bd30a51ea7 libnet/iptables: split ProgramChain and move to bridge driver
The `ProgramChain` method was called exclusively by the bridge driver
to insert totally unrelated ipt rules in two different table-chains.

Break down this method into two functions, and move them into the bridge
pkg.

The new function `addNATJumpRules` inserts rules that aren't related to
any specific network, and depends solely on the driver config. Call it
during driver configuration instead of during network setup.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-12-17 12:31:34 +01:00
Rob Murray
df3c78d061 Combine outgoing and ICC iptables rules
Rather than:

  ACCEPT -i <bridge> -o <bridge>   // icc=true
  ACCEPT -i <bridge> ! -o <bridge> // outgoing

Do:

  ACCEPT -i <bridge>  // icc=true and outgoing

For ICC=false, continue to do:

  DROP -i <bridge> -o <bridge>
  ACCEPT -i <bridge> ! -o <bridge>

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-17 10:38:09 +00:00
Rob Murray
0f259dd76d Rename setupIPTablesInternal -> setupNonInternalNetworkRules
setupIPTablesInternal is/was called from setupIPTables to set
up some rules for a network ... "internal" behaviour of the
outer function.

Then commit 7b64b1c2 added support for "--internal" bridge
networks, calling setupInternalNetworkRules from setupIPTables
instead of setupIPTablesInternal.

So, setupIPTablesInternal is the function that deals with
everything except "--internal" networks ... rename it.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-17 10:38:09 +00:00
Rob Murray
556b8eed16 Tidy setupIPTablesInternal
- Move variable declarations closer to where they're used.
- Put comments in the blocks they apply to.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-17 10:38:09 +00:00
Rob Murray
726b327b83 Merge pull request #48640 from robmry/iptables-static-forward-rules
Create static iptables rules during bridge driver init
2024-12-17 10:36:11 +00:00
Sebastiaan van Stijn
8fd177d79b pkg/reexec: Command: separate public API from implementation
Move the exported `Command` to a platform-agnostic file, and un-export
the platform-specific implementations. This allows us to maintain the
GoDoc in a single place, describing platform-specific differences where
needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-17 10:51:06 +01:00
Sebastiaan van Stijn
6568c06d12 pkg/reexec: make platform-agnostic (again)
The reexec package originally was platform-agnostic, but gained some
Linux-specific handling in 1cb17f03d0.

When Windows support was implemented in Docker, the pkg/reexec package
was adjusted accordingly in 64715c4f33,
which now made the package with with either Linux or Windows, with various
other platforms (freebsd, solaris, darwin) being added back in separate
changes.

Based on the history above, this package should be platform-agnostic, except
for Linux-specific changes introduced in 1cb17f03d0
and 5aee8807a6.

This patch:

- removes the stub-implementation to make it functional on other platforms.
- renames the files for consistency

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-17 10:51:06 +01:00
Sebastiaan van Stijn
7672d60033 pkg/reexec: use const for name of test binary
Also use a slightly different name, because "reexec" is used so
widely as term in this package, making it somewhat confusing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-17 10:51:06 +01:00
Paweł Gronowski
0e8013d72d Merge pull request #49113 from thaJeztah/fix_version_history_typo
docs/api: version-history.md: fix markdown
2024-12-17 09:23:31 +00:00
Rob Murray
0ef2b24c80 Make libnetwork responsible for DOCKER-USER setup/reload
It no longer needs to be moved to the top of the filter-FORWARD
chain after creating a new bridge network. But, it does need to
be rearranged after setting up Swarm ingress.

Similarly, the jump to DOCKER-INGRESS no longer needs to be
shuffled back to the top of the FORWARD chain after adding a
new network.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-17 09:14:26 +00:00
Rob Murray
9699284e8f Add iptablesdoc for a swarm network
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-17 09:14:25 +00:00
Rob Murray
6473d37002 Run commands in an L3Segment netns without failing the test.
Return an error from runCommand instead of calling t.Fatal, and add
Host.Run to return that error.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-17 09:14:25 +00:00
Rob Murray
3bf9a80818 Rename L3Segment Host.Run -> Host.MustRun
Like netip.MustParseIP, it fails on error.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-17 09:14:25 +00:00
Rob Murray
29e20fc904 Add static filter-FORWARD rules during bridge driver init
Rules no longer need to be rearranged when creating a network.

Per-network rules are always appended to the FORWARD chain so,
after adding them, there's no need to delete the per-driver
rules to re-insert them at the top of the chain.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-17 09:14:25 +00:00
Rob Murray
5ccc699513 Use golden testdata in TestUserChain
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-17 09:14:25 +00:00
Akihiro Suda
eb84d54bfa Merge pull request #49116 from tonistiigi/update-buildkit-v0.18.2
vendor: update buildkit to v0.18.2
2024-12-17 13:35:05 +09:00
Tonis Tiigi
cd81985bfa vendor: update buildkit to v0.18.2
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-12-16 15:43:08 -08:00
Sebastiaan van Stijn
84dfd48d48 Merge pull request #49073 from dmcgowan/archive-remove-ioutils
Decouple pkg/archive from pkg/ioutils
2024-12-16 23:50:02 +01:00
Sebastiaan van Stijn
d688389f4a libnetwork/iptables: deprecate Passthrough
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-16 23:23:11 +01:00
Sebastiaan van Stijn
8991c4e382 Deprecate BridgeNfIptables and BridgeNfIp6tables fields
The netfilter module is now loaded on-demand, and no longer during daemon
startup, making these fields obsolete. These fields are now always `false`
and will be removed in the next relase.

This patch deprecates:

- the `BridgeNfIptables` field in `api/types/system.Info`
- the `BridgeNfIp6tables` field in `api/types/system.Info`
- the `BridgeNFCallIPTablesDisabled` field in `pkg/sysinfo.SysInfo`
- the `BridgeNFCallIP6TablesDisabled` field in `pkg/sysinfo.SysInfo`

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-16 22:10:05 +01:00
Sebastiaan van Stijn
30a365f543 docs/api: version-history.md: fix markdown
Fixes a typo introduced in 1932091e21

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-16 21:57:05 +01:00
Sebastiaan van Stijn
9fe5649fed Merge pull request #49109 from thaJeztah/fix_setupIPChains_defer
libnetwork/drivers/bridge: setupIPChains: fix defer checking wrong err
2024-12-16 18:43:07 +01:00
Sebastiaan van Stijn
1519004fc2 Merge pull request #49103 from thaJeztah/update_swagger_headers
docs/api: document correct case for Api-Version header
2024-12-16 18:17:35 +01:00
Sebastiaan van Stijn
01a55860c6 libnetwork/drivers/bridge: setupIPChains: fix defer checking wrong err
The output variable was renamed in 0503cf2510,
but that commit failed to change this defer, which was now checking the
wrong error.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-16 16:46:31 +01:00
Sebastiaan van Stijn
31fc7dd750 libcontainer: ReplaceContainer: fix var shadowing import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-16 16:35:44 +01:00
Sebastiaan van Stijn
51abfcbf4f Merge pull request #49098 from thaJeztah/deprecate_pkg_system
pkg/system: deprecate types and functions that are only used internally
2024-12-16 16:04:58 +01:00
Sebastiaan van Stijn
aa052c8985 Merge pull request #49101 from thaJeztah/archive_stdlib_errs
pkg/archive: replace uses of pkg/errors for stdlib errors
2024-12-16 15:23:20 +01:00
Sebastiaan van Stijn
baabbb4fa2 Merge pull request #49102 from thaJeztah/denoise_TestBuildEmitsImageCreateEvent
integration/build: make TestBuildEmitsImageCreateEvent less noisy
2024-12-16 15:22:22 +01:00
Paweł Gronowski
daacd6c591 Merge pull request #49099 from akerouanton/libnet-netns-path-gc
libnet/osl: drop netns path GC
2024-12-16 14:11:19 +00:00
Sebastiaan van Stijn
4e9df46a6e docs/api: document correct case for Api-Version header
This header is sent in its canonical format; update the docs to
reflect this.

Follow-up to 76a5ca1d4d

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-16 14:06:09 +01:00
Sebastiaan van Stijn
53a9127349 integration/build: make TestBuildEmitsImageCreateEvent less noisy
This test by default was outputing the build-progress output, and printing
a log for every event received, which made the test output rather noisy;

    === RUN   TestBuildEmitsImageCreateEvent
    === RUN   TestBuildEmitsImageCreateEvent/v1
        build_test.go:765: {"stream":"Step 1/2 : FROM busybox"}

            {"stream":"\n"}

            {"stream":" ---\u003e 19d689bc58fd\n"}

            {"stream":"Step 2/2 : RUN echo hello \u003e /hello"}

            {"stream":"\n"}

            {"stream":" ---\u003e Running in 538c10d10d69\n"}

            {"stream":" ---\u003e ca6d3b3e2dea\n"}

            {"aux":{"ID":"sha256:ca6d3b3e2dea645eeddd838da65fd06986da1392b6091dd3d3b89f239dc44f57"}}

            {"stream":"Successfully built ca6d3b3e2dea\n"}

        build_test.go:776: Got event type: container action: create
        build_test.go:776: Got event type: container action: attach
        build_test.go:776: Got event type: network action: connect
        build_test.go:776: Got event type: container action: start
        build_test.go:776: Got event type: network action: disconnect
        build_test.go:776: Got event type: container action: die
        build_test.go:776: Got event type: image action: create
    === RUN   TestBuildEmitsImageCreateEvent/v2
        build_test.go:765: {"id":"moby.buildkit.trace","aux":"Cm8KR3NoYTI1NjowZWViNmZmNTg0ZDJhODEwODhjMTJlNmVkODMxZDcyNWVhMjZmNTg2NjcyNDQ0MzU3NTNkNmZiOGVhMDBiNGFiGiRbaW50ZXJuYWxdIGxvYWQgcmVtb3RlIGJ1aWxkIGNvbnRleHQ="}

            {"id":"moby.buildkit.trace","aux":"CnwKR3NoYTI1NjowZWViNmZmNTg0ZDJhODEwODhjMTJlNmVkODMxZDcyNWVhMjZmNTg2NjcyNDQ0MzU3NTNkNmZiOGVhMDBiNGFiGiRbaW50ZXJuYWxdIGxvYWQgcmVtb3RlIGJ1aWxkIGNvbnRleHQqCwj+tIC7BhCxkpNl"}

            {"id":"moby.buildkit.trace","aux":"CokBCkdzaGEyNTY6MGVlYjZmZjU4NGQyYTgxMDg4YzEyZTZlZDgzMWQ3MjVlYTI2ZjU4NjY3MjQ0NDM1NzUzZDZmYjhlYTAwYjRhYhokW2ludGVybmFsXSBsb2FkIHJlbW90ZSBidWlsZCBjb250ZXh0KgsI/rSAuwYQsZKTZTILCP60gLsGELmTrHg="}

            {"id":"moby.buildkit.trace","aux":"CokBCkdzaGEyNTY6MGVlYjZmZjU4NGQyYTgxMDg4YzEyZTZlZDgzMWQ3MjVlYTI2ZjU4NjY3MjQ0NDM1NzUzZDZmYjhlYTAwYjRhYhokW2ludGVybmFsXSBsb2FkIHJlbW90ZSBidWlsZCBjb250ZXh0KgsI/rSAuwYQpZC3eDILCP60gLsGELbLuXg="}

            {"id":"moby.buildkit.trace","aux":"CqMBCkdzaGEyNTY6MzFjMGEyZDk1N2Q2MTQ2ZjE0NDEyNTM4YTc2YTAxNjhlOWQ5NzY2ZjA0ZjNmMDM4OGQ1YzdjNjQ1ODQ0NDQ3YxJHc2hhMjU2OjBlZWI2ZmY1ODRkMmE4MTA4OGMxMmU2ZWQ4MzFkNzI1ZWEyNmY1ODY2NzI0NDQzNTc1M2Q2ZmI4ZWEwMGI0YWIaD2NvcHkgL2NvbnRleHQgLw=="}

            {"id":"moby.buildkit.trace","aux":"CrABCkdzaGEyNTY6MzFjMGEyZDk1N2Q2MTQ2ZjE0NDEyNTM4YTc2YTAxNjhlOWQ5NzY2ZjA0ZjNmMDM4OGQ1YzdjNjQ1ODQ0NDQ3YxJHc2hhMjU2OjBlZWI2ZmY1ODRkMmE4MTA4OGMxMmU2ZWQ4MzFkNzI1ZWEyNmY1ODY2NzI0NDQzNTc1M2Q2ZmI4ZWEwMGI0YWIaD2NvcHkgL2NvbnRleHQgLyoLCP60gLsGEIyYn3s="}

            {"id":"moby.buildkit.trace","aux":"Cr4BCkdzaGEyNTY6MzFjMGEyZDk1N2Q2MTQ2ZjE0NDEyNTM4YTc2YTAxNjhlOWQ5NzY2ZjA0ZjNmMDM4OGQ1YzdjNjQ1ODQ0NDQ3YxJHc2hhMjU2OjBlZWI2ZmY1ODRkMmE4MTA4OGMxMmU2ZWQ4MzFkNzI1ZWEyNmY1ODY2NzI0NDQzNTc1M2Q2ZmI4ZWEwMGI0YWIaD2NvcHkgL2NvbnRleHQgLyoLCP60gLsGEIyYn3syDAj+tIC7BhCrvMGHAQ=="}

            {"id":"moby.buildkit.trace","aux":"CpYBCkdzaGEyNTY6OTQxZDA2ZjIwMTljOWJmN2FjM2MyZjc5MThhNDQ3ZTU5ZmRkNTEwM2IzMDg0NGRhZmQ5OGFlODE3NjRjYzk4ZBo9W2ludGVybmFsXSBsb2FkIG1ldGFkYXRhIGZvciBkb2NrZXIuaW8vbGlicmFyeS9idXN5Ym94OmxhdGVzdCoMCP60gLsGEPzY+IgB"}

            {"id":"moby.buildkit.trace","aux":"CqQBCkdzaGEyNTY6OTQxZDA2ZjIwMTljOWJmN2FjM2MyZjc5MThhNDQ3ZTU5ZmRkNTEwM2IzMDg0NGRhZmQ5OGFlODE3NjRjYzk4ZBo9W2ludGVybmFsXSBsb2FkIG1ldGFkYXRhIGZvciBkb2NrZXIuaW8vbGlicmFyeS9idXN5Ym94OmxhdGVzdCoMCP60gLsGEPzY+IgBMgwI/rSAuwYQk9mDiQE="}

            {"id":"moby.buildkit.trace","aux":"CrEBCkdzaGEyNTY6ZTNmZGU0ZDc3MmYxZjUyMGVlMzllNzA3YTcyNGNhNjRiN2VhM2IyMGYwOTc2ZDJmN2NiNDBkY2Q5MWU2NTk1YRJHc2hhMjU2OjIyNzAwYzkxMGNmY2I3MjNjZGYyZmNjMGYxNzQ1MjAzMDQxNzk1NmY0ZDhiZjEzZjZkZmRkZWM3NjgxZDcxODAaHVsyLzJdIFJVTiBlY2hvIGhlbGxvID4gL2hlbGxvCnYKR3NoYTI1NjoyMjcwMGM5MTBjZmNiNzIzY2RmMmZjYzBmMTc0NTIwMzA0MTc5NTZmNGQ4YmYxM2Y2ZGZkZGVjNzY4MWQ3MTgwGitbMS8yXSBGUk9NIGRvY2tlci5pby9saWJyYXJ5L2J1c3lib3g6bGF0ZXN0"}

            {"id":"moby.buildkit.trace","aux":"CoQBCkdzaGEyNTY6MjI3MDBjOTEwY2ZjYjcyM2NkZjJmY2MwZjE3NDUyMDMwNDE3OTU2ZjRkOGJmMTNmNmRmZGRlYzc2ODFkNzE4MBorWzEvMl0gRlJPTSBkb2NrZXIuaW8vbGlicmFyeS9idXN5Ym94OmxhdGVzdCoMCP60gLsGEKKYuYkB"}

            {"id":"moby.buildkit.trace","aux":"CpIBCkdzaGEyNTY6MjI3MDBjOTEwY2ZjYjcyM2NkZjJmY2MwZjE3NDUyMDMwNDE3OTU2ZjRkOGJmMTNmNmRmZGRlYzc2ODFkNzE4MBorWzEvMl0gRlJPTSBkb2NrZXIuaW8vbGlicmFyeS9idXN5Ym94OmxhdGVzdCoMCP60gLsGEKKYuYkBMgwI/rSAuwYQhurIiQE="}

            {"id":"moby.buildkit.trace","aux":"CoQBCkdzaGEyNTY6MjI3MDBjOTEwY2ZjYjcyM2NkZjJmY2MwZjE3NDUyMDMwNDE3OTU2ZjRkOGJmMTNmNmRmZGRlYzc2ODFkNzE4MBorWzEvMl0gRlJPTSBkb2NrZXIuaW8vbGlicmFyeS9idXN5Ym94OmxhdGVzdCoMCP60gLsGEPGI0YkB"}

            {"id":"moby.buildkit.trace","aux":"CpIBCkdzaGEyNTY6MjI3MDBjOTEwY2ZjYjcyM2NkZjJmY2MwZjE3NDUyMDMwNDE3OTU2ZjRkOGJmMTNmNmRmZGRlYzc2ODFkNzE4MBorWzEvMl0gRlJPTSBkb2NrZXIuaW8vbGlicmFyeS9idXN5Ym94OmxhdGVzdCoMCP60gLsGEPGI0YkBMgwI/rSAuwYQv9CgkAE="}

            {"id":"moby.buildkit.trace","aux":"Cr8BCkdzaGEyNTY6ZTNmZGU0ZDc3MmYxZjUyMGVlMzllNzA3YTcyNGNhNjRiN2VhM2IyMGYwOTc2ZDJmN2NiNDBkY2Q5MWU2NTk1YRJHc2hhMjU2OjIyNzAwYzkxMGNmY2I3MjNjZGYyZmNjMGYxNzQ1MjAzMDQxNzk1NmY0ZDhiZjEzZjZkZmRkZWM3NjgxZDcxODAaHVsyLzJdIFJVTiBlY2hvIGhlbGxvID4gL2hlbGxvKgwI/rSAuwYQwvqtkgE="}

            {"id":"moby.buildkit.trace","aux":"Cs0BCkdzaGEyNTY6ZTNmZGU0ZDc3MmYxZjUyMGVlMzllNzA3YTcyNGNhNjRiN2VhM2IyMGYwOTc2ZDJmN2NiNDBkY2Q5MWU2NTk1YRJHc2hhMjU2OjIyNzAwYzkxMGNmY2I3MjNjZGYyZmNjMGYxNzQ1MjAzMDQxNzk1NmY0ZDhiZjEzZjZkZmRkZWM3NjgxZDcxODAaHVsyLzJdIFJVTiBlY2hvIGhlbGxvID4gL2hlbGxvKgwI/rSAuwYQwvqtkgEyDAj+tIC7BhDshP7sAQ=="}

            {"id":"moby.buildkit.trace","aux":"CmsKR3NoYTI1NjpmMWM5ZDIzNTNhOWRlZjgwOTI2OGRmMjhhMjU4YzExNTA2ODcxMWE0ZmFiYzM1MjNkOGJhZDIxOTgyMDc3MjFjGhJleHBvcnRpbmcgdG8gaW1hZ2UqDAj+tIC7BhC6trLuARJ3ChBleHBvcnRpbmcgbGF5ZXJzEkdzaGEyNTY6ZjFjOWQyMzUzYTlkZWY4MDkyNjhkZjI4YTI1OGMxMTUwNjg3MTFhNGZhYmMzNTIzZDhiYWQyMTk4MjA3NzIxYzIMCP60gLsGEIe6s+4BOgwI/rSAuwYQq7az7gE="}

            {"id":"moby.buildkit.trace","aux":"EoUBChBleHBvcnRpbmcgbGF5ZXJzEkdzaGEyNTY6ZjFjOWQyMzUzYTlkZWY4MDkyNjhkZjI4YTI1OGMxMTUwNjg3MTFhNGZhYmMzNTIzZDhiYWQyMTk4MjA3NzIxYzIMCP60gLsGEOz5ovsBOgwI/rSAuwYQq7az7gFCDAj+tIC7BhDV8qL7AQ=="}

            {"id":"moby.buildkit.trace","aux":"ErwBClV3cml0aW5nIGltYWdlIHNoYTI1Njo5YjIzODY3ODkzZGMyZDVlM2UxNDBhYjBlY2Y1ZGI4MzlhYjA0YzQ0NjRiNjMyZTQ5ZTg3YzBmOThkZDEyYzFhEkdzaGEyNTY6ZjFjOWQyMzUzYTlkZWY4MDkyNjhkZjI4YTI1OGMxMTUwNjg3MTFhNGZhYmMzNTIzZDhiYWQyMTk4MjA3NzIxYzIMCP60gLsGEPHIq/sBOgwI/rSAuwYQ38Wr+wE="}

            {"id":"moby.buildkit.trace","aux":"EsoBClV3cml0aW5nIGltYWdlIHNoYTI1Njo5YjIzODY3ODkzZGMyZDVlM2UxNDBhYjBlY2Y1ZGI4MzlhYjA0YzQ0NjRiNjMyZTQ5ZTg3YzBmOThkZDEyYzFhEkdzaGEyNTY6ZjFjOWQyMzUzYTlkZWY4MDkyNjhkZjI4YTI1OGMxMTUwNjg3MTFhNGZhYmMzNTIzZDhiYWQyMTk4MjA3NzIxYzIMCP60gLsGEOuB7vwBOgwI/rSAuwYQ38Wr+wFCDAj+tIC7BhCT/+38AQ=="}

            {"id":"moby.buildkit.trace","aux":"CnkKR3NoYTI1NjpmMWM5ZDIzNTNhOWRlZjgwOTI2OGRmMjhhMjU4YzExNTA2ODcxMWE0ZmFiYzM1MjNkOGJhZDIxOTgyMDc3MjFjGhJleHBvcnRpbmcgdG8gaW1hZ2UqDAj+tIC7BhC6trLuATIMCP60gLsGEJG6x4QC"}

            {"id":"moby.image.id","aux":{"ID":"sha256:9b23867893dc2d5e3e140ab0ecf5db839ab04c4464b632e49e87c0f98dd12c1a"}}

        build_test.go:776: Got event type: image action: create

This patch preserves both, but only prints them if the test failed to
help debugging failures.

With this patch:

On success:

    === RUN   TestBuildEmitsImageCreateEvent
    === RUN   TestBuildEmitsImageCreateEvent/v1
    === RUN   TestBuildEmitsImageCreateEvent/v2
    --- PASS: TestBuildEmitsImageCreateEvent (1.53s)
        --- PASS: TestBuildEmitsImageCreateEvent/v1 (0.48s)
        --- PASS: TestBuildEmitsImageCreateEvent/v2 (1.03s)
    PASS

When failing:

    === Failed
    === FAIL: arm64.integration.build TestBuildEmitsImageCreateEvent/v1 (0.97s)
        build_test.go:789: assertion failed: 1 (int) != 0 (imageCreateEvts int)
        build_test.go:790: build-logs:
            {"stream":"Step 1/2 : FROM busybox"}
            {"stream":"\n"}
            {"stream":" ---\u003e 19d689bc58fd\n"}
            {"stream":"Step 2/2 : RUN echo hello \u003e /hello"}
            {"stream":"\n"}
            {"stream":" ---\u003e Running in 119e771bcb1a\n"}
            {"stream":" ---\u003e 289982143d91\n"}
            {"aux":{"ID":"sha256:289982143d912b1c11d95dddfb59640c175fb29a9a00f0223a1ad18972b6df74"}}
            {"stream":"Successfully built 289982143d91\n"}

        build_test.go:791: events received:
            type: container, action: create
            type: container, action: attach
            type: network, action: connect
            type: container, action: start
            type: network, action: disconnect
            type: container, action: die
            type: image, action: create
        --- FAIL: TestBuildEmitsImageCreateEvent/v1 (0.97s)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-16 13:43:05 +01:00
Sebastiaan van Stijn
01b98afeb6 Merge pull request #49054 from maggie44/apiversion
Accurately reflect the canonical casing of `API-Version` and `OS-Type` headers
2024-12-16 13:06:31 +01:00
Sebastiaan van Stijn
fca4d24c53 Merge pull request #49096 from akerouanton/ipt-drop-bestEffortLock
libnet/iptables: remove mutex-based serialization
2024-12-16 13:03:48 +01:00
Sebastiaan van Stijn
92fec6c065 Merge pull request #49061 from cyphar/testing-suse-apparmor
integration-cli: don't skip AppArmor tests on SLES
2024-12-16 12:37:09 +01:00
Sebastiaan van Stijn
504e1d4686 pkg/archive: replace uses of pkg/errors for stdlib errors
Reducing dependencies in preparation of moving pkg/archive to
a separate module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-16 12:13:24 +01:00
Sebastiaan van Stijn
4c8d15fdf8 Merge pull request #49093 from akerouanton/drop-firewalld-ipv
libnet/iptables: deprecate type IPV
2024-12-16 11:57:52 +01:00
Sebastiaan van Stijn
f0ce367e1e pkg/system: deprecate types and functions that are only used internally
These types and functions are only used internally (through pkg/archive).
Deprecate them, and mark them for removal.

This deprecates the `Lstat()`, `Mkdev()`, `Mknod()`, `FromStatT()`
and `Stat()` functions, and related `StatT` type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-16 11:40:52 +01:00
Albin Kerouanton
f053beb34c libnet/osl: drop netns path GC
Commit 3ec19ff62b introduced a GC goroutine to delete files where netns
were mounted. It was primarly added to work around a race in kernel
3.18-4.0.1. Since no distros we support are using such old kernels,
there's no need to keep this code around.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-12-16 11:40:18 +01:00
Albin Kerouanton
27deff4da1 libnet/iptables: deprecate type IPV
The iptables package has two different types to specify the IP version:
IPVersion, used by iptables code, and IPV, used by firewalld code.
Both are representing the ip version as a string.

For iptables, the case doesn't matter because the string is never used
as-is. However, for firewalld the case matters.

Make the IPV type an alias of IPVersion, and deprecate it. Also change
the case used in IPVersion strings to make IPV consts aliases of
IPVersion consts.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-12-16 09:40:21 +01:00
Albin Kerouanton
c8f19e5e4c libnet/iptables: remove mutex-based serialization
All distros we support now ship a version of iptables that support the
`--wait` flag.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-12-16 09:37:05 +01:00
Akihiro Suda
577a7958bb Merge pull request #49077 from thaJeztah/vendor_runc_1.2.3
vendor: github.com/cyphar/filepath-securejoin v0.3.5, github.com/opencontainers/runc v1.2.3
2024-12-15 02:02:23 +09:00
Akihiro Suda
f9957c7fe0 Merge pull request #49094 from thaJeztah/bump_x_net
vendor: golang.org/x/net v0.32.0
2024-12-15 02:01:55 +09:00
Sebastiaan van Stijn
537eea8744 vendor: golang.org/x/net v0.32.0
go maintainers annnounced a security release for this module;
this patch already brings it up to the current version in
case the security issue affects us.

full diff: https://github.com/golang/net/compare/v0.31.0...v0.32.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-14 15:20:40 +01:00
Sebastiaan van Stijn
1ce347468f Merge pull request #49092 from akerouanton/dont-ignore-linksetmtu-error
libnet/d/bridge: unconditionally error out if LinkSetMTU fails
2024-12-14 13:04:00 +01:00
Albin Kerouanton
678ef1a267 libnet/d/bridge: unconditionally error out if LinkSetMTU fails
Since 89470a7 we ignore errors returned by `LinkSetMTU` when the MTU is
greater than 1500 but lower than 65535 to let CentOS/RHEL 7 users set
an MTU in that range (despite their kernel rejecting that value).

We dropped support for those distros, so we can now remove this code
and unconditionally error out if `LinkSetMTU` returns an error.

Commit 89470a7 introduced two unit tests - these are kept, and both now
have a proper GoDoc describing what they're testing.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-12-14 11:22:40 +01:00
Sebastiaan van Stijn
1e033e2d98 Merge pull request #49089 from thaJeztah/no_netfilter_warnings
daemon: info: remove bridge-nf-call-iptables / ip6tables warnings
2024-12-13 12:08:58 +01:00
Sebastiaan van Stijn
5c358743af daemon: info: remove bridge-nf-call-iptables / ip6tables warnings
Historically, the `bridge` network-driver would detect whether netfiltering
was enabled in the kernel or, if disabled, try to do a `modprobe` when
initializing the driver. This approach became problematic, as loading the
module was not always performed  at startup depending on daemon configuration,
or the daemon may have failed to load the module. The `/info` response
would include a warning  to inform the user that some functionality may not
be available;

    WARNING: bridge-nf-call-iptables is disabled
    WARNING: bridge-nf-call-ip6tables is disabled

Starting with db25b0dcd0, detecting whether
netfiltering  is enabled now [happens when needed][1], which was further improved
on to not depend  on `modprobe` in 264c15bfc4 and
4740820716.

Because of the above, the `/info` output would now return warnings in any
situation where netfiltering was not enabled on the host before the daemon
started, which may be either _incorrect_ (i.e., the module may have been
loaded afterwards), or irrelevant, because netfiltering is not needed in
all situations.

This patch removes the warnings from the `/info` response,

[1]: 944e403502/libnetwork/drivers/bridge/setup_bridgenetfiltering.go (L16-L77)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-13 10:09:41 +01:00
Sebastiaan van Stijn
944e403502 Merge pull request #49064 from vvoland/c8d-extract-progress
c8d/pull: Show `Extracting` layer status
2024-12-13 02:04:08 +01:00
Sebastiaan van Stijn
1e0477f6ec Merge pull request #49065 from thaJeztah/deprecate_nondistributable_artifacts
remove support for configuring pushing non-distributable artifacts and deprecate API fields and config
2024-12-12 21:39:34 +01:00
Brian Goff
232cc7ebbc Merge pull request #49078 from vvoland/otel-noop-exporter
otel: Avoid excessive memory allocations if not configured
2024-12-12 11:36:45 -08:00
Paweł Gronowski
d8358ebc87 otel: Use non-noop tracer provider for grpc
Needed for Buildkit history

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-12 19:31:00 +01:00
Paweł Gronowski
96ef85272f c8d/pull: Show Extracting layer status
Before this patch, pull progress wouldn't show the `Extracting` layer
status which made the pull look like it got stuck when extracting a big
layer.

Use the `containerd.io/snapshot/cri.layer-digest` snapshot labels to
find a corresponding snapshot and check whether it's `active` or
`committed` to set the layer status accordingly.

Despite the `cri.` component in the label name, it's not CRI specific -
it only depends on the `snapshotters.AppendInfoHandlerWrapper`.

We _could_ also use the `Usage` snapshot method to query the exact
progress of the unpack, but it would be too expensive as the
implementation time complexity will be proportional to the snapshot size.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-12 19:01:04 +01:00
Paweł Gronowski
899360b649 integration/build_traces: Create own tracer provider
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-12 18:32:05 +01:00
Paweł Gronowski
4847557d1b otel: Avoid excessive memory allocations if not configured
Use noop tracer provider if the OTEL exporter is not configured.
This makes the OTEL tracing avoid doing unneeded memory allocations for
spans which aren't going to be exported anywhere anyway.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-12 18:31:03 +01:00
Sebastiaan van Stijn
927ff16860 vendor: github.com/opencontainers/runc v1.2.3
no changes in vendored code, only updated dependencies

full diff: https://github.com/opencontainers/runc/compare/v1.2.2...v1.2.3
release notes: https://github.com/opencontainers/runc/releases/tag/v1.2.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-12 13:42:04 +01:00
Sebastiaan van Stijn
88a08a070e vendor: github.com/cyphar/filepath-securejoin v0.3.5
- `MkdirAll` will now no longer return an `EEXIST` error if two racing
  processes are creating the same directory. We will still verify that the path
  is a directory, but this will avoid spurious errors when multiple threads or
  programs are trying to `MkdirAll` the same path.

full diff: https://github.com/cyphar/filepath-securejoin/compare/v0.3.4...v0.3.5

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-12 13:42:01 +01:00
Sebastiaan van Stijn
d60e55d613 Merge pull request #49067 from thaJeztah/remove_build_deps_step2
Dockerfile: remove dpkg-dev, libudev-dev, libsecret-1-dev, libbtrfs-dev dependencies
2024-12-12 13:37:07 +01:00
Sebastiaan van Stijn
01bbb4008a Merge pull request #49071 from thaJeztah/bump_runc_binary_1.2.3
Dockerfile: update runc binary to v1.2.3
2024-12-12 12:46:32 +01:00
Paweł Gronowski
135a53220b Merge pull request #49070 from thaJeztah/bump_crypto
vendor: update golang.org/x/ dependencies
2024-12-12 11:25:04 +00:00
Derek McGowan
ba90fd8da0 Decouple pkg/archive from pkg/ioutils
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-12-12 00:14:29 -08:00
Sebastiaan van Stijn
ec5c9e06e3 Dockerfile: update runc binary to v1.2.3
This is the third patch release of the 1.2.z release branch of runc. It
primarily fixes some minor regressions introduced in 1.2.0.

- Fixed a regression in use of securejoin.MkdirAll, where multiple
  runc processes racing to create the same mountpoint in a shared rootfs
  would result in spurious EEXIST errors. In particular, this regression
  caused issues with BuildKit.
- Fixed a regression in eBPF support for pre-5.6 kernels after upgrading
  Cilium's eBPF library version to 0.16 in runc.

full diff: https://github.com/opencontainers/runc/compare/v1.2.2...v1.2.3
release notes: https://github.com/opencontainers/runc/releases/tag/v1.2.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 21:52:50 +01:00
Sebastiaan van Stijn
e6443e4af2 vendor: golang.org/x/crypto v0.31.0
update to the latest version of this dependency, which has a fix for a
authorization bypass in the ssh package. We don't use this functionality,
so there's no need to backport this change (other than de-noising false positives).

This is CVE-2024-45337 and Go issue https://go.dev/issue/70779.

full diff: https://github.com/golang/crypto/compare/v0.29.0...v0.31.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 21:05:35 +01:00
Sebastiaan van Stijn
035eeee209 vendor: golang.org/x/text v0.21.0
no changes in vendored code

full diff: https://github.com/golang/text/compare/v0.20.0...v0.21.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 21:05:29 +01:00
Sebastiaan van Stijn
df8b3e787c vendor: golang.org/x/sync v0.10.0
no changes in vendored code

full diff: https://github.com/golang/sync/compare/v0.9.0...v0.10.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 21:04:23 +01:00
Sebastiaan van Stijn
c4f80dd931 vendor: golang.org/x/sys v0.28.0
full diff: https://github.com/golang/sys/compare/v0.27.0...v0.28.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 21:03:20 +01:00
Sebastiaan van Stijn
8b243a1a82 docs/api: deprecate non-distributable artifacts
Mark the AllowNondistributableArtifactsCIDRs and AllowNondistributableArtifactsHostnames
fields as deprecated in all API versions, as these fields will
no longer be propagated.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 20:30:00 +01:00
Sebastiaan van Stijn
1932091e21 remove support for non-distributable artifacts and deprecate API fields and config
Non-distributable artifacts (foreign layers) were introduced in commit
05bd04350b to accommodate Windows images,
for which the EULA did not allow layers to be distributed through registries
other than those hosted by Microsoft. The concept of foreign / non-distributable
layers was adopted by the OCI distribution spec in [oci#233].

These restrictions were relaxed later to allow distributing these images
through non-public registries, for which a configuration was added in the
daemon in 67fdf574d5. In 2022, Microsoft updated
the EULA and [removed these restrictions altogether][1], and the OCI distribution
spec deprecated the  functionality in [oci#965].

In 2023, Microsoft [removed the use of foreign data layers][2] for their images,
making this functionality obsolete.

This patch:

- Deprecates the `--allow-nondistributable-artifacts` daemon flag and corresponding
  `allow-nondistributable-artifacts` field in `daemon.json`. Setting either
  option will no longer take an effect, but a deprecation warning log is added
  to raise awareness about the deprecation. This warning is planned to become
  an error in the next release.
- Deprecates the `RegistryConfig.AllowNondistributableArtifactsCIDRs` and
  `RegistryConfig.AllowNondistributableArtifactsHostnames` fields in the
  `GET /info` API response. For API version v1.48 and lower, the fields are
  still included in the response, but always `null`. In API version v1.49 and
  higher, the field will be omitted entirely.
- Deprecates the `api/types/registry/ServiceConfig.AllowNondistributableArtifactsCIDRs`
  field.
- Deprecates the `api/types/registry/ServiceConfig.AllowNondistributableArtifactsHostnames`
  field.
- Deprecates the `registry.ServiceOptions.AllowNondistributableArtifacts` field.

[oci#233]: https://github.com/opencontainers/image-spec/pull/233
[oci#965]: https://github.com/opencontainers/image-spec/pull/965
[1]: https://techcommunity.microsoft.com/blog/containers/announcing-windows-container-base-image-redistribution-rights-change/3645201
[2]: https://techcommunity.microsoft.com/blog/containers/announcing-removal-of-foreign-layers-from-windows-container-images/3846833

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 20:29:46 +01:00
Sebastiaan van Stijn
e394ff695c Dockerfile: remove libbtrfs-dev dependency
Starting with [containerd@52f82ac] (containerd 1.7), this dependency is no
longer needed for building containerd.

[containerd@52f82ac]: 52f82acb7b

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 16:56:11 +01:00
Sebastiaan van Stijn
7d79b301bc Dockerfile: remove libsecret-1-dev dependency
This dependency was added in 81d704d15d, but
I could not find a reference to it, and we may not need it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 16:34:20 +01:00
Sebastiaan van Stijn
3192b2aba7 Dockerfile: remove libudev-dev dependency
It was introduced in e89a5e5e91, and probably
used for devicemapper, which we no longer support, so likely unused.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 16:34:19 +01:00
Sebastiaan van Stijn
7c4afb1e6b Dockerfile: remove dpkg-dev dependency
We don't build .deb packages as part of the Dockerfiles in this
repository, so we can remove this dependency.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 16:34:17 +01:00
Akihiro Suda
7faa4ecfbf Merge pull request #49059 from thaJeztah/bump_md2man
man: vendor: github.com/cpuguy83/go-md2man v2.0.5
2024-12-12 00:33:51 +09:00
Akihiro Suda
d263bb3307 Merge pull request #49066 from thaJeztah/remove_build_deps
Dockerfile: remove libapparmor-dev dependency
2024-12-12 00:32:56 +09:00
Sebastiaan van Stijn
7bba43a731 Dockerfile: remove libapparmor-dev dependency
I don't think anything uses this dependency, and runc no longer requires
it either, since [opencontainers/runc@db093f6] (part of v1.0.0-rc5)

[opencontainers/runc@db093f6]: db093f621f

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-11 15:21:02 +01:00
David Karlsson
b08ff81204 builder: fall back to defaultKeepStorage if keepStorage is unset for GC policy
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2024-12-11 11:02:49 +01:00
Aleksa Sarai
1a453abfb1 integration-cli: don't skip AppArmor tests on SLES
This partially reverts e440831802 ("fix and skip some tests based on
API version"), which caused the integration-cli tests to skip all
AppArmor-related tests on SUSE.

It's not really clear why this was done originally, but I have verified
that on modern SLE 12 and SLE 15 systems the AppArmor tests pass without
any adjustments needed.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-12-11 20:31:59 +11:00
Sebastiaan van Stijn
9633556bef Merge pull request #48316 from vvoland/c8d-create-or-replace-img
daemon/containerd: Extract `createOrReplaceImage`
2024-12-10 15:01:39 +01:00
Sebastiaan van Stijn
4ba786058e Merge pull request #49050 from thaJeztah/registry_cleanups
registry: some optimizations to reduce network connections  and DNS lookups if not needed
2024-12-10 14:21:22 +01:00
Sebastiaan van Stijn
969d27df95 Merge pull request #49058 from thaJeztah/bump_xx
update xx to v1.6.1 for compatibility with alpine 3.21
2024-12-10 11:40:29 +01:00
Sebastiaan van Stijn
be9e39b48b registry: ConvertToHostname: use strings.Cut to reduce allocations
Slight refactor to use strings.Cut, which doesn't do allocations

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-10 11:39:18 +01:00
Sebastiaan van Stijn
a6f98dc60d registry: Service.lookupV2Endpoints: add arg to skip mirrors
This function unconditionally constructed endpoints for mirrors when
requesting endpoints for the default (Docker Hub) registry. Doing so
involves validating the config, which involves;

- parsing the hostname
- constructing TLS config
- performing a DNS lookup to resolve the host's IP address and matching
  it against CIDR masks for insecure registries.

When looking up push endpoints or endpoints to consider for authentication,
mirror endpoints were discarded to prevent sending credentials of the upstream
registry to a mirror.

This patch adds a "includeMirrors" argument to skip constructing endpoints
for mirrors when not needed. While at it, also removing named output variables,
as they didn't add much.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-10 11:39:09 +01:00
Sebastiaan van Stijn
50215913db registry: loginV2: move variables closer to where they're used
Also rename a variable that shadowed a package type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-10 11:37:04 +01:00
Sebastiaan van Stijn
c1ef39e56e registry: loginV2: don't contact registry when failing to construct request
Reverse the order in which we call v2AuthHTTPClient and http.NewRequest.
This is mostly theoretical, but v2AuthHTTPClient makes a network connection
to ping the registry, but loginV2 may fail after this if http.NewRequest
fails. Put the (lightweight) http.NewRequest first, so that we can return
early before trying to contact the registry.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-10 11:37:02 +01:00
Sebastiaan van Stijn
a7da6fb2a7 man: vendor: github.com/cpuguy83/go-md2man v2.0.5
full diff: https://github.com/cpuguy83/go-md2man/compare/v2.0.4...v2.0.5

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-10 11:11:11 +01:00
Sebastiaan van Stijn
89899b71a0 update xx to v1.6.1 for compatibility with alpine 3.21
This fixes compatibility with alpine 3.21

- Fix additional possible `xx-cc`/`xx-cargo` compatibility issue with Alpine 3.21
- Support for Alpine 3.21
- Fix `xx-verify` with `file` 5.46+
- Fix possible error taking lock in `xx-apk` in latest Alpine without `coreutils`

full diff: https://github.com/tonistiigi/xx/compare/v1.5.0...v1.6.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-10 10:02:01 +01:00
Sebastiaan van Stijn
b249c5ebd2 Merge pull request #49051 from thaJeztah/cleanup_routers
api/server/router: fix debug routes, and refactor
2024-12-09 18:42:41 +01:00
Sebastiaan van Stijn
d84cbab015 Merge pull request #49055 from avoidaway/master
chore: fix some function names in comment
2024-12-09 18:12:52 +01:00
Sebastiaan van Stijn
9da0e69608 api/server: Server.CreateMux: pass context and use structured logs
Pass the context that's used for logging, and add minimal handling of
context-cancellation. Also update logs to use structured fields.

Before this  patch:

    DEBU[2024-12-08T15:24:47.324420709Z] Registering POST, /networks/{id:.*}/disconnect
    DEBU[2024-12-08T15:24:47.324447251Z] Registering POST, /networks/prune
    DEBU[2024-12-08T15:24:47.324460626Z] Registering DELETE, /networks/{id:.*}

With this patch:

    DEBU[2024-12-08T15:33:50.408445543Z] Registering route                              method=POST path="/networks/{id:.*}/disconnect"
    DEBU[2024-12-08T15:33:50.408484335Z] Registering route                              method=POST path=/networks/prune
    DEBU[2024-12-08T15:33:50.408505251Z] Registering route                              method=DELETE path="/networks/{id:.*}"

Or in JSON format:

    {"level":"debug","method":"POST","msg":"Registering route","path":"/networks/{id:.*}/connect","time":"2024-12-08T15:37:19.235209667Z"}
    {"level":"debug","method":"POST","msg":"Registering route","path":"/networks/{id:.*}/disconnect","time":"2024-12-08T15:37:19.235243001Z"}
    {"level":"debug","method":"POST","msg":"Registering route","path":"/networks/prune","time":"2024-12-08T15:37:19.235290876Z"}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-09 15:58:46 +01:00
Sebastiaan van Stijn
9c1ff095e8 cmd/dockerd: pass debug-router instead of constructing in CreateMux
Now that debug-routes are identical to regular routers, we can pass them
the same as those routers. With this, the daemon also logs those routes
as part of its startup (when in debug mode).

Before this patch, only non-debug endpoints would be logged:

    DEBU[2024-12-08T15:24:47.320933959Z] Registering routers
    ...
    DEBU[2024-12-08T15:24:47.324420709Z] Registering POST, /networks/{id:.*}/disconnect
    DEBU[2024-12-08T15:24:47.324447251Z] Registering POST, /networks/prune
    DEBU[2024-12-08T15:24:47.324460626Z] Registering DELETE, /networks/{id:.*}
    INFO[2024-12-08T15:24:47.324828334Z] API listen on /var/run/docker.sock

With this patch, debug endpoints are also logged:

    DEBU[2024-12-08T15:24:47.320933959Z] Registering routers
    ...
    DEBU[2024-12-08T15:24:47.324420709Z] Registering POST, /networks/{id:.*}/disconnect
    DEBU[2024-12-08T15:24:47.324447251Z] Registering POST, /networks/prune
    DEBU[2024-12-08T15:24:47.324460626Z] Registering DELETE, /networks/{id:.*}
    DEBU[2024-12-08T15:24:47.324486834Z] Registering GET, /debug/vars
    DEBU[2024-12-08T15:24:47.324506751Z] Registering GET, /debug/pprof/
    DEBU[2024-12-08T15:24:47.324532126Z] Registering GET, /debug/pprof/cmdline
    DEBU[2024-12-08T15:24:47.324549293Z] Registering GET, /debug/pprof/profile
    DEBU[2024-12-08T15:24:47.324564501Z] Registering GET, /debug/pprof/symbol
    DEBU[2024-12-08T15:24:47.324582043Z] Registering GET, /debug/pprof/trace
    DEBU[2024-12-08T15:24:47.324604751Z] Registering GET, /debug/pprof/{name}
    INFO[2024-12-08T15:24:47.324828334Z] API listen on /var/run/docker.sock

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-09 15:55:26 +01:00
Sebastiaan van Stijn
27294df576 api/server: Server.CreateMux: also register API-version debug endpoints
The debug endpoints are currently only provided non-versioned (e.g. `/debug/vars`).
While this is convenient, we "officially" deprecated non-versioned endpoints
in the API.

This patch also registers the debug-endpoints under the API-versioned paths,
so that they can be used either without version ("latest") and versioned
paths.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-09 15:55:25 +01:00
Sebastiaan van Stijn
e2d2834be1 api/server: Server.CreateMux: register debug endpoints with correct methods
The debug handlers were created for GET methods, but were registered for
any method;

    curl -s -XGET --unix-socket /var/run/docker.sock http://localhost/debug/vars | jq -c .cmdline
    ["dockerd","--debug"]
    curl -s -XPOST --unix-socket /var/run/docker.sock http://localhost/debug/vars | jq -c .cmdline
    ["dockerd","--debug"]
    curl -s -XDELETE --unix-socket /var/run/docker.sock http://localhost/debug/vars | jq -c .cmdline
    ["dockerd","--debug"]

After this patch, they're only registered with the intended method, and a
404 is returned for incorrect ones;

    curl -s -XGET --unix-socket /var/run/docker.sock http://localhost/debug/vars | jq -c .cmdline
    ["dockerd","--debug"]
    curl -s -XPOST --unix-socket /var/run/docker.sock http://localhost/debug/vars
    {"message":"page not found"}
    curl -s -XDELETE --unix-socket /var/run/docker.sock http://localhost/debug/vars
    {"message":"page not found"}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-09 15:55:25 +01:00
Sebastiaan van Stijn
2f5412de8d api/server: set /debug prefix as part of debug-router routes
Update the debug-router to include  the prefix, instead of adding it
when registering the routes.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-09 15:55:22 +01:00
Sebastiaan van Stijn
d313bb58c4 Merge pull request #49005 from thaJeztah/registry_deprecate_trimname
registry: deprecate APIEndpoint.TrimHostname
2024-12-09 14:46:09 +01:00
avoidaway
694c01620b chore: fix some function names in comment
Signed-off-by: avoidaway <cmoman@126.com>
2024-12-09 21:05:29 +08:00
Sebastiaan van Stijn
5d72419486 Merge pull request #49049 from thaJeztah/hostwrapper_remove_unused
daemon/containerd: hostsWrapper: remove  unused regService argument
2024-12-09 12:04:19 +01:00
Albin Kerouanton
f1bb2bc446 Merge pull request #49052 from thaJeztah/remove_daemon_NetworkControllerEnabled
daemon: remove Daemon.NetworkControllerEnabled
2024-12-09 11:50:16 +01:00
maggie44
76a5ca1d4d Accurately reflect the canonical casing of API-Version and OS-Type headers
Go automatically canonicalises HTTP headers, meaning the string `API-Version` passed as a header has always been returned as `Api-Version`. Similarly, `OSType` is returned as `Ostype`.

This commit updates the documentation to reflect this behaviour and modifies the codebase to ensure that input strings are aligned with their canonical output values.

Signed-off-by: maggie44 <64841595+maggie44@users.noreply.github.com>
2024-12-08 22:23:57 +00:00
Sebastiaan van Stijn
9da4ae2ef3 Merge pull request #49053 from thaJeztah/daemon_unhandled_errs
cmd/dockerd: ignore some unhandled errors
2024-12-08 23:17:01 +01:00
Sebastiaan van Stijn
5fc32c12c7 cmd/dockerd: ignore some unhandled errors
These are unlikely to fail ever, so should be fine to ignore.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-08 17:18:33 +01:00
Sebastiaan van Stijn
b0ec823cc7 daemon: remove Daemon.NetworkControllerEnabled
This function was added in eb982e7c00, at
which time networking was not yet implemented for Windows, resulting
in a panic when trying to call network-related endpoints.

That's no longer the case, so we should be able to add network-endpoints
unconditionally.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-08 17:13:38 +01:00
Sebastiaan van Stijn
b1c525a424 Merge pull request #49045 from thaJeztah/gw_priority_godoc
api/types/network: add godoc for EndpointSettings.GwPriority
2024-12-08 11:48:04 +01:00
Sebastiaan van Stijn
59bfc32a33 daemon/containerd: hostsWrapper: remove unused regService argument
The argument was no longer used since 8b4cb6f58c,
so we can remove it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-08 11:42:42 +01:00
Sebastiaan van Stijn
3014d6d7a3 registry: deprecate APIEndpoint.TrimHostName
This field was added in 19515a7ad8, but looks
to be always set for endpoints used, so we can trim remote names unconditionally.

This option was added for possible future expansion, allowing registry-
mirrors to get the full reference of the image (including domain-name),
for them to host a mirror for multiple upstreams on the same registry.

That approach will unlikely be implemented, and containerd has a different
approach for this, where the reference to the original registry is passed
through a query parameter instead.

The field is unlikely used outside of our codebased, but deprecating it
before removal just in case.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-07 12:02:17 +01:00
Sebastiaan van Stijn
fe2637a05b api/types/network: add godoc for EndpointSettings.GwPriority
This field was introduced in 5b752fab32,
which added documentation in the API documentation (swagger), but did
not document the field in the API go types.

This patch adds documentation, using a variant of the description used
in swagger.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-06 22:25:03 +01:00
Sebastiaan van Stijn
68dbb8b385 Merge pull request #49022 from robmry/ignore_kernel_ll_for_fcidrv6
Ignore kernel-assigned LL addrs when selecting "bip6"
2024-12-06 21:31:29 +01:00
Rob Murray
4b8c72060d Merge pull request #49038 from robmry/modprobeless
Try to load kernel modules, without modprobe
2024-12-06 14:08:17 +00:00
Rob Murray
15ba03c8fc Jenkins: don't modprobe kernel module
These modprobes were added as a workaround in commit cce5dfe1, but
dockerd should now be able to load the modules it needs.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-06 10:27:24 +00:00
Rob Murray
2af19b6b7c Don't try to modprobe ip6_tables in the moby dev container
dockerd will now do this itself, if ip6tables is enabled.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-06 10:27:24 +00:00
Rob Murray
f2e1f52a04 Try to load kernel module ip6_tables, when necessary.
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-06 10:27:24 +00:00
Rob Murray
4740820716 Use ioctl to try to trigger kernel module loads
An ioctl() call to get the "interface index" for a kernel module triggers
the kernel to try to load the module, if the process is running with
CAP_SYS_MODULE. This tends to be more reliable than "modprobe" for
docker-in-docker.

If the ioctl() method fails, fall back to trying "modprobe".

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-06 10:27:24 +00:00
Rob Murray
56eb47c622 Ignore kernel-assigned LL addrs when selecting "bip6"
Commit facb2323 aligned the way the default bridge's IPv6 subnet
and gateway addresses are selected with IPv4.

Part of that involved looking at addresses already on the bridge,
along with daemon config options. But, for IPv6, the kernel will
assign a link-local address to the bridge.

Make sure that address is ignored when selecting "bip6" when it's
not explicitly specified.

This is made slightly complicated because we allow fixed-cidr-v6
to be a link-local subnet (either the standard "fe80::/64", or
any other non-overlapping LL subnet in "fe80::/10").

Following this change, if fixed-cidr-v6 is (or is included by)
"fe80::/64", the bridge's kernel-assigned LL address may be used
as the network's gateway address - even though it may also get an
IPAM-assigned LL address.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-04 18:19:41 +00:00
Akihiro Suda
b1fc766e48 Merge pull request #49031 from thaJeztah/vendor_protobuf
vendor: google.golang.org/protobuf v1.35.2
2024-12-05 00:02:41 +09:00
Akihiro Suda
d031afae2e Merge pull request #49030 from thaJeztah/vendor_golang_x
vendor: update various golang.org/x/ dependencies for containerd/cgroups
2024-12-05 00:01:35 +09:00
Akihiro Suda
f3749f94ff Merge pull request #49021 from thaJeztah/verifySchema1Manifest_context
distribution: verifySchema1Manifest: pass through context
2024-12-05 00:01:02 +09:00
Sebastiaan van Stijn
404118c22b vendor: google.golang.org/protobuf v1.35.2
full diff: https://github.com/protocolbuffers/protobuf-go/compare/v1.35.1...v1.35.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-04 14:46:52 +01:00
Sebastiaan van Stijn
20ddbe2a0b vendor: golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f
no changes in vendored code

full diff: 701f63a606...2d47ceb269

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-04 14:41:07 +01:00
Sebastiaan van Stijn
1e51b7a28c vendor: golang.org/x/tools v0.27.0
full diff: https://github.com/golang/tools/compare/v0.25.0...v0.27.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-04 14:35:05 +01:00
Sebastiaan van Stijn
750d6f4423 vendor: golang.org/x/mod v0.22.0
no changes in vendored code

full diff: https://github.com/golang/mod/compare/v0.21.0...v0.22.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-04 14:32:11 +01:00
Sebastiaan van Stijn
99f593b762 vendor: golang.org/x/net v0.31.0
full diff: https://github.com/golang/net/compare/v0.29.0...v0.31.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-04 14:30:15 +01:00
Sebastiaan van Stijn
e5895eacac vendor: golang.org/x/crypto v0.29.0
full diff: https://github.com/golang/crypto/compare/v0.27.0...v0.29.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-04 14:27:51 +01:00
Sebastiaan van Stijn
fb9977e42e vendor: golang.org/x/text v0.20.0
no changes in vendored code

full diff: https://github.com/golang/text/compare/v0.18.0...v0.20.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-04 14:25:01 +01:00
Sebastiaan van Stijn
115acf7c15 vendor: golang.org/x/sync v0.9.0
no changes in vendored code

full diff: https://github.com/golang/sync/compare/v0.8.0...v0.9.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-04 14:24:38 +01:00
Sebastiaan van Stijn
e542dee0a6 vendor: golang.org/x/sys v0.27.0
full diff: https://github.com/golang/sys/compare/v0.26.0...v0.27.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-04 14:19:17 +01:00
Rob Murray
8fee8a759f Remove test env var DOCKER_TEST_CREATE_DEFAULT_BRIDGE
Env var DOCKER_TEST_CREATE_DEFAULT_BRIDGE could be set to
override the name of the default bridge - without the bridge
being user-managed (unlike the '--bridge' daemon option).

It was needed by tests looking at docker0 behaviour, using
their own instance of the daemon, without breaking the
docker0 instance belonging to CI's daemon.

Now, those tests run in their own netns using the name docker0.

So, remove the unused env var.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-04 12:02:03 +00:00
Rob Murray
0eb3d431c0 Run tests that change docker0 in their own netns
These tests create iptables rules for different addresses on
docker0 but, unlike tests that do that for user-defined bridges,
those rules aren't removed when the test deletes the network,
because the default bridge network can't be deleted.

So, use (abuse) the L3Segment code to run the tests in their
own network namespace.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-04 12:02:03 +00:00
Sebastiaan van Stijn
9552706f45 Merge pull request #49025 from thaJeztah/update_go_1.23.4
update to go1.23.4
2024-12-04 12:09:55 +01:00
Sebastiaan van Stijn
52d7e407b7 update to go1.23.4
go1.23.4 (released 2024-12-03) includes fixes to the compiler, the runtime,
the trace command, and the syscall package. See the Go 1.23.4 milestone on
our issue tracker for details:

- https://github.com/golang/go/issues?q=milestone%3AGo1.23.4+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.23.3...go1.23.4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-04 10:02:48 +01:00
Akihiro Suda
f0d7e6294f Merge pull request #49023 from tonistiigi/update-buildkit-v0.18.1
vendor: update buildkit to v0.18.1
2024-12-04 12:52:25 +09:00
Tonis Tiigi
504ee465fc vendor: update buildkit to v0.18.1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-12-03 17:46:09 -08:00
Sebastiaan van Stijn
05e91b6ce6 Merge pull request #48541 from ereslibre/cdi-rootless
Dockerd rootless: make {/etc,/var/run}/cdi available
2024-12-04 02:01:53 +01:00
Rafael Fernández López
4e30acb63f Dockerd rootless: make {/etc,/var/run}/cdi available
When dockerd is executed with the `dockerd-rootless.sh` script, make
/etc/cdi and /var/run/cdi available to the daemon if they exist.

This makes it possible to enable the CDI integration in rootless mode.

Fixes: #47676

Signed-off-by: Rafael Fernández López <ereslibre@ereslibre.es>
2024-12-03 21:51:51 +01:00
Sebastiaan van Stijn
820520affd distribution: verifySchema1Manifest: pass through context
Before this patch:

    go test -run TestValidateManifest
    ERRO[0000] image verification failed for digest sha256:02fee8c3220ba806531f606525eceb83f4feb654f62b207191b1c9209188dedd
    PASS
    ok  	github.com/docker/docker/distribution	0.008s

With this patch:

    go test -run TestValidateManifest
    PASS
    ok  	github.com/docker/docker/distribution	0.010s

Note that in verbose mode, the logs are still printed, but through t.Log;

    go test -run TestValidateManifest -v
    === RUN   TestValidateManifest
        log_hook.go:47: time="2024-12-03T13:41:19.308383552Z" level=error msg="image verification failed for digest sha256:02fee8c3220ba806531f606525eceb83f4feb654f62b207191b1c9209188dedd" func=distribution.verifySchema1Manifest file="/go/src/github.com/docker/docker/distribution/pull_v2.go:1010" testcase=TestValidateManifest
    --- PASS: TestValidateManifest (0.00s)
    PASS
    ok  	github.com/docker/docker/distribution	0.011s

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-03 14:42:40 +01:00
Sebastiaan van Stijn
84aeea2f11 Merge pull request #49015 from thaJeztah/registry_test_cleanups
registry: remove assignment of default values in some tests
2024-12-03 12:58:43 +01:00
Sebastiaan van Stijn
612b853a00 Merge pull request #48999 from thaJeztah/no_dnslookup
registry: isCIDRMatch: avoid performing DNS lookups if not needed
2024-12-03 12:45:18 +01:00
Sebastiaan van Stijn
efa041adfb Merge pull request #49017 from robmry/stable_goroutine_count
Wait longer for a stable goroutine count in tests
2024-12-03 10:49:36 +01:00
Sebastiaan van Stijn
97240e47f3 Merge pull request #49019 from coolljt0725/fix_a_typo
daemon/daemon_linux.go: Fix a typo in comment
2024-12-03 10:49:15 +01:00
Jitang Lei
9a0b61ab29 daemon/daemon_linux.go: Fix a minor typo
Signed-off-by: Jitang Lei <leijitang@outlook.com>
2024-12-03 08:59:00 +08:00
Rob Murray
d75394bf77 Wait longer for a stable goroutine count in tests
Test 'TestDockerCLIRunSuite/TestRunAttachFailedNoLeak' does this ...

- start a container that exits immediately, its comment says:
  - "Run a dummy container to ensure all goroutines are up and running
    before we get a count"
- wait for the number of goroutines to be stable for 400ms, and remember
  that number
- start a container
- start another container, expecting it to fail with a port-mapping clash
- stop the running container
- wait for up to 30s for the number of goroutines to fall back to the
  remembered number.

In a CI run - hacking in some debug to count goroutines once a second,
before waiting for the number to stablilise for 400ms, showed that the
initial (dummy) container run had no immediate effect. But, three more
goroutines appeared within a few seconds. For example:

  === RUN   TestDockerCLIRunSuite/TestRunAttachFailedNoLeak
    docker_cli_run_test.go:3822: goroutines before container run: 47 err <nil>
    docker_cli_run_test.go:3830: goroutines after container run: 47 i 0 err <nil>
    docker_cli_run_test.go:3830: goroutines after container run: 48 i 1 err <nil>
    docker_cli_run_test.go:3830: goroutines after container run: 48 i 2 err <nil>
    docker_cli_run_test.go:3830: goroutines after container run: 48 i 3 err <nil>
    docker_cli_run_test.go:3830: goroutines after container run: 48 i 4 err <nil>
    docker_cli_run_test.go:3830: goroutines after container run: 50 i 5 err <nil>
    docker_cli_run_test.go:3830: goroutines after container run: 50 i 6 err <nil>
    docker_cli_run_test.go:3830: goroutines after container run: 50 i 7 err <nil>
    docker_cli_run_test.go:3830: goroutines after container run: 50 i 8 err <nil>
    docker_cli_run_test.go:3830: goroutines after container run: 50 i 9 err <nil>

That means a delay while running the rest of the test risks finding the
extra goroutines that are going to start anyway and not go away (regardless
of whether more containers are started).

So - wait for the goroutine count to be stable for 7s, rather than 400ms.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-02 18:49:02 +00:00
Rob Murray
dd7831187d Fix typo in waitForStableGourtineCount
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-12-02 18:48:32 +00:00
Paweł Gronowski
f91afea6ea c8d/commit,import,build: Preserve overriden image
If the commit, import or build targets an image tag that already exists,
persist the old image under a dangling reference instead of just
deleting it.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-02 15:15:30 +01:00
Paweł Gronowski
f0c8becffb c8d/tag: Extract createOrReplaceImage
Extract a method that creates an image if it doesn't exists and replaces
it otherwise.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-02 14:32:05 +01:00
Sebastiaan van Stijn
0194a18ca8 registry: remove assignment of default values in some tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-02 14:00:34 +01:00
Sebastiaan van Stijn
87fbd9cd3b Merge pull request #49009 from vvoland/c8d-tag-remove-warning
c8d/tag: Don't log a warning if the source image is not dangling
2024-12-02 12:52:49 +01:00
Paweł Gronowski
a93f6c61db c8d/tag: Don't log a warning if the source image is not dangling
After the image is tagged, the engine attempts to delete a dangling
image of the source image, so the image is no longer dangling.

When the source image is not dangling, the removal errors out (as
expected), but a warning is logged to the daemon log:

```
time="2024-12-02T10:44:25.386957553Z" level=warning msg="unexpected error when deleting dangling image" error="NotFound: image \"moby-dangling@sha256:54d8c2251c811295690b53af7767ecaf246f1186c36e4f2b2a63e0bfa42df045\": not found" imageID="sha256:54d8c2251c811295690b53af7767ecaf246f1186c36e4f2b2a63e0bfa42df045" spanID=bd10a21a07830d72 tag="docker.io/library/test:latest" traceID=4cf61671c2dc6da3dc7a09c0c6ac4e16
```

Remove that log as it causes unnecessary confusion, as the failure is
expected.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-12-02 11:44:37 +01:00
Paweł Gronowski
796fcf6331 Merge pull request #49006 from thaJeztah/deprecate_repoinfo_scope
registry: deprecate RepositoryInfo.Class
2024-12-02 09:59:03 +00:00
Paweł Gronowski
f251739789 Merge pull request #49004 from thaJeztah/registry_remove_version
registry: remove deprecated APIEndpoint.Version and APIVersion type
2024-12-02 09:58:48 +00:00
Sebastiaan van Stijn
28a700bf5b registry: override net.LookupIP per test, not globally
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-02 10:23:35 +01:00
Sebastiaan van Stijn
d17cd847ea registry: isCIDRMatch: don't try to resolve host if not needed
isCIDRMatch defaulted to trying to resolve a hostname to get its
IP-address(es) before trying if the given host was an IP address
already.

Let's reverse the order so that we can avoid performing a DNS lookup
when it's not needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-12-02 10:21:16 +01:00
Sebastiaan van Stijn
5f91c769f5 registry: deprecate RepositoryInfo.Class
The Class field was added in a12b466183 because
Docker Hub registry required a special scope to be set for pulling plugins;

    HTTP/1.1 401 Unauthorized
    ...
    Www-Authenticate: Bearer realm="https://auth.docker.io/token",service="registry.docker.io",scope="repository(plugin):vieux/sshfs:pull",error="insufficient_scope"

This is no longer a requirement, and the field is no longer set.

This patch deprecates the field and removes its use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-30 14:31:18 +01:00
Sebastiaan van Stijn
3903f71f9f registry: remove deprecated APIEndpoint.Version and APIVersion type
This field was unused, and support for v1 registries was removed a long
time ago. It was deprecated in d43e61758a
(part of v25.0), and marked for deletion after that release.

This removes the deprecated field and types;

- `registry.APIEndpoint.Version` field
- `registry.APIVersion` type
- `registry.APIVersion1` const
- `registry.APIVersion2` const

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-30 12:52:33 +01:00
Sebastiaan van Stijn
0bd8738e33 registry: isCIDRMatch: return early if no CIDRs are set
Skip all code if there's nothing to match against.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-30 12:00:53 +01:00
Austin Vazquez
bff7444993 Merge pull request #48993 from thaJeztah/modprobe_br_netfilter
Jenkinsfile: modprobe br_netfilter
2024-11-29 18:47:06 -08:00
Sebastiaan van Stijn
321f9c2d1c Merge pull request #48988 from robmry/dockerd_manpage_host-gateway-ip
Add --host-gateway-ip to the dockerd manpage
2024-11-29 23:00:36 +01:00
Sebastiaan van Stijn
cce5dfe1e7 Jenkinsfile: modprobe br_netfilter
Make sure the module is loaded, as we're not able to load it from within
the dev-container;

    time="2024-11-29T20:40:42Z" level=error msg="Running modprobe br_netfilter failed with message: modprobe: WARNING: Module br_netfilter not found in directory /lib/modules/5.15.0-1072-aws\n" error="exit status 1"

Also moving these steps _before_ the "print info" step, so that docker info
doesn't show warnings that bridge-nf-call-iptables and bridge-nf-call-ip6tables
are not loaded.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-29 22:54:25 +01:00
Rob Murray
59c5919b12 Put --help before --host in the dockerd manpage
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-29 17:16:37 +00:00
Rob Murray
2fbb18ece2 Add --host-gateway to the dockerd manpage
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-29 17:16:03 +00:00
Sebastiaan van Stijn
24fd633ebb Merge pull request #48597 from robmry/nat-unprotected
Add gateway mode "nat-unprotected"
2024-11-29 16:42:28 +01:00
Sebastiaan van Stijn
a0c82a3434 Merge pull request #48936 from akerouanton/EndpointSettings-Priority-v2
api: add GwPriority field to EndpointSettings
2024-11-29 01:45:37 +01:00
Rob Murray
0aba67203a Implement gateway mode "nat-unprotected"
Same as "nat" mode, there's masquerading and port mapping from the
host - but no port/protocol filtering for direct access to the
container's address from remote hosts.

This is the old default behaviour for IPv4 when the filter-FORWARD
chain's default policy was "ACCEPT" (the daemon would only set it
to "DROP" when it set sysctl "ip_forward" itself, but it didn't set
up DROP rules for unpublished ports).

Now, port filtering doesn't depend on the filter-FORWARD policy. So,
this mode is added as a way to restore the old/surprising/insecure
behaviour for anyone who's depending on it. Networks will need to
be re-created with this new gateway mode.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-28 19:33:37 +00:00
Rob Murray
07dff11a7e Wrap errors rather than using err.Error()
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-28 19:03:10 +00:00
Sebastiaan van Stijn
71b93a881c Merge pull request #48986 from thaJeztah/daemon_routeropts
cmd/dockerd: change routerOptions.Build to a regular func
2024-11-28 20:00:24 +01:00
Sebastiaan van Stijn
ab83458701 Merge pull request #48984 from thaJeztah/daemon_RegistryHosts_use_internal
daemon: Daemon.RegistryHosts: use internal method to get daemon config
2024-11-28 19:46:55 +01:00
Sebastiaan van Stijn
d3c2376ff1 cmd/dockerd: change routerOptions.Build to a regular func
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-28 17:39:52 +01:00
Sebastiaan van Stijn
781dd8aa8f Merge pull request #48985 from thaJeztah/daemon_config_cleanup
daemon/config: some refactor and  deprecate Config.ValidatePlatformConfig
2024-11-28 17:31:44 +01:00
Albin Kerouanton
5b752fab32 api: add Priority field to EndpointSettings
This new field is used by libnetwork to determine which endpoint
provides the default gateway for a container.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-11-28 17:06:26 +01:00
Albin Kerouanton
229dc6676c daemon: early-return from buildJoinOptions
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-11-28 16:54:24 +01:00
Sebastiaan van Stijn
c9f17bedc7 daemon/config: extract validation of userland-proxy config
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-28 16:41:19 +01:00
Sebastiaan van Stijn
83f8f4efd7 daemon/config: deprecate Config.ValidatePlatformConfig
This method was only used internally as part of config.Validate; deprecate
it in favor of config.Validate and make it a non-exported function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-28 16:41:18 +01:00
Sebastiaan van Stijn
74a00f183b daemon/config: move utility-functions separate from Config methods
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-28 16:41:18 +01:00
Sebastiaan van Stijn
a4714fa04d daemon/config: verifyDefaultCgroupNsMode: update error message for consistency
Most validation errors have the "invalid xxxxx" prefix; format this error
to be consitent with other errors.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-28 16:41:18 +01:00
Sebastiaan van Stijn
2c000b8ac4 daemon: Daemon.RegistryHosts: use internal method to get daemon config
The Daemon.Config() option was added to expose the Config outside of the
daemon package. Limit the use of that function to that purpose and use
the internal, non-exported functions within the daemon itself; this makes
it easier to see if there's still external consumers of the Config()
method.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-28 16:32:51 +01:00
Sebastiaan van Stijn
c017e88ad9 Merge pull request #48981 from thaJeztah/daemon_minor_refactor
daemon: getCD: remove use of parsers.ParseKeyValueOpt
2024-11-28 15:50:20 +01:00
Paweł Gronowski
6ba1b05985 Merge pull request #48980 from thaJeztah/newRouterOptions_noshadow
cmd/dockerd: newRouterOptions: rename arg that shadowed import
2024-11-28 14:45:05 +00:00
Sebastiaan van Stijn
b7974a1ff1 Merge pull request #48982 from crazy-max/ci-buildx-edge
ci: use edge releases of buildx
2024-11-28 15:33:09 +01:00
CrazyMax
16be996b6b ci: use edge releases of buildx
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-11-28 14:38:01 +01:00
Sebastiaan van Stijn
3e4f437697 cmd/dockerd: newRouterOptions: rename arg that shadowed import
Also remove an intermediate variable

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-28 13:43:02 +01:00
Sebastiaan van Stijn
68a98a7263 daemon: getCD: remove use of parsers.ParseKeyValueOpt
We were discarding the error returned by it, and its functionality
is very minimal, so inline the equivalent.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-28 13:18:53 +01:00
Paweł Gronowski
4d2fbe325a Merge pull request #48978 from thaJeztah/gofumpt
gofumpt code
2024-11-28 11:33:39 +00:00
Sebastiaan van Stijn
003e35fea5 libnetwork/ipams/null: gofumpt code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-28 10:05:40 +01:00
Sebastiaan van Stijn
a8e5a19706 libnetwork/drivers/bridge: gofumpt code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-28 10:05:07 +01:00
Sebastiaan van Stijn
da5e86a82b daemon: gofumpt code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-28 10:03:46 +01:00
Sebastiaan van Stijn
7b8b63ec22 Merge pull request #48520 from arcenik/43080-zfs-destroy-missing-volume-fails
daemon/graphdriver/zfs: ignore non-existent dataset on removal
2024-11-27 22:23:28 +01:00
Sebastiaan van Stijn
b8db6d143a Merge pull request #48956 from thaJeztah/poll_default_delay
integration: remove default poll delay and timeouts
2024-11-27 22:20:36 +01:00
Sebastiaan van Stijn
8277fc78e9 Merge pull request #48940 from thaJeztah/integration_add_wait
integration: add wait
2024-11-27 22:20:08 +01:00
Sebastiaan van Stijn
c565f74698 Merge pull request #48807 from robmry/v6only/host_gateway_ip
IPv6 only: Allow IPv4 and IPv6 host-gateway-ip addresses
2024-11-27 17:28:56 +01:00
Akihiro Suda
fb6e650ab9 integration: add wait
Cherry-picked several WIP commits from
b0a592798f/

Originally-authored-by: Rodrigo Campos <rodrigoca@microsoft.com>
Co-Authored-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-27 15:52:49 +01:00
Sebastiaan van Stijn
d58e56eadb Merge pull request #48960 from sshedi/br_net-fix
Fix br_netfilter module loading logic
2024-11-27 15:44:30 +01:00
Sebastiaan van Stijn
f704a1c9d7 Merge pull request #48961 from tonistiigi/update-buildkit-v0.18.0
vendor: update buildkit to v0.18.0
2024-11-27 14:45:47 +01:00
François Scala
e7d15d4d58 daemon/graphdriver/zfs: ignore non-existent dataset on removal
Ignore "dataset does not exist" error in Remove function

Signed-off-by: François Scala <github@arcenik.net>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-27 14:44:21 +01:00
Shreenidhi Shedi
264c15bfc4 Fix br_netfilter module loading logic
Checking for `/proc/sys/net/bridge` directory alone is not enough to
decide if bridge, br_netfilter module to be loaded.
Check for specific file for br_netfilter module and then
do modprobe if the file is not found under `/proc/sys/net/bridge`

Loading br_netfilter implicitly loads bridge module.

fixes: #48948

Signed-off-by: Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
2024-11-27 18:20:33 +05:30
Sebastiaan van Stijn
f052dbb54b Merge pull request #48953 from thaJeztah/carry_buildkit_init_timeout
Remove buildkit init timeout
2024-11-27 10:23:24 +01:00
Tonis Tiigi
b4769e86a4 vendor: update buildkit to v0.18.0
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-11-26 18:02:14 -08:00
Sebastiaan van Stijn
d3cc051f50 Merge pull request #48910 from dmcgowan/containerd-lease-cleanup
Fix lease management during pull and export
2024-11-26 15:34:12 +01:00
Sebastiaan van Stijn
b57aa7f3b7 integration: remove default poll delay and timeouts
The default delay is 100ms and default timeout is 10s, so we can
remove cases where we are setting the defaults;

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-26 14:05:02 +01:00
Sebastiaan van Stijn
d8fa0581ee Merge pull request #48952 from tonistiigi/update-buildkit-v0.18.0-rc2
vendor: update buildkit to v0.18.0-rc2
2024-11-26 13:32:35 +01:00
Rob Murray
c9a1e4dc8c Test host-gateway addresses from docker0
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-26 11:47:31 +00:00
Rob Murray
af0b973595 Allow IPv4 and IPv6 host-gateway-ip addresses
Running a container with "--add-host blah:host-gateway" adds an /etc/hosts
entry for host "blah" and an address on the docker host - to give the
container a convenient way of reaching the host.

If no --host-gateway-ip option is supplied, the IPv4 address of the
default bridge is used - and that's been fine until now, it's a host
address we know will exist. But, in a container that's only connected
to IPv6-only networks, that doesn't work.

So:
- if the default bridge has an IPv6 address, create an additional
  /etc/hosts entry with that adddress
- allow two --host-gateway-ip options
  - at most one IPv4 and one IPv6 address
- in daemon.json, allow a JSON array value in --host-gateway-ips (plural)
  - for a single address, a JSON string is also allowed

For example:
  --host-gateway-ip 192.0.2.1 --host-gateway-ip 2001:db8::1111
And the daemon.json version would be:
  "host-gateway-ips": ["192.0.2.1", "2001:db8::1111"]
But, this is also still valid:
  "host-gateway-ip": "192.0.2.1"

Note that the /etc/hosts entries follow the usual rules. If IPv6 is
disabled in a container (by sysctl, or lack of kernel support), IPv6
addresses are not included in the file. In other cases, IPv4 and IPv6
addresses will both be included, whether or not the container currently
has network endpoints that support IPv4 or IPv6.

buildx has its own code to interpret the host-gateway-ip option. When
it's updated to understand two addresses, moby will need to pass it
both. For now, it passes an IPv4 address if there is one, else IPv6.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-26 11:47:31 +00:00
Rob Murray
01e2168c1e Move Linux-only integration/network tests into Linux-only file
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-26 11:47:31 +00:00
Tonis Tiigi
90250ce93a vendor: update buildkit to v0.18.0-rc2
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-11-25 18:48:25 -08:00
Brian Goff
b7f43c3729 Remove buildkit init timeout
Buildkit *can* take a long time to start, we don't want the daemon to fail
to startup because buildkit took too long.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-11-26 00:37:20 +00:00
Rob Murray
2f6953fcd8 Merge pull request #48319 from robmry/optional_fixed-cidr-v6
Align fixed-cidr-v6 with fixed-cidr, use default ULA prefix if no fixed-cidr-v6
2024-11-25 21:15:53 +00:00
Rob Murray
0b5b1db1c1 Use default ULA prefix if fixed-cidr-v6 is not specified
Use the same logic to generate IPAMConf for IPv6 as for IPv4.

- When no fixed-cidr-v6 is specified, rather than error out, use
  the default address pools (as for an IPv4 default bridge with no
  fixed-cidr, and as for user-defined networks).
- Add daemon option --bip6, similar to --bip.
  - Necessary because it's the only way to override an old address
    on docker0 (daemon-managed default bridge), as illustrated by
    test cases.
- For a user-managed default bridge (--bridge), use IPv6 addresses
  on the user's bridge to determine the pool, sub-pool and gateway.
  Following the same rules as IPv4.
- Don't set up IPv6 IPAMConf if IPv6 is not enabled.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-25 18:29:25 +00:00
Rob Murray
fdd2591cbe Separate IPv4 IPAM conf from the rest of default bridge conf
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-25 18:28:37 +00:00
Rob Murray
cc538b2bf0 Drop fixed-cidr if not within user-managed bridge subnet
When a user-managed bridge is used for the default network (--bridge),
an address from the bridge determines the subnet for the network.

If a fixed-cidr is supplied, it should fall within that subnet. If it
doesn't, it's a misconfiguration - fixed-cidr is the range of
allocatable addresses, and they need to be in the network. (Either
the user's bridge is missing an address that matches their fixed-cidr
or the fixed-cidr is wrong.)

When this happens, because it's been allowed in the past (and, because
the address-pool implementation treats fixed-cidr/SubPool as an offset
into the network rather than an actual address range, so working IP
addresses would normally still be assigned to containers) ... don't
reject the config and cause daemon startup to fail. Just log a warning
and ignore fixed-cidr.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-25 18:28:37 +00:00
Rob Murray
311a8bc899 Allow increase of fixed-cidr subnet size
For a docker-managed default bridge (docker0), when no --bip is
supplied, the gateway address and subnet size can be inferred
from existing bridge addresses.

But, if fixed-cidr's subnet size is increased so that it's biggger
than the subnet of the bridge's existing address - the bridge's
subnet needs to be incresed to match. (fixed-cidr determines the
range of addresses that can be automatically allocated, and these
should not fall outside the default bridge's subnet.)

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-25 18:28:37 +00:00
Rob Murray
85159ce09f Allow non-overlapping change of fixed-cidr
When a docker-managed default bridge (docker0) already has an
address, and the fixed-cidr subnet fits within the subnet defined
by that address, the existing address should be used as the
gateway and to define the subnet.

But, when fixed-cidr is changed, no --bip is supplied, and no
existing bridge network includes fixed-cidr ... the existing
bridge address needs to be updated.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-25 18:28:37 +00:00
Rob Murray
237654a553 Refactor IPAM config for default bridge
Factor out selection of addresses from an existing bridge from
the code that uses the selected address to set up IPAM for the
default bridge.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-25 18:28:37 +00:00
Rob Murray
90baa2bc36 Fix selection of subnet from user-managed default bridge
When a user-managed bridge is used instead of docker0 (--bridge), with
a fixed-cidr - the bridge should have an IP address/subnet that
encompasses fixed-cidr ... the bridge address's subnet then defines
the network's subnet, and fixed-cidr defines the allocatable range
within that.

But, selection of the correct subnet/address from the bridge depended
on the address being within fixed-cidr (within the allocatable range).

This change removes that assumption. So, a bridge address with a
subnet that includes fixed-cidr is selected.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-25 18:28:37 +00:00
Rob Murray
63b558af77 Don't clear top bits of IP then check if it's global unicast
The intention may have been to only accept a globally routable
address as the gateway address on a user-supplied default bridge.
But, the test didn't do anything, so it's been allowing LL
subnets. It's too late to change that now so, remove the broken
check.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-25 18:28:37 +00:00
Rob Murray
facb2323a0 Add tests for IPAM Config of default bridge
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-25 18:28:37 +00:00
Rob Murray
4a2bd1085e Move default bridge test into linux-only file
Becuase I'm about to add tests that use netlink, and the netlink
package breaks compilation under Windows.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-25 18:28:37 +00:00
Sebastiaan van Stijn
7a23d69f7b Merge pull request #48945 from thaJeztah/filters_clean
api/types/filters: rewrite / improve some tests
2024-11-25 18:52:01 +01:00
Sebastiaan van Stijn
46a91a947e api/types/filters: reduce uses of non-exported fields in tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-25 17:09:08 +01:00
Sebastiaan van Stijn
cffee85725 api/types/filters: also test generated JSON
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-25 17:07:41 +01:00
Sebastiaan van Stijn
848f11aa7c api/types/filters: rewrite tests with gotest.tools
Use assert.Check() for most cases, instead of failing early.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-25 17:07:36 +01:00
Derek McGowan
4becdaca72 Add label on PrepareSnapshot to warn about non-expiring leases
Currently when preparing a snapshot for a container, a lease is used to
hold that snapshot for the lifespan of a container. That is workaround
to preserve the snapshot when a container is recreated, however, the
containerd object should be able to hold this reference itself.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-11-25 06:42:16 -08:00
Derek McGowan
eef6b83e53 Update containerd image builder to use lease prune label
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-11-25 06:41:29 -08:00
Derek McGowan
e6170a5c4f Fix lease management during image operations
Ensure that leases have a reasonable expiration and are
cleaned up during prune

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-11-25 06:41:29 -08:00
Sebastiaan van Stijn
54fff36d95 Merge pull request #48906 from robmry/network_generic_opts
Disallow "network generic data" with type options.Generic
2024-11-25 15:41:00 +01:00
Sebastiaan van Stijn
431e829f50 Merge pull request #48937 from thaJeztah/bump_netns
vendor: github.com/vishvananda/netns v0.0.5
2024-11-25 12:25:19 +01:00
Sebastiaan van Stijn
1a26e627bc vendor: github.com/vishvananda/netns v0.0.5
full diff: https://github.com/vishvananda/netns/compare/v0.0.4...v0.0.5

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-25 10:02:20 +01:00
Sebastiaan van Stijn
ca0910c1b9 Merge pull request #48915 from cyphar/tests-assert-modern
tests: migrate assertions to be more modern
2024-11-22 18:16:43 +01:00
Sebastiaan van Stijn
4def7cbc61 Merge pull request #48930 from vvoland/vendor-singleflight
vendor: resenje.org/singleflight v0.4.3
2024-11-22 17:11:01 +01:00
Sebastiaan van Stijn
d37761996b Merge pull request #48923 from tonistiigi/buildkit-v0.18.0-rc1
vendor: update buildkit to v0.18.0-rc1
2024-11-22 16:52:18 +01:00
Sebastiaan van Stijn
0666d4a585 vendor: github.com/moby/buildkit 94d0f6ed85e5 (master / v0.18.0-rc.2)
full diff: https://github.com/moby/buildkit/compare/v0.18.0-rc1...94d0f6ed85e504e1851495fa98485ffbd9cfddb0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-22 14:20:44 +01:00
Aleksa Sarai
557e4ed83b tests: migrate simple cases to assert.ErrorIs
There were a handful of direct checks against errors.Is that can be
translated to assert.ErrorIs without too much thought. Unfortunately
there are a load of other examples where ErrorIs probably makes sense
but would require testing whether this subtly breaks the test.

These transformations were done by hand.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-11-22 23:59:21 +11:00
Aleksa Sarai
caae3c051d tests: migrate to assert.ErrorContains when possible
If we have an error type that we're checking a substring against, we
should really be checking using ErrorContains to indicate the right
semantics to assert.

Mostly done using these transforms:

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

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

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

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

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-11-22 23:59:20 +11:00
Aleksa Sarai
0553d3d994 tests: migrate away from assert.Assert(err == nil)
Unfortunately, gofmt doesn't know about types so it was necessary to
find all of the err == nil statements through trial and error. Note that
there is no is.NilError, so for assert.Check(t, err == nil) we need to
switch to just doing assert.Check(t, err). If err is an error type, this
is equivalent (and there isn't another trivial way of doing it). Here
are the full set of rules used:

Generic "err == nil":

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

Generic, but with a different variable name:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, sr.err == nil) -> assert.NilError(t, sr.err)"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, sr.err == nil) -> assert.Check(t, sr.err)"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, err2 == nil) -> assert.NilError(t, err2)"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, err2 == nil) -> assert.Check(t, err2)"

JSON-related error assertions:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, json.Unmarshal(a, b) == nil) -> assert.NilError(t, json.Unmarshal(a, b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, json.Unmarshal(a, b) == nil) -> assert.Check(t, json.Unmarshal(a, b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, json.NewDecoder(a).Decode(b) == nil) -> assert.NilError(t, json.NewDecoder(a).Decode(b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, json.NewDecoder(a).Decode(b) == nil) -> assert.Check(t, json.NewDecoder(a).Decode(b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, json.NewEncoder(a).Encode(b) == nil) -> assert.NilError(t, json.NewEncoder(a).Encode(b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, json.NewEncoder(a).Encode(b) == nil) -> assert.Check(t, json.NewEncoder(a).Encode(b))"

Process-related error assertions:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, a.Start() == nil) -> assert.NilError(t, a.Start())"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, a.Start() == nil) -> assert.Check(t, a.Start())"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, a.Kill() == nil) -> assert.NilError(t, a.Kill())"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, a.Kill() == nil) -> assert.Check(t, a.Kill())"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, a.Signal(b) == nil) -> assert.NilError(t, a.Signal(b))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, a.Signal(b) == nil) -> assert.Check(t, a.Signal(b))"

waitInspect:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, waitInspect(a, b, c, d) == nil) -> assert.NilError(t, waitInspect(a, b, c, d))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, waitInspect(a, b, c, d) == nil) -> assert.Check(t, waitInspect(a, b, c, d))"

File closing error assertions:

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

mount.MakeRShared:

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

daemon.SwarmLeave:

  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Assert(t, d.SwarmLeave(a, b, c) == nil) -> assert.NilError(t, d.SwarmLeave(a, b, c))"
  find . -type f -name "*_test.go" | \
    xargs gofmt -w -r "assert.Check(t, d.SwarmLeave(a, b, c) == nil) -> assert.Check(t, d.SwarmLeave(a, b, c))"

os.MkdirAll:

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

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-11-22 23:59:20 +11:00
Aleksa Sarai
5e4e34a966 tests: migrate strings.Contains -> is.Contains in assertions
Migrated using

  find . -type f -name "*_test.go" |
    xargs gofmt -w \
      -r "assert.Check(t, strings.Contains(a, b)) -> assert.Check(t, is.Contains(a, b))"

  find . -type f -name "*_test.go" |
    xargs gofmt -w \
      -r "assert.Assert(t, strings.Contains(a, b)) -> assert.Assert(t, is.Contains(a, b))"

Using a boolean in assert.Assert or assert.Check results in error
messages that don't contain the actual problematic string, and when
running the integration suite on an actual machine (where the source
code parsing doesn't work) this makes it almost impossible to figure out
what the actual error is.

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-11-22 23:59:20 +11:00
Tonis Tiigi
48b237f7af vendor: update buildkit to v0.18.0-rc1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-11-22 13:59:09 +01:00
Sebastiaan van Stijn
0b77888fab Merge pull request #48932 from thaJeztah/update_go-actions-cache
vendor: github.com/tonistiigi/go-actions-cache 394979b8119e
2024-11-22 13:57:17 +01:00
Sebastiaan van Stijn
113d3cecea Merge pull request #48929 from thaJeztah/cdi_test_use_fixtures
integration/container: TestCDISpecDirsAreInSystemInfo: use fixtures
2024-11-22 13:21:11 +01:00
Sebastiaan van Stijn
44f9eec1ae vendor: github.com/tonistiigi/go-actions-cache 394979b8119e
updates to github.com/golang-jwt/jwt/v5

full diff: 58651d5e11...394979b811

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-22 12:45:19 +01:00
Paweł Gronowski
1551d95727 vendor: resenje.org/singleflight v0.4.3
full diff: https://resenje.org/singleflight/compare/v0.4.1...v0.4.3

Changes:
- Fix incorrect `Forget` behavior
- Make panic behavior consistent with x/sync package

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-22 11:40:51 +01:00
Sebastiaan van Stijn
1832afcf69 Merge pull request #48925 from thaJeztah/bump_continuity
vendor: github.com/containerd/continuity v0.4.5
2024-11-22 10:59:50 +01:00
Sebastiaan van Stijn
b9a904c48a integration/container: TestCDISpecDirsAreInSystemInfo: use fixtures
Set the daemon.json config as a string-literal in the tests, instead of
using a map[string]interface{} as intermediary format.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-22 10:55:55 +01:00
Sebastiaan van Stijn
d23bc11b97 vendor: github.com/containerd/continuity v0.4.5
full diff: https://github.com/containerd/continuity/compare/v0.4.4...v0.4.5

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-22 10:10:07 +01:00
Sebastiaan van Stijn
8d4d6c8ae6 Merge pull request #48918 from austinvazquez/update-containerd-v1.7.24-in-ci
Dockerfile: update containerd v1.7.24
2024-11-21 18:54:30 +01:00
Sebastiaan van Stijn
7c82eb823a Merge pull request #48917 from dmcgowan/update-containerd-1.7.24
Update containerd to v1.7.24
2024-11-21 18:54:07 +01:00
Sebastiaan van Stijn
0aa664fb5f Merge pull request #48916 from thaJeztah/volume_testutils_simplify_mock
volume/testutils: simplify fakePluginGetter
2024-11-21 17:26:34 +01:00
Sebastiaan van Stijn
21f7414096 Merge pull request #47666 from thaJeztah/update_runc_1.2.0
Dockerfile: update to runc v1.2.2
2024-11-21 17:12:43 +01:00
Austin Vazquez
8cecf3a71c Dockerfile: update containerd to v1.7.24
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2024-11-21 15:20:52 +00:00
Derek McGowan
a650dbd951 Update containerd to v1.7.24
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-11-21 06:45:23 -08:00
Sebastiaan van Stijn
821d974789 volume/testutils: simplify fakePluginGetter
Embed the interface to simplify the mock

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-21 11:33:19 +01:00
Sebastiaan van Stijn
803534fb4e Merge pull request #48911 from austinvazquez/vendor-golang-jwt-v4.5.1
vendor: github.com/golang-jwt/jwt/v4@v4.5.1
2024-11-21 09:57:54 +01:00
Sebastiaan van Stijn
e5c2b5e10d Merge pull request #48897 from thaJeztah/client_import_no_empties
client: ImageImport: omit empty query-parameters
2024-11-20 15:27:49 +01:00
Sebastiaan van Stijn
968213c763 Merge pull request #48902 from thaJeztah/save_load_multiplat
client: support multiple platforms on save and load
2024-11-20 15:24:51 +01:00
Akihiro Suda
1c00dfc77e Merge pull request #48901 from thaJeztah/bump_golangci_lint
update golangci-lint to v1.62.0
2024-11-20 06:45:23 +09:00
Akihiro Suda
1e80bb9391 Merge pull request #48900 from thaJeztah/vendor_runc_1.2.2
vendor: github.com/opencontainers/runc v1.2.2
2024-11-20 06:45:08 +09:00
Rob Murray
b656cffe4c Disallow "network generic data" with type options.Generic
Field 'generic' in 'libnetwork.Network' is used to store driver options,
it has type 'options.Generic', which is 'map[string]any'.

In that map, there may be a key 'netlabel.GenericData' holding options
known as "network generic options", used for options like:
  -o com.docker.network.bridge.name=br-foo

The value type for key 'netlabel.GenericData' is always 'map[string]string'
when created via an API request. But, some unit tests use type
'options.Generic'.

That works because the bridge, ipvlan and macvlan drivers look for type
'options.Generic' as well as 'map[string]string'. If they find
'options.Generic', Go reflection is used to map keys to fields of the
config struct with the expectation that the value has the same type as
that field. But, that's only used in unit tests (so the tests aren't
testing the same code path as the API would use). The 'options.Generic'
form of the bridge name option is:
  "BridgeName": "br-foo"
(Because "BridgeName" is the name of the field in the bridge driver's
network config struct.)

The libnetwork code expects "network generic options" to have type
'map[string]string', and makes no provision for 'options.Generic'. So,
for example, function Network.DriverOptions will panic if called when
'Network.generic[netlabel.GenericData]' has type 'options.Generic'.

The type of 'Network.generic[netlabel.GenericData]' can't be statically
checked, because it's just a field in a 'map[string]any'.

So - remove the driver code that converts "network generic options"
from type 'options.Generic', as it's only used in tests and just makes
things more confusing.

This should reduce the chances of things appearing to work when the
type is wrong, and converting unit tests to use 'map[string]string'
means they're testing the right thing.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-19 20:13:39 +00:00
Rob Murray
069e41afd9 Merge pull request #48596 from robmry/48526_gateway_routed_inc
Make containers on routed-mode networks accessible from other bridge networks
2024-11-19 16:24:22 +00:00
Sebastiaan van Stijn
d3609fa9c2 Merge pull request #48855 from vvoland/c8d-inspect-imagemanifest
c8d/container/inspect: Return `ImageManifestDescriptor`
2024-11-19 16:47:47 +01:00
Rob Murray
223929a44d Test routed n/w inter-network communication
Add an integration test to check that a container on a network
with gateway-mode=nat can access a container on a network with
gateway-mode=routed, but not vice-versa.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-19 15:28:42 +00:00
Rob Murray
0546d9084f Routed networks accept traffic from anywhere.
Create ipsets containing the subnet of each non-internal bridge network.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-19 15:28:42 +00:00
Rob Murray
10338053f0 Don't add default-RETURN rules to DOCKER-ISOLATION chains
The default for a user-defined chain is RETURN anyway.

This opens up the possibilty of sorting rules into two groups
by using insert or append, without having to deal with appending
after the unconditional RETURN.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-19 15:28:42 +00:00
Rob Murray
939bc14616 Tidy bridgeNetwork.isolateNetwork
IPv4 before IPv6, with consistent error paths.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-19 15:28:42 +00:00
Rob Murray
255fff4acd Propagate error from INC rule setup
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-19 15:28:42 +00:00
Rob Murray
d3b7d84b23 Simplify setINC()
After an error, there's no need for it to roll back rules
it's created, the caller already does that.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-19 15:28:41 +00:00
Rob Murray
1a607cf257 Rename gwMode.natDisabled() to gwMode.routed()
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-19 15:28:41 +00:00
Sebastiaan van Stijn
9c9eccfb23 client: support multiple platforms on save and load
We don't yet support this at the API level, so for now it returns
an error when trying to set multiple, but this makes sure that the
client types are already ready for this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-19 15:56:28 +01:00
Sebastiaan van Stijn
e257856116 Dockerfile: update to runc v1.2.2
- 1.2.2 release notes: https://github.com/opencontainers/runc/releases/tag/v1.2.2
- 1.2.1 release notes: https://github.com/opencontainers/runc/releases/tag/v1.2.1
- 1.2.0 release notes: https://github.com/opencontainers/runc/releases/tag/v1.2.0

Breaking changes and deprecations are included below;

Breaking changes:

Several aspects of how mount options work has been adjusted in a way that
could theoretically break users that have very strange mount option strings.
This was necessary to fix glaring issues in how mount options were being
treated. The key changes are:

- Mount options on bind-mounts that clear a mount flag are now always
  applied. Previously, if a user requested a bind-mount with only clearing
  options (such as rw,exec,dev) the options would be ignored and the
  original bind-mount options would be set. Unfortunately this also means
  that container configurations which specified only clearing mount options
  will now actually get what they asked for, which could break existing
  containers (though it seems unlikely that a user who requested a specific
  mount option would consider it "broken" to get the mount options they
  asked foruser who requested a specific mount option would consider it
  "broken" to get the mount options they asked for). This also allows us to
  silently add locked mount flags the user did not explicitly request to be
  cleared in rootless mode, allowing for easier use of bind-mounts for
  rootless containers.
- Container configurations using bind-mounts with superblock mount flags
  (i.e. filesystem-specific mount flags, referred to as "data" in
  mount(2), as opposed to VFS generic mount flags like MS_NODEV) will
  now return an error. This is because superblock mount flags will also
  affect the host mount (as the superblock is shared when bind-mounting),
  which is obviously not acceptable. Previously, these flags were silently
  ignored so this change simply tells users that runc cannot fulfil their
  request rather than just ignoring it.

Deprecated

- runc option --criu is now ignored (with a warning), and the option will
  be removed entirely in a future release. Users who need a non-standard
  criu binary should rely on the standard way of looking up binaries in
  $PATH.
- runc kill option -a is now deprecated. Previously, it had to be specified
  to kill a container (with SIGKILL) which does not have its own private PID
  namespace (so that runc would send SIGKILL to all processes). Now, this is
  done automatically.
- github.com/opencontainers/runc/libcontainer/user is now deprecated, please
  use github.com/moby/sys/user instead. It will be removed in a future
  release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-19 15:16:30 +01:00
Sebastiaan van Stijn
84ad184fe5 Merge pull request #48766 from kolyshkin/runc120-followups
runc-1.2.0 merge followups
2024-11-19 14:13:44 +01:00
Paweł Gronowski
44ed3067ca c8d/container/inspect: Return ImageManifestDescriptor
`ImageManifestDescriptor` will contain an OCI descriptor of
platform-specific manifest of the image that was picked when creating
the container.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-19 13:55:56 +01:00
Paweł Gronowski
0020c41e3a daemon: Best-effot container OS to ImagePlatform migration
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-19 13:55:55 +01:00
Paweł Gronowski
638172417c container: Add ImagePlatform field and deprecate OS
Change the persistent container metadata to store the whole platform
(as defined by OCI) instead of only the operating system.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-19 13:55:54 +01:00
Paweł Gronowski
60cd165012 Dockerfile/frozen-images: Add amd64 and arm64 hello world
Add platform specific variants of the hello-world image

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-19 13:55:52 +01:00
Sebastiaan van Stijn
f303531757 client: ImageImport: omit empty query-parameters
Don't set query-parameters for options that weren't set.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-19 13:30:59 +01:00
Sebastiaan van Stijn
fc11756d25 Merge pull request #48896 from thaJeztah/client_test_improve
client: improve/refactor some unit-tests and add "platform" test-cases to them
2024-11-19 13:30:41 +01:00
Rodrigo Campos
f96994ec17 Skip tests that are flaky for 4 already
Some other tests on this file where skipped with this same line. Let's
skip this one, that seems to be flaky too.

Signed-off-by: Rodrigo Campos <rodrigoca@microsoft.com>
2024-11-19 12:44:25 +01:00
Kir Kolyshkin
be36ac13e5 .golanci.yml: rm runc exception
This is not needed since commit a6d5b48e67
("vendor: github.com/opencontainers/runc v1.2.0").

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-11-19 12:44:22 +01:00
Sebastiaan van Stijn
acf920823b update golangci-lint to v1.62.0
full diff: https://github.com/golangci/golangci-lint/compare/v1.60.2...v1.62.0
Changelog: https://golangci-lint.run/product/changelog/#v1620

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-19 10:53:59 +01:00
Sebastiaan van Stijn
329d35bcca vendor: github.com/opencontainers/runc v1.2.2
full diff: https://github.com/opencontainers/runc/compare/v1.2.0...v1.2.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-19 10:39:15 +01:00
Sebastiaan van Stijn
b2dd38b1d1 Merge pull request #48898 from thaJeztah/bump_grpc
vendor: google.golang.org/grpc v1.66.3
2024-11-19 09:54:57 +01:00
Sebastiaan van Stijn
4b26582bc6 vendor: google.golang.org/grpc v1.66.3
- transport: Fix reporting of bytes read while reading headers
- xds/server: Fix xDS Server leak

full diff: https://github.com/grpc/grpc-go/compare/v1.66.2...v1.66.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-19 00:23:38 +01:00
Sebastiaan van Stijn
02a2f64986 Merge pull request #48891 from thaJeztah/remove_logentries_migration
remove logentries check and migration code
2024-11-18 19:01:28 +01:00
Sebastiaan van Stijn
21cb06418b Merge pull request #48894 from vvoland/c8d-image-inspect-manifest
c8d/image/inspect: Return `Descriptor`
2024-11-18 19:00:53 +01:00
Austin Vazquez
1eccc326de vendor: github.com/golang-jwt/jwt/v4@v4.5.1
Signed-off-by: Austin Vazquez <macedonv@amazon.com>
2024-11-18 10:48:50 -07:00
Sebastiaan van Stijn
22f1ea4f8c Merge pull request #48895 from thaJeztah/makefile_no_inherit_graphdriver
Makefile: don't automatically inherit graph-driver from host
2024-11-18 15:42:38 +01:00
Sebastiaan van Stijn
a333c2990f client: TestImageImport: use table-test, asserts, add platform test-case
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-18 15:14:33 +01:00
Sebastiaan van Stijn
2bab030d6c client: TestImageSave: use table-test, asserts, add platform test-case
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-18 14:56:55 +01:00
Sebastiaan van Stijn
1ea24b7be3 client: TestImageLoad: add test-case for platform
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-18 14:06:12 +01:00
Sebastiaan van Stijn
613538469b client: TestImageLoad: rewrite to use table-tests, use asserts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-18 14:00:32 +01:00
Sebastiaan van Stijn
b0b6357701 Makefile: don't automatically inherit graph-driver from host
This was originally added in 54aa3a3c21,
when there was still a wide variety of storage-drivers used, and some
hosts would be running aufs of devicemapper. Let's return to make this
an explicit override if needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-18 13:16:35 +01:00
Paweł Gronowski
d88ab0f3a2 c8d/image/inspect: Return Descriptor
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-18 13:00:44 +01:00
Sebastiaan van Stijn
1608746b24 Merge pull request #48871 from thaJeztah/fix_godoc
daemon/images: fix godoc for ImageActions
2024-11-18 10:47:10 +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
fc68ffcb18 Merge pull request #48887 from thaJeztah/logger_withfields
daemon/logger: logDriverError: use WithFields for logs
2024-11-17 12:40:56 +01:00
Rob Murray
be84220f53 Merge pull request #48888 from robmry/fix_enableipv4_api_version
EnableIPv4 will be in API 1.48, not 1.47
2024-11-15 19:35:39 +00:00
Rob Murray
5ef5ca3adc EnableIPv4 will be in API 1.48, not 1.47
Numbering has changed since commit d4d8611164

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-15 18:21:25 +00:00
Sebastiaan van Stijn
1a16f5099b daemon/logger: logDriverError: use WithFields for logs
Slightly more performant than multiple `WithField` calls

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-15 18:24:41 +01:00
Sebastiaan van Stijn
b0431a07fd Merge pull request #48884 from thaJeztah/more_build_tags
fix missing go:build tags
2024-11-15 15:00:08 +01:00
Sebastiaan van Stijn
9a808f8b95 Merge pull request #48873 from thaJeztah/austin_maintainer
Move Austin Vazquez (austinvazquez) to maintainers
2024-11-15 13:57:36 +01:00
Rob Murray
4e1b178fc3 Merge pull request #48857 from robmry/fix_hosts_update_for_net_disconnect
Fix /etc/hosts update for net disconnect
2024-11-15 12:17:41 +00:00
Sebastiaan van Stijn
451fee91c5 libnetwork: add missing go:build tag
This was introduced in 18327745c00d4d2e98e5ea7241c1a1ef43b0401b;

    make BIND_DIR=. shell
    make -C ./internal/gocompat/
    GO111MODULE=on go test -v
    # github.com/docker/docker/libnetwork
    ../../libnetwork/sandbox.go:588:6: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    FAIL	gocompat [build failed]

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-15 12:53:42 +01:00
Sebastiaan van Stijn
0f0c5eeaca api/server/router/container: add missing go:build tag
This was introduced in 3f2e9da0100af2ceb3ef0d6431cb2b27dc3e1e49;

    make BIND_DIR=. shell
    make -C ./internal/gocompat/
    GO111MODULE=on go test -v
    # github.com/docker/docker/api/server/router/container
    ../../api/server/router/container/inspect.go:29:18: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    FAIL	gocompat [build failed]

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-15 12:53:20 +01:00
Sebastiaan van Stijn
835b1f1063 daemon/containerd: add missing go:build tag
This was introduced in ba454f573b02922340761c0d44687c0b5daa60a6;

    make BIND_DIR=. shell
    make -C ./internal/gocompat/
    GO111MODULE=on go test -v
    # github.com/docker/docker/daemon/containerd
    ../../daemon/containerd/image_inspect.go:107:18: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    FAIL	gocompat [build failed]

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-15 12:52:14 +01:00
Rob Murray
354dfdb928 Delete /etc/hosts entries on network disconnect
Delete the entries that were added, rather than looking at the service
map (DNS config) and trying to delete entries without accounting for
the container's --hostname.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-15 10:58:30 +00:00
Paweł Gronowski
e1dd1c5d1d Merge pull request #47955 from CharityKathure/windows-containerd-as-managed-process
Windows: Run containerd as managed process
2024-11-15 10:20:18 +00:00
Albin Kerouanton
4c19680fc5 Merge pull request #48854 from robmry/12632_noproxy_masquerade
Only masquerade access to own published ports for userland-proxy=false
2024-11-15 09:38:32 +01:00
Sebastiaan van Stijn
cd8d2c56c3 Merge pull request #48861 from vvoland/c8d-list-index
c8d/list: Return `Descriptor`
2024-11-14 21:27:45 +01:00
Sebastiaan van Stijn
c1bf84fdbc Move Austin Vazquez (austinvazquez) to maintainers
I nominated Austin to become a maintainer last week, and we reached a
majority with no blocking votes, so opening a PR to move Austin to the
maintainers section.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 19:56:35 +01:00
Sebastiaan van Stijn
82fdae7730 daemon/images: fix godoc for ImageActions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 19:39:13 +01:00
Sebastiaan van Stijn
da3cc1c8eb Merge pull request #48866 from thaJeztah/bump_compose_buildx
Dockerfile: update buildx to v0.18.0, compose to v2.30.3
2024-11-14 12:35:41 +01:00
Sebastiaan van Stijn
4a2c48e231 Dockerfile: update compose to v2.30.3
Update the compose cli plugin used in the dev-container

full diff: https://github.com/docker/compose/compare/v2.29.7...v2.30.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 10:50:26 +01:00
Sebastiaan van Stijn
ee95c7bd89 Dockerfile: update buildx to v0.18.0
Update the buildx cli plugin used in the dev-container

full diff: https://github.com/docker/buildx/compare/0.17.1..0.18.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-14 10:49:50 +01:00
Sebastiaan van Stijn
a2f7293405 Merge pull request #48860 from vvoland/hack-features-c8d
hack: Add explicit containerd feature to `daemon.json`
2024-11-13 22:21:42 +01:00
Rob Murray
8a81a97af5 Only delete /etc/hosts entries for disconnected network
When a container is connected to a network, it gets /etc/hosts
entries for its addresses on that network. So, when it's connected
to two networks, it has a hosts entry for each. For example, if
the hostname is the default short-id and it's connected to two
networks (172.19.0.0/16 and 172.20.0.0/17, plus IPv6 address for
each), the hosts file might include:

  172.19.0.2	4b92a573912d
  fd8c:c894:d68::2	4b92a573912d
  172.20.0.2	4b92a573912d
  fd8c:c894:d68:1::2	4b92a573912d

If the container is disconnected from 172.19.0.2, only remove
the hosts entries with addresses on that network.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-13 19:35:58 +00:00
Sebastiaan van Stijn
d0a4bbced2 Merge pull request #48862 from thaJeztah/deprecate_pkg_platform
deprecate pkg/platform and move internal
2024-11-13 18:23:58 +01:00
Sebastiaan van Stijn
b034dc41a2 deprecate pkg/platform and move internal
Functions in this package are only used internally in the daemon for
the `/info` endpoint (Architecture), and as part of `stats` (NumProcs).

I was not able to find external consumers, but deprecating the package
first, so that we can remove / dismantle the package in a follow-up.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-13 15:05:56 +01:00
Paweł Gronowski
b15cd283d8 c8d/list: Return Descriptor
While the endpoint returns a detailed information about its children, it
doesn't actually expose the descriptor of the root OCI index/manifest
list.
This commits adds the target description to the returned JSON.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-13 15:02:18 +01:00
Paweł Gronowski
fc590032f3 hack: Add explicit containerd feature to daemon.json
While it's still turned off by default, it's easier to just flip the
`false` to `true` inside the devcontainer.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-13 14:45:01 +01:00
Sebastiaan van Stijn
a95a6788b5 Merge pull request #48856 from thaJeztah/copyloopvar
update go:build tags to use go1.22, and enable copyloopvar linter
2024-11-12 18:01:58 +01:00
Sebastiaan van Stijn
ae21b3c8ac Merge pull request #48756 from akerouanton/reduce-number-of-firewalld-jobs
ci: re-add firewalld jobs
2024-11-12 15:34:57 +01:00
Sebastiaan van Stijn
7d89d83485 golangci-lint: enable copyloopvar linter
go1.22 now creates a copy of variables when assigned in a loop; enable the
copyloopvar linter to find locations where we capture loop vars that are
now redundant; https://go.dev/ref/spec#Go_1.22

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:19 +01:00
Sebastiaan van Stijn
d67a21b6fc pkg/idtools: remove redundant capturing of loop vars (copyloopvar)
pkg/idtools/idtools_unix_test.go:188:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:19 +01:00
Sebastiaan van Stijn
3350920788 integration/service: remove redundant capturing of loop vars (copyloopvar)
integration/service/update_test.go:290:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:19 +01:00
Sebastiaan van Stijn
70b354713b runconfig: remove redundant capturing of loop vars (copyloopvar)
runconfig/config_test.go:43:3: The copy of the 'for' variable "f" can be deleted (Go 1.22+) (copyloopvar)
            f := f
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:19 +01:00
Sebastiaan van Stijn
1a89c1e4a6 pkg/archive: remove redundant capturing of loop vars (copyloopvar)
pkg/archive/archive_test.go:820:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:19 +01:00
Sebastiaan van Stijn
517baee5f2 distribution: remove redundant capturing of loop vars (copyloopvar)
distribution/pull_v2_test.go:290:3: The copy of the 'for' variable "tt" can be deleted (Go 1.22+) (copyloopvar)
            tt := tt
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:18 +01:00
Sebastiaan van Stijn
04d8766d4e integration/network/bridge: remove redundant capturing of loop vars (copyloopvar)
integration/network/bridge/bridge_linux_test.go:177:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:18 +01:00
Sebastiaan van Stijn
020b7102e3 daemon/logger/syslog: remove redundant capturing of loop vars (copyloopvar)
daemon/logger/syslog/syslog_test.go:113:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:18 +01:00
Sebastiaan van Stijn
59f68d3f99 api/server/middleware: remove redundant capturing of loop vars (copyloopvar)
api/server/middleware/version_test.go:59:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:18 +01:00
Sebastiaan van Stijn
243442280e integration/system: remove redundant capturing of loop vars (copyloopvar)
integration/system/disk_usage_test.go:261:5: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
                    tc := tc
                    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:18 +01:00
Sebastiaan van Stijn
bb682f75f9 integration-cli: remove redundant capturing of loop vars (copyloopvar)
integration-cli/docker_api_containers_test.go:1748:3: The copy of the 'for' variable "x" can be deleted (Go 1.22+) (copyloopvar)
            x := x
            ^
    integration-cli/docker_api_containers_test.go:1916:3: The copy of the 'for' variable "x" can be deleted (Go 1.22+) (copyloopvar)
            x := x
            ^
    integration-cli/docker_cli_build_test.go:6203:3: The copy of the 'for' variable "builder" can be deleted (Go 1.22+) (copyloopvar)
            builder := builder
            ^
    integration-cli/docker_cli_build_test.go:6227:4: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
                tc := tc
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:17 +01:00
Sebastiaan van Stijn
a19b892c29 integration/volume: remove redundant capturing of loop vars (copyloopvar)
integration/volume/volume_test.go:202:3: The copy of the 'for' variable "ep" can be deleted (Go 1.22+) (copyloopvar)
            ep := ep
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:17 +01:00
Sebastiaan van Stijn
cd5e043aff daemon/cluster/executor/container: remove redundant capturing of loop vars (copyloopvar)
daemon/cluster/executor/container/adapter.go:449:3: The copy of the 'for' variable "mount" can be deleted (Go 1.22+) (copyloopvar)
            mount := mount
            ^
    daemon/cluster/executor/container/container_test.go:124:3: The copy of the 'for' variable "c" can be deleted (Go 1.22+) (copyloopvar)
            c := c
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:17 +01:00
Sebastiaan van Stijn
f797d70649 api/types/container: remove redundant capturing of loop vars (copyloopvar)
api/types/container/hostconfig_test.go:94:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:17 +01:00
Sebastiaan van Stijn
08dbb7a593 integration/build: remove redundant capturing of loop vars (copyloopvar)
integration/build/build_test.go:95:3: The copy of the 'for' variable "c" can be deleted (Go 1.22+) (copyloopvar)
            c := c
            ^
    integration/build/build_test.go:615:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/build/build_test.go:743:3: The copy of the 'for' variable "builderVersion" can be deleted (Go 1.22+) (copyloopvar)
            builderVersion := builderVersion
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:17 +01:00
Sebastiaan van Stijn
ee54e43bf1 integration/daemon: remove redundant capturing of loop vars (copyloopvar)
integration/daemon/daemon_test.go:115:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/daemon/daemon_test.go:161:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/daemon/daemon_test.go:234:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:16 +01:00
Sebastiaan van Stijn
9a7278fbdc integration/capabilities: remove redundant capturing of loop vars (copyloopvar)
integration/capabilities/capabilities_linux_test.go:73:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:16 +01:00
Sebastiaan van Stijn
ff97ff8320 daemon/logger/loggerutils: remove redundant capturing of loop vars (copyloopvar)
daemon/logger/loggerutils/logfile.go:809:3: The copy of the 'for' variable "ra" can be deleted (Go 1.22+) (copyloopvar)
            ra := ra
            ^
    daemon/logger/loggerutils/sharedtemp_test.go:117:4: The copy of the 'for' variable "i" can be deleted (Go 1.22+) (copyloopvar)
                i := i
                ^
    daemon/logger/loggerutils/sharedtemp_test.go:179:4: The copy of the 'for' variable "i" can be deleted (Go 1.22+) (copyloopvar)
                i := i
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:16 +01:00
Sebastiaan van Stijn
67d91e7622 volume/local: remove redundant capturing of loop vars (copyloopvar)
volume/local/local_linux_test.go:232:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    volume/local/local_linux_test.go:316:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:16 +01:00
Sebastiaan van Stijn
f7b547ba0d integration/network/ipvlan: remove redundant capturing of loop vars (copyloopvar)
integration/network/ipvlan/ipvlan_test.go:499:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:15 +01:00
Sebastiaan van Stijn
b5c0f6cd70 daemon: remove redundant capturing of loop vars (copyloopvar)
daemon/daemon_unix_test.go:277:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/delete_test.go:71:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/exec_linux_test.go:65:4: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
                tc := tc
                ^
    daemon/info_unix_test.go:54:3: The copy of the 'for' variable "test" can be deleted (Go 1.22+) (copyloopvar)
            test := test
            ^
    daemon/runtime_unix_test.go:173:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/runtime_unix_test.go:333:3: The copy of the 'for' variable "tt" can be deleted (Go 1.22+) (copyloopvar)
            tt := tt
            ^
    daemon/seccomp_linux_test.go:194:3: The copy of the 'for' variable "x" can be deleted (Go 1.22+) (copyloopvar)
            x := x
            ^
    daemon/top_unix_test.go:88:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:15 +01:00
Sebastiaan van Stijn
d885d097ef libnetwork/ipams/defaultipam: remove redundant capturing of loop vars (copyloopvar)
libnetwork/ipams/defaultipam/parallel_test.go:231:3: The copy of the 'for' variable "index" can be deleted (Go 1.22+) (copyloopvar)
            index := index
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:15 +01:00
Sebastiaan van Stijn
7db58fefdc internal/mod: remove redundant capturing of loop vars (copyloopvar)
internal/mod/mod_test.go:62:3: The copy of the 'for' variable "tt" can be deleted (Go 1.22+) (copyloopvar)
            tt := tt
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:15 +01:00
Sebastiaan van Stijn
74e44345e7 distribution/xfer: remove redundant capturing of loop vars (copyloopvar)
distribution/xfer/download_test.go:394:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:15 +01:00
Sebastiaan van Stijn
874ad2fcf0 api/types/filters: remove redundant capturing of loop vars (copyloopvar)
api/types/filters/parse_test.go:543:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:14 +01:00
Sebastiaan van Stijn
3a34264129 volume/mounts: remove redundant capturing of loop vars (copyloopvar)
volume/mounts/lcow_parser_test.go:260:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    volume/mounts/linux_parser_test.go:253:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    volume/mounts/parser_test.go:82:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    volume/mounts/validate_test.go:59:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    volume/mounts/validate_test.go:117:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    volume/mounts/windows_parser_test.go:283:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:14 +01:00
Sebastiaan van Stijn
a505b19170 integration/plugin/common: remove redundant capturing of loop vars (copyloopvar)
integration/plugin/common/plugin_test.go:46:3: The copy of the 'for' variable "ep" can be deleted (Go 1.22+) (copyloopvar)
            ep := ep
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:14 +01:00
Sebastiaan van Stijn
742509150b libnetwork/bitmap: remove redundant capturing of loop vars (copyloopvar)
libnetwork/bitmap/sequence_test.go:1210:3: The copy of the 'for' variable "tt" can be deleted (Go 1.22+) (copyloopvar)
            tt := tt
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:14 +01:00
Sebastiaan van Stijn
082a52e8ac oci: remove redundant capturing of loop vars (copyloopvar)
oci/oci_test.go:157:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:14 +01:00
Sebastiaan van Stijn
e9b009fef5 integration/networking: remove redundant capturing of loop vars (copyloopvar)
integration/networking/bridge_linux_test.go:648:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:13 +01:00
Sebastiaan van Stijn
0b2d687b06 daemon/containerd: remove redundant capturing of loop vars (copyloopvar)
daemon/containerd/image_list.go:162:3: The copy of the 'for' variable "img" can be deleted (Go 1.22+) (copyloopvar)
            img := img
            ^
    daemon/containerd/image_delete_test.go:222:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/containerd/image_list_test.go:89:3: The copy of the 'for' variable "count" can be deleted (Go 1.22+) (copyloopvar)
            count := count
            ^
    daemon/containerd/image_list_test.go:306:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/containerd/image_test.go:145:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/containerd/platform_matchers_test.go:131:4: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
                tc := tc
                ^
    daemon/containerd/platform_matchers_test.go:134:5: The copy of the 'for' variable "strict" can be deleted (Go 1.22+) (copyloopvar)
                    strict := strict
                    ^
    daemon/containerd/platform_matchers_test.go:159:7: The copy of the 'for' variable "p" can be deleted (Go 1.22+) (copyloopvar)
                            p := p
                            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:13 +01:00
Sebastiaan van Stijn
b5b077f2ea api/types/network: remove redundant capturing of loop vars (copyloopvar)
api/types/network/endpoint_test.go:84:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    api/types/network/endpoint_test.go:166:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    api/types/network/ipam_test.go:127:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:13 +01:00
Sebastiaan van Stijn
0fc7b1c201 daemon/cluster/convert: remove redundant capturing of loop vars (copyloopvar)
daemon/cluster/convert/service_test.go:312:3: The copy of the 'for' variable "c" can be deleted (Go 1.22+) (copyloopvar)
            c := c
            ^
    daemon/cluster/convert/service_test.go:375:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/cluster/convert/volume_test.go:64:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/cluster/convert/volume_test.go:116:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:13 +01:00
Sebastiaan van Stijn
6a85a13c0a internal/testutils/specialimage: remove redundant capturing of loop vars (copyloopvar)
internal/testutils/specialimage/partial.go:41:3: The copy of the 'for' variable "platform" can be deleted (Go 1.22+) (copyloopvar)
            platform := platform
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:13 +01:00
Sebastiaan van Stijn
1c6958bf13 integration/network/macvlan: remove redundant capturing of loop vars (copyloopvar)
integration/network/macvlan/macvlan_test.go:97:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/network/macvlan/macvlan_test.go:496:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:12 +01:00
Sebastiaan van Stijn
88e24ccda6 image/cache: remove redundant capturing of loop vars (copyloopvar)
image/cache/compare_test.go:195:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:12 +01:00
Sebastiaan van Stijn
89add8c64f libnetwork/drivers/overlay: remove redundant capturing of loop vars (copyloopvar)
libnetwork/drivers/overlay/encryption.go:682:3: The copy of the 'for' variable "sp" can be deleted (Go 1.22+) (copyloopvar)
            sp := sp
            ^
    libnetwork/drivers/overlay/encryption.go:692:3: The copy of the 'for' variable "sa" can be deleted (Go 1.22+) (copyloopvar)
            sa := sa
            ^
    libnetwork/drivers/overlay/peerdb.go:134:3: The copy of the 'for' variable "pEntry" can be deleted (Go 1.22+) (copyloopvar)
            pEntry := pEntry
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:12 +01:00
Sebastiaan van Stijn
ce1a39ab34 client: remove redundant capturing of loop vars (copyloopvar)
client/client_test.go:91:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    client/client_test.go:326:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    client/client_test.go:481:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    client/image_list_test.go:183:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    client/image_push_test.go:163:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    client/image_tag_test.go:50:3: The copy of the 'for' variable "repo" can be deleted (Go 1.22+) (copyloopvar)
            repo := repo
            ^
    client/image_tag_test.go:61:3: The copy of the 'for' variable "repotag" can be deleted (Go 1.22+) (copyloopvar)
            repotag := repotag
            ^
    client/ping_test.go:114:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    client/request_test.go:53:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:12 +01:00
Sebastiaan van Stijn
ea10382ffa integration/image: remove redundant capturing of loop vars (copyloopvar)
integration/image/import_test.go:107:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/image/import_test.go:174:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/image/list_test.go:189:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/image/prune_test.go:193:4: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
                tc := tc
                ^
    integration/image/pull_test.go:177:3: The copy of the 'for' variable "ref" can be deleted (Go 1.22+) (copyloopvar)
            ref := ref
            ^
    integration/image/save_test.go:136:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/image/tag_test.go:44:3: The copy of the 'for' variable "repo" can be deleted (Go 1.22+) (copyloopvar)
            repo := repo
            ^
    integration/image/tag_test.go:77:3: The copy of the 'for' variable "name" can be deleted (Go 1.22+) (copyloopvar)
            name := name
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:12 +01:00
Sebastiaan van Stijn
69d0c773ca daemon/logger/fluentd: remove redundant capturing of loop vars (copyloopvar)
daemon/logger/fluentd/fluentd_test.go:172:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:11 +01:00
Sebastiaan van Stijn
c2e22d85b3 api/server/httputils: remove redundant capturing of loop vars (copyloopvar)
api/server/httputils/form_test.go:152:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:11 +01:00
Sebastiaan van Stijn
aea8a0724a integration/network: remove redundant capturing of loop vars (copyloopvar)
integration/network/inspect_test.go:77:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    integration/network/network_test.go:81:3: The copy of the 'for' variable "ep" can be deleted (Go 1.22+) (copyloopvar)
            ep := ep
            ^
    integration/network/network_test.go:143:3: The copy of the 'for' variable "ep" can be deleted (Go 1.22+) (copyloopvar)
            ep := ep
            ^
    integration/network/network_test.go:221:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:11 +01:00
Sebastiaan van Stijn
f0b896c5f2 builder/remotecontext/git: remove redundant capturing of loop vars (copyloopvar)
builder/remotecontext/git/gitutils_test.go:116:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:11 +01:00
Sebastiaan van Stijn
4768d680d1 libcontainerd/remote: remove redundant capturing of loop vars (copyloopvar)
pkg/idtools/idtools_unix_test.go:188:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:11 +01:00
Sebastiaan van Stijn
443a074fa4 profiles/seccomp: remove redundant capturing of loop vars (copyloopvar)
profiles/seccomp/kernel_linux_test.go:52:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    profiles/seccomp/kernel_linux_test.go:111:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    profiles/seccomp/seccomp_test.go:135:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    profiles/seccomp/seccomp_test.go:223:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    profiles/seccomp/seccomp_test.go:265:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:10 +01:00
Sebastiaan van Stijn
93f98535c3 daemon/logger/loggertest: remove redundant capturing of loop vars (copyloopvar)
daemon/logger/loggertest/logreader.go:183:3: The copy of the 'for' variable "tt" can be deleted (Go 1.22+) (copyloopvar)
            tt := tt
            ^
    daemon/logger/loggertest/logreader.go:201:3: The copy of the 'for' variable "i" can be deleted (Go 1.22+) (copyloopvar)
            i, tail := i, tail
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:10 +01:00
Sebastiaan van Stijn
35aa84fbc2 pkg/plugins: remove redundant capturing of loop vars (copyloopvar)
pkg/plugins/client_test.go:108:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    pkg/plugins/client_test.go:132:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:10 +01:00
Sebastiaan van Stijn
63f0b9a1d5 opts: remove redundant capturing of loop vars (copyloopvar)
opts/env_test.go:107:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    opts/opts_test.go:72:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    opts/opts_test.go:303:3: The copy of the 'for' variable "testCase" can be deleted (Go 1.22+) (copyloopvar)
            testCase := testCase
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:10 +01:00
Sebastiaan van Stijn
c0de852afa integration/config: remove redundant capturing of loop vars (copyloopvar)
integration/config/config_test.go:111:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:10 +01:00
Sebastiaan van Stijn
41bf78226f daemon/config: remove redundant capturing of loop vars (copyloopvar)
daemon/config/config_linux_test.go:167:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/config/config_test.go:550:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    daemon/config/config_test.go:581:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:10 +01:00
Sebastiaan van Stijn
b01a37a6b7 libnetwork/drivers/bridge: remove redundant capturing of loop vars (copyloopvar)
libnetwork/drivers/bridge/bridge_linux_test.go:1079:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    libnetwork/drivers/bridge/port_mapping_linux_test.go:763:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:09 +01:00
Sebastiaan van Stijn
53e48e8623 libnetwork: remove redundant capturing of loop vars (copyloopvar)
libnetwork/endpoint_info.go:467:3: The copy of the 'for' variable "r" can be deleted (Go 1.22+) (copyloopvar)
            r := r
            ^
    libnetwork/firewall_linux_test.go:52:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    libnetwork/libnetwork_internal_test.go:403:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    libnetwork/libnetwork_linux_test.go:2045:3: The copy of the 'for' variable "i" can be deleted (Go 1.22+) (copyloopvar)
            i := i
            ^
    libnetwork/libnetwork_linux_test.go:2165:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:09 +01:00
Sebastiaan van Stijn
8b190b16df registry: remove redundant capturing of loop vars (copyloopvar)
registry/search_endpoint_v1_test.go:140:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    registry/search_test.go:134:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^
    registry/search_test.go:397:3: The copy of the 'for' variable "tc" can be deleted (Go 1.22+) (copyloopvar)
            tc := tc
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:09 +01:00
Sebastiaan van Stijn
21e1038d12 golanci-lint: sync comments with docker/cli
Using the same descriptions as used in docker/cli to make it
easier to compare configurations between both repositories.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-12 14:02:09 +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
Paweł Gronowski
615d72a9b9 Merge pull request #48848 from thaJeztah/update_registry
Dockerfile: update registry to v3.0.0-rc.1
2024-11-12 12:43:07 +00:00
Rob Murray
bf251c33d0 Only masquerade access to own published ports for userland-proxy=false
When a container sends a packet to one of its own published ports on the
host, it's normally picked up by the userland proxy and sent back.

When the userland proxy is disabled, a masquerade rule is needed in
order for responses to the container to have the host's source address.

The masquerade rule matches the container's address as source and dest,
and the published port as the dest. It's only used for the no-proxy
case.

So, when the userland proxy is enabled, don't create the masquerade
rule.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-12 12:37:25 +00:00
Sebastiaan van Stijn
5fa779e532 Merge pull request #48846 from pinglanlu/master
chore(libnetwork): fix some comments
2024-11-11 16:14:57 +01:00
Sebastiaan van Stijn
e53b1fa511 Merge pull request #48594 from robmry/48365_iptables_forward_policy
Only set ip6tables filter-FORWARD DROP if necessary
2024-11-11 14:23:51 +01:00
Rob Murray
3dea9fd4e6 Add TestFilterForwardPolicy
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-11 12:12:57 +00:00
Rob Murray
3cadadb4eb Add daemon option --ip-forward-no-drop
The daemon no longer depends on the iptables/ip6tables filter-FORWARD
chain's policy being DROP in order to implement its port filtering
rules.

However, if the daemon enables IP forwarding in the host's system
config, by default it will set the policy to DROP to avoid potential
security issues for other applications/networks.

If docker does need to enable IP forwarding, but other applications
on the host require filter-FORWARD's policies to be ACCEPT, this
option can be used to tell the daemon to leave the policy unchanged.
(Equivalent to enabling IP forwarding before starting the daemon,
but without needing to do that.)

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-11 12:12:57 +00:00
Rob Murray
5823b05c97 Modify IP forwarding and filter-FORWARD DROP setup.
Before this change, for IPv4:
- sysctl net.ipv4.ip_forward was enabled during bridge driver
  initialisation, if:
  - not already enabled
  - ip-forward=true, and
  - iptables=true.
- the filter-FORWARD chain's policy was set to DROP, if the daemon
  updated the sysctl.
- if setting the policy failed, the sysctl change was reverted.

But, for IPv6:
- sysctls net.ipv6.conf.[default|all].forwarding were both enabled
  when creating the first IPv6-enabled network, if:
  - they weren't already enabled,
  - ip-forward=true, and
  - ip6tables=true.
- the filter-FORWARD chain's policy was set to DROP when creating
  an IPv4 enabled bridge network (inc. the default bridge), if:
  - ip6tables=true.
  - (this happened whether or not the daemon would ever enable
    IPv6 forwarding, or even create an IPv6 network.)

The bridge driver no longer needs the default policy to be DROP to
implement its own port-filtering rules. But, enabling IP forwarding
without setting the filter-FORWARD policy to DROP would potentially
be a security risk.

This change aligns IPv4 and IPv6 behaviours:
- only try to set the sysctls when creating a bridge network that
  needs them (for IPv4, that's still during daemon init because
  the default bridge is IPv4 enabled).
- only check/set the filter-FORWARD policy after updating sysctls.
- if the filter-FORWARD policy can't be set, treat it as an error
  and revert sysctl changes.

We enabled ip6tables by default in 27.0. Setting the filter-FORWARD
policy to DROP even when no IPv6 enabled network was created
caused issues for some users. In particular, those running with
iptables=false suddenly got the IPv6 DROP policy enabled (which
broke unrelated services on the host). This change solves that by
only setting the policy when necessary.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-11 12:08:43 +00:00
Rob Murray
a4d74c6383 Move setupIPv6Forwarding() to setup_ip_forwarding.go
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-11 12:08:43 +00:00
Rob Murray
24f53eba7f Move integration/network/bridge_test.go to bridge subdir
Also make it Linux-only, as the bridge driver is Linux only and
all of the tests had skips for Windows.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-11 12:08:43 +00:00
Sebastiaan van Stijn
ca273f465a Dockerfile: update registry to v3.0.0-rc.1
release notes: https://github.com/distribution/distribution/releases/tag/v3.0.0-rc.1
full diff: https://github.com/distribution/distribution/compare/v3.0.0-beta.1...v3.0.0-rc.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-11 12:57:31 +01:00
pinglanlu
c9570da15b chore(libnetwork): fix some comments
Signed-off-by: pinglanlu <pinglanlu@outlook.com>
2024-11-11 18:19:04 +08:00
Sebastiaan van Stijn
48e43eb860 Merge pull request #48836 from tonistiigi/buildkit-v0.17.1
vendor: update buildkit to v0.17.1
2024-11-08 13:39:58 +01:00
Tonis Tiigi
756586e437 vendor: update buildkit to v0.17.1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-11-07 17:23:17 -08:00
Sebastiaan van Stijn
222b3a9e5c Merge pull request #48834 from vvoland/gounits-alias
all: Remove redundant `units` alias for `go-units`
2024-11-07 19:37:19 +01:00
Sebastiaan van Stijn
0a3831d939 Merge pull request #48323 from robmry/v6only/bridge
IPv6 only: changes to bridge driver and gateway Endpoint selection
2024-11-07 19:34:11 +01:00
Sebastiaan van Stijn
1f44d54913 Merge pull request #48831 from vvoland/update-go
update to go1.23.3
2024-11-07 18:21:06 +01:00
Rob Murray
a6e5f7f86b Structured logs in sbJoin/sbLeave and funcs they call
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-07 17:17:21 +00:00
Rob Murray
18327745c0 Allow separate IPv4/IPv6 gateway endpoints.
A dual-stack endpoint still has priority when selecting a gateway
Endpoint for a Sandbox. But, now there are IPv6-only networks, it
is possible to have a Sandbox with only IPv4-only and IPv6-only
endpoints. This change means they are both gateway endpoints.

Tell the network driver it mustn't proxy host-IPv6 to endpoint-IPv4
when there's an IPv6 gateway endpoint (which may belong to a different
net driver). Update that when networks are connected/disconnected.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-07 17:17:21 +00:00
Rob Murray
869f7996fc Option to disable implicit mapping IPv6 host to IPv4.
When the host has IPv6 support but the container doesn't, the
default bind address is 0.0.0.0, and a port mapping does not
include a host address - the default behaviour (of the bridge
driver) is to run a docker-proxy to map from any IPv6 host
address to the IPv4 address of a container's gateway endpoint.

Driver option com.docker.network.driver.private.no_proxy_6to4
can now be used to disable that behaviour when configuring
a Sandbox's external connectivity.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-07 17:17:21 +00:00
Rob Murray
4ac7f14e99 Add EnableIPv4 to the bridge driver
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-07 17:17:21 +00:00
Sebastiaan van Stijn
9ecf18cf04 Merge pull request #48825 from thaJeztah/update_linting
golangci: enable all govet linters, run gosec on tests as well
2024-11-07 17:14:49 +01:00
Paweł Gronowski
c0045476b8 all: Remove redundant units alias for go-units
The alias is not needed as the package is already named `units`.
It was also not aliases consistently across the project.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-07 15:55:16 +01:00
Sebastiaan van Stijn
66d45fa56c Merge pull request #48823 from robmry/simplify_etchosts
Improve /etc/hosts generation
2024-11-07 13:30:46 +01:00
Paweł Gronowski
20818454c4 update to go1.23.3
- https://github.com/golang/go/issues?q=milestone%3AGo1.23.3+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.23.2...go1.23.3

go1.23.3 (released 2024-11-06) includes fixes to the linker, the
runtime, and the net/http, os, and syscall packages. See the Go 1.23.3
milestone on our issue tracker for details.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-07 13:22:47 +01:00
Sebastiaan van Stijn
ecb028741a Merge pull request #48827 from thaJeztah/bump_typeurl
vendor: github.com/containerd/typeurl v2.2.3
2024-11-07 13:01:50 +01:00
Rob Murray
16f6fd1a95 Add a comment explaining host-networking hosts file generation
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-07 11:18:06 +00:00
Sebastiaan van Stijn
7c1e41a06d libnetwork: Sandbox.buildHostsFile: remove intermediate var
Call the respective (`etchosts.BuildNoIPv6` or `etchosts.Build`) functions
directly instead of using the intermediate `buildf` variable.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-07 11:06:34 +00:00
Sebastiaan van Stijn
6a5ab42f28 libnetwork/etchosts: Delete: truncate file instead of close and write
We already have the filehandle open, so we could just truncate, and
overwrite the content.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-07 11:06:34 +00:00
Sebastiaan van Stijn
7d98e45a6e libnetwork/etchosts: Add: combine with "mergeRecords()"
The `mergeRecords` function wasn't actually _merging_ anything, but only
appended records to the existing `/etc/hosts` content. However, doing so
was split across two functions; `Add` and `mergeRecords()`;

- `Add()` obtains a lock for the given path
- then calls `mergeRecords` which reads the file-content and appends the
  new records to the content.
- Closes the file and returns the new content
- Then `Add` does a `os.WriteFile` to ... the same file

Given that we're appending, we won't have to read the file's content, and
we can append to the file itself.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-07 11:06:34 +00:00
Sebastiaan van Stijn
28d029cf9f libnetwork/etchosts: don't panic on invalid regex
This regex is constructed using user-input, which could technically
produce an invalid regex.

Given that we have an error-return to our availability, let's return
any error we get, instead of panicking.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-07 11:06:34 +00:00
Rob Murray
80e4631998 Use netip.Addr instead of string when building /etc/hosts
Also, libnetwork: Sandbox.buildHostsFile: rename var that shadowed type

Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-07 11:05:34 +00:00
Rob Murray
c2a09d2721 Don't update /etc/hosts separately for each initial network
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-07 10:22:38 +00:00
Sebastiaan van Stijn
0af6203b46 vendor: github.com/containerd/typeurl v2.2.3
- add a `no_gogo` build-tag to allow compiling without support for gogoproto (github.com/gogo/protobuf)
- fix panic when type is not found and no handler is hit.
- fix unmarshalling of registered types

full diff: https://github.com/containerd/typeurl/compare/v2.2.0...v2.2.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-07 09:25:25 +01:00
Charity Kathure
84965c0752 Windows: Run containerd as managed process
Signed-off-by: Charity Kathure <ckathure@microsoft.com>
Co-authored-by: Olli Janatuinen <olli.janatuinen@gmail.com>
2024-11-06 21:04:31 +03:00
Sebastiaan van Stijn
4f4e34f33a Merge pull request #48357 from vvoland/improve-docs
api/swagger: Improve description for platform in images/push
2024-11-06 15:47:22 +01:00
Paweł Gronowski
5014c90516 api/swagger: Improve description for platform in images/push
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-11-06 13:14:20 +01:00
Sebastiaan van Stijn
7766b35d74 golangci: govet: enable more rules
Enable all rules, except for fieldalignment, which needs some work.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:59 +01:00
Sebastiaan van Stijn
24bd11ce22 pkg/plugins: TestLocalSocket ignore deepequalerrors (govet)
govet produces this linting warning because the Plugin types that are
compared contain a activateErr field. This should be fine to ignore here.

    pkg/plugins/discovery_unix_test.go:48:7: deepequalerrors: avoid using reflect.DeepEqual with errors (govet)
            if !reflect.DeepEqual(p, pp) {
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:54 +01:00
Sebastiaan van Stijn
626d9b421b distribution: TestLayerAlreadyExists: fix deepequalerrors (govet)
distribution/push_v2_test.go:417:7: deepequalerrors: avoid using reflect.DeepEqual with errors (govet)
            if !reflect.DeepEqual(err, tc.expectedError) {
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:54 +01:00
Sebastiaan van Stijn
06bf2a2699 distribution: manifestStore.Put: fix unusedwrite (govet)
This was added in 9ca3bb632e, but looks like
the manifest-type was never used.

    distribution/manifest.go:236:7: unusedwrite: unused write to field MediaType (govet)
        desc.MediaType = mt
             ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:54 +01:00
Sebastiaan van Stijn
facdfc1751 daemon/images: onlyFallbackMatcher.Match: fix unusedwrite (govet)
daemon/images/image.go:269:9: unusedwrite: unused write to field Variant (govet)
        otherN.Variant = "" // normalization adds a default variant... which is the whole problem with `platforms.Only`
               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:53 +01:00
Sebastiaan van Stijn
406e3a0ff7 daemon/containerd: storeJson: fix redundant err-check (govet)
daemon/containerd/image_import.go:370:9: nilness: impossible condition: nil != nil (govet)
        if err != nil {
               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:53 +01:00
Sebastiaan van Stijn
8e76998aee integration-cli: loadSpecialImage: fix shadowed variables (govet)
integration-cli/docker_utils_test.go:492:3: shadow: declaration of "line" shadows declaration at line 491 (govet)
            line := strings.TrimSpace(line)
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:53 +01:00
Sebastiaan van Stijn
a0b84a34c2 layer: verifiedReadCloser.Read: fix shadowed variables (govet)
layer/ro_layer.go:167:6: shadow: declaration of "n" shadows declaration at line 164 (govet)
            if n, err := vrc.verifier.Write(p[:n]); err != nil {
               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:53 +01:00
Sebastiaan van Stijn
38db7265fc pkg/plugins: loadWithRetry: fix shadowed variables (govet)
pkg/plugins/plugins.go:231:6: shadow: declaration of "pl" shadows declaration at line 214 (govet)
            if pl, exists := storage.plugins[name]; exists {
               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:53 +01:00
Sebastiaan van Stijn
a28e6e2d21 daemon/graphdriver/btrfs: Driver.parseStorageOpt: fix shadowed variables (govet)
daemon/graphdriver/btrfs/btrfs.go:562:3: shadow: declaration of "key" shadows declaration at line 561 (govet)
            key := strings.ToLower(key)
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:52 +01:00
Sebastiaan van Stijn
b3705f12cd distribution: pushDescriptor.layerAlreadyExists: fix shadowed variables (govet)
distribution/push_v2.go:558:9: shadow: declaration of "exists" shadows declaration at line 538 (govet)
            if _, exists := digestToMetadata[meta.Digest]; exists {
                  ^
    distribution/push_v2.go:562:9: shadow: declaration of "exists" shadows declaration at line 538 (govet)
            if _, exists := pd.checkedDigests[meta.Digest]; exists {
                  ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:52 +01:00
Sebastiaan van Stijn
0c8c098719 libnetwork: Network.rmLBBackend: fix shadowed variables (govet)
libnetwork/service_linux.go:226:7: shadow: declaration of "ep" shadows declaration at line 175 (govet)
                if ep := sb.getGatewayEndpoint(); ep != nil {
                   ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:52 +01:00
Sebastiaan van Stijn
544b1574e2 builder/dockerfile: fix shadowed variables (govet)
builder/dockerfile/builder.go:361:2: shadow: declaration of "dispatchRequest" shadows declaration at line 189 (govet)
        dispatchRequest := newDispatchRequest(b, dockerfile.EscapeToken, nil, NewBuildArgs(b.options.BuildArgs), newStagesBuildResults())
        ^
    builder/dockerfile/copy.go:217:2: shadow: declaration of "copyInfo" shadows declaration at line 39 (govet)
        copyInfo, err := copyInfoForFile(o.source, origPath)
        ^
    builder/dockerfile/dispatchers.go:97:2: shadow: declaration of "copyInstruction" shadows declaration at line 60 (govet)
        copyInstruction, err := copier.createCopyInstruction(c.SourcesAndDest, "ADD")
        ^
    builder/dockerfile/dispatchers.go:124:2: shadow: declaration of "copyInstruction" shadows declaration at line 60 (govet)
        copyInstruction, err := copier.createCopyInstruction(c.SourcesAndDest, "COPY")
        ^
    builder/dockerfile/dispatchers.go:162:3: shadow: declaration of "v" shadows declaration at line 161 (govet)
            v, err := d.getExpandedString(d.shlex, v)
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:52 +01:00
Sebastiaan van Stijn
bb9251c46d daemon/containerd: fix shadowed variable in tests (govet)
daemon/containerd/image_test.go:173:3: shadow: declaration of "service" shadows declaration at line 30 (govet)
            service := &ImageService{
            ^
    daemon/containerd/image_test.go:207:3: shadow: declaration of "service" shadows declaration at line 30 (govet)
            service := &ImageService{
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:52 +01:00
Sebastiaan van Stijn
979227484f daemon/containerd: ImageService.imageDeleteHelper: fix shadowed variable (govet)
daemon/containerd/image_delete.go:378:4: shadow: declaration of "img" shadows declaration at line 355 (govet)
                img := images.Image{
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:51 +01:00
Sebastiaan van Stijn
6dc31171c5 builder/builder-next/exporter: patchImageConfig: fix shadowed variable (govet)
builder/builder-next/exporter/mobyexporter/writer.go:83:3: shadow: declaration of "dt" shadows declaration at line 42 (govet)
            dt, err := json.Marshal(cache.Data)
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:51 +01:00
Sebastiaan van Stijn
b019372446 libnetwork/bitmap: fix shadowed variable in tests (govet)
libnetwork/bitmap/sequence_test.go:746:5: shadow: declaration of "o" shadows declaration at line 738 (govet)
        if o, err := hnd.SetAnyInRange(0, uint64(blockLen), false); err == nil {
           ^
    libnetwork/bitmap/sequence_test.go:750:5: shadow: declaration of "o" shadows declaration at line 738 (govet)
        if o, err := hnd.SetAnyInRange(0, firstAv-1, false); err == nil {
           ^
    libnetwork/bitmap/sequence_test.go:754:5: shadow: declaration of "o" shadows declaration at line 738 (govet)
        if o, err := hnd.SetAnyInRange(111*uint64(blockLen), 161*uint64(blockLen), false); err == nil {
           ^
    libnetwork/bitmap/sequence_test.go:793:6: shadow: declaration of "o" shadows declaration at line 738 (govet)
            if o, err := hnd.SetAnyInRange(0, 7, false); err != nil {
               ^
    libnetwork/bitmap/sequence_test.go:808:6: shadow: declaration of "o" shadows declaration at line 738 (govet)
            if o, err := hnd.SetAnyInRange(8, 15, false); err != nil {
               ^
    libnetwork/bitmap/sequence_test.go:824:6: shadow: declaration of "o" shadows declaration at line 738 (govet)
            if o, err := hnd.SetAnyInRange(28, 29, false); err != nil {
               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:51 +01:00
Sebastiaan van Stijn
32aa56af00 pkg/idtools: fix shadowed variable (govet)
pkg/idtools/usergroupadd_linux.go:94:2: shadow: declaration of "ranges" shadows declaration at line 25 (govet)
        ranges, err := parseSubuid(name)
        ^
    pkg/idtools/usergroupadd_linux.go:131:2: shadow: declaration of "ranges" shadows declaration at line 25 (govet)
        ranges, err := parseSubuid("ALL")
        ^
    pkg/idtools/usergroupadd_linux.go:140:2: shadow: declaration of "ranges" shadows declaration at line 25 (govet)
        ranges, err := parseSubgid("ALL")
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:51 +01:00
Sebastiaan van Stijn
6f3dd5f040 plugin: TestPluginAlreadyRunningOnStartup: fix shadowed variable (govet)
plugin/manager_linux_test.go:215:4: shadow: declaration of "root" shadows declaration at line 173 (govet)
                root := filepath.Join(root, desc)
                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:51 +01:00
Sebastiaan van Stijn
e46e159001 plugin: Manager.getManifestDescriptor: fix shadowed variable (govet)
plugin/backend_linux.go:527:2: shadow: declaration of "manifest" shadows declaration at line 473 (govet)
        manifest, err := buildManifest(ctx, pm.blobStore, p.Config, p.Blobsums)
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:50 +01:00
Sebastiaan van Stijn
d058e09200 daemon/graphdriver/overlay2: fix shadowed variable (govet)
daemon/graphdriver/overlay2/overlay.go:430:3: shadow: declaration of "key" shadows declaration at line 429 (govet)
            key := strings.ToLower(key)
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:50 +01:00
Sebastiaan van Stijn
ee425a9773 builder/builder-next: fix "id" variable being shadowed (govet)
builder/builder-next/builder.go:435:3: shadow: declaration of "id" shadows declaration at line 294 (govet)
            id, ok := resp.ExporterResponse["containerimage.digest"]
            ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:50 +01:00
Sebastiaan van Stijn
79c5b938f4 daemon: Daemon.autoRemove: fix shadowing (govet)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:50 +01:00
Sebastiaan van Stijn
007daf5045 daemon: Daemon.handleContainerExit rename vars to prevent shadowing (govet)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:50 +01:00
Sebastiaan van Stijn
738fb74a1a libnetwork/datastore: MockStore.AtomicPut: remove redundant nil check (govet)
libnetwork/datastore/mockstore_test.go:70:12: nilness: tautological condition: non-nil != nil (govet)
            if mData != nil && mData.Index != previous.LastIndex {
                     ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:54:49 +01:00
Sebastiaan van Stijn
473b1d419c golangci: run gosec on test files as well
Add a single exclusion for use of non-crypto rand in some tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:53:16 +01:00
Sebastiaan van Stijn
f6d86126c4 distribution/xfer: createChainIDFromParent: ignore G602 false positive (gosec)
distribution/xfer/download_test.go:72:53: G602: slice index out of range (gosec)
            return createChainIDFromParent(layer.ChainID(dgsts[0]), dgsts[1:]...)
                                                              ^
    distribution/xfer/download_test.go:75:69: G602: slice index out of range (gosec)
        dgst := digest.FromBytes([]byte(string(parent) + " " + string(dgsts[0])))
                                                                           ^
    distribution/xfer/download_test.go:76:59: G602: slice bounds out of range (gosec)
        return createChainIDFromParent(layer.ChainID(dgst), dgsts[1:]...)
                                                                 ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:22 +01:00
Sebastiaan van Stijn
a309e88dff pkg/tarsum: renderSumForHeader: ignore G110 in tests (gosec)
pkg/tarsum/tarsum_test.go:555:15: G110: Potential DoS vulnerability via decompression bomb (gosec)
            if _, err = io.Copy(io.Discard, tr); err != nil {
                        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:22 +01:00
Sebastiaan van Stijn
41b5645ba2 integration-cli: TestDaemonStartWithDefaultTLSHost: fix G402: TLS MinVersion too low
integration-cli/docker_cli_daemon_test.go:1528:101: G402: TLS MinVersion too low. (gosec)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:22 +01:00
Sebastiaan van Stijn
4bb96a5a4a awslogs: TestNewAWSLogsClientCredentialEndpointDetect: ignore G101 (gosec)
daemon/logger/awslogs/cloudwatchlogs_test.go:1652:2: G101: Potential hardcoded credentials (gosec)
        credsResp := `{
            "AccessKeyId" :    "test-access-key-id",
            "SecretAccessKey": "test-secret-access-key"
            }`

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:22 +01:00
Sebastiaan van Stijn
6f220c3340 daemon/logger/splunk: HTTPEventCollectorMock: fix G114 (gosec)
Not a real issue for tests, but easy to fix;

    daemon/logger/splunk/splunkhecmock_test.go:79:9: G114: Use of net/http serve function that has no support for setting timeouts (gosec)
        return http.Serve(hec.tcpListener, hec)
               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:21 +01:00
Sebastiaan van Stijn
79196deae9 pkg/authorization: fix G112 Potential Slowloris Attack (gosec)
Not a real issue for tests, but easy to fix;

    pkg/authorization/authz_unix_test.go:387:12: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:21 +01:00
Sebastiaan van Stijn
e6e6f0cdca client: TestTLSCloseWriter: fix G112 Potential Slowloris Attack (gosec)
Not a real issue for tests, but easy to fix;

    client/hijack_test.go:23:34: G112: Potential Slowloris Attack because ReadHeaderTimeout is not configured in the http.Server (gosec)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:21 +01:00
Sebastiaan van Stijn
963a9d7504 integration-cli: ignore some file-permissions issues (gosec)
These already had a comment, so let's make it a ignore-comment

    integration-cli/docker_cli_exec_test.go:409:13: G302: Expect file permissions to be 0600 or less (gosec)
            f, err := os.OpenFile(netFilePath, os.O_WRONLY|os.O_SYNC|os.O_APPEND, 0o644)
                      ^
    integration-cli/docker_cli_run_test.go:3050:12: G302: Expect file permissions to be 0600 or less (gosec)
        if err := os.Chmod(filename, 0o646); err != nil {
                  ^
    integration-cli/docker_cli_run_test.go:3072:12: G302: Expect file permissions to be 0600 or less (gosec)
        if err := os.Chmod(filename, 0o646); err != nil {
                  ^
    integration-cli/docker_cli_run_test.go:3094:12: G302: Expect file permissions to be 0600 or less (gosec)
        if err := os.Chmod(filename, 0o646); err != nil {
                  ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:21 +01:00
Sebastiaan van Stijn
7d7412af31 integration-cli: TestRunCreateVolumesInSymlinkDir: adjust file perms (gosec)
integration-cli/docker_cli_run_test.go:401:12: G302: Expect file permissions to be 0600 or less (gosec)
        f, err := os.OpenFile(filepath.Join(dir, "test"), os.O_CREATE, 0o700)
                  ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:21 +01:00
Sebastiaan van Stijn
0d1c645919 integration-cli: writeFile: fix file permissions (gosec)
integration-cli/docker_utils_test.go:187:12: G302: Expect file permissions to be 0600 or less (gosec)
        f, err := os.OpenFile(dst, os.O_CREATE|os.O_RDWR|os.O_TRUNC, 0o700)
                  ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:20 +01:00
Sebastiaan van Stijn
6ca0d3b1b1 integration-cli: inspectMountPoint: fix implicit memory aliasing (gosec)
integration-cli/docker_utils_test.go:149:8: G601: Implicit memory aliasing in for loop. (gosec)
                m = &c
                    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:20 +01:00
Sebastiaan van Stijn
c8e085b56a volume/mounts: TestConvertTmpfsOptions: fix implicit memory aliasing (gosec)
volume/mounts/linux_parser_test.go:335:38: G601: Implicit memory aliasing in for loop. (gosec)
            data, err := p.ConvertTmpfsOptions(&tc.opt, tc.readOnly)
                                               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:20 +01:00
Sebastiaan van Stijn
c3fa5b2e57 integration/plugin/logging: adjust file permissions in test (gosec)
integration/plugin/logging/cmd/discard/driver.go:40:13: G302: Expect file permissions to be 0600 or less (gosec)
    		f, err := os.OpenFile(req.File, syscall.O_RDONLY, 0o700)
    		          ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 12:50:17 +01:00
Sebastiaan van Stijn
20062ef358 Merge pull request #48824 from thaJeztah/update_golangci_config
fix, and update golangci-lint config, and fix some linting issues
2024-11-06 12:49:46 +01:00
Sebastiaan van Stijn
110ab719d5 Merge pull request #48826 from thaJeztah/fix_vendor
fix vendor of github.com/containerd/containerd
2024-11-06 12:20:12 +01:00
Sebastiaan van Stijn
9fc2b45fa5 fix vendor of github.com/containerd/containerd
The github.com/containerd/containerd/remotes/docker/config package
was vendored incorrectly due to 5f39567e56
(update to containerd v1.7.23) being merged from an outdated branch that
missed the changes from 8b4cb6f58c that
brought in the dependency on the config package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-06 10:31:39 +01:00
Sebastiaan van Stijn
f0cec02a40 Merge pull request #48813 from tcpdumppy/patch-1
chore: fix function name
2024-11-05 21:52:05 +01:00
Sebastiaan van Stijn
73fae59cef golangci: remove invalid govet config
The govet linter now uses a new schema for its config; let's remove
for now, and work on enabling more of its functionality in a follow-up.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 21:18:24 +01:00
Sebastiaan van Stijn
1188e80cc5 golangci: move gosec exclusions to linters-settings section
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 21:12:46 +01:00
Sebastiaan van Stijn
a0807e7cfe golangci: set go version to prevent fallback to go1.17 semantics
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 21:12:45 +01:00
Sebastiaan van Stijn
29e5bfb0f0 golangci: fix deprecated run option
It's now a top-level option, with exclude-dirs in the "issues" section

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 21:12:45 +01:00
Sebastiaan van Stijn
7809dc08f1 golangci: remove global ignore for EXC0006 / G103 (gosec)
We only have a few locations where it's flagged, so we can add ignores there.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 21:12:45 +01:00
Sebastiaan van Stijn
79e9619412 pkg/archive: ignore G103 (gosec)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 21:12:45 +01:00
Sebastiaan van Stijn
88c178328f libnetwork/drivers/bridge: ignore G103 (gosec)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 21:12:45 +01:00
Sebastiaan van Stijn
62e137377b integration/image: ignore G103 (gosec)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 21:12:44 +01:00
Sebastiaan van Stijn
e567b816d2 golangci: sort linters-settings
Use a consistent order, which helps comparing settings with other
repositories, such as docker/cli.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 21:12:01 +01:00
Sebastiaan van Stijn
4e22c17647 Merge pull request #48822 from thaJeztah/libnetwork_fix_shadow
libnetwork: endpointJoinInfo.UnmarshalJSON: fix shadowed variable (go…
2024-11-05 20:15:31 +01:00
Sebastiaan van Stijn
e49bce5fd2 Merge pull request #48812 from Octol1ttle/patch-1
fix(systemd): start Docker engine *after* DNS resolution is ready
2024-11-05 18:42:57 +01:00
Sebastiaan van Stijn
0940460c2f libnetwork: endpointJoinInfo.UnmarshalJSON: fix shadowed variable (govet)
looks like this was added in [libnetwork@be153a1], but not spotted.

    libnetwork/endpoint_info.go:467:20: nilness: range of nil slice (govet)
        for _, r := range tStaticRoute {
                          ^

[libnetwork@be153a1]: be153a13e4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 16:45:33 +01:00
Sebastiaan van Stijn
070ebb9112 Merge pull request #48821 from robmry/remove_islinkable
Remove function isLinkable
2024-11-05 16:14:42 +01:00
Rob Murray
e601e71681 Remove function isLinkable
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-05 14:22:53 +00:00
Sebastiaan van Stijn
6c2e77a58c Merge pull request #48819 from thaJeztah/image_history_nowrap
client: Client.ImageHistory: don't decorate error twice, and improve tests
2024-11-05 15:08:03 +01:00
Sebastiaan van Stijn
ad8196f48a Merge pull request #48722 from vvoland/c8d-save-addtests
c8d/save: Add tests
2024-11-05 14:35:06 +01:00
Sebastiaan van Stijn
083d595286 client: TestImageHistory: add minimal test for platform
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 13:28:28 +01:00
Sebastiaan van Stijn
73fabd5a21 client: TestImageHistory: use fixture for JSON response
Use a fixture instead of encoding with the current definition of the type,
to make sure we don't regress if any changes are made in the type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 13:28:27 +01:00
Sebastiaan van Stijn
5cfd326aa4 client: Client.ImageHistory: don't decorate error twice
I forgot to include this patch in 96039276b6,
which introduced the encodePlatform, which already decorates the error to
have a `invalid platform:` prefix.

While updating, also be more explicit on no result being returned on error.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-11-05 13:28:15 +01:00
Rob Murray
47a6de71c2 Merge pull request #47406 from robmry/defer_ipv6_addr_allocation
Allocate IPv6 addresses after detecting IPv6 support
2024-11-05 12:07:54 +00:00
Sebastiaan van Stijn
f03c49008d Merge pull request #48806 from thaJeztah/client_platform_util
client: add utilities to encode platforms
2024-11-05 12:24:22 +01:00
Rob Murray
caf2d5dc7c Change meaning of return from DNSBackend.ResolveName
Interface DNSBackend.ResolveName, implemented by Network,
Sandbox (and noopDNSBackend) had a bool return value that
meant 'ipv6Miss'.

But, it was always set to true on a hit, and callers had
to deal with that.

So, changed the meaning of the return value to indicate
whether the name was found - which will also work for
'ipv4Miss' when we have IPv6-only containers/networks.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-05 10:01:52 +00:00
Rob Murray
ec3dde7001 Only allocate IPv6 addresses if IPv6 is enabled.
When a container doesn't support IPv6 and it's joined to an IPv6
network, don't allocate an IPv6 address for it.

Update the DNS resolver to understand that it can have an 'ipv6miss'
(meaning an IPv4 address exists, but no IPv6) when a network is
IPv6 enabled.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-05 10:01:52 +00:00
Rob Murray
fe856b94b5 Configure network endpoints after creating a container
For Linux, delay construction and configuration of network endpoints
until the container has been created (but not started).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-05 10:01:49 +00: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
Rob Murray
4c553defce Separate Sandbox/Endpoint construction
If config for legacy links needs to be added to a libnetwork.Sandbox,
add it when constructing the Endpoint that needs it - removing the
constraint on ordering of Endpoint construction, and the dependency
between Endpoint and Sandbox construction.

So, now a Sandbox can be constructed in one place, before the first
Endpoint.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-05 10:00:10 +00:00
Rob Murray
a715ccaaa3 Unconditionally update NetworkSettings
When connecting a container to a new network, its NetworkSettings were
unconditionally updated.

But, when creating a new container, they were only updated if there
were no NetworkSettings before a network was connected. But, that's
always the case - so, make the update unconditionally.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-05 10:00:10 +00:00
Rob Murray
933fcc9814 Re-remove the SetKey OCI prestart hook
Second attempt to stop using the OCI prestart hook to call SetKey
to set up the OS Sandbox's key and perform network config in the
new network namespace.

The first attempt was reverted because it made it impossible to
use --sysctl to set per-interface sysctls on an interface that had
not yet been moved into the new network namespace.

Now, per-interface sysctls can be used to do that (with less
ambiguity because the setting is not tied to the interface using
an unpredictably assigned name).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-11-05 10:00:09 +00:00
tcpdumppy
035b8afe04 chore: fix function name
Signed-off-by: tcpdumppy <847462026@qq.com>
2024-11-05 10:34:33 +08:00
Octol1ttle
330e717403 fix(systemd): start Docker engine *after* DNS resolution is ready
On systems using systemd to autostart Docker on boot, containers might encounter a problem where they will not have any DNS access until the container is restarted manually. This PR fixes this issue by requiring that the Docker engine service starts after nss-lookup.target. This target is reached when DNS resolution is available. See https://wiki.archlinux.org/title/Systemd#Running_services_after_the_network_is_up (paragraph "If a service needs to perform DNS queries...")

Signed-off-by: Octol1ttle <l1ttleofficial@outlook.com>
2024-11-04 15:57:24 +05:00
Sebastiaan van Stijn
6ac445c42b Merge pull request #48544 from thaJeztah/vendor_containerd_1.7.23
vendor: github.com/containerd/containerd v1.7.23, hcsshim v0.12.8
2024-10-31 20:41:40 +01:00
Sebastiaan van Stijn
96039276b6 client: add utilities to encode platforms
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-31 20:40:27 +01:00
Albin Kerouanton
816dbbfddc ci: re-enable firewalld jobs
Commit 4e567e16 added firewalld to the test matrix for various CI jobs
(namely unit, integration and integration-cli).

Commit 2807c0c2 reverted that commit as it was putting too much load on
GHA cache, and thus it was returning 429 more frequently, so builds had
a greater chance of spending time building everything from scratch. This
was slowing down our CI even more than what it was before.

This new commit re-adds firewalld to the test matrix of unit,
integration and integration-cli jobs. Unlike 4e567e16, not all
combinations of OS, storage and 'mode' will be tested. Instead,
firewalld jobs will run only on ubuntu-22.04, and with the containerd
snapshotter.

Also, the revert commit mistakenly reverted a fix that was originally
intended for commit 8883db20, but was actually 'fixed up' in the wrong
commit. Let's re-revert that too.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-10-31 18:01:37 +01:00
Sebastiaan van Stijn
8c3945c761 client: rename vars for consistency
We use "query" for this everywhere else in the client.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-31 13:50:33 +01:00
Sebastiaan van Stijn
32e2c05bb6 Merge pull request #48801 from tonistiigi/vendor-buildkit-v0.17.0
vendor: update buildkit to v0.17.0
2024-10-31 13:02:15 +01:00
Tonis Tiigi
0e72863b9d vendor: update buildkit to v0.17.0
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-30 15:44:27 -07:00
AmirBuddy
17b76511d5 Fix: Duplicate event on network disconnect #48797
This fix resolves the issue where a network disconnect generates duplicate events.

Co-authored-by: eyeamnoob <a.afraz.1380@gmail.com>

Signed-off-by: AmirBuddy <badinlu.amirhossein@gmail.com>
Signed-off-by: eyeamnoob <a.afraz.1380@gmail.com>
2024-10-30 22:02:19 +03:30
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
3e96728d56 Merge pull request #48796 from robmry/remove_libnet_testmain
Remove libnetwork_test.TestMain
2024-10-30 10:36:20 +00:00
Paweł Gronowski
b08bc5df85 Merge pull request #47553 from vvoland/testing-libnetwork-rerun-flaky
hack/unit: Rerun failed flaky libnetwork tests
2024-10-30 10:21:08 +00:00
Sebastiaan van Stijn
6d6ee62dd3 Merge pull request #48789 from thaJeztah/volumedriver_warning
container create: add warning for volumeDriver together with mounts
2024-10-30 10:50:11 +01:00
Sebastiaan van Stijn
85153dd282 Merge pull request #48794 from thaJeztah/mobyexporter_use_platform_directly
builder-next: exporter: emptyImageConfig: use platform directly
2024-10-30 10:49:44 +01:00
Rob Murray
fbb595cb66 Remove libnetwork_test.TestMain
It only removed the test host's libnet Bolt db file, and didn't
need to do that because the tests use a TempDir for it.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-30 09:31:13 +00:00
Sebastiaan van Stijn
5f39567e56 vendor: github.com/containerd/containerd v1.7.23, hcsshim v0.12.8
full diff:

- https://github.com/containerd/containerd/compare/v1.7.22...v1.7.23
- https://github.com/microsoft/hcsshim/compare/v0.12.7...v0.12.8

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-30 09:19:20 +01:00
Sebastiaan van Stijn
dc9390cd75 Merge pull request #48792 from tonistiigi/vendor-buildkit-v0.17.0-rc2
vendor: update buildkit to v0.17.0-rc2
2024-10-30 09:17:10 +01:00
Sebastiaan van Stijn
741cc494cd builder-next: exporter: emptyImageConfig: use platform directly
The OCI image spec now has the platform as field, so we can just
set it directly now.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-30 01:15:12 +01:00
Rob Murray
e775c68fab Merge pull request #48793 from robmry/fix_libnet_db_path
Restore 27.x path for libnet's Bolt database
2024-10-29 19:21:09 +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
Tonis Tiigi
2cc21208e6 vendor: update buildkit to v0.17.0-rc2
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-10-29 10:15:57 -07:00
Sebastiaan van Stijn
53013c1e8c Merge pull request #48790 from thaJeztah/bump_hcsshim
vendor: github.com/Microsoft/hcsshim v0.12.7
2024-10-29 14:43:45 +01:00
Sebastiaan van Stijn
cb966073ce container create: add warning for volumeDriver together with mounts
commit 77fe35b3b9 added a warning if the
"volumeDriver" option was used in combination with --mount.

That change put the warning in the CLI, which should not have to handle
this logic. Let's move it to the daemon as we have a warnings response
in the container create response.

The warning is gated by API version, so that older clients can continue
to produce the warning client-side.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-29 12:16:48 +01:00
Sebastiaan van Stijn
93255bd748 vendor: github.com/Microsoft/hcsshim v0.12.7
- full diff: https://github.com/Microsoft/hcsshim/compare/v0.12.5...v0.12.7

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-29 11:43:32 +01:00
Sebastiaan van Stijn
3dc042b1df vendor: sigs.k8s.io/yaml v1.4.0
full diff: https://github.com/kubernetes-sigs/yaml/compare/v1.3.0...v1.4.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-29 11:43:25 +01:00
Sebastiaan van Stijn
571d65906b Merge pull request #48757 from thaJeztah/bump_otel_v0.28_v0.53
vendor: go.opentelemetry.io/otel v1.28.0, go.opentelemetry.io/contrib v0.53.0
2024-10-29 11:35:44 +01:00
Sebastiaan van Stijn
9b5c909738 Merge pull request #48781 from jinjiadu/master
chore: fix some function names
2024-10-28 19:46:09 +01:00
Sebastiaan van Stijn
25787fce1a Merge pull request #48788 from akerouanton/revert-firewalld-jobs
Revert "ci: run integration tests with firewalld enabled"
2024-10-28 19:45:48 +01:00
Albin Kerouanton
2807c0c2d2 Revert "ci: run integration tests with firewalld enabled"
Temporarily remove firewallds jobs. These are actually not running
firewalld due to a typo in GHA definitions. Moreover, these new jobs
are putting too much load on the CI, causing GHA cache backend to return
429 for many jobs. This slows down build jobs (as they can't use
existing cache), and at least one buildkit test is now failing.

This reverts commit 4e567e1622.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-10-28 18:24:14 +01:00
Sebastiaan van Stijn
4ade1b1ac8 Merge pull request #48775 from thaJeztah/anonymous_use_default_driver
volume/service: use local driver as default for anonymous volumes
2024-10-28 16:47:10 +01:00
Sebastiaan van Stijn
cfe4b4dc66 Merge pull request #48777 from vvoland/c8d-inspect-duplicate-repodigests
c8d/inspect: Fix duplicate RepoDigests
2024-10-28 14:42:38 +01:00
Akihiro Suda
1cf8a43090 Merge pull request #48779 from thaJeztah/rm_deprecated_bits
remove deprecated pkg/longpath.Prefix, pkg/directory
2024-10-28 22:14:28 +09:00
Paweł Gronowski
db68a019fd c8d/save: Add tests
Test saving a shallow/partial image

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-10-28 13:23:10 +01:00
Sebastiaan van Stijn
5f0f32ba98 Merge pull request #48776 from thaJeztah/mount_improve_tests
volume/mounts: minor linting issues, touch-ups, and improve test-coverage
2024-10-28 11:35:08 +01:00
jinjiadu
3cc736e95c chore: fix some function names
Signed-off-by: jinjiadu <jinjiadu@aliyun.com>
2024-10-28 18:20:43 +08:00
Paweł Gronowski
ba454f573b c8d/inspect: Fix duplicate RepoDigests
Multiple images with the same repository name but different tag caused
the `RepoDigests` to contain duplicated entries for each of the image.

Deduplicate the slice before setting the `RepoDigests` field.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-10-28 11:16:24 +01:00
Sebastiaan van Stijn
61433c2a6e Merge pull request #48774 from thaJeztah/safepath_nits
internal/safepath: log some unhandled errors, and remove workaround for ECI / Sysbox
2024-10-28 10:39:38 +01:00
Paweł Gronowski
89c0170aee Merge pull request #48771 from thaJeztah/cdi_noshadow
daemon: cdiHandler.getErrors: remove var that shadowed import
2024-10-28 10:30:23 +01:00
Paweł Gronowski
22d94b2165 Merge pull request #48770 from thaJeztah/mount_struct_logs
demon: ImageService.Mount: use structured logs
2024-10-28 10:30:03 +01:00
Sebastiaan van Stijn
ae87c1d84c remove deprecated pkg/directory
This package was deprecated in 3a3bb1cb50,
and moved internally. The deprecation was backported to v27.1.0 through
d1ea2b1fec, so this package can be removed
for v28.0.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-28 10:25:51 +01:00
Sebastiaan van Stijn
2054fd99b1 pkg/longpath: remove deprecated Prefix const
This const was deprecated in 424c22390e in
v27.0 and is no longer used, so can be removed.

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

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

Before this patch:

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

With this patch:

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-28 09:11:05 +01:00
Sebastiaan van Stijn
31880791a4 volumes/mounts: test the actual MountConfig returned
Make sure we're asserting the right fields to be propagated, as there
are some fields that shadow top-level fields (by design).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 21:51:25 +01:00
Sebastiaan van Stijn
275609eb37 volumes/mounts: test the actual error returned
Update the tests to have a match for the actual error string returned.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 20:40:59 +01:00
Sebastiaan van Stijn
6b0c4b5216 volumes/mounts: don't set "expected" values for fail cases
ParseMountRaw returns a nil value on error, so there's nothing to
check other than it not returning a value.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 19:07:56 +01:00
Sebastiaan van Stijn
e141be8752 volumes/mounts: remove backticks from test logs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 18:53:36 +01:00
Sebastiaan van Stijn
be7d57367b volumes/mounts: remove backticks from errors
These errors used a backtick, which is not commonly used in our errors.
Change them to use single quotes instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 18:46:18 +01:00
Sebastiaan van Stijn
0b290094b5 volume/mounts: windowsParser.ConvertTmpfsOptions don't use runtime.GOOS
These parsers can be compiled and used cross-platform, but follow platform-
specific semantics. Remove the use of runtime.GOOS, as it would result in
confusing errors ("linux does not support tmpfs").

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 18:44:11 +01:00
Akihiro Suda
56445e13dc Merge pull request #48769 from thaJeztah/remove_alias
remove redundant alias for runtime-spec
2024-10-27 22:48:16 +09:00
Sebastiaan van Stijn
75e8f57579 internal/safepath: Join(): remove workaround for ECI / Sysbox
This workaround was added in 9a0cde66ba to
work around an issue on Docker Desktop with ECI (Enhanced Container Isolation)
enabled, which uses the Sysbox runtime under the hood.

A comment was added during review of the PR that added it (see [1]), and the
internal discussion on Slack tracked down the issue to code in [nestybox/sysfs].

That issue was resolved Sysbox EE, and upstreamed to Sysbox CE through
[nestybox/sysbox-fs@9cf74e4], which is part of Sysbox CE v0.6.3, so we
can remove this workaround.

[1]: https://github.com/moby/moby/pull/45687#discussion_r1280867905
[nestybox/sysfs]: 30fd49edbd/process/process.go (L644-L684)
[nestybox/sysbox-fs@9cf74e4]: 9cf74e4cbf

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 13:13:55 +01:00
Sebastiaan van Stijn
4b60c68803 internal/safepath: Join(): log some unhandled errors
Similar to the kubernetesSafeOpen function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 13:13:50 +01:00
Sebastiaan van Stijn
5fc5b0574b internal/safepath: kubernetesSafeOpen: explicitly suppress unhandled err
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-27 12:35:47 +01:00
Sebastiaan van Stijn
b5f000896f Merge pull request #36766 from Myeongjoon/dev_moby
Update tmLanguage file to cover first escape character
2024-10-27 02:04:54 +02:00
Sebastiaan van Stijn
4e5c7eeafc daemon: cdiHandler.getErrors: remove var that shadowed import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-26 18:59:56 +02:00
Sebastiaan van Stijn
9e00a63d65 Merge pull request #48767 from thaJeztah/fix_debug_level
volume: VolumesService.Create: fix log-level for debug logs
2024-10-26 18:57:58 +02:00
Sebastiaan van Stijn
0c43bc6891 demon: ImageService.Mount: use structured logs
Before this patch:

    DEBU[2024-10-26T15:51:12.666160042Z] stat snapshot                                 key="sha256:12660636fe55438cc3ae7424da7ac56e845cdb52493ff9cf949c47a7f57f8b43"
    DEBU[2024-10-26T15:51:12.669595334Z] prepare snapshot                              key=7e947822249514b6239657a0c54d091d90e0fed4b09da472f3f6258f2b4920bc-init-key parent="sha256:12660636fe55438cc3ae7424da7ac56e845cdb52493ff9cf949c47a7f57f8b43"
    DEBU[2024-10-26T15:51:12.678485001Z] commit snapshot                               key=7e947822249514b6239657a0c54d091d90e0fed4b09da472f3f6258f2b4920bc-init-key name=7e947822249514b6239657a0c54d091d90e0fed4b09da472f3f6258f2b4920bc-init
    DEBU[2024-10-26T15:51:12.679995167Z] prepare snapshot                              key=7e947822249514b6239657a0c54d091d90e0fed4b09da472f3f6258f2b4920bc parent=7e947822249514b6239657a0c54d091d90e0fed4b09da472f3f6258f2b4920bc-init
    DEBU[2024-10-26T15:51:12.681101209Z] get snapshot mounts                           key=7e947822249514b6239657a0c54d091d90e0fed4b09da472f3f6258f2b4920bc
    DEBU[2024-10-26T15:51:12.681547126Z] container mounted via snapshotter: /var/lib/docker/rootfs/overlayfs/7e947822249514b6239657a0c54d091d90e0fed4b09da472f3f6258f2b4920bc  container=7e947822249514b6239657a0c54d091d90e0fed4b09da472f3f6258f2b4920bc
    ...

With this patch:

    DEBU[2024-10-26T16:43:40.724448597Z] stat snapshot                                 key="sha256:12660636fe55438cc3ae7424da7ac56e845cdb52493ff9cf949c47a7f57f8b43"
    DEBU[2024-10-26T16:43:40.728187889Z] prepare snapshot                              key=3d6442ad828a043c5bd3a466aae17946da9df9c89d5aeeb7b5af160491e8a6fa-init-key parent="sha256:12660636fe55438cc3ae7424da7ac56e845cdb52493ff9cf949c47a7f57f8b43"
    DEBU[2024-10-26T16:43:40.734372930Z] commit snapshot                               key=3d6442ad828a043c5bd3a466aae17946da9df9c89d5aeeb7b5af160491e8a6fa-init-key name=3d6442ad828a043c5bd3a466aae17946da9df9c89d5aeeb7b5af160491e8a6fa-init
    DEBU[2024-10-26T16:43:40.735592180Z] prepare snapshot                              key=3d6442ad828a043c5bd3a466aae17946da9df9c89d5aeeb7b5af160491e8a6fa parent=3d6442ad828a043c5bd3a466aae17946da9df9c89d5aeeb7b5af160491e8a6fa-init
    DEBU[2024-10-26T16:43:40.736778055Z] get snapshot mounts                           key=3d6442ad828a043c5bd3a466aae17946da9df9c89d5aeeb7b5af160491e8a6fa
    DEBU[2024-10-26T16:43:40.737387847Z] container mounted via snapshotter             container=3d6442ad828a043c5bd3a466aae17946da9df9c89d5aeeb7b5af160491e8a6fa root=/var/lib/docker/rootfs/overlayfs/3d6442ad828a043c5bd3a466aae17946da9df9c89d5aeeb7b5af160491e8a6fa snapshotter=overlayfs
    ...

And for graphdrivers:

    DEBU[2024-10-26T16:51:21.612155255Z] container mounted via layerStore              container=a339b74e0d90fc31dea2b79ba7478a0acf4172e6d7bc11ee4a0053531fa5455f storage-driver=overlay2 root=/var/lib/docker/overlay2/35132769364e5d139d8e52f5b6e3d6a8826649c9ad99b843199b3525645f52d2/merged
    DEBU[2024-10-26T16:51:21.620449046Z] attach: stdout: begin
    DEBU[2024-10-26T16:51:21.620482380Z] attach: stderr: begin
    DEBU[2024-10-26T16:51:21.622254796Z] container mounted via layerStore              container=a339b74e0d90fc31dea2b79ba7478a0acf4172e6d7bc11ee4a0053531fa5455f storage-driver=overlay2 root=/var/lib/docker/overlay2/35132769364e5d139d8e52f5b6e3d6a8826649c9ad99b843199b3525645f52d2/merged
    ...

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-26 18:57:32 +02:00
Sebastiaan van Stijn
5c48736863 remove redundant alias for runtime-spec
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-26 18:31:39 +02:00
Sebastiaan van Stijn
352b4ff2f1 volume: VolumesService.Create: fix log-level for debug logs
These log-entries were added in 10d57fde44,
but it looks like I accidentally left them as Error-logs following some
debugging (whoops!).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-26 17:38:58 +02:00
Derek McGowan
2aaae08ade Cleanup legacy mirror string to registry host
Move the conversion to its own function and add unit tests.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-10-25 12:44:44 -07:00
Derek McGowan
b3569ebd5a Add HTTP fallback to all insecure registries
Note that while it is not safe to use http fallback on non-localhost
registries, this can be avoided using the new host directories. The
previous legacy insecure configuration is ambiguous and less secure.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-10-25 12:44:44 -07:00
Derek McGowan
1c34581812 Use daemon config to check for legacy config
Use the daemon's configuration to check whether the legacy registry
configuration is used. Only attempt to merge with the legacy
configuration if it has been provided. This avoids merging in based on
a defaulted legacy config.

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-10-25 12:44:44 -07:00
Derek McGowan
8b4cb6f58c Update host resolver to use containerd host config
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-10-25 12:44:43 -07:00
Sebastiaan van Stijn
8eba9bfa64 Merge pull request #48718 from vvoland/c8d-load-platform-notinarchive
c8d/load: Don't ignore missing platform when requested
2024-10-25 18:34:44 +02:00
Sebastiaan van Stijn
1240301299 Merge pull request #48736 from laurazard/client-set-conn-timeout
client: prevent idle connections leaking FDs
2024-10-25 17:28:14 +02:00
Sebastiaan van Stijn
d96020ba7c Merge pull request #48726 from thaJeztah/container_update_comment
container: update confusing GoDoc for Container and State
2024-10-25 16:29:51 +02:00
Sebastiaan van Stijn
b50f8affc6 Merge pull request #48754 from thaJeztah/fix_anonymous_volumes_labels
volume/mounts: fix anonymous volume not being labeled
2024-10-25 15:16:32 +02:00
Sebastiaan van Stijn
8e0bf25bc3 container: update confusing GoDoc for Container and State
This comment was added in f49c3f287b, following
517ba44e37, which embedded the State, which
caused the JSON presentation to change.

Referring to a very old (and now removed) API version made this confusing;
while it was added to preserve the pre-v1.11 API format, it still applies
to current API versions (i.e., we cannot change this unless an explicit
API change).

This patch;

- removes the confusing comment
- touches up the comment describing the reason for embedding the State
- also mentions the State's sync.Mutex, which acts as a lock not only
  for the state itself, but for the container as a whole (which was the
  motivation for 517ba44e37).
- Update GoDoc for the State struct to clarify the purpose of the Mutex.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-25 14:46:25 +02:00
Sebastiaan van Stijn
f2a3acc104 vendor: go.opentelemetry.io/contrib/instrumentation/xxx v0.53.0
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-25 13:11:55 +02:00
Sebastiaan van Stijn
d9a2ca7b49 vendor: go.opentelemetry.io/otel v1.28.0
aligning all related packages to v1.28.0 as well

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-25 13:07:38 +02:00
Sebastiaan van Stijn
070d6c75a7 vendor: google.golang.org/genproto/googleapis/api f6361c86f094
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-25 12:59:41 +02:00
Sebastiaan van Stijn
b04246ce8f Merge pull request #48752 from thaJeztah/bump_hcsshim_deps
vendor: github.com/go-logr/logr v1.4.2, github.com/cenkalti/backoff/v4 v4.3.0
2024-10-25 12:38:39 +02:00
Sebastiaan van Stijn
7d5ec050c1 Merge pull request #48750 from thaJeztah/bump_ansiterm
vendor: github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161
2024-10-25 12:38:21 +02:00
Sebastiaan van Stijn
9b2bff805d Merge pull request #48745 from thaJeztah/filters_remove_unreachableCode
api/types/filters: GetBoolOrDefault: remove unreachableCode
2024-10-25 12:03:30 +02:00
Sebastiaan van Stijn
7298401b71 Merge pull request #48753 from thaJeztah/bump_prometheus
vendor: github.com/prometheus/client_golang v1.20.5
2024-10-25 11:58:37 +02:00
Sebastiaan van Stijn
d3c3a74982 Merge pull request #47668 from thaJeztah/vendor_runc_1.2.0
vendor: github.com/opencontainers/runc v1.2.0
2024-10-25 10:39:56 +02:00
Albin Kerouanton
025c84bfd4 Merge pull request #48749 from akerouanton/fix-L3Segment-Destroy
inte/t/networking: delete veth ifaces before netns
2024-10-25 09:55:13 +02:00
Joon
c2029cb257 Update tmLanguage file to cover first escape character
If matched escape character like \" before enter " in begin statement, text editor return invalid Highlighting.
So included escape character outside of begin statement and did some refactoring.
Signed-off-by: Myeongjooon Kim kimmj8409@gmail.com

Signed-off-by: Myeongjoon Kim <kimmj8409@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-25 09:43:53 +02:00
Sebastiaan van Stijn
95959f7000 vendor: github.com/prometheus/client_golang v1.20.5
full diff: https://github.com/prometheus/client_golang/compare/v1.17.0...v1.20.5

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-25 09:24:30 +02:00
Akihiro Suda
3f02bcaa26 Merge pull request #48751 from thaJeztah/bump_protobuf
vendor: google.golang.org/protobuf v1.34.2
2024-10-25 09:48:13 +09:00
Sebastiaan van Stijn
10d57fde44 volume/mounts: fix anonymous volume not being labeled
`Parser.ParseMountRaw()` labels anonymous volumes with a `AnonymousLabel` label
(`com.docker.volume.anonymous`) label based on whether a volume has a name
(named volume) or no name (anonymous) (see [1]).

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

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

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

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

With this patch applied:

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

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

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-25 01:57:22 +02:00
Sebastiaan van Stijn
7d7089247c api/types/filters: GetBoolOrDefault: remove unreachableCode
We already check if

- the key is set (otherwise default)
- a value is set (otherwise default and error)

This check can be simplified to check if they're equal (boolean cannot be both
true and false), or both false (boolean must be either true or false), although
the latter could be considered for a tri-state boolean (but we already do this
through the "not set" case).

We may need some additional checks, for example, currently it ignores invalid
values if the filter contains at least one valid one (e.g. ["true", "bananas"]).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-24 23:00:14 +02:00
Sebastiaan van Stijn
f31188bc4c vendor: github.com/cenkalti/backoff/v4 v4.3.0
full diff: https://github.com/cenkalti/backoff/compare/v4.2.1...v4.3.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-24 22:36:45 +02:00
Sebastiaan van Stijn
c3cab4170b vendor: github.com/go-logr/logr v1.4.2
full diff: https://github.com/go-logr/logr/compare/v1.4.1...v1.4.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-24 22:36:44 +02:00
Sebastiaan van Stijn
d2557466c6 vendor: google.golang.org/protobuf v1.34.2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-24 22:33:33 +02:00
Sebastiaan van Stijn
c98c6d4f08 vendor: github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161
full diff: d185dfc1b5...306776ec81

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-24 22:29:11 +02:00
Sebastiaan van Stijn
032721ff75 Merge pull request #48746 from robmry/48282_disable_sysctl_migration_in_api1.48
From 28.0.0, don't migrate per-endpoint sysctls
2024-10-24 21:55:57 +02:00
Sebastiaan van Stijn
281bdbd519 Merge pull request #48738 from robmry/47732_remove_windows-dns-proxy_featflag
Remove feature flag "windows-dns-proxy"
2024-10-24 21:54:35 +02:00
Sebastiaan van Stijn
c8ff3502c7 Merge pull request #48715 from AkihiroSuda/go1.23
update to go1.23.2
2024-10-24 21:51:22 +02:00
Sebastiaan van Stijn
a6d5b48e67 vendor: github.com/opencontainers/runc v1.2.0
Removes dependency on various libcontainer packages;

- github.com/opencontainers/runc/libcontainer/system
- github.com/opencontainers/runc/libcontainer/user
- github.com/opencontainers/runc/libcontainer/userns

full diff: https://github.com/opencontainers/runc/compare/v1.1.14..v1.2.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-24 19:38:37 +02:00
Akihiro Suda
45bfb197c1 Merge pull request #48735 from thaJeztah/bump_ebpf
vendor: github.com/cilium/ebpf v0.16.0
2024-10-25 02:03:05 +09:00
Akihiro Suda
e8bab0fefd Merge pull request #48741 from thaJeztah/bump_selinux
vendor: github.com/opencontainers/selinux v1.11.1
2024-10-25 02:02:39 +09:00
Albin Kerouanton
bb364cc0f3 inte/t/networking: delete veth ifaces before netns
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-10-24 18:18:13 +02:00
Paweł Gronowski
4ab7644d8d c8d/load: Don't ignore missing platform when requested
Commit f143f4ec51 introduced platform support
when loading images. However when loading a specific platform variant from
a tar that contains multiple, we should not ignore cases if that platform is
missing.

Before this patch, the missing platform was silently ignored, potentially
loading an empty image:

    $ docker image load -i image.tar --platform=linux/riscv64
    Loaded image: alpine:latest

    $ docker image ls --tree
    IMAGE           ID             DISK USAGE   CONTENT SIZE   USED
    alpine:latest   beefdbd8a1da           0B             0B

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-10-24 16:05:40 +02:00
Rob Murray
533e7d150a From 28.0.0, don't migrate per-endpoint sysctls.
Re-add checks that were removed until 28.0.0's API version was
known, in commit 17adc1478b

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-24 12:20:01 +01:00
Rob Murray
b79bba6b68 Remove feature flag "windows-dns-proxy"
Added in 26.1.0, commit 6c68be24a2
Default changed to true in 27.0.0, commit 33f9a5329a

No sign of problems so, remove.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-24 11:19:42 +01:00
Sebastiaan van Stijn
5aaceefe5b Merge pull request #48729 from kolyshkin/go-cache
ci/gha: enable go caching
2024-10-24 11:38:37 +02:00
Sebastiaan van Stijn
88b90ebbd2 vendor: github.com/opencontainers/selinux v1.11.1
full diff: https://github.com/opencontainers/selinux/compare/v1.11.0...v1.11.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-24 00:44:30 +02:00
Laura Brehm
5c72a95a30 client: prevent idle connections leaking FDs
Patch from af6ada910f

Without this change, if a long-lived process uses the client and creates
connections, these connections are not released and grow over time.

We can also look into addressing this issue from the server side, but it
doesn't hurt for the `client` package to have good defaults and not
cause this.

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-10-23 16:14:10 +01:00
Sebastiaan van Stijn
0105091745 vendor: github.com/cilium/ebpf v0.16.0
full diff: https://github.com/cilium/ebpf/compare/v0.12.3...v0.16.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-23 15:25:08 +02:00
Sebastiaan van Stijn
43bbacb239 Merge pull request #48732 from thaJeztah/bump_securejoin
vendor: github.com/cyphar/filepath-securejoin v0.3.4
2024-10-23 15:24:36 +02:00
Sebastiaan van Stijn
9369a391d8 Merge pull request #48703 from thaJeztah/daemon_remove_configsSupported
daemon: remove configsSupported, secretsSupported utilities
2024-10-23 15:21:03 +02:00
Sebastiaan van Stijn
a136ebab04 Merge pull request #48725 from thaJeztah/daemon_cleanup_bits
daemon: remove Daemon.containerRoot, Daemon.newBaseContainer
2024-10-23 15:15:06 +02:00
Sebastiaan van Stijn
914ed0240b Merge pull request #48713 from thaJeztah/client_prune_zerotype
client: explicitly return zero-type on failures in prune functions
2024-10-23 15:14:32 +02:00
Sebastiaan van Stijn
33d45801e6 Merge pull request #48728 from thaJeztah/container_remove_deprecated_errs
container: remove deprecated ErrNameReserved, ErrNameNotReserved
2024-10-23 15:13:49 +02:00
Rob Murray
87365d9f28 Merge pull request #48724 from robmry/no_dependency_on_filter_forward_policy
Remove dependency on the filter-FORWARD policy
2024-10-23 11:39:43 +01:00
Sebastiaan van Stijn
51dd387bc9 vendor: github.com/cyphar/filepath-securejoin v0.3.4
full diff: https://github.com/cyphar/filepath-securejoin/compare/v0.2.4...v0.3.4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-23 12:03:31 +02:00
Sebastiaan van Stijn
34898da50b Merge pull request #48730 from kolyshkin/own-cgroup-path
daemon: use OwnCgroupPath in withCgroups
2024-10-23 11:56:28 +02:00
Kir Kolyshkin
6be2074aef daemon: use OwnCgroupPath in withCgroups
Note: this usage comes from commit 56f77d5ade (part of PR 23430).

cgroups.InitCgroupPath is removed from runc (see [1]), and it is
suggested that users use OwnCgroupPath instead, because using init's is
problematic when in host PID namespace (see [2]) and is generally not
the right thing to do (see [3]).

[1]: https://github.com/opencontainers/runc/commit/fd5debf3
[2]: https://github.com/opencontainers/runc/commit/2b28b3c2
[3]: https://github.com/opencontainers/runc/commit/54e20217

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-10-22 22:11:57 -07:00
Kir Kolyshkin
d4159a7e73 ci/gha: enable go caching
actions/setup-go complains:

> Restore cache failed: Dependencies file is not found in
> /home/runner/work/moby/moby. Supported file pattern: go.sum

Let's give it one to chew.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-10-22 21:55:28 -07:00
Sebastiaan van Stijn
0acdc37a20 container: remove deprecated ErrNameReserved, ErrNameNotReserved
These errors were deprecated in 3cf90ca73f
in favor of using errdefs types. They're no longer used, so we can remove
them.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-22 23:34:18 +02:00
Sebastiaan van Stijn
1dcb7af2cb daemon: remove Daemon.containerRoot, Daemon.newBaseContainer
Daemon.containerRoot was only used in a single place, but defined far
from where it was used, and Daemon.newBaseContainer was a _very_ thin
abstraction on top of container.NewBaseContainer.

Let's remove these.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-22 17:27:19 +02:00
Sebastiaan van Stijn
7f8ef5c09d Merge pull request #48723 from thaJeztah/daemon_remove_exists_ispaused
daemon: remove deprecated Daemon.Exists and Daemon.IsPaused
2024-10-22 16:54:27 +02: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
Rob Murray
aba8df74a1 Add TestDirectRoutingOpenPorts
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-22 14:38:13 +01:00
Rob Murray
c9fdeaf70e Explicitly DROP packets for ports/protos that aren't mapped.
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-22 14:38:13 +01:00
Rob Murray
6634fc5136 Allow ICMP in routed mode
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-22 14:38:13 +01:00
Sebastiaan van Stijn
6131322c6f daemon: remove deprecated Daemon.IsPaused
This was deprecated in ac6e32cb5c, and
no longer used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-22 15:19:22 +02:00
Sebastiaan van Stijn
692024a18c daemon: remove deprecated Daemon.Exists
This was deprecated in d47c31ffdd, and
no longer used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-22 15:18:18 +02:00
Sebastiaan van Stijn
96bb0b4af3 Merge pull request #48650 from thaJeztah/bump_etcd
vendor: go.etcd.io/etcd v3.5.16, go.etcd.io/etcd/server/v3 v3.5.16
2024-10-22 13:39:00 +02:00
Paweł Gronowski
3bbb9749f4 c8d/test: Add memoryLabelStore
Add an implementation of label store that's needed to create a local
content store for testing purposes.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-10-22 13:28:55 +02:00
Paweł Gronowski
3f745f2b21 c8d/list: Extract fake service helpers
Extract to a separate file as they're also used by other files in this
package.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-10-22 13:28:51 +02:00
Paweł Gronowski
11aa9e1aae Merge pull request #48417 from adams1mon/try-fix-flaky-plugin-client-test
Increase flaky test sleep, replace deprecated assert
2024-10-22 13:06:51 +02:00
Akihiro Suda
1bb5f8bb67 update to go1.23.2
vendor.mod still allows go1.22.

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-10-22 00:04:58 +09:00
Akihiro Suda
d99294e58d Merge pull request #48670 from thaJeztah/deprecate_daemon_exists
daemon: deprecate Daemon.Exists and Daemon.IsPaused
2024-10-21 23:56:08 +09:00
Sebastiaan van Stijn
3f9e489ce5 Merge pull request #48706 from thaJeztah/stringid_optimize
pkg/stringid: optimize GenerateRandomID
2024-10-21 16:53:04 +02:00
Sebastiaan van Stijn
03b2d96d1d Merge pull request #48704 from thaJeztah/refactor_hostname
daemon: Daemon.newContainer: inline Daemon.generateHostname
2024-10-21 15:26:08 +02:00
Sebastiaan van Stijn
a8cd0fc4d4 vendor: go.etcd.io/etcd/server/v3 v3.5.16
This dependency comes from SwarmKit, but didn't update dependencies
for quite some time. Update the dependencies to their latest patch
release.

For some reason, updating this dependency brings back various legacy
versions of dependencies through `github.com/coreos/etcd/clientv3/concurrency`;

    go: finding module for package github.com/coreos/etcd/clientv3/concurrency
    go: finding module for package github.com/coreos/etcd/clientv3
    go: found github.com/coreos/etcd/clientv3 in github.com/coreos/etcd v3.3.27+incompatible
    go: found github.com/coreos/etcd/clientv3/concurrency in github.com/coreos/etcd v3.3.27+incompatible
    go: finding module for package github.com/coreos/go-systemd/journal
    go: finding module for package github.com/coreos/pkg/capnslog
    go: found github.com/coreos/pkg/capnslog in github.com/coreos/pkg v0.0.0-20240122114842-bbd7aa9bf6fb
    go: found github.com/coreos/go-systemd/journal in github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf

The above resolution results in these legacy versions to be added;

    github.com/coreos/etcd v3.3.27+incompatible // indirect
    github.com/coreos/go-systemd v0.0.0-20191104093116-d3cd4ed1dbcf // indirect
    github.com/coreos/pkg v0.0.0-20240122114842-bbd7aa9bf6fb // indirect

However, none of those are _used_, and they don't appear as vendored file.

That change happens with v3.5.7 and up, but nothing immediately stands
out what change causes this. Possibly it's due to the switch to go1.17
in go.mod, which is the first version that flattened indirect dependencies,
potentially causing intermediate dependency versions to be used during
resolution; https://github.com/etcd-io/etcd/compare/server/v3.5.6...server/v3.5.7

changelog: f0187c38d1/CHANGELOG/CHANGELOG-3.5.md

full diff: https://github.com/etcd-io/etcd/compare/server/v3.5.6...server/v3.5.16

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-21 13:23:54 +02:00
Sebastiaan van Stijn
5f994c49e8 vendor: go.etcd.io/etcd v3.5.16
This dependency comes from SwarmKit, but didn't update dependencies
for quite some time. Update the dependencies to their latest patch
release.

Keeping the server at v3.5.6, because newer versions pull in some
odd dependencies (but not used in code).

changelog: f0187c38d1/CHANGELOG/CHANGELOG-3.5.md

full diff: https://github.com/etcd-io/etcd/compare/v3.5.6...v3.5.16

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-21 13:23:53 +02:00
Sebastiaan van Stijn
ac6e32cb5c daemon: deprecate Daemon.IsPaused
This function was poorly documented as it uses fuzzy matching under the hood,
and it's no longer used. Mark it as deprecated, and to be removed in the
next release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-21 13:22:02 +02:00
Sebastiaan van Stijn
d47c31ffdd daemon: deprecate Daemon.Exists
This function was poorly documented as it uses fuzzy matching under the hood,
and it's no longer used. Mark it as deprecated, and to be removed in the
next release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-21 13:22:00 +02:00
Sebastiaan van Stijn
71fffa7a03 Merge pull request #48707 from thaJeztah/stringid_tabletest
pkg/stringid: replace TestShortenIdXXX with TestTruncateID table test
2024-10-21 13:20:25 +02:00
Albin Kerouanton
89ff523adf Merge pull request #48577 from am97/48560-setup-user-chains
Fix: setup user chains during libnetwork controller initialization
2024-10-21 13:16:03 +02:00
Paweł Gronowski
e3c4ed1139 Merge pull request #48517 from grautxo/48516-release-layer-on-container-export
Releases container layer on docker export
2024-10-21 12:10:33 +02:00
Sebastiaan van Stijn
d9ae34289a daemon: Daemon.newContainer: explicitly return nil-error
The error would always be nil at this point, so let's make that explicit.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-21 11:36:00 +02:00
Sebastiaan van Stijn
303530c1f5 daemon: Daemon.newContainer: inline Daemon.generateHostname
generateHostname was only used here, and defined as a method on Daemon
without depending on the daemon type. Inline the function and simplify
the logic (as both the "network=host" and non-host code only had to be
executed if no hostname was set).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-21 11:36:00 +02:00
Sebastiaan van Stijn
7faaa3afa8 client: explicitly return zero-type on failures in prune functions
Mostly a "nit", but it makes it clearer that we're returning an empty result,
and not a (partially) propagated struct.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-21 11:29:59 +02:00
Sebastiaan van Stijn
0539b7073e pkg/stringid: optimize GenerateRandomID
GenerateRandomID has a check to verify if the generated ID was numeric. This
check was added because a container's short-ID is used as default hostname for
containers, which isn't allowed to be consisting of only numbers (see [moby#3869]
and https://bugzilla.redhat.com/show_bug.cgi?id=1059122.

Producing an random ID with only numbers is a rare corner-case, but the check
would always be executed and wasn't optimized.

This patch applies some optimizations:

- The code was using `strconv.ParseUInt`, which has additional checks for
  signs ("+" or "-"); `hex.EncodeToString` would never produce these, so
  we can use `strconv.ParseInt` instead (which doesn't have these checks).
- The code was using `TruncateID(id)` to get the short-ID. The `TruncateID`
  function is designed to also handle digests, and for that checks for
  the given ID to contain colons (`:`), which it would split to remove
  the algorithm (`sha256:`) before truncating to the short-ID length.
  That check wasn't needed either, because those would not be produced
  by `hex.EncodeToString`, so instead, we can just truncate the ID.
- Finally, all we _really_ need to check for is if the ID consists of only
  numeric characters (`0-9`) so, let's do just that; if any non-numeric
  value is found, the ID is valid, and we can terminate the loop.

I did some basic benchmark to compare all of the above in isolation;

- BenchmarkParseInt: `strconv.ParseInt(TruncateID(id), 10, 64)`
- BenchmarkParseUInt: `strconv.ParseUint(TruncateID(id), 10, 64)`
- BenchmarkParseUIntNoTrunc: `strconv.ParseUint(id[:shortLen], 10, 64)`
- BenchmarkAllNum: `allNum(id[:shortLen])`

Results of the above:

    BenchmarkParseInt-10                1713937       691.0 ns/op     480 B/op      18 allocs/op
    BenchmarkParseIntNoTrunc-10         3385483       356.1 ns/op     480 B/op      18 allocs/op
    BenchmarkParseUInt-10               2112538       567.7 ns/op     384 B/op      12 allocs/op
    BenchmarkParseUIntNoTrunc-10        4325847       266.7 ns/op     384 B/op      12 allocs/op
    BenchmarkAllNum-10                 77277264        15.29 ns/op      0 B/op       0 allocs/op

Difference for `GenerateRandomID` as a whole is less dramatic, as in most
cases `ParseInt` would bail out early, but still saves some allocations, and
performance is ~14% better:

    BenchmarkGenerateRandomID-10        2807764       424.5 ns/op     240 B/op       6 allocs/op
    BenchmarkGenerateRandomIDNew-10     3288866       366.6 ns/op     160 B/op       3 allocs/op

[moby#3869]: https://github.com/moby/moby/issues/3869

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-21 11:17:05 +02:00
Sebastiaan van Stijn
e0384101da Merge pull request #48701 from thaJeztah/keep_manifest_order
api: GET /images/json: preserve original manifest order
2024-10-21 10:14:42 +02:00
Akihiro Suda
5039225fcf Merge pull request #48702 from thaJeztah/deprecate_daemon_register
daemon: deprecate Daemon.Register and make it internal
2024-10-21 13:34:46 +09:00
Akihiro Suda
4194bc0c93 Merge pull request #48708 from thaJeztah/pkg_archive_remove_deprecated
pkg/archive: remove deprecated CanonicalTarNameForPath, NewTempArchive, TempArchive
2024-10-21 13:32:51 +09:00
Akihiro Suda
de083b2f79 Merge pull request #48705 from thaJeztah/stringid_cleanups_step2
pkg/stringid: remove deprecated IsShortID, ValidateID
2024-10-21 13:26:27 +09:00
Sebastiaan van Stijn
7ebe625db7 pkg/archive: move deprecated NewTempArchive, TempArchive to test-utils
These were deprecated in 7ce1edd7c6, which
is part of v27.0.0. Move them to a test-file as they were only used for
tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-20 17:36:04 +02:00
Sebastiaan van Stijn
b313fcb8ff pkg/archive: remove deprecated CanonicalTarNameForPath
This was deprecated in 92b8d93f47, which
is part of v27.0.0, so we can remove it from master.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-20 17:24:04 +02:00
Sebastiaan van Stijn
c837027a9c pkg/stringid: replace TestShortenIdXXX with TestTruncateID table test
These tests were named confusingly as they're testing `TruncateID`.
While renaming, let's also combine them into a single test using
a test-table, so that the test-cases can carry some description
what they're testing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-20 16:59:36 +02:00
Sebastiaan van Stijn
83f17b0cbb pkg/stringid: remove deprecated IsShortID, ValidateID
- `IsShortID` was deprecated in 2100a70741
- `ValidateID` was deprecated in e19e6cf7f4

Both are part of 27.0, so we can remove these.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-20 16:15:22 +02:00
Sebastiaan van Stijn
77f97926ad daemon: remove secretsSupported utility
This utility was originally added in 3716ec25b4
at which time it was not yet implemented for Windows, so this utility was
used to print a warning when trying to use it on that platform.

Windows support was added in bd4e8aa64e, which
kept the utility, but adjusted it to support for both Windows and Linux, and
excluding any other platform.

Let's remove this utility, given that we currently only support Windows and
Linux (there's been some partial support for other platforms, but they are
very likely broken in many ways).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-20 14:10:17 +02:00
Sebastiaan van Stijn
c0b86dd068 daemon: remove configsSupported utility
This utility was originally added in 9e9fc7b57c
at which time it was not yet implemented for Windows, so this utility was
used to print a warning when trying to use it on that platform.

Windows support was added in e0d533b1e8, which
kept the utility, but adjusted it to support for both Windows and Linux, and
excluding any other platform.

Let's remove this utility, given that we currently only support Windows and
Linux (there's been some partial support for other platforms, but they are
very likely broken in many ways).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-20 14:04:07 +02: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
d122ea0aea api: GET /images/json: preserve original manifest order
The `manifests` option, as used for the `--tree` option on `docker image ls`
currently sorts manifests to put those that are present first. The intent was
to present "available" images at the top of each tree, followed by images that
were not pulled.

However, there's some limitations to this. First of all, the current approach
makes the output non-deterministic as the order in which variants are pulled
determines the order in which they're presented, i.e., the last pulled variant
is returned first (I omitted some variants in the example for brevity);

Here's the result of pulling `linux/riscv64`, then pulling `linux/arm64`;

    docker pull --platform=linux/riscv64 alpine:latest
    docker image ls -a --tree

    IMAGE                   ID             DISK USAGE   CONTENT SIZE   USED
    alpine:latest           beefdbd8a1da       10.6MB         3.37MB
    ├─ linux/riscv64        80cde017a105       10.6MB         3.37MB
    ├─ linux/amd64          33735bd63cf8           0B             0B
    └─ linux/arm64/v8       9cee2b382fe2           0B             0B

    docker pull --platform=linux/arm64 alpine:latest
    docker image ls -a --tree

    IMAGE                   ID             DISK USAGE   CONTENT SIZE   USED
    alpine:latest           beefdbd8a1da       24.2MB         7.46MB
    ├─ linux/riscv64        80cde017a105       10.6MB         3.37MB
    ├─ linux/arm64/v8       9cee2b382fe2       13.6MB         4.09MB
    └─ linux/amd64          33735bd63cf8           0B             0B

Repeating the steps but in reverse order results in the output to be reversed;

    docker image rm alpine:latest
    docker pull --platform=linux/arm64 alpine:latest
    docker image ls -a --tree

    IMAGE                   ID             DISK USAGE   CONTENT SIZE   USED
    alpine:latest           beefdbd8a1da       13.6MB         4.09MB
    ├─ linux/arm64/v8       9cee2b382fe2       13.6MB         4.09MB
    ├─ linux/amd64          33735bd63cf8           0B             0B
    └─ linux/riscv64        80cde017a105           0B             0B

    docker image ls -a --tree

    IMAGE                   ID             DISK USAGE   CONTENT SIZE   USED
    alpine:latest           beefdbd8a1da       24.2MB         7.46MB
    ├─ linux/riscv64        80cde017a105       10.6MB         3.37MB
    ├─ linux/arm64/v8       9cee2b382fe2       13.6MB         4.09MB
    └─ linux/amd64          33735bd63cf8           0B             0B

The second limitation is that order sometimes matters; when matching a
platform from a manifest-index, implementations may find multiple suitable
candidates. In most cases the _most_ suitable candidate can be selected
(e.g., prefer `linux/arm/v7` over `linux/arm/v6`), but manifest-indices do
allow multiple entries for the same platform, in which case implementations
match the first entry found.

While these situations will be less common (and usually due to incorect use
of tooling such as `docker manifest`), being able to observe the order in
which manifests appeared in the index can help debugging or help the user
understand why a specific variant was selected.

We should therefore not re-order these manifests, and return them in the
order in which they appeared. If we decide to present "present" variants
before "non-present" variants, we can do this ordering on the client side.

With this patch applied;

    docker pull --quiet --platform=linux/riscv64 alpine:latest
    docker pull --quiet --platform=linux/arm64 alpine:latest
    docker image ls --tree alpine

    IMAGE                   ID             DISK USAGE   CONTENT SIZE   USED
    alpine:latest           beefdbd8a1da       24.2MB         7.46MB
    ├─ linux/amd64          33735bd63cf8           0B             0B
    ├─ linux/arm/v6         50f635c8b04d           0B             0B
    ├─ linux/arm/v7         f2f82d424957           0B             0B
    ├─ linux/arm64/v8       9cee2b382fe2       13.6MB         4.09MB
    ├─ linux/386            b3e87f642f5c           0B             0B
    ├─ linux/ppc64le        c7a6800e3dc5           0B             0B
    ├─ linux/riscv64        80cde017a105       10.6MB         3.37MB
    └─ linux/s390x          2b5b26e09ca2           0B             0B

Which matches the order of the manifests in the index:

    docker buildx imagetools inspect --raw alpine:latest | jq -c .manifests[].platform
    {"architecture":"amd64","os":"linux"}
    {"architecture":"arm","os":"linux","variant":"v6"}
    {"architecture":"arm","os":"linux","variant":"v7"}
    {"architecture":"arm64","os":"linux","variant":"v8"}
    {"architecture":"386","os":"linux"}
    {"architecture":"ppc64le","os":"linux"}
    {"architecture":"riscv64","os":"linux"}
    {"architecture":"s390x","os":"linux"}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-20 11:59:33 +02:00
Joan Grau
1aba291cd4 Releases container layer on export
When running docker export command the container layer
is only released in case there is an error.

This makes the daemon not being able to remove
them when using docker rmi or docker system prune
leaving the container layer and the image used
in an orphaned state on the docker file system.

After applying this patch, the layer is always
released allowing dockerd to remove/prune it.

Signed-off-by: Joan Grau <grautxo.dev@proton.me>
2024-10-19 12:08:54 +02:00
Sebastiaan van Stijn
b0632b2345 Merge pull request #48675 from thaJeztah/volumes_more_structured_logs
volume/service: change some logs to use structured logs
2024-10-18 23:36:46 +02:00
Sebastiaan van Stijn
66f159dc24 build: log when build is cancelled
I noticed that the daemon logs, even in debug, did not give any
indication that the build was cancelled. This patch adds some logs
to help debugging.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-18 23:22:32 +02:00
Brian Goff
e7f9f0640f Merge pull request #48677 from thaJeztah/debug_structured_logs
api/server/middleware: use structured logs for debug-logs
2024-10-18 11:02:11 -07:00
Sebastiaan van Stijn
ba222fc682 Merge pull request #48683 from AkihiroSuda/fix-48678
dockerd-rootless-setuptool.sh: let --force ignore smoke test errors
2024-10-18 17:17:57 +02:00
Sebastiaan van Stijn
36a3bd0904 Merge pull request #48690 from vvoland/otel-meter-leak
cmd/dockerd: Add workaround for OTEL meter leak
2024-10-18 16:22:20 +02:00
Paweł Gronowski
cca7085464 cmd/dockerd: Add workaround for OTEL meter leak
OTEL meter implementation has a memory leak issue which causes each
meter counter invocation to create a new instrument when the meter
provider is not set.

Also add a test, which will fail once a fixed OTEL is vendored.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-10-18 14:41:54 +02:00
Sebastiaan van Stijn
e33fcb47b1 Merge pull request #48669 from thaJeztah/daemon_fix_restore
daemon: fix restoring containers with name matching an ID
2024-10-18 12:59:08 +02:00
Albin Kerouanton
8c5a6c68ea Merge pull request #48603 from akerouanton/firewalld-ci-jobs
ci: run integration tests with firewalld enabled
2024-10-18 12:25:28 +02:00
Paweł Gronowski
d5ec1e2a79 Merge pull request #48686 from thaJeztah/bump_swarmkit
vendor: github.com/moby/swarmkit/v2 v2.0.0-20241017191044-e8ecf83ee08e
2024-10-18 12:19:09 +02:00
Sebastiaan van Stijn
d828b032a8 Merge pull request #48565 from crazy-max/build-split-history-db
build: create distinct history db for each store
2024-10-17 22:49:05 +02:00
Sebastiaan van Stijn
21b0d5f0c1 vendor: github.com/moby/swarmkit/v2 v2.0.0-20241017191044-e8ecf83ee08e
- add Unwrap error to custom error types
- removes dependency on github.com/rexray/gocsi
- fix CSI plugin load issue

full diff: ea1a7cec35...e8ecf83ee0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-17 22:26:33 +02:00
Sebastiaan van Stijn
5e9c96eb53 Merge pull request #48679 from thaJeztah/resize_uint
api: container, exec resize: improve errors for invalid width/height
2024-10-17 21:15:16 +02:00
Akihiro Suda
921ac59a73 Merge pull request #48682 from thaJeztah/remove_formatPlatform
distribution: remove formatPlatform utility
2024-10-18 00:36:39 +09:00
Akihiro Suda
fafdcd1194 dockerd-rootless-setuptool.sh: let --force ignore smoke test errors
Now `dockerd-rootless-setuptool.sh install --force` ignores errors
from `rootlesskit`.

This might be useful when installing Rootless Docker into a container
image with `RUN` instructions.

Fix issue 48678

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-10-18 00:11:59 +09:00
Albin Kerouanton
6649a32cb3 Merge pull request #48676 from robmry/48664_br_netfilter_noproxy
Enable bridge netfiltering if userland-proxy=false
2024-10-17 15:31:45 +02:00
Sebastiaan van Stijn
e7e555f573 distribution: remove formatPlatform utility
It was used in a single place, and the containerd/platforms module now
provides a format for a platform including os.version (through FormatAll),
which means we no longer have to create our own formatting for this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-17 14:25:35 +02:00
Sebastiaan van Stijn
abed0e1f97 client: ContainerResize, ContainerExecResize: don't overflow width/height
Mostly theoretical, but let's be correct here. It's worth noting that the API
(backend) accepts uint32, but container.ResizeOptions uses uint (uint64). We
could decide to add checks for this on the client side, or to change the
type (but that would be a breaking change).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-17 14:04:37 +02:00
Sebastiaan van Stijn
ed44a05607 api: backend.ContainerExecResize: pass context and use uint32 for width, height
Containerd accepts uints for these, so make the backend signature align
with that, so that we don't have to cast values. Also pass the context
along.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-17 14:04:37 +02:00
Sebastiaan van Stijn
2b2aa69100 api: exec resize: improve errors for invalid width/height
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-17 14:04:37 +02:00
Sebastiaan van Stijn
8553d34593 api: backend.ContainerResize: pass context and use uint32 for width, height
Containerd accepts uints for these, so make the backend signature  align
with that, so that we don't have to cast values. Also pass the context
along.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-17 14:04:36 +02:00
Sebastiaan van Stijn
d19aa0c590 api: container resize: improve errors for invalid width/height
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-17 14:04:36 +02:00
Sebastiaan van Stijn
1dd9d2c780 api/server/httputils: add Uint32Value utility
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-17 14:04:32 +02:00
Sebastiaan van Stijn
3900f9a0c0 Merge pull request #48680 from thaJeztah/decodeplatform_coverage
api/server/httputils: DecodePlatform: improve test-coverage
2024-10-17 14:02:01 +02:00
Rob Murray
091b09f26e Merge pull request #48575 from robmry/port_mapping_validation
Log rather than error if port mapping is overspecified
2024-10-17 12:39:14 +01:00
Rob Murray
0548fe251c Enable bridge netfiltering if userland-proxy=false
In release 27.0, ip6tables was enabled by default. That caused a
problem on some hosts where iptables was explicitly disabled and
loading the br_netfilter module (which loads with its nf-call-iptables
settings enabled) caused user-defined iptables rules to block traffic
on bridges, breaking inter-container communication.

In 27.3.0, commit 5c499fc4b2 delayed
loading of the br_netfilter module until it was needed. The load
now happens in the function that sets bridge-nf-call-ip[6]tables when
needed. It was only called for icc=false networks.

However, br_netfilter is also needed when userland-proxy=false.
Without it, packets addressed to a host-mapped port for a container
on the same network are not DNAT'd properly (responses have the server
container's address instead of the host's).

That means, in all releases including 26.x, if br_netfilter was loaded
before the daemon started - and the OS/user/other-application had
disabled bridge-nf-call-ip[6]tables, it would not be enabled by the
daemon. So, ICC would fail for host-mapped ports with the userland-proxy
disabled.

The change in 27.3.0 made this worse - previously, loading br_netfilter
whenever iptables/ip6tables was enabled meant that bridge-netfiltering
got enabled, even though the daemon didn't check it was enabled.

So... check that br_netfilter is loaded, with bridge-nf-call-ip[6]tables
enabled, if userland-proxy=false.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-17 12:33:49 +01:00
Sebastiaan van Stijn
039e164bf5 api/server/httputils: DecodePlatform: improve test-coverage
- Use fixtures for the JSON strings
- Add test-cases for invalid / malformed JSON
- Check error-message produced
- Add test for "happy path"

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-17 10:47:10 +02:00
Andrés Maldonado
a8bfa83667 Fix: setup user chains even if there are running containers
Currently, the DOCKER-USER chains are set up on firewall reload or network
creation. If there are running containers at startup, configureNetworking won't
be called (daemon/daemon_unix.go), so the user chains won't be setup.

This commit puts the setup logic on a separate function, and calls it on the
original place and on initNetworkController.

Signed-off-by: Andrés Maldonado <maldonado@codelutin.com>
2024-10-16 22:41:39 +02:00
Sebastiaan van Stijn
1b7c209de1 Merge pull request #48651 from thaJeztah/cleaner_buildopts
client: imageBuildOptionsToQuery: omit empty and default values from query
2024-10-16 17:34:11 +02:00
Sebastiaan van Stijn
1701bce9e0 api/server/middleware: use structured logs for debug-logs
Rewrite the debug-logs produced

- Use structured logs
- Combine into a single log per request, instead of separate log-entry
  for the "form-data".
- Include error-messages returned by the handler ("error-response" field)
- Include HTTP status-code returned ("status" field)
- Include the "vars" as a field; these are fields extracted from the URL
  and passed to the handler

Examples below are logs for:

    docker ps
    docker container inspect nosuchcontainer
    docker volume create --name foo

Before this change:

    DEBU[2024-10-16T10:59:40.484254465Z] Calling HEAD /_ping                           spanID=43d76043f8e30dbb traceID=04f980a33901f35ba33c3927d3bb4bbb
    DEBU[2024-10-16T10:59:40.485551840Z] Calling GET /v1.47/containers/json            spanID=b9979f2b36572a43 traceID=5c2167537df2dede6bdbab030f8350bc
    DEBU[2024-10-16T11:00:00.374864502Z] Calling HEAD /_ping                           spanID=d637e39684d56a16 traceID=efaed7838901dd6a597c5446ce3f83e2
    DEBU[2024-10-16T11:00:00.384198127Z] Calling GET /v1.47/containers/nosuchcontainer/json  spanID=f9cc4520b95d814b traceID=c15ae04ca248929d6e52474e711d48b0
    DEBU[2024-10-16T11:00:11.576426632Z] Calling HEAD /_ping                           spanID=2bc30d2be873a8e5 traceID=53ccc3d2af87aa5425421306906660a6
    DEBU[2024-10-16T11:00:11.588877966Z] Calling POST /v1.47/volumes/create            spanID=30816d2b51dd75b2 traceID=020b0e612195466468b46eb0d35a8f23
    DEBU[2024-10-16T11:00:11.589198966Z] form data: {"Driver":"local","Name":"foo"}    spanID=30816d2b51dd75b2 traceID=020b0e612195466468b46eb0d35a8f23
    DEBU[2024-10-16T11:00:11.594828216Z] using regular volume                          spanID=30816d2b51dd75b2 traceID=020b0e612195466468b46eb0d35a8f23

After this:

When using plain-text, we continue encoding the form-data to JSON, but
as it's now in a field, it'll be shown escaped;

    DEBU[2024-10-16T11:17:35.465777379Z] handling HEAD request                         method=HEAD module=api request-url=/_ping spanID=9b7ea0288b2b70c3 status=200 traceID=94ef9345624e92ac0263931fbe9e15db vars="map[]"
    DEBU[2024-10-16T11:17:35.468050171Z] handling GET request                          method=GET module=api request-url=/v1.47/containers/json spanID=04675edee7b5ec9d status=200 traceID=a9d81dcdbf2650fa6d794a7a856fb66b vars="map[version:1.47]"
    DEBU[2024-10-16T11:17:38.502289297Z] handling HEAD request                         method=HEAD module=api request-url=/_ping spanID=7c43a8dfd8fb5043 status=200 traceID=7a2a7c71cd421570e811474749a04ccd vars="map[]"
    DEBU[2024-10-16T11:17:38.504847506Z] handling GET request                          error-response="No such container: nosuchcontainer" method=GET module=api request-url=/v1.47/containers/nosuchcontainer/json spanID=ab721bbbe5cf8035 status=404 traceID=4a08dcd5054fc8090e3af8846beea10d vars="map[name:nosuchcontainer version:1.47]"
    DEBU[2024-10-16T11:17:40.788838340Z] handling HEAD request                         method=HEAD module=api request-url=/_ping spanID=2dbc18ba1334635b status=200 traceID=ea9af681d096dc4a2c2f2ed7338ea417 vars="map[]"
    DEBU[2024-10-16T11:17:40.790496465Z] handling POST request                         form-data="{\"Driver\":\"local\",\"Name\":\"foo\"}" method=POST module=api request-url=/v1.47/volumes/create spanID=03690760b6f6dec4 status=200 traceID=79a985fff0dd5fac7c90d36b04941e0a vars="map[version:1.47]"

The alternative to the above would be to unconditionally set it as-is,
but in that case it would use Go's formatting for `map[string]any`;

    DEBU[2024-10-16T11:27:54.937232805Z] handling POST request                         form-data="map[Driver:local Name:foo]" method=POST module=api request-url=/v1.47/volumes/create spanID=2d7985a900791bf6 status=200 traceID=33feab9fd5feba3b0f4b6ec5a6971a67 vars="map[version:1.47]"

Or to use some trickery to not quote this specific field, but that may limit the
output from being parsable;

    DEBU[2024-10-16T11:17:40.790496465Z] handling POST request                         form-data={"Driver":"local","Name":"foo"} method=POST module=api request-url=/v1.47/volumes/create spanID=03690760b6f6dec4 status=200 traceID=79a985fff0dd5fac7c90d36b04941e0a vars="map[version:1.47]"

When using `--log-format=json`, the form-data is kept as structured, becoming
part of the main JSON struct:

    {"level":"debug","method":"HEAD","module":"api","msg":"handling HEAD request","request-url":"/_ping","spanID":"166dc12eeeadf82b","status":200,"time":"2024-10-16T11:16:09.427380423Z","traceID":"7f4f2501eee3b15ae608481ba214bd56","vars":{}}
    {"level":"debug","method":"GET","module":"api","msg":"handling GET request","request-url":"/v1.47/containers/json","spanID":"bf95e2ce9eca41c2","status":200,"time":"2024-10-16T11:16:09.429077631Z","traceID":"041b26b30dacc240e8e3afc9c567195d","vars":{"version":"1.47"}}
    {"level":"debug","method":"HEAD","module":"api","msg":"handling HEAD request","request-url":"/_ping","spanID":"454953906c36ea6b","status":200,"time":"2024-10-16T11:16:13.455633008Z","traceID":"3ffc0a256d6ec1a56cd7f6bf1008e55d","vars":{}}
    {"error-response":"No such container: nosuchcontainer","level":"debug","method":"GET","module":"api","msg":"handling GET request","request-url":"/v1.47/containers/nosuchcontainer/json","spanID":"dcf0d42921928b29","status":404,"time":"2024-10-16T11:16:13.460309925Z","traceID":"fdfd2c89941c9c7a459bec7a05e46ef8","vars":{"name":"nosuchcontainer","version":"1.47"}}
    {"level":"debug","method":"HEAD","module":"api","msg":"handling HEAD request","request-url":"/_ping","spanID":"701dc623cf1b0253","status":200,"time":"2024-10-16T11:16:16.155730884Z","traceID":"786885a9f79cbfba99097eeb4145ca1e","vars":{}}
    {"form-data":{"Driver":"local","Name":"foo"},"level":"debug","method":"POST","module":"api","msg":"handling POST request","request-url":"/v1.47/volumes/create","spanID":"dc1429c1c636b30a","status":200,"time":"2024-10-16T11:16:16.162002426Z","traceID":"fc49ee4a7acafbbb8eb50ed34c434765","vars":{"version":"1.47"}}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-16 14:47:53 +02:00
Sebastiaan van Stijn
277cd940e5 Merge pull request #48655 from thaJeztah/vanity_badges
README: add some badges
2024-10-16 14:30:22 +02:00
Sebastiaan van Stijn
4992869c48 Merge pull request #48668 from thaJeztah/container_viewdb_fix_errtypes
container: deprecate ErrNameReserved, ErrNameNotReserved, use errdefs instead
2024-10-16 14:05:58 +02:00
Sebastiaan van Stijn
b849b4df48 Merge pull request #48673 from thaJeztah/daemon_kill_logs
daemon: killWithSignal: use more structured logs
2024-10-16 14:00:46 +02:00
Sebastiaan van Stijn
4e840b9e29 volume/service: change some logs to use structured logs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-16 12:48:44 +02:00
Sebastiaan van Stijn
f96c0597c0 Merge pull request #48665 from thaJeztah/integration_resize
container/integration: TestResize: add more test-cases, and add TestExecResize
2024-10-16 12:45:38 +02:00
Sebastiaan van Stijn
3f2bf91c85 Merge pull request #48672 from thaJeztah/inspect_move_to_api
api/server/router/container: move API adjustments to API
2024-10-16 11:58:26 +02:00
Sebastiaan van Stijn
bca54a6838 daemon: killWithSignal: use more structured logs
Use more structured logs, and provide a human-readable presentation of the signal
that's sent. For the human-readable presentation, we should probably look at
converting back to the signal _names_ (e.g. `SIGWINCH` or `SIGKILL`), which may
be easier to interpret, but we currently don't have a utility for that.

Before:

    DEBU[2024-10-14T10:24:51.538705343Z] Sending kill signal 28 to container 7e9e99e52fc69ef1038b2fd212c8dc18948a56e6f024fbe46192f43006a229aa
    DEBU[2024-10-14T10:24:51.740502218Z] Calling POST /v1.47/containers/7e9e99e52fc69ef1038b2fd212c8dc18948a56e6f024fbe46192f43006a229aa/kill?signal=WINCH  spanID=9b993a93d28479f3 traceID=a37022e0429abaf9fb8b66a6cd4e4a19
    DEBU[2024-10-14T10:24:51.740874218Z] Sending kill signal 28 to container 7e9e99e52fc69ef1038b2fd212c8dc18948a56e6f024fbe46192f43006a229aa
    DEBU[2024-10-14T10:24:51.740501843Z] Calling POST /v1.47/containers/7e9e99e52fc69ef1038b2fd212c8dc18948a56e6f024fbe46192f43006a229aa/resize?h=39&w=127  spanID=f1563bdd86230804 traceID=9c25ff5910b30a4a04b774c8f5d0160e

After:

    DEBU[2024-10-15T17:17:18.988605173Z] Calling POST /v1.47/containers/cafc94ca93a8e10eb79ce86235c4510d6bba1dab9cf4827abe490328148418c8/kill?signal=WINCH  spanID=491d75545f89902a traceID=de72bdd1130bfc010ff1172ac23695b3
    DEBU[2024-10-15T17:17:18.988763173Z] sending signal 28 (window changed) to container  container=cafc94ca93a8e10eb79ce86235c4510d6bba1dab9cf4827abe490328148418c8 signal=28
    DEBU[2024-10-15T17:17:18.988605214Z] Calling POST /v1.47/containers/cafc94ca93a8e10eb79ce86235c4510d6bba1dab9cf4827abe490328148418c8/resize?h=46&w=152  spanID=8b18f64b12931da2 traceID=0a38e4a16dbbfda72172209382faec91
    ...
    ...
    DEBU[2024-10-15T20:26:16.863097005Z] sending signal 1 (hangup) to container        container=824197a9af794c4bcda13914021f13d702954114d3410c9db629a51bf685bdc7 signal=1
    DEBU[2024-10-15T20:26:31.431432554Z] sending signal 10 (user defined signal 1) to container  container=824197a9af794c4bcda13914021f13d702954114d3410c9db629a51bf685bdc7 signal=10
    DEBU[2024-10-15T19:52:41.717507211Z] shutting down container                       container=824197a9af794c4bcda13914021f13d702954114d3410c9db629a51bf685bdc7
    DEBU[2024-10-15T19:52:41.717681920Z] sending signal 15 (terminated) to container   container=824197a9af794c4bcda13914021f13d702954114d3410c9db629a51bf685bdc7 signal=15

Or in JSON format:

    {"level":"debug","msg":"Calling POST /v1.47/containers/6a62783bc6a591381dd625b8dca20bebf6b0f6e927956b92a4c8ea0438f2ff76/kill?signal=WINCH","spanID":"d7622e49d248a2e5","time":"2024-10-15T19:54:36.258464042Z","traceID":"8dcc62a38b0289c9eeb7d9fa7f9a485d"}
    {"container":"6a62783bc6a591381dd625b8dca20bebf6b0f6e927956b92a4c8ea0438f2ff76","level":"debug","msg":"sending signal 28 (window changed) to container","signal":28,"time":"2024-10-15T19:54:36.258546167Z"}
    {"level":"debug","msg":"Calling POST /v1.47/containers/6a62783bc6a591381dd625b8dca20bebf6b0f6e927956b92a4c8ea0438f2ff76/kill?signal=WINCH","spanID":"0c908cb6fe55a921","time":"2024-10-15T19:54:36.458532084Z","traceID":"a0225edfaa0b3c3b0ce93e3d2c98f326"}
    {"container":"6a62783bc6a591381dd625b8dca20bebf6b0f6e927956b92a4c8ea0438f2ff76","level":"debug","msg":"sending signal 28 (window changed) to container","signal":28,"time":"2024-10-15T19:54:36.458614126Z"}
    {"level":"debug","msg":"Calling POST /v1.47/containers/6a62783bc6a591381dd625b8dca20bebf6b0f6e927956b92a4c8ea0438f2ff76/resize?h=50\u0026w=167","spanID":"1679a419b3f8b5e4","time":"2024-10-15T19:54:36.458560459Z","traceID":"cad46e855dc5975799a7c82bdbed1b81"}

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-15 22:40:39 +02:00
Sebastiaan van Stijn
87390ae849 Merge pull request #48571 from akerouanton/proxy-udp-with-correct-saddr
cmd/docker-proxy: UDP: reply to clients with original daddr
2024-10-15 20:51:37 +02:00
Sebastiaan van Stijn
44010e76c2 integration/container: add TestExecResize
Add integration tests for resizing exec's.

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-15 17:56:46 +02:00
Sebastiaan van Stijn
3f2e9da010 api/server/router/container: move API adjustments to API
The daemon used to have various implementation to adjust the container-inspect
output for different API versions, which could return different go structs,
and because of that required a function with a `interface{}` output type.

Most of those adjustments have been removed, and we no longer need separate
types for backward compatibility with old API versions.

This patch;

- Removes the Daemon.ContainerInspectCurrent method
- Introduces a backend.ContainerInspectOptions struct
- Updates the Daemon.ContainerInspect method's signature to accept the above
- Moves API-version specific adjustments to api/server/router/container,
  similar to how such adjustments are made for other endpoints.

Note that we should probably change the backend's signature further,
and define separate types for the backend's inspect and the API's
inspect response. Considering that the Backend signatures should be
considered "internal", we can do that in a future change.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-15 17:03:03 +02:00
Sebastiaan van Stijn
0c595fe781 api/server/router/container: fix inconsistent receiver name
It's good practice to use a consistent name; we couldn't use `r` as name,
as it's used for the request argument, and `s` honestly didn't make much
sense as name, so changing it to `c`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-15 16:43:16 +02:00
Rob Murray
3ba06cf6b9 Merge pull request #48593 from robmry/iptables_doc
Internal documentation for iptables rules
2024-10-15 15:41:30 +01:00
Rob Murray
59cf8e8565 Add iptables doc for a gateway-mode=routed network
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-15 14:02:49 +01:00
Rob Murray
19328fdd4f Add iptables doc for a --internal network
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-15 14:02:49 +01:00
Rob Murray
bc84b4b6d9 Add iptables doc for a network with icc=false
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-15 14:02:49 +01:00
Rob Murray
a8eaeba3f9 Add iptables doc for a network with userland-proxy disabled
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-15 14:02:49 +01:00
Rob Murray
ac4a95d1d0 Add iptables doc for a user-defined network
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-15 14:02:49 +01:00
Rob Murray
20571e453b Generate iptables documentation
In an integration test - run a daemon, capture iptables, and feed them
to a markdown text/template describing them.

Prep for repeating that, for different network configurations.

Fail the test if the generated markdown differs from a "golden" version.

(So, at-least the golden markdown will need to be updated if the
iptables rules are deliberately changed - hopefully the corresponding
description in the template will also be updated.)

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-15 14:02:49 +01:00
Sebastiaan van Stijn
2c68149290 Merge pull request #48598 from robmry/netlink_dump_interrupted
After retries, use netlink data even if the dump is still interrupted
2024-10-15 14:58:27 +02:00
Sebastiaan van Stijn
28925c9175 Merge pull request #48653 from thaJeztah/docs_update_api_links
update links to API documentation
2024-10-15 14:51:28 +02:00
Sebastiaan van Stijn
a602054826 daemon: fix restoring containers with name matching an ID
This patch fixes a bug in the daemon's restore step on startup, where
a container with a name matching another container's ID would not be
restored.

`Daemon.registerName` is used during startup as part of the daemon's
container restore code
97b1233a15/daemon/daemon.go (L331-L344)

In that process, it first registers the containers names through
[`Daemon.registerName()`][1], then registers the container's ID through
[`Daemon.Register()`][1], which calls `Daemon.containers.Add()` under the
hood.

Restoring containers is done in a goroutine, and at this stage of the daemon's
lifecycle, not all containers may be restored yet. However, `Daemon.registerName()`
has some safeguard to prevent the same container from being restored _twice_
through [`Daemon.Exists()`][3]. If a duplicate is found, an error is logged, and
the container is not restored (but kept on disk).

While it's disputable if this logic is needed at all, perhaps a panic would be
more appropriate (duplicate containers were stored on disk), there's also a
flaw in the current implementation of this check.

The [`Daemon.Exists()`][3] function uses [`Daemon.GetContainer()`][4] to look
up the container. This function performs fuzzy matching on the given reference,
first trying to match containers on their full ID, which _should_ not give a
match at this stage, before falling back to matching containers by name and
partial prefix.

This last part can be problematic in situations where a container exists that
uses the container to restore's ID as name. In such cases, the container will
be considered "already present", and not restored.

Create a container, then create a number of containers, each of which using
the ID of the previous container as name.

    docker create --name one hello-world
    d54301b7560f3c3544acc2d9c9dd55a194d6db37c2af64fe83fa34238c7ce6ab

    docker create --name d54301b7560f3c3544acc2d9c9dd55a194d6db37c2af64fe83fa34238c7ce6ab hello-world
    217c53b9826eb7875ca2620596864d039848470befeb5f963b3ebffe509e7a6d
    docker create --name 217c53b9826eb7875ca2620596864d039848470befeb5f963b3ebffe509e7a6d hello-world
    b125af485d6d1875b586b314f93af1b49d5baaa94cec4199ae4ef4c6da05e7e4
    docker create --name b125af485d6d1875b586b314f93af1b49d5baaa94cec4199ae4ef4c6da05e7e4 hello-world

The daemon should now have a number of containers where the ID and name
conflict:

    docker ps -a --no-trunc --format 'table {{.ID}}\t{{.Names}}'
    CONTAINER ID                                                       NAMES
    f59e8e4044471c45d4c9841d11a2c586cbfa4703b1344035fd51a15e15899ea7   b125af485d6d1875b586b314f93af1b49d5baaa94cec4199ae4ef4c6da05e7e4
    b125af485d6d1875b586b314f93af1b49d5baaa94cec4199ae4ef4c6da05e7e4   217c53b9826eb7875ca2620596864d039848470befeb5f963b3ebffe509e7a6d
    217c53b9826eb7875ca2620596864d039848470befeb5f963b3ebffe509e7a6d   d54301b7560f3c3544acc2d9c9dd55a194d6db37c2af64fe83fa34238c7ce6ab
    d54301b7560f3c3544acc2d9c9dd55a194d6db37c2af64fe83fa34238c7ce6ab   one

Restart the daemon. Depending on the order in which containers are restored,
a conflict may happen, and the conflicting container will not be restored.
Logs below are from the daemon with debug enabled;

    INFO[2024-10-15T11:13:38.770744797Z] Loading containers: start.
    DEBU[2024-10-15T11:13:38.771152214Z] processing event stream                       module=libcontainerd namespace=moby
    DEBU[2024-10-15T11:13:38.771599797Z] loaded container                              container=d54301b7560f3c3544acc2d9c9dd55a194d6db37c2af64fe83fa34238c7ce6ab paused=false running=false
    DEBU[2024-10-15T11:13:38.771637464Z] loaded container                              container=217c53b9826eb7875ca2620596864d039848470befeb5f963b3ebffe509e7a6d paused=false running=false
    DEBU[2024-10-15T11:13:38.771672714Z] loaded container                              container=bbe03a6554867810c2d7464ed3cb853865c755bae797b8d1f4caf60fb3f9fa04 paused=false running=false
    DEBU[2024-10-15T11:13:38.771765297Z] loaded container                              container=f59e8e4044471c45d4c9841d11a2c586cbfa4703b1344035fd51a15e15899ea7 paused=false running=false
    DEBU[2024-10-15T11:13:38.771780839Z] loaded container                              container=b125af485d6d1875b586b314f93af1b49d5baaa94cec4199ae4ef4c6da05e7e4 paused=false running=false
    ERRO[2024-10-15T11:13:38.772114505Z] failed to register container name: /217c53b9826eb7875ca2620596864d039848470befeb5f963b3ebffe509e7a6d  container=b125af485d6d1875b586b314f93af1b49d5baaa94cec4199ae4ef4c6da05e7e4 error="container is already loaded"

And the conflicting container (`217c53b9826eb7875ca2620596864d039848470befeb5f963b3ebffe509e7a6d`)
is not present:

    docker ps -a --no-trunc --format 'table {{.ID}}\t{{.Names}}'
    CONTAINER ID                                                       NAMES
    f59e8e4044471c45d4c9841d11a2c586cbfa4703b1344035fd51a15e15899ea7   b125af485d6d1875b586b314f93af1b49d5baaa94cec4199ae4ef4c6da05e7e4
    b125af485d6d1875b586b314f93af1b49d5baaa94cec4199ae4ef4c6da05e7e4   217c53b9826eb7875ca2620596864d039848470befeb5f963b3ebffe509e7a6d
    d54301b7560f3c3544acc2d9c9dd55a194d6db37c2af64fe83fa34238c7ce6ab   one

[1]: 97b1233a15/daemon/names.go (L22-L38)
[2]: 97b1233a15/daemon/container.go (L106-L121)
[3]: 97b1233a15/daemon/container.go (L71-L76)
[4]: 97b1233a15/daemon/container.go (L30-L69)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-15 14:20:13 +02:00
Sebastiaan van Stijn
71977a841c daemon: Daemon.registerName: inline validateID utility
This function only checked for the ID to be non-empty, and was only
used in a single location. Also move this check as first check in
registerName, to allow for an early return.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-15 13:21:35 +02:00
Albin Kerouanton
4e567e1622 ci: run integration tests with firewalld enabled
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-10-15 12:54:51 +02:00
Albin Kerouanton
8883db20c5 hack: run firewalld when $DOCKER_FIREWALLD is set
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-10-15 12:52:25 +02:00
Albin Kerouanton
6c6174b371 cmd/docker-proxy: UDP: reply to clients with original daddr
When a UDP server is running on a multihomed server, as is the case with
pretty much _all_ Docker hosts (eg. eth0 + docker0), the kernel has to
choose which source address is used when replying to a UDP client. But
that process is based on heuristics and is fallible.

If the address picked doesn't match the original destination address
used by the client, it'll drop the datagram and return an ICMP Port
Unreachable.

To prevent that, we need to:

- `setsockopt(IP_PKTINFO)` on proxy's sockets.
- Extract the original destination address from an ancillary message
  every time a new 'UDP connection' is 'established' (ie. every time we
  insert a new entry into the UDP conntrack table).
- And finally, pass a control message containing the desired source
  address to the kernel, every time we send a response back to the
  client.

Also, update the inline comment on read errors in `(*UDPProxy).Run()`.
This comment was misleadingly referencing ECONNREFUSED - Linux's UDP
implementation never returns this error (see [1]). Instead, state why
`net.ErrClosed` is perfectly fine and doesn't need to be logged
(although, docker-proxy currently logs to nowhere).

[1]: https://github.com/search?q=repo%3Atorvalds%2Flinux+ECONNREFUSED+path%3A%2F%5Enet%5C%2F%28ipv4%7Cipv6%29%5C%2F%28udp%7Ctcp%29%2F&type=code

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-10-15 12:42:15 +02:00
Rob Murray
a0a0bbae6c Discard ErrDumpInterrupted and return data after maxRetries
Returning possibly inconsistent data avoids retrying indefinitely, and
matches the behaviour of vishvananda/netlink prior to version 1.2.1, in
which the NLM_F_DUMP_INTR flag was ignored.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-15 11:35:23 +01: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
0200c58c4a container: viewDB.ReserveName, view.GetID: return errdefs errors
Follow-up to 94dea2018e. Change these to return
errdefs types, which could allow us to move away from the sentinel errors
defined in the package, and instead use errdefs definitions.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-15 12:31:48 +02:00
Sebastiaan van Stijn
0603bd9577 container: viewDB.withTxn: don't wrap errors
The withTxn function takes a custom function to execute; we should not
wrap those errors as the only responsibility of this function is to
execute the given function in a transaction.

This was introduced in 6549a270e9, and
an oversight of me.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-15 11:53:16 +02:00
Sebastiaan van Stijn
0d36ab1875 container: TestNames: don't string-match error assertions
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-15 11:52:38 +02:00
Paweł Gronowski
97b1233a15 Merge pull request #48663 from thaJeztah/api_resize_required
docs: api: document w (width) and h (height) query params as required
2024-10-15 11:01:41 +02:00
Paweł Gronowski
731832efd1 Merge pull request #48652 from thaJeztah/build_use_consts
builder/builder-next: Builder.Build: use network-mode consts
2024-10-15 10:08:19 +02:00
Bjorn Neergaard
9eeec5fbb4 Merge pull request #48654 from thaJeztah/gha_more_limits_and_updates
gha:  more limits, update alpine version, and some minor improvements
2024-10-14 14:33:36 -06:00
Sebastiaan van Stijn
d9627b6159 docs: api: document w (width) and h (height) query params as required
Query parameters default to being _optional_ in swagger, but for these
endpoints, they were required. Omitting these parameters (or passing an
empty value) produces a 400 (bad request);

    docker run -d --name foo nginx:alpine

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize'
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w='
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=&h='
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=100&h='
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=100&h=100'

This patch updates the swagger to reflect that these parameters are required.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-14 20:12:07 +02:00
Sebastiaan van Stijn
2a3a7e8ee8 api: document w (width) and h (height) query params as required
Query parameters default to being _optional_ in swagger, but for these
endpoints, they were required. Omitting these parameters (or passing an
empty value) produces a 400 (bad request);

    docker run -d --name foo nginx:alpine

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize'
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w='
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=&h='
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=100&h='
    {"message":"strconv.Atoi: parsing \"\": invalid syntax"}

    curl -XPOST --unix-socket /var/run/docker.sock 'http://localhost/v1.47/containers/foo/resize?w=100&h=100'

This patch amends the swagger to reflect that these parameters are required.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-14 20:11:07 +02:00
Sebastiaan van Stijn
075918c924 Merge pull request #48631 from thaJeztah/improve_multiarch_errors
Touch-up some errors for missing platforms
2024-10-14 17:22:01 +02:00
Sebastiaan van Stijn
a051aba82e gha: shorter time limits for smoke, validate
- validate-prepare and smoke-prepare took 10 seconds; limiting to 10 minutes
- smoke tests took less than 3 minutes; limiting to 10 minutes
- validate: most took under a minute, but "deprecate-integration-cli" took
  14 minutes; limiting to 30 minutes

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 18:33:15 +02:00
Sebastiaan van Stijn
91c448bfb5 gha: use "ubuntu-24.04" instead of "ubuntu-latest"
To be more explicit on what we're using.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 18:20:22 +02:00
Sebastiaan van Stijn
9a14299540 gha: dco: small tweaks to running the container
- add `--quiet` to suppress pull progress output
- use `./` instead of `$(pwd)` now that relative paths are supported
- set the working directory on the container, so that we don't have to `cd`

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 18:20:21 +02:00
Sebastiaan van Stijn
3cb98d759d gha: dco: update ALPINE_VERSION to 3.20
Alpine 3.16 has been EOL for some time. Update to the latest version.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 18:20:08 +02:00
Sebastiaan van Stijn
7da4ab9a91 README: add some badges
Add badges for pkg.go.dev docs, go-reportcard, and OpenSSF score.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 18:08:25 +02:00
Sebastiaan van Stijn
cfe0d2a131 gha: build (binary), build (dynbinary): limit to 20 minutes
Regular runs are under 5 minutes.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 17:34:33 +02:00
Sebastiaan van Stijn
e75f7aca2f gha: dco: limit to 10 minutes
Regular runs are under a minute.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 17:32:41 +02:00
Sebastiaan van Stijn
4a2361ea09 pkg/authorization: update link to API documentation
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 17:23:29 +02:00
Sebastiaan van Stijn
5b149d3faa client: update link to API documentation
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 17:23:09 +02:00
Sebastiaan van Stijn
0f8f143a27 docs/api: version-history: update documentation links
URLs were updated on docs.docker.com

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 17:22:30 +02:00
Sebastiaan van Stijn
e06245a2a6 client: imageBuildOptionsToQuery: omit "default" networkmode
Both the classic builder and buildkit treat empty value and "default"
as equivalent;

classic builder: c9619248d0/builder/dockerfile/internals.go (L379-L386)
buildkit: c9619248d0/builder/builder-next/builder.go (L350-L356)

Before:

    DEBU[2024-10-12T11:30:47.716478170Z] Calling POST /v1.47/build?dockerfile=Dockerfile&networkmode=default&version=1  spanID=893f850bd8bda19d traceID=e7ab3b76fd7a9c27a7aa7b25f4528fb8

After:

    DEBU[2024-10-12T13:42:56.799531715Z] Calling POST /v1.47/build?dockerfile=Dockerfile&version=1  spanID=d37f36ca6325422e traceID=a5eb4637fc3d0acf56cbb6a0a1d4a5ca

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 16:06:43 +02:00
Sebastiaan van Stijn
b13cf4fc5f client: imageBuildOptionsToQuery: only send "rm" when disabling
The "rm" option was made the default in API version 1.12  in commit
b60d647172, so the query-parameter can be
omitted unless the user opted to disable removing intermediate containers.

Before:

    DEBU[2024-10-12T11:30:47.716478170Z] Calling POST /v1.47/build?dockerfile=Dockerfile&networkmode=default&rm=1&version=1  spanID=893f850bd8bda19d traceID=e7ab3b76fd7a9c27a7aa7b25f4528fb8

After:

    DEBU[2024-10-12T11:30:47.716478170Z] Calling POST /v1.47/build?dockerfile=Dockerfile&networkmode=default&version=1  spanID=893f850bd8bda19d traceID=e7ab3b76fd7a9c27a7aa7b25f4528fb8

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 16:06:36 +02:00
Sebastiaan van Stijn
805e2c67e2 builder/builder-next: Builder.Build: use network-mode consts
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 16:02:39 +02:00
Sebastiaan van Stijn
740798da34 client: imageBuildOptionsToQuery: omit empty values from query
Before:

    DEBU[2024-10-12T11:26:55.791312715Z] Calling POST /v1.47/build?buildargs=%7B%7D&cachefrom=%5B%5D&cgroupparent=&cpuperiod=0&cpuquota=0&cpusetcpus=&cpusetmems=&cpushares=0&dockerfile=Dockerfile&labels=%7B%7D&memory=0&memswap=0&networkmode=default&rm=1&shmsize=0&target=&ulimits=%5B%5D&version=1  spanID=893f850bd8bda19d traceID=e7ab3b76fd7a9c27a7aa7b25f4528fb8

After:

    DEBU[2024-10-12T11:30:47.716478170Z] Calling POST /v1.47/build?dockerfile=Dockerfile&networkmode=default&rm=1&version=1  spanID=893f850bd8bda19d traceID=e7ab3b76fd7a9c27a7aa7b25f4528fb8

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-12 15:20:29 +02:00
Sebastiaan van Stijn
c9619248d0 Merge pull request #48645 from thaJeztah/gha_cross_bin_image_timeout
gha: restrict cross and bin-image to 20 minutes
2024-10-12 00:40:19 +02:00
Sebastiaan van Stijn
c68c9aed8c gha: restrict cross and bin-image to 20 minutes
We had a couple of runs where these jobs got stuck and github
actions didn't allow terminating them, so that they were only
terminated after 120 minutes.

These jobs usually complete in 5 minutes, so let's give them
a shorter timeout. 20 minutes should be enough (don't @ me).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-11 23:04:24 +02:00
Sebastiaan van Stijn
61030f0e87 Merge pull request #48634 from thaJeztah/bump_buildkit
vendor: github.com/moby/buildkit v0.17.0-rc1
2024-10-11 21:29:11 +02:00
Sebastiaan van Stijn
7fe04c142d vendor: github.com/moby/buildkit v0.17.0-rc1
full diff:

- https://github.com/moby/buildkit/compare/v0.16.0...v0.17.0-rc1
- 91a3fc4684...3f140a1299
- 9b4947da39...701f63a606

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-11 18:37:23 +02:00
Sebastiaan van Stijn
8cc4029162 Merge pull request #48605 from akx/48601-pull-opt-2
Use `pools.Copy` for archive file copy operations
2024-10-11 17:31:48 +02:00
Sebastiaan van Stijn
afc0fcce92 Merge pull request #48642 from robmry/remove-iptables-conflict-between-tests
Disable iptables/ip6tables in two tests to remove conflict
2024-10-11 17:29:25 +02:00
Sebastiaan van Stijn
cd551b936b daemon/containerd: getPushDescriptor: fix formatting of platform in errors
The platform was printed in its raw format, which didn't produce a very
readable output;

Before this change:

    $ docker image save --platform=linux/amd64 -o alpine_amd64.tar alpine:latest
    Error response from daemon: no suitable export target found for platform linux/amd64: no suitable image manifest found for platform {amd64 linux [] }

After this change:

    $ docker image save --platform=linux/amd64 -o alpine_amd64.tar alpine:latest
    Error response from daemon: no suitable export target found: image with reference alpine:latest was found but does not provide the specified platform (linux/amd64)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-11 17:16:29 +02:00
Sebastiaan van Stijn
c16be54040 daemon/containerd: touch-up errPlatformNotFound error
- Changed "match" to "provide", in an attempt to indicate that the image is
  a multi-platform image that doesn't contain the given platform.
- Remove the "wanted" and instead make the requested platforms to be a part
  of the sentence, but within braces.

Before this patch:

    docker pull --quiet --platform=linux/riscv64 alpine:latest
    docker image history --platform=linux/amd64 alpine
    Error response from daemon: image with reference alpine:latest was found but does not match the specified platform: wanted linux/nosuch

With this patch:

    docker pull --quiet --platform=linux/riscv64 alpine:latest
    docker image history --platform=linux/amd64 alpine
    Error response from daemon: image with reference alpine:latest was found but does not provide the specified platform (linux/amd64)

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

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

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

Disable iptables and ip6tables in both tests.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-11 14:45:49 +01:00
Sebastiaan van Stijn
8681b3c2ac images: GetImage: touch-up error message for missing platform
Slightly touching up the error message, because the "wanted/actual" output
felt too much like a assertion failure in a test-case.

- Format the image-reference using "familiar" format, which shows the
  image's short name for official images.
- Move the actual and requested platforms to be a part of the sentence,
  but within braces.

Before this patch:

    docker image push --platform=linux/amd64 alpine:latest
    Error response from daemon: image with reference docker.io/library/alpine:latest was found but does not match the specified platform: wanted linux/amd64, actual: linux/riscv64

With this patch:

    docker image push --platform=linux/amd64 alpine:latest
    Error response from daemon: image with reference alpine:latest was found but its platform (linux/riscv64) does not match the specified platform (linux/amd64)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-11 14:52:35 +02:00
Sebastiaan van Stijn
d31c241ea5 PushImage: remove misleading error about --platform without containerd
Without containerd store enabled, we were discarding underlying errors,
and instead informing the user that `--platform` is not suported;

    docker pull --quiet --platform=linux/riscv64 alpine:latest
    docker image push --platform=linux/amd64 alpine:latest
    Error response from daemon: graphdriver backed image store doesn't support multiplatform images

However, that's not the case; platform filtering works, but if the image
is not the right platform, the push fails (which is the same as would
happen with the containerd image store enabled).

    docker image push --platform=linux/amd64 alpine:latest
    Error response from daemon: image with reference docker.io/library/alpine:latest was found but does not match the specified platform: wanted linux/amd64, actual: linux/riscv64

When specifying the platform and that platform matches, it finds the image,
and the push continue;

    docker image push --platform=linux/riscv64 alpine:latest
    The push refers to repository [docker.io/library/alpine]
    3fd4750fd687: Layer already exists
    ...

(The above example obviously fails because I don't have permissions to
push official images).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-11 14:47:13 +02:00
Tianon Gravi
c09e5265db Merge pull request #48636 from thaJeztah/gha_white_noise_space
gha: remove stray double empty line
2024-10-10 16:36:49 -07:00
Sebastiaan van Stijn
037bac89fc gha: remove stray double empty line
Accidentally introduced in 6b7e2783d1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 22:17:22 +02:00
Sebastiaan van Stijn
2d32d75041 Merge pull request #48629 from thaJeztah/gha_timeout
gha: add guardrails timeouts on all jobs
2024-10-10 18:18:38 +02:00
Daniel Guns
26049febb2 api: Allow for an empty string for Isolation in Swagger specs This adds an empty string as a valid option for the Isolation field when inspecting a container. On non windows systems, this is always empty, so no error should be returned. Fixes #47452
Signed-off-by: Daniel Guns <danbguns@gmail.com>
2024-10-10 09:48:42 -03:00
Sebastiaan van Stijn
810c7c1dce Merge pull request #48628 from thaJeztah/integration_remove_TestBuildWithSession
integration/build: remove TestBuildWithSession, and fsutil direct dependency
2024-10-10 13:47:13 +02:00
Sebastiaan van Stijn
6b7e2783d1 gha: add guardrails timeouts on all jobs
We had a few "runaway jobs" recently, where the job got stuck, and kept
running for 6 hours (in one case even 24 hours, probably due some github
outage). Some of those jobs could not be terminated.

While running these actions on public repositories doesn't cost us, it's
still not desirable to have jobs running for that long (as they can still
hold up the queue).

This patch adds a blanket "2 hours" time-limit to all jobs that didn't
have a limit set. We should look at tweaking those limits to actually
expected duration, but having a default at least is a start.

Also changed the position of some existing timeouts so that we have a
consistent order in which it's set; making it easier to spot locations
where no limit is defined.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 13:43:59 +02:00
Sebastiaan van Stijn
7fa6d3c230 integration/build: remove TestBuildWithSession, and fsutil direct dependency
This test was originally used to test the experimental `--stream` option with
the classic builder. This feature was removed in Docker 20.10 through
6ca3ec88ae, which also disabled the test
(adding a note to rewrite the test for BuildKit).

The above is 5 years ago, and we now run the BuildKit integration tests
as part of our CI, which (I assume) should cover this functionality.

Removing this test, as it depends on github.com/tonistiigi/fsutil, which
does not have a stable API, and frequently cannot be updated independently
from BuildKit.

Also adding a linter-rule to prevent it from accidentally being imported;

    errdefs/defs.go:3:8: import 'github.com/tonistiigi/fsutil' is not allowed from list 'main': The fsutil module does not have a stable API, so we should not have a direct dependency unless necessary. (depguard)
    import _ "github.com/tonistiigi/fsutil"
           ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 12:35:57 +02:00
Sebastiaan van Stijn
eacb99db41 Merge pull request #48613 from thaJeztah/bump_buildkit_deps
vendor assorted dependencies in preparation of BuildKit v0.17
2024-10-10 11:38:59 +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
Sebastiaan van Stijn
e007ef71c1 vendor: google.golang.org/protobuf v1.34.1
full diff: https://github.com/protocolbuffers/protobuf-go/compare/v1.33.0...v1.34.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 02:36:05 +02:00
Sebastiaan van Stijn
30b6e58242 vendor: github.com/cespare/xxhash/v2 v2.3.0
full diff: https://github.com/cespare/xxhash/compare/v2.2.0...v2.3.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 02:36:05 +02:00
Sebastiaan van Stijn
4592ce42b6 vendor: golang.org/x/tools v0.25.0
full diff: https://github.com/golang/tools/compare/v0.24.0...v0.25.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 02:36:04 +02:00
Sebastiaan van Stijn
36549fb56e vendor: golang.org/x/mod v0.21.0
full diff: https://github.com/golang/mod/compare/v0.20.0...v0.21.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 02:35:59 +02:00
Sebastiaan van Stijn
cc80652bcd vendor: golang.org/x/net v0.29.0
no changes in vendored code

full diff: https://github.com/golang/net/compare/v0.28.0...v0.29.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 02:35:35 +02:00
Sebastiaan van Stijn
9d6db83acc vendor: golang.org/x/crypto v0.27.0
full diff: https://github.com/golang/crypto/compare/v0.26.0...v0.27.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 02:35:35 +02:00
Sebastiaan van Stijn
6e32888caa vendor: golang.org/x/text v0.18.0
no changes in vendored code

full diff: https://github.com/golang/text/compare/v0.17.0...v0.18.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 02:35:35 +02:00
Sebastiaan van Stijn
51cf0ed303 vendor: golang.org/x/sys v0.25.0
full diff: https://github.com/golang/sys/compare/v0.24.0...v0.25.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 02:35:34 +02:00
Sebastiaan van Stijn
6b7565ba40 vendor: go.etcd.io/bbolt v1.3.11
BoltDB

- Fix the freelist.allocs isn't rollbacked when a tx is rollbacked.

CMD

- Add -gobench-output option for bench command to adapt to benchstat.

Other

- Bump go version to 1.22.x.
- This patch also added dmflakey package, which can be reused by other projects. See #812.

full diff: https://github.com/etcd-io/bbolt/compare/v1.3.10...v1.3.11

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-10 02:35:08 +02:00
Sebastiaan van Stijn
d945d0cd92 Merge pull request #48615 from thaJeztah/fix_buildkit_go_version
gha: buildkit: make sure expected Go version is installed
2024-10-10 02:32:05 +02:00
Sebastiaan van Stijn
02d4fc3234 gha: buildkit: make sure expected Go version is installed
The buildkit workflow uses Go to determine the version of Buildkit to run
integration-tests for. It currently uses on the default version that's
installed on the GitHub actions runners (1.21.13 currently), but this fails
if the go.mod/vendor.mod specify a higher version of Go as required version.

If this fails, the BUILDKIT_REF and REPO env-vars are not set / empty,
resulting in the workflow checking out the current (moby) repository instead
of buildkit, which fails.

This patch adds a step to explicitly install the expected version of Go.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-09 23:57:23 +02:00
Rob Murray
d7ff538467 Fix iptables rule descriptions
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-09 10:25:16 +01:00
Albin Kerouanton
aafdd33c35 Merge pull request #48567 from akerouanton/add-SO_REUSEADDR-to-docker-proxy
cmd/docker-proxy: re-add SO_REUSEADDR
2024-10-08 21:30:23 +02:00
Albin Kerouanton
60a624cd3e Merge pull request #48570 from akerouanton/proxy-LL-connections
libnet/d/bridge: port mapping: proxy LL connections
2024-10-08 21:29:03 +02:00
Sebastiaan van Stijn
16154dc15c Merge pull request #48609 from robmry/nodad_bridge_address
Set NODAD on bridge IPv6 addresses
2024-10-08 19:07:51 +02:00
Albin Kerouanton
77e51657fe cmd/docker-proxy: re-add SO_REUSEADDR
Since commit b3fabede, the Engine creates the listening sockets used by
docker-proxy by making raw syscalls (ie. socket, setsockopt, bind).
Before that commit, those sockets were created by docker-proxy through
Go's `net.ListenX` functions.

Unlike `net.ListenX` functions, the raw syscall code doesn't set the
`SO_REUSEADDR` option. This option is typically used by TCP servers to
make sure that they can be restarted even if there are client sockets
referencing the server port as their sport (eg. in TIME_WAIT state, or
any other state).

Citing UNIX Network Programming, Section 7.5 (p210):

> By default, when the listening server is restarted by calling socket,
> bind, and listen, the call to bind fails because the listening server
> is trying to bind a port that is part of an existing connection [...]
> _All_ TCP servers should specify this socket option to allow the
> server to be restarted in this situation.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-10-08 18:08:07 +02:00
Rob Murray
38f0483ea7 Set NODAD on bridge IPv6 addresses
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-08 16:27:11 +01:00
CrazyMax
58f4e916a3 build: create distinct history db for each store
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-10-08 14:49:09 +02:00
Aarni Koskela
367125e0cc Use pools.Copy for archive file copy operations
Signed-off-by: Aarni Koskela <akx@iki.fi>
2024-10-08 12:47:41 +03:00
Rob Murray
2f02f456f5 Fix comments
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-07 18:32:06 +01:00
Rob Murray
fd0d008504 vendor: github.com/vishvananda/netlink v1.3.1-0.20240922070040-084abd93d350
Particularly for:
- Preserve results when NLM_F_DUMP_INTR is set (1018).
- Fix SetSendTimeout/SetReceiveTimeout (1012).

full diff: https://github.com/vishvananda/netlink/compare/v1.3.0...084abd93d350

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-07 18:32:06 +01:00
Albin Kerouanton
7ca9e9b496 libnet/d/bridge: port mapping: proxy LL connections
Link-local connections were DNATed like other non-loopback connections,
but the kernel would drop them even before their reach the container.

This commit changes the DNAT rule inserted in ip6tables to exclude
link-local addresses. Instead, these connections will be proxied by
docker-proxy, at least if --userland-proxy=true.

If dockerd is started with the userland-proxy disabled, link-local
port-bindings won't be supported (ie. silently discarded).

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-10-07 17:59:28 +02:00
Bjorn Neergaard
367c9100c8 Merge pull request #48588 from thaJeztah/fix_platform_api_versions
api: postImagesLoad: fix API version for platform
2024-10-07 09:45:21 -06:00
Sebastiaan van Stijn
352395c053 Merge pull request #48592 from robmry/fix_docker_image_spec_vendoring
Fix vendoring for moby/docker-image-spec
2024-10-07 17:29:03 +02:00
Rob Murray
49ab30ea2c Fix vendoring for moby/docker-image-spec
hack/vendor.sh has wanted to make these changes since
commit f5cc04284d.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-07 14:43:44 +01:00
Sebastiaan van Stijn
2d049d11a9 Merge pull request #48545 from akerouanton/integration-networking-port-mapper
integration: Add tests for port mappings
2024-10-07 15:07:32 +02:00
Sebastiaan van Stijn
7eb508e14c api: postImagesLoad: fix API version for platform
This option was added in f143f4ec51,
which changed the minimum API version for "save" but forgot to update
the version for "load".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-07 11:40:47 +02:00
Albin Kerouanton
5875b6e8cf inte/networking: test access to published ports from remote host
Along with this new test, a new struct `L3Segment` is introduced to
simulate hosts connected on a same switched network. This struct will
let us test various scenarios where published ports and containers
should or should not be accessible from remote hosts.

The new test introduced, `TestAccessPublishedPortFromRemoteHost`, skips
link-local address as port publishing doesn't work on those addresses
currently. This will be fixed in a future commit.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-10-04 20:09:05 +02:00
Albin Kerouanton
2552782c1d inte/networking: test accessing a published port from the host
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-10-04 20:09:05 +02:00
Akihiro Suda
3bc752cc89 Merge pull request #48573 from thaJeztah/bump_golang_1.22.8
update to go1.22.8
2024-10-04 22:27:45 +09:00
Sebastiaan van Stijn
f1506992e3 Merge pull request #48518 from thaJeztah/windows_daemon_nofatal
cmd/dockerd: windows: don't use Fatal log to prevent early exit
2024-10-04 15:03:48 +02:00
Rob Murray
98efe665a5 Log rather than error if port mapping is overspecified
Previously, if a port mapping specified a host IP or port that
could not be used because the endpoint's network was in routed
mode (so, there's no host binding), it'd be treated as an error.

However:
- the selected gateway endpoint may change over time, as networks
  are connected and disconnected - so the binding may make sense
  for some other endpoint.
- the validation was complicated, duplicated logic in order to
  fail early, and wasn't complete.

So, just log when fields are ignored, at the point where they're
ignored.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-04 11:40:15 +01:00
Sebastiaan van Stijn
83a1693c16 Merge pull request #48551 from thaJeztah/normalize_caps
client: ContainerCreate: normalize CapAdd, CapDrop capabilities
2024-10-04 12:38:23 +02:00
Rob Murray
339592f59b Pass context to the port mapping code
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-10-04 10:30:45 +01:00
Sebastiaan van Stijn
ca4c68ab95 update to go1.22.8
go1.22.8 (released 2024-10-01) includes fixes to cgo, and the maps and syscall
packages. See the Go 1.22.8 milestone on our issue tracker for details;

- https://github.com/golang/go/issues?q=milestone%3AGo1.22.8+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.22.7...go1.22.8

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-10-03 13:12:30 +02:00
Sebastiaan van Stijn
4001d0704b Merge pull request #48552 from laurazard/exec-exit-code-race
daemon/exec: don't overwrite exit code if set
2024-09-30 20:34:28 +02:00
Tianon Gravi
b5d04e4f26 Merge pull request #48478 from thaJeztah/deprecate_info_expected_version
api: info: deprecate "Commit.Expected" fields
2024-09-30 09:32:15 -07:00
Laura Brehm
c866a7e5f8 daemon/exec: don't overwrite exit code if set
If we fail to start an exec, the deferred error-handling block in [L181-L193](c7e42d855e/daemon/exec.go (L181-L193))
would set the exit code to `126` (`EACCES`). However, if we get far enough along
attempting to start the exec, we set the exit code according to the error returned
from starting the task [L288-L291](c7e42d855e/daemon/exec.go (L288-L291)).

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

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

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-09-30 15:49:04 +01:00
Sebastiaan van Stijn
34950b5ede Merge pull request #48554 from thaJeztah/runconfig_simplify_validateNetContainerMode
runconfig: validateNetContainerMode: simplify validation
2024-09-27 17:29:21 +02:00
Laura Brehm
4babd72186 tests: skip docker-py exec exit code test
Temporarily skip the exec run failed exit code test in `docker-py` –
a3652028b1/tests/integration/models_containers_test.py (L356-L363)

We can reenable this after the PR fixing the expected exit code in that
test is merged/released/included – https://github.com/docker/docker-py/pull/3290

Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-09-27 15:43:43 +01:00
Sebastiaan van Stijn
e6488c9c0e runconfig: validateNetContainerMode: simplify validation
- use an early return if we're not using container-mode, instead
  of checking multiple times
- use ConnectedContainer() method to check if a container is specified

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-27 09:42:02 +02:00
Tianon Gravi
62120a727c Merge pull request #48546 from thaJeztah/carry_48533
Update download-frozen-image-v2.sh added OCI v1 support (carry 48533)
2024-09-26 12:05:01 -07:00
Sebastiaan van Stijn
5bdbc2f026 client: ContainerCreate: normalize CapAdd, CapDrop capabilities
Before this change, capabilities would be sent un-normalized, un-sorted,
and could contain duplicates;

    docker create --name foo --cap-add SYS_ADMIN --cap-add sys_admin --cap-add cap_sys_admin --cap-add ALL busybox
    docker container inspect --format '{{json .HostConfig.CapAdd }}' foo
    ["SYS_ADMIN","sys_admin","cap_sys_admin","ALL"]

After this change, capabilities are sent in their normalized form, sorted,
and with duplicates removed;

    docker create --name foo --cap-add SYS_ADMIN --cap-add sys_admin --cap-add cap_sys_admin --cap-add ALL busybox
    docker container inspect --format '{{json .HostConfig.CapAdd }}' foo
    ["ALL", "CAP_SYS_ADMIN"]

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-26 17:11:13 +02:00
Sebastiaan van Stijn
b9cd744f99 Merge pull request #48553 from thaJeztah/container_create_switch_type
client.ContainerCreate: use container.CreateRequest instead of local type
2024-09-26 17:09:49 +02:00
Sebastiaan van Stijn
be248d18b5 client.ContainerCreate: use container.CreateRequest instead of local type
This function used a locally defined `configWrapper`, which was identical
to the `container.CreateRequest`, with the exception of `CreateRequest`
defining `omitempty` for HostConfig and NetworkingConfig, but this should
not impact our use as the same type is used to handle the request on the
daemon side.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-26 15:30:16 +02:00
jjimbo137
98d74e3a3c Update download-frozen-image-v2.sh added OCI v1 support
Shortened to minimum code because OCI v1 is essentially equivalent to
Docker v2.2 format. Also fixed formatting issue with jq where it wouldn't
accept newline character in chained jq commands.

Co-authored-by: Tianon Gravi <admwiggin@gmail.com>
Signed-off-by: Jimbo Jones <jjjimbo137@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-24 21:59:30 +02:00
Albin Kerouanton
91df504bf1 inte/networking: move port mapping tests into a dedicated file
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-09-24 11:42:42 +02:00
Sebastiaan van Stijn
c7e42d855e Merge pull request #48540 from thaJeztah/insecure_ipv6_localhost
daemon: add IPv6 loopback as insecure registry
2024-09-23 19:07:32 +02:00
Sebastiaan van Stijn
3cf65ec598 Merge pull request #48537 from thaJeztah/bump_compose_cli
Dockerfile: update docker CLI to v27.3.1, compose to v2.29.7
2024-09-23 17:57:23 +02:00
Sebastiaan van Stijn
6a1d8a9899 daemon: add IPv6 loopback as insecure registry
commit 11380a109e updated the daemon to
always treat 127.0.0.1 as insecure for all cases anytime anywhere. This
was initially a hard-coded list, but later made configurable to allow
the user to mark additional CIDRs or registries as insecure in
6aba75db4e.

This patch expands the default list of insecure registries to also
include the IPv6 loopback-address (::1); IPv6, unlike IPv4 only has
a single loopback address (::1/128).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-23 16:27:06 +02:00
Sebastiaan van Stijn
7624a6bfa5 Dockerfile: update compose to v2.29.7
Update the compose cli plugin used in the dev-container

full diff: https://github.com/docker/compose/compare/v2.29.4...v2.29.7

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-23 12:49:42 +02:00
Sebastiaan van Stijn
233dce3dba Dockerfile: update docker CLI to v27.3.1
Update the Docker CLI used in the dev-container

full diff: https://github.com/docker/cli/compare/v27.2.1...v27.3.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-23 12:49:33 +02:00
Sebastiaan van Stijn
96ea6e0f9b Merge pull request #47992 from akerouanton/libnet-datastore-cleanup
libnet/ds, libnet/config: various cleanups
2024-09-20 12:21:51 +02:00
Albin Kerouanton
edcefd4efb libnet/i/kv/boltdb: fail fast in case of contention
Make sure an error is returned straight away if there's contention on
the underlying db file. This makes sure we don't reintroduce the issue
fixed in d21d088, and it will help detect contention in parallelized
tests if they're badly written. It effectively adds a new error mode to
the daemon, but if anyone faces this error, they should fix their
process manager.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-09-20 08:48:16 +02:00
Albin Kerouanton
ed08486ec7 libnet/ds: simplify datastore.New()
That function was needlessly complex. Instead of relying on a struct and
a sub-struct, it now just takes two string params: a path and a bucket
name.

Libnetwork config is now initialized with default values. A new struct
is introduced in libnetwork/config to let tests customize the path and
bucket name.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-09-20 08:48:16 +02:00
Albin Kerouanton
3ca91a6a12 libnetwork: unit tests: drop OptionBoltdbWithRandomDBFile
This option fn was defining a custom directory, file name and bucket
name for boltdb. Users can only change data-dir through `OptionDataDir`.
Better reuse that function instead, that'll make refactorings easier.

It won't set a custom bucket name or file name as `OptionBoltdbWithRandomDBFile`
was doing, but that's not needed since every test will use a different
temp dir anyway.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-09-19 13:46:56 +02:00
Sebastiaan van Stijn
dfbc3a89a5 Merge pull request #47034 from thaJeztah/add_codeql
gha: add CodeQL Analysis workflow
2024-09-19 13:04:02 +02:00
Sebastiaan van Stijn
450200b4a6 gha: add CodeQL Analysis workflow
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-19 11:02:34 +02:00
Albin Kerouanton
32b9e7b8b9 libnet/i/kv/boltdb: remove unused field 'timeout'
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-09-19 09:52:10 +02:00
Sebastiaan van Stijn
d8b7ae78c0 Merge pull request #48524 from thaJeztah/govulncheck_permissions
gha: govulncheck: make sure read permissions are set
2024-09-18 12:25:26 +02:00
Sebastiaan van Stijn
4f1d739de5 gha: govulncheck: make sure read permissions are set
If any permission is set, any permission not included in the list is
implicitly set to "none".

see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions

The govulncheck check need read permissions, which is not problematic
for public repositories, but may be needed when running in a private
fork (such as those used for security releases).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-18 10:29:58 +02:00
Sebastiaan van Stijn
92da1065f6 Merge pull request #48519 from thaJeztah/cleanup_daemon_start_step2
cmd/dockerd: runDaemon: extract platform-agnostic code
2024-09-17 19:11:00 +02:00
Sebastiaan van Stijn
408f51b90f Merge pull request #48513 from thaJeztah/windows_svc_consts
cmd/dockerd: use golang.org/x/sys/windows/service param-change consts
2024-09-17 19:10:42 +02:00
Rob Murray
6bfeb5f41b Merge pull request #48489 from robmry/enable_ipv4_for_old_networks
IPv6 only: bug fix - enableIPv4 for old networks
2024-09-17 18:02:07 +01:00
Sebastiaan van Stijn
8c598b1005 cmd/dockerd: runDaemon: extract platform-agnostic code
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-17 16:21:31 +02:00
Sebastiaan van Stijn
5228850225 cmd/dockerd: windows: don't use Fatal log to prevent early exit
cmd/dockerd: notifyShutdown: don't use Fatal log to prevent early exit
------------------------------------------------------------------------

Commit 40868e263d added this log for situations
where the daemon failed to start, and where no event-log was created
to discover the failure.

However, it used a `Fatal` log which, when using logrus, not only logs
a message, but also calls the [logger's Exit function][1], which defaults
[to `os.Exit`][2].

The error passed to the `notifyShutdown` function can be the result of
different steps in the service's lifecycle; `cli.start()` starts a long-
lived process, and the error returned can be either because it failed
to start the service, or an error produced while shutting down the service.

We should reduce ambiguity here (which could be for `cli.Start()` to return
whether the service was started in the first place). Regardless, we want
code following the log-entry to be executed, to make sure that codepaths
following the `notifyShutdown` (which could be (defer) statements or cleanup
steps) are executed.

This patch changes the log to an `Error`, which is non-fatal, and should
make sure that at least the `service.stopped` is executed to signal the
service no longer running. The logging is also moved out of the
`notifyShutdown`.

Disclaimer: this is with the assumption that calling `service.stopped` is
always acceptable, even if the service is not running, or in other states.

cmd/dockerd: preNotifyReady: return error instead of logging and exit
------------------------------------------------------------------------

Commit 57aef3b490 added support for running
the daemon as a Windows service. As part of this, it introduced a log
for situations where the service failed to start. However, it used a
`Fatal` log for this purpose which, when using logrus, not only logs
a message, but also calls the [logger's Exit function][1], which defaults
[to `os.Exit`][2].

A result of this is that the daemon does an unclean shutdown, causing
other code (which could be (defer) statements or cleanup steps) not to
be executed.

This patch updates the `preNotifyReady` to return the error instead of
logging and exiting. `preNotifyReady` is executed as part of `cli.start()`,
which has an error-return, and the error that is returned, is already
logged by `runDaemon` (so logging it as part of `preNotifyReady` would
result in the error being logged twice).

[1]: 5098132d84/vendor/github.com/sirupsen/logrus/entry.go (L336-L339)
[2]: 5098132d84/vendor/github.com/sirupsen/logrus/logger.go (L342-L348)

- relates to https://github.com/moby/moby/pull/22340

cmd/dockerd: preNotifyReady: return error instead of logging and exit

Commit 57aef3b490 added support for running
the daemon as a Windows service. As part of this, it introduced a log
for situations where the service failed to start. However, it used a
`Fatal` log for this purpose which, when using logrus, not only logs
a message, but also calls the [logger's Exit function][1], which defaults
[to `os.Exit`][2].

A result of this is that the daemon does an unclean shutdown, causing
other code (which could be (defer) statements or cleanup steps) not to
be executed.

This patch changes the `preNotifyReady` to

[1]: 5098132d84/vendor/github.com/sirupsen/logrus/entry.go (L336-L339)
[2]: 5098132d84/vendor/github.com/sirupsen/logrus/logger.go (L342-L348)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-17 16:08:26 +02:00
Sebastiaan van Stijn
0aebbd0ba9 cmd/dockerd: use golang.org/x/sys/windows/service param-change consts
- The `ParamChange` const was introduced in [golang/sys@e62c3de][1]
- The `AcceptParamChange` const was introduced in [golang/sys@f7928cf][2]

Both are part of golang.org/x/sys v0.1.0 and higher.

[1]: e62c3de784
[2]: f7928cfef4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-17 16:02:53 +02:00
Sebastiaan van Stijn
32a29bfa95 Merge pull request #47412 from thaJeztah/cleanup_daemon_start
cmd/dockerd: assorted changes to improve context-passing, config loading
2024-09-17 16:01:48 +02:00
Sebastiaan van Stijn
b186261b84 cmd/dockerd: un-export DaemonCli, NewDaemonCli
They're only used within this package, and are not expected to be used
externally. Some exported functions also take non-exported types as
argument, so would not be usable outside of this package either way.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-17 12:44:25 +02:00
Sebastiaan van Stijn
6f83fda310 cmd/dockerd: construct context in main
Construct the context we use in the main function, and set it as context
for the root-command.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-17 12:44:25 +02:00
Sebastiaan van Stijn
52694ebe16 cmd/dockerd: windows: move setting PIDFile location to setPlatformOptions
Unlike Linux, which uses fixed locations as default, the Windows daemon uses
paths relative to the data-root as defaults for storing both the PIDFile, and
the daemon configuration file (daemon.json).

The data-root is configurable both through command-line options (`--data-root`),
and through the daemon configuration file (daemon.json). This patch moves Windows-
specific config handling to config-related code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-17 12:44:25 +02:00
Sebastiaan van Stijn
44a3bba2a2 cmd/dockerd: apply options when creating daemonCLI, not when starting
Validate and apply options when creating the CLI, so that starting the
CLI does not have to mutate the config, and to have a clearer separation
between "creating", "validating", and starting the daemon.

This also allows skipping the service-registration code in situations
where we only want to validate the config.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-17 12:44:24 +02:00
Sebastiaan van Stijn
5c1b037ff5 cmd/dockerd: rename loadCLIPlatformConfig to setPlatformOptions
Make it more explicit that this function is mutating the passed
configuration.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-17 12:44:24 +02:00
Sebastiaan van Stijn
1388d959bc cmd/dockerd: set default configfile location as part of newDaemonOptions
Make creating the options slightly more atomic, and set the defaults when
instancing the options.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-17 12:44:24 +02:00
Sebastiaan van Stijn
19a8e7ff7e cmd/dockerd: getDefaultDaemonConfigFile: add GoDoc for Windows implementation
Document why we cannot return a default on Windows.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-17 12:44:24 +02:00
Sebastiaan van Stijn
388c0a8cda cmd/dockerd: remove unused error-returns
getDefaultDaemonConfigDir would never return an error and because of that,
neither would getDefaultDaemonConfigFile, so we can remove these error returns.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-17 12:44:24 +02:00
Sebastiaan van Stijn
1624ae197e cmd/dockerd: move Windows code for data-root
This patch moves Windows-specific config for the config-file location to config-
related code to help discoverability.

Unlike Linux, which uses fixed locations as default, the Windows daemon uses
paths relative to the data-root as defaults for storing both the PIDFile, and
the daemon configuration file (daemon.json).

For the PIDfile, additional changes will be needed, as using a PIDfile depends
on whether the daemon is run as a service or not.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-17 12:44:21 +02:00
Rob Murray
5098132d84 Merge pull request #48515 from robmry/wsl2_nlwrap_merge_conflict
Fix merge problem
2024-09-17 11:25:33 +01:00
Rob Murray
333cfa6402 Fix merge problem
Commit f9c0103 (WSL2 mirrored-mode loopback) uses netlink funcs
that were removed/wrapped by commit 00bf437.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-17 10:38:09 +01:00
Rob Murray
d89eaad740 Merge pull request #48075 from robmry/wsl2_mirrored_loopback0_workaround
Do not DNAT packets from WSL2's loopback0
2024-09-17 09:09:05 +01:00
Brian Goff
fe09cab7fe Merge pull request #48407 from robmry/48400_netlink_eintr
Retry on EINTR from netlink dump calls
2024-09-16 09:08:53 -07:00
Sebastiaan van Stijn
205a4fe82e Merge pull request #48509 from thaJeztah/bump_buildx_compose
Dockerfile: update buildx to v0.17.1, compose to v2.29.4
2024-09-16 16:58:53 +02:00
Sebastiaan van Stijn
83d8064b51 Merge pull request #48492 from robmry/48375_bridge_netfiltering
Only enable bridge netfiltering when needed
2024-09-16 16:51:15 +02:00
Rob Murray
db25b0dcd0 Only enable bridge netfiltering when needed
Kernel module br_netfilter is loaded when the daemon starts with
either iptables or ip6tables enabled. That automatically sets:
  net.bridge.bridge-nf-call-arptables = 1
  net.bridge.bridge-nf-call-ip6tables = 1
  net.bridge.bridge-nf-call-iptables = 1

So, when:
- docker was running happily with iptables=false, and
- no explicit ip6tables=false, and
- br_netfilter was not loaded
... the change in moby 27.0 to enable ip6tables by default, resulted
in net.bridge.bridge-nf-call-iptables being enabled.

If the host also had a firewall with default-drop on its forward
chain - that resulted in packets getting dropped between containers
on a bridge network.

So, only try to load br_netfilter when it's needed - it's only needed
to implement "--icc=false", which can only be used when iptables or
ip6tables is enabled.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-16 14:30:59 +01:00
Sebastiaan van Stijn
605f51172a Dockerfile: update compose to v2.29.4
Update the compose cli plugin used in the dev-container

full diff: https://github.com/docker/compose/compare/v2.29.2...v2.29.4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-16 14:54:35 +02:00
Sebastiaan van Stijn
3d4831a23f Dockerfile: update buildx to v0.17.1
Update the buildx cli plugin used in the dev-container

full diff: https://github.com/docker/buildx/compare/0.17.0...0.17.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-16 14:53:54 +02:00
Sebastiaan van Stijn
b6398f1d4c Merge pull request #48460 from thaJeztah/remove_deprecated_image_spec
remove deprecated image/spec package
2024-09-16 14:43:29 +02:00
Sebastiaan van Stijn
96128f7136 Merge pull request #48504 from thaJeztah/man_remove_cors_flag
man: remove docs for deprecated --api-cors-header
2024-09-16 14:38:41 +02:00
Sebastiaan van Stijn
719ec8632e Merge pull request #48505 from thaJeztah/man_dockerd_logformat
man: dockerd: add description for --log-format option
2024-09-16 14:38:18 +02:00
Sebastiaan van Stijn
e8139af428 Merge pull request #48502 from thaJeztah/dockerd_typo
dockerd: fix docs, improve validation and improve coverage of "--feature" flag
2024-09-16 14:12:02 +02:00
Sebastiaan van Stijn
45a9dde660 man: dockerd: add description for --log-format option
This option was added in a08abec9f8,
as part of Docker v25.0, but did not update the docs and manpage.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-16 12:41:23 +02:00
Sebastiaan van Stijn
c4aaa97f02 man: remove docs for deprecated --api-cors-header
It was deprecated in 27.0x through 7ea9acc97f,
and removed in ae96ce866f.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-16 12:10:21 +02:00
Sebastiaan van Stijn
c2fc1f4a40 internal/opts: SetOpts: invalidate empty option-names
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-16 11:00:06 +02:00
Sebastiaan van Stijn
908bb959e7 internal/opts: SetOpts.Set: remove redundant var assignment
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-16 10:39:20 +02:00
Sebastiaan van Stijn
758cca6036 internal/opts: SetOpts,NamedSetOpts: test for optional value
The value is optional for SetOpts (and NamedSetOpts), and implied
"true" when omitted.

This patch adds a test-case for this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-16 10:38:32 +02:00
Sebastiaan van Stijn
50e83a0713 man: dockerd: value is optional for --feature flag
The --feature flag allows the boolean value to be omitted.
If only a name is provided, the default is "true".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-16 10:38:21 +02:00
Rob Murray
f9c0103413 Do not DNAT packets from WSL2's loopback0
When running WSL2 with mirrored mode networking, add an iptables
rule to skip DNAT for packets arriving on interface loopback0 that
are addressed to a localhost address - they're from the Windows
host.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-16 09:28:24 +01:00
Sebastiaan van Stijn
2b6550bb2e man: fix duplicate word in --feature flag description
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-16 09:57:39 +02:00
Rob Murray
edaa0eb56d Add linting rules to spot use of un-wrapped netlink functions.
Spot netlink functions that may return EINTR because
network configuration changed during a state dump, and
point at the nlutil wrappers.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-15 12:28:58 +01:00
Rob Murray
00bf437d84 Add nlutil functions to retry on netlink EINTR
A recent change to the vishvananda/netlink package exposes
NLM_F_DUMP_INTR in some netlink responses as an EINTR (with
no data).

Retry the requests when that happens, up to five times, before
returning the error. The limit of five is arbitrary, on most
systems a single retry will be rare but, there's no guarantee
that a retry will succeed. So, on a very busy or misbehaving
system the error may still be returned. In most cases, this
will lead to failure of the operation being attempted (which
may lead to daemon startup failure, network initialisation
failure etc).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-15 12:28:58 +01:00
Sebastiaan van Stijn
4515f152a0 Merge pull request #48497 from robmry/update_dlv
Update dlv in the dev-env
2024-09-14 06:53:43 +02:00
Rob Murray
8b0e94ffaf Update dlv in the dev-env
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-13 19:57:13 +01:00
Rob Murray
7156bfa729 Merge pull request #48299 from robmry/v6only/macvlan_ipvlan
IPv6 only: macvlan and ipvlan drivers
2024-09-13 16:19:13 +01:00
Sebastiaan van Stijn
e33f48584c Merge pull request #48486 from thaJeztah/dockerd_man_features
man: update dockerd man-page to include --feature flag
2024-09-12 22:23:00 +02:00
Rob Murray
3dd96ce3c4 Fix enableIPv4 for old networks
The new Network.enableIPv4 flag needs to be set for IPv4
networks created before it was introduced.

Commit 903daa4 attempted to do that in the unmarshalling code
by checking Network.ipamV4Info - but, that field hadn't been
unmarshalled yet, so it was never present.

Instead, check for its presence in the saved map.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-09-12 20:40:23 +01:00
Sebastiaan van Stijn
fa06acc851 man: update dockerd man-page to include --feature flag
commit f13c08246d introduced
this flag, but did not yet update the manpage.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-12 20:51:20 +02:00
Sebastiaan van Stijn
ff191c58f7 api: info: deprecate "Commit.Expected" fields
The `Commit` type was introduced in 2790ac68b3,
to assist triaging issues that were reported with an incorrect version of
runc or containerd. At the time, both `runc` and `containerd` were not yet
stable, and had to be built from a specific commit to guarantee compatibility.

We encountered various situations where unexpected (and incompatible) versions
of those binaries were packaged, resulting in hard to trace bug-reports.
For those situations, a "expected" version was set at compile time, to
indicate if the version installed was different from the expected version;

    docker info
    ...
    runc version: a592beb5bc4c4092b1b1bac971afed27687340c5 (expected: 69663f0bd4b60df09991c08812a60108003fa340)

Both `runc` and `containerd` are stable now, and docker 19.03 and up set the
expected version to the actual version since c65f0bd13c
and 23.0 did the same for the `init` binary b585c64e2b,
to prevent the CLI from reporting "unexpected version".

In short; the `Expected` fields no longer serves a real purpose.

In future, we can even consider deprecating the `ContainerdCommit`, `RuncCommit`
and `InitCommit` fields on the `/info` response (as we also include this
information as part of the components returned in `/version`), but those
can still be useful currently for situations where a user only provides
`docker info` output.

This patch starts with deprecating the `Expected` field.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-12 19:40:12 +02:00
Sebastiaan van Stijn
164cae56ed Merge pull request #48167 from dmcgowan/add-feature-flags-daemon
Add `--feature` to daemon flags
2024-09-12 19:15:19 +02:00
Sebastiaan van Stijn
2936af4c02 Merge pull request #48295 from vvoland/c8d-saveload-platform
c8d: Add `platform` parameter to history, save and load
2024-09-12 18:52:49 +02:00
Sebastiaan van Stijn
a484c7c29a Merge pull request #48076 from vvoland/c8d-prune-keeplastref
c8d/prune: Keep the last tagged image instead of creating dangling image
2024-09-12 18:50:14 +02:00
Sebastiaan van Stijn
53a370ad74 Merge pull request #48482 from elezar/fix-gpus-0
Explicitly disable nvidia device injection for --gpus=0
2024-09-12 16:42:10 +02:00
Derek McGowan
f13c08246d Add feature to daemon flags
Signed-off-by: Derek McGowan <derek@mcg.dev>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-12 15:35:15 +02:00
Sebastiaan van Stijn
b3c7750593 Merge pull request #48480 from thaJeztah/no_xfail_colon
TestIPRangeAt64BitLimit: remove colon after XFAIL to help grepping
2024-09-11 23:02:02 +02:00
Paweł Gronowski
fefa98ae90 c8d/prune: Keep deletion order stable
When untagging multiple images targetting the same digest, delete the
images in lexographic order to be consistent with graphdrivers.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-11 19:58:25 +02:00
Paweł Gronowski
521fa833fe images: Support platform selection on graphdrivers
Allows load to filter image manifests to load based on their platform.
For save, verify that the image platform matches the requested platform,
otherwise error out.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-11 19:44:36 +02:00
Paweł Gronowski
f143f4ec51 image/save&load: Support Platform parameter
Add `Platform` parameter that allows to select a specific platform to
save/load.

This is a breaking change to the Go client as it changes the signatures
of `ImageLoad` and `ImageSave`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-11 19:44:35 +02:00
Paweł Gronowski
ab075ecd10 image/history: Support Platform parameter
Add `Platform` parameter that allows to select a specific platform to
show the history for.

This is a breaking change to the Go client as it changes the signature
of `ImageHistory`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-11 19:44:32 +02:00
Sebastiaan van Stijn
419e1a28fe Merge pull request #48172 from AkihiroSuda/rootlesskit-2.2.0
update RootlessKit to v2.3.1
2024-09-11 18:26:41 +02:00
Evan Lezar
5128007116 Explicitly disable nvidia device injection for --gpus=0
This change ensures that when --gpus=0 is selected, the injection of
NVIDIA device nodes and libraries is disabled by setting the
NVIDIA_VISIBLE_DEVICES environment variable to void instead of
leaving this unspecfied.

Signed-off-by: Evan Lezar <elezar@nvidia.com>
2024-09-11 17:20:07 +02:00
Sebastiaan van Stijn
adb00d3d55 TestIPRangeAt64BitLimit: remove colon after XFAIL to help grepping
When looking for failures in CI, I always search for `FAIL:` (with a
trailing colon) to find tests that fail. This test has some test-cases
that are currently expected to fail, but due to the colon would also
be included when searching;

    === RUN   TestIPRangeAt64BitLimit/ipRange_at_end_of_64-bit_subnet
        bridge_test.go:196: XFAIL: Container startup failed with error: Error response from daemon: no available IPv6 addresses on this network's address pools: test64bl (b014e28c35c14cc34514430a8cfe1c97632c7988c56d89cea46abb10fa32229d)
    === RUN   TestIPRangeAt64BitLimit/ipRange_at_64-bit_boundary_inside_56-bit_subnet
        bridge_test.go:196: XFAIL: Container startup failed with error: Error response from daemon: no available IPv6 addresses on this network's address pools: test64bl (fb70301550d7a2d1d3425f5c1010a9ef487a9a251221a2d68ac49d257b249013)

Remove the trailing `:` so that searching for unexpected failures does not
include these tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-11 15:21:01 +02:00
Paweł Gronowski
23e79a261e c8d/prune: Add OTEL spans
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-11 14:44:30 +02:00
Paweł Gronowski
e4c2eb9d8a c8d/prune: Keep the last tagged image instead of creating dangling image
Don't turn images into dangling when they are used by containers created
with an image specified by an ID only (e.g. `docker run 82d1e9d`).

Keep the last image reference with the same target when all other
references would be pruned.

If the container was created with a digested and tagged reference (e.g.
`docker run alpine:latest@sha256:82d1e9d7ed48a7523bdebc18cf6290bdb97b82302a8a9c27d4fe885949ea94d1`),
the `alpine:latest` image won't get untagged.

This change makes the behavior consistent with the graphdriver
implementation.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-11 14:44:29 +02:00
Paweł Gronowski
09044f8702 Merge pull request #48475 from vvoland/dockerfile-update
Dockerfile: Update CLI, buildx and compose
2024-09-11 11:14:25 +00:00
Paweł Gronowski
bcf105d4f0 Merge pull request #48467 from thaJeztah/image_tarexpost_cleanup
image/tarexport: fix some minor linting issues
2024-09-11 10:34:52 +00:00
Paweł Gronowski
3bfee27449 Merge pull request #48461 from thaJeztah/layerstore_deadcode
layer: layerStore.deleteLayer(): remove redundant error-check
2024-09-11 10:32:59 +00:00
Sebastiaan van Stijn
59fe9e09bd Merge pull request #48474 from corhere/ltm-v23-v25
project: update 23.0 EOL and add 25.0 LTM branch
2024-09-11 12:30:05 +02:00
Akihiro Suda
34a2f953b1 Merge pull request #48476 from thaJeztah/bump_api_1.48
API: bump version to 1.48
2024-09-11 18:44:55 +09:00
Paweł Gronowski
962da27cdf Dockerfile: update compose to v2.29.2
Update the compose cli plugin used in the dev-container

full diff: https://github.com/docker/cli/compare/v2.29.0...v2.29.2

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-11 10:34:03 +02:00
Sebastiaan van Stijn
2b43979395 API: bump version to 1.48
The 27.x branch was created and is on API 1.47, so changes in master/main
should now be targeting the next version of the API (1.48).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-11 10:18:55 +02:00
Sebastiaan van Stijn
47855a7b4e Merge pull request #48443 from thaJeztah/fix_push_docs
api: swagger: fix documentation for image push endpoint
2024-09-11 10:13:36 +02:00
Paweł Gronowski
e5e8addeee Dockerfile: update buildx to 0.17.0
Update the buildx cli plugin used in the dev-container

full diff: https://github.com/docker/buildx/compare/0.16.1...0.17.0

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-11 10:13:22 +02:00
Sebastiaan van Stijn
d57bcd92dd Merge pull request #48446 from thaJeztah/api_fix_deprecation_version
api/swagger: update deprecation version for erroneous fields
2024-09-11 10:12:51 +02:00
Paweł Gronowski
d291722110 Dockerfile: update docker CLI to v27.2.1
Update the Docker CLI used in the dev-container

full diff: https://github.com/docker/cli/compare/v27.0.2...v27.2.1

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-11 10:07:27 +02:00
Cory Snider
c095dbe512 project: update 23.0 EOL and add 25.0 LTM branch
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-10 17:32:40 -04:00
Sebastiaan van Stijn
e18e72749c Merge pull request #48473 from thaJeztah/integration_system_noshadow
integration/system: rename vars to prevent shadowing imports
2024-09-10 22:38:20 +02:00
Akihiro Suda
43036f350a Dockerfile: update RootlessKit to v2.3.1
https://github.com/rootless-containers/rootlesskit/compare/v2.0.2...v2.3.1

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-09-11 04:35:59 +09:00
Akihiro Suda
c98aad0518 vendor.mod: github.com/rootless-containers/rootlesskit/v2 v2.3.1
https://github.com/rootless-containers/rootlesskit/compare/v2.0.2...v2.3.1

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-09-11 04:35:59 +09:00
Sebastiaan van Stijn
a6f1d72be1 Merge pull request #48472 from crazy-max/buildkit-0.16.0
vendor: update buildkit to v0.16.0
2024-09-10 21:18:19 +02:00
Sebastiaan van Stijn
829aa845bb integration/system: rename vars to prevent shadowing imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-10 20:17:39 +02:00
Sebastiaan van Stijn
1f2a18ba67 Merge pull request #48458 from thaJeztah/bump_containerd_1.7.22
Dockerfile/vendor: update containerd to v1.7.22
2024-09-10 19:07:27 +02:00
CrazyMax
71e449de0a vendor: update buildkit to v0.16.0
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-09-10 18:28:37 +02:00
Sebastiaan van Stijn
e5a088d752 Merge pull request #48455 from gdams/seccomp
seccomp: add riscv64 mapping to seccomp_linux.go
2024-09-10 12:33:48 +02:00
Sebastiaan van Stijn
7263cd226f image/tarexport: saveSession.save: inline variables
Remove some intermediate variables that were only used in a single place.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-10 11:52:48 +02:00
Sebastiaan van Stijn
2e4079ff31 image/tarexport: saveSession.save: remove redundant Platform
Commit 9160b9fda6 removed the platform from
the descriptor, but this field was still used further in the code, and now
always taking an empty platform.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-10 11:48:57 +02:00
Sebastiaan van Stijn
ab5c5df1d5 image/tarexport: rename variables that shadowed imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-10 11:48:23 +02:00
Sebastiaan van Stijn
5fd3cd2d77 layer: layerStore.deleteLayer(): remove redundant error-check
Commit e1ea911aba removed the error return from
.Size() and .DiffSize(), but forgot to remove this error-check.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-10 11:22:19 +02:00
Sebastiaan van Stijn
f5cc04284d remove deprecated image/spec package
The specification moved to a separate module (github.com/moby/docker-image-spec),
and this package was deprecated in in 03a17a2887,
which is part of docker v26.0.0 and up.

This patch remove the deprecated package.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-10 11:01:01 +02:00
Sebastiaan van Stijn
92195c1333 Dockerfile: update containerd binary to v1.7.22
Update the containerd binary that's used in CI and static binaries

- Update to go1.22.7, go1.23.1
- CRI: Cumulative stats can't decrease
- Fix bug where init exits were being dropped
- Update runc binary to 1.1.14

- diff: https://github.com/containerd/containerd/compare/v1.7.21...v1.7.22
- release notes: https://github.com/containerd/containerd/releases/tag/v1.7.22

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-10 10:44:44 +02:00
Sebastiaan van Stijn
b4a3e8a307 vendor: github.com/containerd/containerd v1.7.22
no significant changes in vendored code

- diff: https://github.com/containerd/containerd/compare/v1.7.21...v1.7.22
- release notes: https://github.com/containerd/containerd/releases/tag/v1.7.22

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-10 10:41:44 +02:00
Sebastiaan van Stijn
29f4a79edd Merge pull request #48456 from tonistiigi/buildkit-v0.16.0-rc2
vendor: update buildkit to v0.16.0-rc2
2024-09-10 09:56:54 +02:00
Tonis Tiigi
6f37e5a168 vendor: update buildkit to v0.16.0-rc2
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-09-09 16:36:22 -07:00
Tõnis Tiigi
34182f6202 Merge pull request #48309 from crazy-max/buildkit-0.16.0-rc1
vendor: update buildkit to v0.16.0-rc1
2024-09-09 16:32:13 -07:00
George Adams
1161b790cf seccomp: add riscv64 mapping to seccomp_linux.go
Signed-off-by: George Adams <georgeadams1995@gmail.com>
2024-09-09 21:18:30 +01:00
Sebastiaan van Stijn
3174616aaf Merge pull request #48453 from thaJeztah/fix_package_doc
internal/unix_noeintr: fix godoc for package
2024-09-09 22:13:26 +02:00
Albin Kerouanton
0d91e80dbb Merge pull request #48435 from thaJeztah/stream_errorsjoin
container/stream: Config.CloseStreams(): use errors.Join
2024-09-09 21:48:32 +02:00
Sebastiaan van Stijn
5c96ed4109 Merge pull request #48450 from vvoland/binimage-relbranch
gha/bin-image: Also run on branches like `27.x`
2024-09-09 21:18:46 +02:00
Sebastiaan van Stijn
16d686c7bc internal/unix_noeintr: fix godoc for package
Put the comment in the expected format :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-09 19:32:11 +02:00
Paweł Gronowski
47d5ce0ef8 gha/bin-image: Also run on branches like 27.x
We moved to the major release branches with a `.x` suffix and forgot to
adjust this workflow.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-09 18:55:42 +02:00
Sebastiaan van Stijn
09fc6ab2d9 docs/api: update deprecation version for erroneous fields (v1.46, v1.47)
commit af0cdc36c7 officially marked these
fields as deprecated and to be removed in API v1.47 (which was targeted
for v28.0). We shipped v1.47 with the v27.2 release, but did not yet
remove the erroneous fields.

This patch updates the version to v1.48.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-09 14:45:00 +02:00
Sebastiaan van Stijn
3df03d8e66 api/swagger: update deprecation version for erroneous fields
commit af0cdc36c7 officially marked these
fields as deprecated and to be removed in API v1.47 (which was targeted
for v28.0). We shipped v1.47 with the v27.2 release, but did not yet
remove the erroneous fields.

This patch updates the version to v1.48.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-09 14:44:21 +02:00
Sebastiaan van Stijn
aca38a4218 docs: api: fix documentation for image push endpoint (API v1.25-v1.47)
The documentation was incorrect and didn't properly document the use of
tags;

- Image push currently only accepts an image-name, not an ID / digest.
- When giving a name, it's expected to be without tag included; when
  including a tag, it is ignored.
- The tag parameter is required when pushing a single image (i.e., it
  does not default to "latest"); omitting the tag parameter will push
  all tags of the given image.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-09 14:33:50 +02:00
Sebastiaan van Stijn
07e31e393a api: swagger: fix documentation for image push endpoint
The documentation was incorrect and didn't properly document the use of
tags;

- Image push currently only accepts an image-name, not an ID / digest.
- When giving a name, it's expected to be without tag included; when
  including a tag, it is ignored.
- The tag parameter is required when pushing a single image (i.e., it
  does not default to "latest"); omitting the tag parameter will push
  all tags of the given image.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-09 14:23:38 +02:00
Sebastiaan van Stijn
6b617699c5 Merge pull request #48434 from thaJeztah/more_gocompat
add more //go:build directives to prevent downgrading to go1.16
2024-09-09 12:34:56 +02:00
Sebastiaan van Stijn
fb6da4f4b7 daemon/logger/loggerutils: add //go:build directives to prevent downgrading to go1.16
commit 77f2d90e27 introduced the slices import,
which uses generics, but failed to add the go:build directives.

    # github.com/docker/docker/daemon/logger/loggerutils
    ../../daemon/logger/loggerutils/logfile.go:770:2: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-06 23:06:20 +02:00
Sebastiaan van Stijn
5403e3f4de libnetwork/networkdb: add //go:build directives to prevent downgrading to go1.16
commit 2847c4b7fe switched networkdb to use
go-immutable-radix v2, which uses generics, but failed to add the go:build
directives.

    # github.com/docker/docker/libnetwork/networkdb
    ../../libnetwork/networkdb/networkdb.go:47:19: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/networkdb/networkdb.go:259:33: type instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/networkdb/networkdb.go:269:25: function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/networkdb/networkdb.go:270:27: function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-06 23:06:20 +02:00
Sebastiaan van Stijn
928e5aa524 container/stream: Config.CloseStreams(): use errors.Join
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-06 22:44:28 +02:00
Laura Brehm
96898c8be6 Merge pull request #48393 from NathanBaulch/typos
Fix typos
2024-09-06 15:28:11 +01:00
Nathan Baulch
59eba0ae13 Fix typos
Signed-off-by: Nathan Baulch <nathan.baulch@gmail.com>
2024-09-06 21:53:09 +10:00
Sebastiaan van Stijn
a22a2875a1 Merge pull request #48432 from vvoland/update-go
update to go1.22.7
2024-09-06 11:57:11 +02:00
Paweł Gronowski
a2e14dd8bd update to go1.22.7
- https://github.com/golang/go/issues?q=milestone%3AGo1.22.7+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.22.6...go1.22.7

These minor releases include 3 security fixes following the security policy:

- go/parser: stack exhaustion in all Parse* functions

    Calling any of the Parse functions on Go source code which contains deeply nested literals can cause a panic due to stack exhaustion.

    This is CVE-2024-34155 and Go issue https://go.dev/issue/69138.

- encoding/gob: stack exhaustion in Decoder.Decode

    Calling Decoder.Decode on a message which contains deeply nested structures can cause a panic due to stack exhaustion.

    This is a follow-up to CVE-2022-30635.

    Thanks to Md Sakib Anwar of The Ohio State University (anwar.40@osu.edu) for reporting this issue.

    This is CVE-2024-34156 and Go issue https://go.dev/issue/69139.

- go/build/constraint: stack exhaustion in Parse

    Calling Parse on a "// +build" build tag line with deeply nested expressions can cause a panic due to stack exhaustion.

    This is CVE-2024-34158 and Go issue https://go.dev/issue/69141.

View the release notes for more information:
https://go.dev/doc/devel/release#go1.23.1

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-05 17:47:03 +02:00
CrazyMax
5ebc179cb1 test: update since session signature has changed
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-09-04 16:36:09 +02:00
CrazyMax
f4261dbb75 vendor: update buildkit to v0.16.0-rc1
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-09-04 16:36:09 +02:00
Paweł Gronowski
0b9779f7cc Merge pull request #48425 from thaJeztah/vendor_runc_1.1.14
vendor: github.com/opencontainers/runc v1.1.14
2024-09-04 08:54:03 +00:00
Sebastiaan van Stijn
fa734fe3d2 Merge pull request #48421 from thaJeztah/make_update_link
hack/make/.binary: enable pie mode on windows/arm64
2024-09-03 23:08:17 +02:00
Brian Goff
55752bb1ec Merge pull request #47983 from cpuguy83/skip_corrupted_log_files
Make log reading more robust to errors
2024-09-03 08:58:08 -07:00
Sebastiaan van Stijn
f9bac835b4 Merge pull request #48424 from thaJeztah/bump_runc_1.1.14
update runc binary to 1.1.14
2024-09-03 16:11:29 +02:00
Sebastiaan van Stijn
b5ec31f090 vendor: github.com/opencontainers/runc v1.1.14
diff: https://github.com/opencontainers/runc/compare/v1.1.13...v1.1.14

Release Notes:

- Fix CVE-2024-45310 / GHSA-jfvp-7x6p-h2pv, a low-severity attack that allowed maliciously configured containers to create empty files and directories on the host.
- Add support for Go 1.23.
- Revert "allow overriding VERSION value in Makefile" and add EXTRA_VERSION.
- rootfs: consolidate mountpoint creation logic.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-03 13:58:23 +02:00
Sebastiaan van Stijn
2189aa2426 update runc binary to 1.1.14
Update the runc binary that's used in CI and for the static packages.

diff: https://github.com/opencontainers/runc/compare/v1.1.13...v1.1.14

Release Notes:

- Fix CVE-2024-45310, a low-severity attack that allowed maliciously configured containers to create empty files and directories on the host.
- Add support for Go 1.23.
- Revert "allow overriding VERSION value in Makefile" and add EXTRA_VERSION.
- rootfs: consolidate mountpoint creation logic.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-03 13:30:19 +02:00
Paweł Gronowski
5213a5afe7 Merge pull request #48422 from vvoland/docs-api-147
docs/api: add documentation for API v1.47
2024-09-03 10:57:27 +00:00
Paweł Gronowski
4e0d1dfc17 docs/api: add documentation for API v1.47
API version used by the v27.2.0 release.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-03 11:58:17 +02:00
Sebastiaan van Stijn
d000f12fcc hack/make/.binary: enable pie mode on windows/arm64
pie-mode is supported for windows/arm64 since https://go.dev/cl/452415,
which is part of go1.20. Also update link to Go source for pie-mode support
to match the location for current versions of Go because the package was
moved in https://go.dev/cl/438475.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-03 10:24:00 +02:00
Adam Simon
28dc2f6fac Increase test handler sleep, replace deprecated assert
- increase mock handler processing time to 50ms to try to prevent it from finishing before the 10ms client timeout occurs
- replace deprecated error type assertion

Signed-off-by: Adam Simon <adamsimon85100@gmail.com>
2024-09-02 16:40:45 +00:00
Sebastiaan van Stijn
6acf01366c Merge pull request #46982 from thaJeztah/update_go_1.22
update to go1.22.6
2024-09-02 18:23:36 +02:00
Paweł Gronowski
0473cfa0bd Merge pull request #48414 from vvoland/c8d-pull-msg
c8d/pull: Same error message for non-matching platform
2024-09-02 14:38:48 +00:00
Paweł Gronowski
c7f8557310 c8d/pull: Same error message for non-matching platform
Use the same error message as the graphdrivers image store backend.
It's more informative as it also includes the requested platform and
won't break clients checking doing error check with string-matching.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-09-02 13:30:12 +02:00
Sebastiaan van Stijn
f5108e9c6b golangci-lint: temporarily disable G115: integer overflow conversion
it produces many hits, some of which may be false positives, but we need to
look into these, e.g.;

    container/container.go:517:72: G115: integer overflow conversion int -> uint32 (gosec)
        shouldRestart, _, _ := container.RestartManager().ShouldRestart(uint32(container.ExitCode()), container.HasBeenManuallyStopped, container.FinishedAt.Sub(container.StartedAt))
                                                                              ^
    container/view.go:401:25: G115: integer overflow conversion int -> uint16 (gosec)
                        PrivatePort: uint16(p),
                                           ^
    container/view.go:413:25: G115: integer overflow conversion int -> uint16 (gosec)
                        PrivatePort: uint16(p),
                                           ^
    container/view.go:414:25: G115: integer overflow conversion int -> uint16 (gosec)
                        PublicPort:  uint16(h),
                                           ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-02 12:50:49 +02:00
Sebastiaan van Stijn
9b11bb507b update golangci-lint to v1.60.2
Update to add go1.23 support

full diff: https://github.com/golangci/golangci-lint/compare/v1.59.1...v1.60.2
Changelog: https://golangci-lint.run/product/changelog/#1602

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-02 12:47:54 +02:00
Sebastiaan van Stijn
3df59c9dcf update to go1.22.6
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-09-02 12:47:48 +02:00
Cory Snider
4cd5c2b643 hack/make/.binary: set CGO_LDFLAGS=-latomic for arm/v5
cross-compiling for arm/v5 was failing;

    #56 84.12 /usr/bin/arm-linux-gnueabi-clang -marm -o $WORK/b001/exe/a.out -Wl,--export-dynamic-symbol=_cgo_panic -Wl,--export-dynamic-symbol=_cgo_topofstack -Wl,--export-dynamic-symbol=crosscall2 -Qunused-arguments -Wl,--compress-debug-sections=zlib /tmp/go-link-759578347/go.o /tmp/go-link-759578347/000000.o /tmp/go-link-759578347/000001.o /tmp/go-link-759578347/000002.o /tmp/go-link-759578347/000003.o /tmp/go-link-759578347/000004.o /tmp/go-link-759578347/000005.o /tmp/go-link-759578347/000006.o /tmp/go-link-759578347/000007.o /tmp/go-link-759578347/000008.o /tmp/go-link-759578347/000009.o /tmp/go-link-759578347/000010.o /tmp/go-link-759578347/000011.o /tmp/go-link-759578347/000012.o /tmp/go-link-759578347/000013.o /tmp/go-link-759578347/000014.o /tmp/go-link-759578347/000015.o /tmp/go-link-759578347/000016.o /tmp/go-link-759578347/000017.o /tmp/go-link-759578347/000018.o -O2 -g -O2 -g -O2 -g -lpthread -O2 -g -no-pie -static
    #56 84.12 ld.lld: error: undefined symbol: __atomic_load_4
    #56 84.12 >>> referenced by gcc_libinit.c
    #56 84.12 >>>               /tmp/go-link-759578347/000009.o:(_cgo_wait_runtime_init_done)
    #56 84.12 >>> referenced by gcc_libinit.c
    #56 84.12 >>>               /tmp/go-link-759578347/000009.o:(_cgo_wait_runtime_init_done)
    #56 84.12 >>> referenced by gcc_libinit.c
    #56 84.12 >>>               /tmp/go-link-759578347/000009.o:(_cgo_wait_runtime_init_done)
    #56 84.12 >>> referenced 2 more times
    #56 84.12
    #56 84.12 ld.lld: error: undefined symbol: __atomic_store_4
    #56 84.12 >>> referenced by gcc_libinit.c
    #56 84.12 >>>               /tmp/go-link-759578347/000009.o:(_cgo_wait_runtime_init_done)
    #56 84.12 >>> referenced by gcc_libinit.c
    #56 84.12 >>>               /tmp/go-link-759578347/000009.o:(x_cgo_notify_runtime_init_done)
    #56 84.12 >>> referenced by gcc_libinit.c
    #56 84.12 >>>               /tmp/go-link-759578347/000009.o:(x_cgo_set_context_function)
    #56 84.12 clang: error: linker command failed with exit code 1 (use -v to see invocation)

From discussion on GitHub;
https://github.com/moby/moby/pull/46982#issuecomment-2206992611

The arm/v5 build failure looks to be due to libatomic not being included
in the link. For reasons probably buried in mailing list archives,
[gcc](https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81358) and clang don't
bother to implicitly auto-link libatomic. This is not a big deal on many
modern platforms with atomic intrinsics as the compiler generates inline
instruction sequences, avoiding any libcalls into libatomic. ARMv5 is not
one of those platforms: all atomic operations require a libcall.

In theory, adding `CGO_LDFLAGS=-latomic` should fix arm/v5 builds.

While it could be argued that cgo should automatically link against
libatomic in the same way that it automatically links against libpthread,
the Go maintainers would have a valid counter-argument that it should be
the C toolchain's responsibility to link against libatomic automatically,
just like it does with libgcc or compiler-rt.

Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-02 12:45:46 +02:00
Cory Snider
e853c093bf hack/make/.binary: set CCGO_CFLAGS=-Wno-atomic-alignment for arm/v5
cross-compiling for arm/v5 fails on go1.22; a fix is included for this
in go1.23 (https://github.com/golang/go/issues/65290), but for go1.22
we can set the correct option manually.

    1.189 + go build -mod=vendor -modfile=vendor.mod -o /tmp/bundles/binary-daemon/dockerd -tags 'netgo osusergo static_build journald' -ldflags '-w -X "github.com/docker/docker/dockerversion.Version=dev" -X "github.com/docker/docker/dockerversion.GitCommit=HEAD" -X "github.com/docker/docker/dockerversion.BuildTime=2024-08-29T16:59:57.000000000+00:00" -X "github.com/docker/docker/dockerversion.PlatformName=" -X "github.com/docker/docker/dockerversion.ProductName=" -X "github.com/docker/docker/dockerversion.DefaultProductLicense=" -extldflags -static ' -gcflags= github.com/docker/docker/cmd/dockerd
    67.78 # runtime/cgo
    67.78 gcc_libinit.c:44:8: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0 bytes) [-Werror,-Watomic-alignment]
    67.78 gcc_libinit.c:47:6: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0 bytes) [-Werror,-Watomic-alignment]
    67.78 gcc_libinit.c:49:10: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0 bytes) [-Werror,-Watomic-alignment]
    67.78 gcc_libinit.c:69:9: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0 bytes) [-Werror,-Watomic-alignment]
    67.78 gcc_libinit.c:71:3: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0 bytes) [-Werror,-Watomic-alignment]
    78.20 + rm -f /go/src/github.com/docker/docker/go.mod

Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-09-02 12:45:44 +02:00
Sebastiaan van Stijn
5ea96cad4b Merge pull request #48119 from thaJeztah/deprecate_RequestPrivilegeFunc
api/types: move RequestPrivilegeFunc to api/types/registry
2024-08-30 15:41:03 +02:00
Sebastiaan van Stijn
bb899c654a api/types: move RequestPrivilegeFunc to api/types/registry
Move the definition, but mostly keep it for documentation purposes,
to prevent having to import the registry package in all places.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-30 14:13:09 +02:00
Tianon Gravi
04b0e61d8b Merge pull request #48388 from corhere/dockerd-manpage-install
man: create parent directories in install recipe
2024-08-29 14:34:00 -07:00
Cory Snider
88b118688e man: create parent directories in install recipe
Support the use of `make install` in packaging scripts, where the
$mandir tree might not exist under $DESTDIR.

For portability, create the parent directories using a separate install
command instead of relying on the non-portable `-D` flag.

Set errexit so the install target fails if any install step fails.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-08-29 15:39:03 -04:00
Sebastiaan van Stijn
980d8e5d54 Merge pull request #48403 from thaJeztah/test_registry_v3
Dockerfile: update registry to v3.0.0-beta.1
2024-08-29 20:52:43 +02:00
Paweł Gronowski
980275dc90 Merge pull request #48399 from vvoland/c8d-list-nonimage
c8d/list: Don't exclude non-container images
2024-08-29 19:16:23 +02:00
Sebastiaan van Stijn
3cf42971b9 Merge pull request #48398 from AkihiroSuda/golang-x-20240829
vendor.mod: golang.org/x/* latest
2024-08-29 18:05:18 +02:00
Sebastiaan van Stijn
9bbe5a50dd Dockerfile: update registry to v3.0.0-beta.1
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-29 17:02:55 +02:00
Paweł Gronowski
f4e82e2fb0 c8d/list: Don't exclude non-container images
Before this, the image list would not show images that are not a valid
container image, but could be a valid artifact.

While they're not directly usable by docker, we should still show them
so the user can still discover them and at least be able to delete them.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-29 11:56:17 +02:00
Sebastiaan van Stijn
623e717bc4 Merge pull request #48373 from thaJeztah/cleanup_portallocator
libnetwork/portallocator: assorted cleanups
2024-08-29 11:39:20 +02:00
Akihiro Suda
d6446d81d8 vendor.mod: golang.org/x/net v0.28.0, etc.
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-08-29 16:52:02 +09:00
Akihiro Suda
65fdd363a0 vendor.mod: golang.org/x/time v0.6.0
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-08-29 16:48:19 +09:00
Akihiro Suda
4bfdfd6f72 vendor.mod: golang.org/x/sys v0.24.0
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-08-29 16:46:40 +09:00
Akihiro Suda
78d0ef5e87 vendor.mod: golang.org/x/sync v0.8.0
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-08-29 16:46:08 +09:00
Akihiro Suda
492fe40052 vendor.mod: golang.org/x/mod v0.20.0
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-08-29 16:45:21 +09:00
Akihiro Suda
d7ff6b5085 vendor.mod: drop direct dependency on golang.org/x/exp
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-08-29 16:44:32 +09:00
Sebastiaan van Stijn
92a05cf414 Merge pull request #48359 from thaJeztah/fix_linting_issues
Fix linting issues in preparation of Go and GolangCI-lint update
2024-08-28 15:48:29 +02:00
Sebastiaan van Stijn
9fca5e7b6f Merge pull request #48368 from thaJeztah/vendor_netlink_1.2.1
vendor: github.com/vishvananda/netlink v1.3.0
2024-08-28 10:26:55 +02:00
Sebastiaan van Stijn
8e580efb73 portallocator: un-export PortAllocator.Begin, PortAllocator.End
These values are configured when instantiating the allocator, and not
intended to be mutated externally. They're only used internally with
the exception of a test in the bridge driver that uses it to pick a
port that can be used for testing.

This patch:

- un-exports the Begin and End fields
- introduces a GetPortRange() utility to allow the bridge driver
  to get the port, but marking it as a function for internal use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 17:15:30 +02:00
Sebastiaan van Stijn
fb1ae4bdb7 portallocator: RequestPortsInRange: validate range once
RequestPortsInRange calls portMap.getPortRange() in a loop, but the given
port-range is always the same. Perform validation once instead of for each
iteration.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 17:15:24 +02:00
Sebastiaan van Stijn
05d784d6da portallocator: make newPortMap a regular constructor
It was a method on PortAllocator, but not really related, other than
reading the default values.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 17:07:26 +02:00
Sebastiaan van Stijn
c00f6281d9 portallocator: RequestPort: skip RequestPortInRange as intermediate
RequestPortInRange is a wrapper for RequestPortsInRange; skip it as
intermediate function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 17:07:25 +02:00
Sebastiaan van Stijn
78d88d06dc portallocator: use net.IPv4zero for defaultIP, and make it a property
Use the variable that's provided by the net package, and make the defaultIP
a property of the allocator instead of a package variable.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 17:07:25 +02:00
Sebastiaan van Stijn
630a47177b portallocator: use new instance in tests
Test the functionality in isolation instead of using the singleton that's
returned by the `GET` function; this makes sure tests don't affect each other,
and doesn't require resetting the singleton in between tests, potentially
allowing these tests to eb run in parallel.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 17:07:25 +02:00
Sebastiaan van Stijn
1897a21d60 portallocator: ReleaseAll: remove unused error-return
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 17:07:25 +02:00
Sebastiaan van Stijn
2a2176f317 portallocator: RequestPortInRange: fix doc-link in godoc
The doc-link was not formatted correctly and didn't work. While updating
also slightly touch-up the description to explain "defaultIP".

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 17:07:22 +02:00
Paweł Gronowski
dfb88e57d5 Merge pull request #48382 from vvoland/update-containerd-1.7.21
Dockerfile/vendor: update containerd to v1.7.21
2024-08-27 14:19:04 +02:00
Paweł Gronowski
a88efd7359 vendor: github.com/containerd/containerd v1.7.21
full diff: https://github.com/containerd/containerd/compare/v1.7.20...v1.7.21

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-27 13:32:35 +02:00
Paweł Gronowski
de4fc1c927 Dockerfile: update containerd binary to v1.7.21 (static binaries and CI only)
Update the containerd binary that's used in CI and static binaries

- full diff: https://github.com/containerd/containerd/compare/v1.7.20...v1.7.21
- release notes: https://github.com/containerd/containerd/releases/tag/v1.7.21

```markdown changelog
Update containerd (static binaries only) to [v1.7.21](https://github.com/containerd/containerd/releases/tag/v1.7.21)
```

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-27 13:28:34 +02: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
005b488506 api/types: fix non-constant format string in call (govet)
api/types/container/hostconfig.go:328:43: printf: non-constant format string in call to fmt.Errorf (govet)
                return &errInvalidParameter{fmt.Errorf(msg)}
                                                       ^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:41:58 +02:00
Sebastiaan van Stijn
0fd3a53c12 api/server/router: fix non-constant format string in call (govet)
api/server/router/container/container_routes.go:943:22: printf: non-constant format string in call to fmt.Fprintf (govet)
                fmt.Fprintf(conn, "HTTP/1.1 101 UPGRADED\r\nContent-Type: "+contentType+"\r\nConnection: Upgrade\r\nUpgrade: tcp\r\n\r\n")
                                  ^
    api/server/router/image/image_routes.go:144:50: printf: non-constant format string in call to github.com/docker/docker/pkg/streamformatter.FormatStatus (govet)
                output.Write(streamformatter.FormatStatus("", id.String()))
                                                              ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:41:46 +02:00
Sebastiaan van Stijn
4a93233b88 container/stream: fix non-constant format string in call (govet)
container/stream/streams.go:111:21: printf: non-constant format string in call to fmt.Errorf (govet)
            return fmt.Errorf(strings.Join(errors, "\n"))
                              ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:40 +02:00
Sebastiaan van Stijn
068c1bf3be libnetwork/drivers/bridge: fix non-constant format string in call (govet)
libnetwork/drivers/bridge/setup_ip_tables_linux.go:385:23: printf: non-constant format string in call to fmt.Errorf (govet)
                    return fmt.Errorf(msg)
                                      ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:40 +02:00
Sebastiaan van Stijn
f434cdd14a volume/testutils: fix non-constant format string in call (govet)
volume/testutils/testutils.go:98:26: printf: non-constant format string in call to fmt.Errorf (govet)
            return nil, fmt.Errorf(opts["error"])
                                   ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:40 +02:00
Sebastiaan van Stijn
81a1ca0217 builder/dockerfile: parseChownFlag: fix non-constant format string in call (govet)
builder/dockerfile/internals_linux.go:38:48: printf: non-constant format string in call to github.com/docker/docker/vendor/github.com/pkg/errors.Wrapf (govet)
            return idtools.Identity{}, errors.Wrapf(err, "can't find uid for user "+userStr)
                                                         ^
    builder/dockerfile/internals_linux.go:42:48: printf: non-constant format string in call to github.com/docker/docker/vendor/github.com/pkg/errors.Wrapf (govet)
            return idtools.Identity{}, errors.Wrapf(err, "can't find gid for group "+grpStr)
                                                         ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:40 +02:00
Sebastiaan van Stijn
b56c58a860 layer: ignore G602: slice index out of range (gosec)
This looks to be a false positive;

    layer/layer.go:202:47: G602: slice index out of range (gosec)
            return createChainIDFromParent(ChainID(dgsts[0]), dgsts[1:]...)
                                                        ^
    layer/layer.go:205:69: G602: slice index out of range (gosec)
        dgst := digest.FromBytes([]byte(string(parent) + " " + string(dgsts[0])))
                                                                           ^
    layer/layer.go:206:53: G602: slice bounds out of range (gosec)
        return createChainIDFromParent(ChainID(dgst), dgsts[1:]...)
                                                           ^
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:39 +02:00
Sebastiaan van Stijn
c308bd3e0e internal/cleanups: fix non-constant format string in call (govet)
internal/cleanups/composite_test.go:46:9: printf: non-constant format string in call to (*testing.common).Logf (govet)
        t.Logf(err.Error())
               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:39 +02:00
Sebastiaan van Stijn
7b60a7047d libnetwork/cnmallocator: fix non-constant format string in call (govet)
libnetwork/cnmallocator/drivers_ipam.go:43:31: printf: non-constant format string in call to (*github.com/docker/docker/vendor/github.com/sirupsen/logrus.Entry).Infof (govet)
            log.G(context.TODO()).Infof("Swarm initialized global default address pool to: " + str.String())
                                        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:39 +02:00
Sebastiaan van Stijn
06bfe8bab3 cmd/dockerd: fix non-constant format string in call (govet)
cmd/dockerd/required.go:17:24: printf: non-constant format string in call to github.com/docker/docker/vendor/github.com/pkg/errors.Errorf (govet)
            return errors.Errorf("\n" + strings.TrimRight(cmd.UsageString(), "\n"))
                                 ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:39 +02:00
Sebastiaan van Stijn
6008c42ca2 libnetwork: fix non-constant format string in call (govet)
libnetwork/controller.go:1054:32: printf: non-constant format string in call to github.com/docker/docker/libnetwork/types.NotFoundErrorf (govet)
                return types.NotFoundErrorf(err.Error())
                                            ^
    libnetwork/controller.go:1073:32: printf: non-constant format string in call to github.com/docker/docker/libnetwork/types.NotFoundErrorf (govet)
                return types.NotFoundErrorf(err.Error())
                                            ^
    libnetwork/sandbox_externalkey_unix.go:113:21: printf: non-constant format string in call to fmt.Errorf (govet)
            return fmt.Errorf(string(buf[0:n]))
                              ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:39 +02:00
Sebastiaan van Stijn
b79a4696ee integration-cli: fix non-constant format string in call (govet)
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:39 +02:00
Sebastiaan van Stijn
6bbacbec26 integration-cli: DockerSwarmSuite: rm redundant Fprintf, handle errors
Also fix some unhandled errors.

    integration-cli/docker_cli_swarm_test.go:697:19: printf: non-constant format string in call to fmt.Fprintf (govet)
                fmt.Fprintf(w, `{"Error":"failed to add veth pair: `+err.Error()+`"}`)
                               ^
    integration-cli/docker_cli_swarm_test.go:731:18: printf: non-constant format string in call to fmt.Fprintf (govet)
            fmt.Fprintf(w, `{"LocalDefaultAddressSpace":"`+lAS+`", "GlobalDefaultAddressSpace": "`+gAS+`"}`)
                           ^
    integration-cli/docker_cli_swarm_test.go:742:19: printf: non-constant format string in call to fmt.Fprintf (govet)
                fmt.Fprintf(w, `{"Error":"Unknown address space in pool request: `+poolRequest.AddressSpace+`"}`)
                               ^
    integration-cli/docker_cli_swarm_test.go:746:19: printf: non-constant format string in call to fmt.Fprintf (govet)
                fmt.Fprintf(w, `{"PoolID":"`+poolID+`", "Pool":"`+pool+`"}`)
                               ^
    integration-cli/docker_cli_swarm_test.go:763:19: printf: non-constant format string in call to fmt.Fprintf (govet)
                fmt.Fprintf(w, `{"Address":"`+gw+`"}`)
                               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:38 +02:00
Sebastiaan van Stijn
3ca38f0b5e integration-cli: DockerNetworkSuite: rm redundant Fprintf, handle errors
Also rename some variables that shadowed imports, and fix some
unhandled errors.

    integration-cli/docker_cli_network_unix_test.go:102:19: printf: non-constant format string in call to fmt.Fprintf (govet)
                fmt.Fprintf(w, `{"Error":"failed to add veth pair: `+err.Error()+`"}`)
                               ^
    integration-cli/docker_cli_network_unix_test.go:136:18: printf: non-constant format string in call to fmt.Fprintf (govet)
            fmt.Fprintf(w, `{"LocalDefaultAddressSpace":"`+lAS+`", "GlobalDefaultAddressSpace": "`+gAS+`"}`)
                           ^
    integration-cli/docker_cli_network_unix_test.go:147:19: printf: non-constant format string in call to fmt.Fprintf (govet)
                fmt.Fprintf(w, `{"Error":"Unknown address space in pool request: `+poolRequest.AddressSpace+`"}`)
                               ^
    integration-cli/docker_cli_network_unix_test.go:151:19: printf: non-constant format string in call to fmt.Fprintf (govet)
                fmt.Fprintf(w, `{"PoolID":"`+poolID+`", "Pool":"`+pool+`"}`)
                               ^
    integration-cli/docker_cli_network_unix_test.go:168:19: printf: non-constant format string in call to fmt.Fprintf (govet)
                fmt.Fprintf(w, `{"Address":"`+gw+`"}`)
                               ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 10:23:27 +02:00
Sebastiaan van Stijn
2b7a687554 integration-cli: use erors.New() instead of fmt.Errorf
integration-cli/benchmark_test.go:49:27: printf: non-constant format string in call to fmt.Errorf (govet)
                            chErr <- fmt.Errorf(out)
                                                ^
    integration-cli/benchmark_test.go:62:27: printf: non-constant format string in call to fmt.Errorf (govet)
                            chErr <- fmt.Errorf(out)
                                                ^
    integration-cli/benchmark_test.go:68:27: printf: non-constant format string in call to fmt.Errorf (govet)
                            chErr <- fmt.Errorf(out)
                                                ^
    integration-cli/benchmark_test.go:73:27: printf: non-constant format string in call to fmt.Errorf (govet)
                            chErr <- fmt.Errorf(out)
                                                ^
    integration-cli/benchmark_test.go:78:27: printf: non-constant format string in call to fmt.Errorf (govet)
                            chErr <- fmt.Errorf(out)
                                                ^
    integration-cli/benchmark_test.go:84:27: printf: non-constant format string in call to fmt.Errorf (govet)
                            chErr <- fmt.Errorf(out)
                                                ^
    integration-cli/benchmark_test.go:94:27: printf: non-constant format string in call to fmt.Errorf (govet)
                            chErr <- fmt.Errorf(out)
                                                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 09:57:17 +02:00
Sebastiaan van Stijn
c7b36f8953 libnetwork: TestDNSOptions: remove redundant skip check
libnetwork/sandbox_dns_unix_test.go:17:13: SA4032: due to the file's build constraints, runtime.GOOS will never equal "windows" (staticcheck)
        skip.If(t, runtime.GOOS == "windows", "test only works on linux")
                   ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 09:57:17 +02:00
Sebastiaan van Stijn
6bd7835cb6 integration-cli: remove redundant platform checks
This condition was added in 0215a62d5b, which
removed pkg/homedir as abstraction, but didn't consider that this test
is currently only ran on Unix.

    integration-cli/docker_cli_run_unix_test.go:254:5: SA4032: due to the file's build constraints, runtime.GOOS will never equal "windows" (staticcheck)
        if runtime.GOOS == "windows" {
           ^
    integration-cli/docker_cli_run_unix_test.go:338:5: SA4032: due to the file's build constraints, runtime.GOOS will never equal "windows" (staticcheck)
        if runtime.GOOS == "windows" {
           ^

Added a TODO, because this functionality should also be tested on Windows,
probably as part of tests in docker/cli instead.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-27 09:57:14 +02:00
Sebastiaan van Stijn
609c6987f1 Merge pull request #48374 from vvoland/c8d-pull-keep-old
c8d/pull: Keep the replaced image as dangling
2024-08-26 20:07:38 +02:00
Paweł Gronowski
84fd1a3954 Merge pull request #48293 from vvoland/c8d-load-multiplatform-fixes
c8d/load: Multi-platform fixes
2024-08-26 18:38:56 +02:00
Paweł Gronowski
0afe684685 c8d/pull: Replace pointer to interface with interface
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-26 18:38:08 +02:00
Sebastiaan van Stijn
d6e9b5fe30 Merge pull request #48298 from corhere/dockerd-manpage
Move dockerd man page back from docker/cli
2024-08-26 18:06:34 +02:00
Akihiro Suda
f0aa0b95b1 Merge pull request #48372 from thaJeztah/bump_mergo
vendor: dario.cat/mergo v1.0.1
2024-08-26 23:55:11 +09:00
Paweł Gronowski
db40a6132b c8d/pull: Keep the replaced image as dangling
With graphdrivers, the old image was still kept as a dangling image.
Keep the same behavior with containerd.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-26 15:55:57 +02:00
Paweł Gronowski
6ebe6a7353 c8d/load: Only unpack host platform images
When loading a multi-platform image, it's not necessary to unpack all
platforms, especially those which have a completely different OS.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-26 15:15:03 +02:00
Paweł Gronowski
728894b7d0 c8d/load: Don't fail whole operation if unpack failed
Log the error to the progress output instead.
The image is still loaded into the content store and image service even
if the unpacking failed, so don't error out the whole operation to avoid
missing the load events for other image names loaded from the same
archive.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-26 15:15:02 +02:00
Paweł Gronowski
cbfe418681 Merge pull request #48367 from vvoland/c8d-list-race-fix
c8d/list: Fix race condition when traversing containers
2024-08-26 13:02:07 +02:00
Sebastiaan van Stijn
d9fa66dbd0 Merge pull request #48370 from thaJeztah/resolvconf_clean
libnetwork: resolvconf: remove dependency on errdefs
2024-08-26 12:48:05 +02:00
Sebastiaan van Stijn
0db71bb629 vendor: dario.cat/mergo v1.0.1
- fix: overwriteWithEmptyValue is forced to true when merging an object
  involving maps
- fix: WithoutDereference should respect non-nil struct pointers

full diff: https://github.com/darccio/mergo/compare/v1.0.0...v1.0.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-26 12:39:23 +02:00
Sebastiaan van Stijn
2c498c6a74 vendor: github.com/vishvananda/netlink v1.3.0
full diff: https://github.com/vishvananda/netlink/compare/v1.2.1...v1.3.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-26 12:33:20 +02:00
Sebastiaan van Stijn
6d0a5e31d7 vendor: github.com/vishvananda/netlink v1.2.1
Local changes related to:

- c96b03b4be
- dedb7ec04b

full diff: https://github.com/vishvananda/netlink/compare/v1.2.1-beta.2...v1.2.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-26 12:32:10 +02:00
Paweł Gronowski
55f693e7b7 integration/TestAPIImagesListManifests: Check Containers
Verify that the ImageData.Containers contains the ID of the container
using that image.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-26 10:38:34 +02:00
Akihiro Suda
e0b61d4c98 Merge pull request #48371 from thaJeztah/cdi_0.8.0
vendor: tags.cncf.io/container-device-interface v0.8.0
2024-08-25 01:29:12 +09:00
Paweł Gronowski
29a2f6d339 c8d/list: Update benchmark to also have containers
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-23 22:13:58 +02:00
Paweł Gronowski
a5d75f6d27 c8d/list: Fix race condition when traversing containers
Use a regular for loop instead of ApplyAll which spawns a separate
goroutine for each separate container.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-23 22:12:52 +02:00
Sebastiaan van Stijn
2f0180934d vendor: tags.cncf.io/container-device-interface v0.8.0
Breaking change: The .ToOCI() functions in the specs-go package have been
removed. This removes the dependency on the OCI runtime specification from
the CDI specification definition itself.

What's Changed

- Add workflow to mark prs and issues as stale
- Remove the ToOCI functions from the specs-go package
- docs: add a pointer to community meetings in our docs.
- Bump spec version to v0.8.0
- Update spec version in README

Full diff:  https://github.com/cncf-tags/container-device-interface/compare/v0.7.2...v0.8.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-23 21:59:22 +02:00
Sebastiaan van Stijn
202d9ccfb5 Merge pull request #48355 from thaJeztah/libcontainer_consolidate_defaults_step2
libcontainerd/supervisor: set log-level through the config-file
2024-08-23 18:49:17 +02:00
Sebastiaan van Stijn
fe307b5dab libnetwork: resolvconf: remove dependency on errdefs
the resolvconf package is imported in BuildKit, and this is the only
location that used the errdefs package outside of the client.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-23 17:54:21 +02:00
Sebastiaan van Stijn
afdfc04e10 libnetwork: resolvconf: remove var that shadowed import
It was only used in a single place, so we can remove the
intermediate variable.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-23 17:54:16 +02:00
Cory Snider
6d94122217 logger/journald: plumb contexts into reader
Co-authored-by:: Cory Snider <csnider@mirantis.com>
Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-08-22 21:33:49 +00:00
Brian Goff
9b6ba18fc9 logfile: Close reader when caller cancels
This allows for an individual decode operation to be cancelled while the
log reader is reading data from a log file by closing the underlying file.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-08-22 21:33:46 +00:00
Sebastiaan van Stijn
d8f079deb6 Merge pull request #48261 from thaJeztah/bump_xx
Dockerfile: update xx to v1.5.0
2024-08-21 14:12:01 +02:00
Sebastiaan van Stijn
c4ba1f4718 Dockerfile: update xx to v1.5.0
full diff: https://github.com/tonistiigi/xx/compare/v1.4.0...v1.5.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-21 10:38:57 +02:00
Sebastiaan van Stijn
abcb9e972b libcontainerd/supervisor: set log-level through the config-file
The config.logLevel field, when set, is used to set the `--log-level`
flag when starting the managed `containerd` binary. This flag is the
equivalent to setting the `Config.Debug.Level` field, as can be seen
in the [`md/containerd/command.setLogLevel()`][1] function.

As we're already producing a generated containerd configuration file,
and this file already includes `Debug` options, we might as well include
the option in that file, instead of using the `--log-level` flag.

For entertainment of whoever reads this commit-message, it's worth noting
that previously we were writing this option to the config-file, and
yours truly removed that part in b6b0b0a05f,
but to my defence, we were _also_ setting the `--log-level` flag at the
time :)

[1]: https://github.com/containerd/containerd/blob/v1.7.20/cmd/containerd/command/main.go#L348-L357

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-20 15:58:48 +02:00
Sebastiaan van Stijn
7e864f163c Merge pull request #48353 from thaJeztah/libcontainer_consolidate_defaults_step1
libcontainerd/supervisor: consolidate platform-specific defaults
2024-08-20 14:43:05 +02:00
Paweł Gronowski
22b5cb254b Merge pull request #48351 from thaJeztah/integration_nits3
integration/container: rename var that collided with import
2024-08-20 10:38:04 +02:00
Cory Snider
edfde78355 man: support bringing your own go-md2man
Set the GO_MD2MAN make variable to elide building go-md2man from
vendored sources and use the specified command instead.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-08-19 14:01:48 -04:00
Cory Snider
05d7008419 man: build dockerd man pages using make
Vendor the go-md2man tool used to generate the man pages so that the
only dependency is a Go toolchain.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-08-19 14:01:38 -04:00
Sebastiaan van Stijn
2c0100fbde Merge pull request #48174 from AkihiroSuda/hcsshim-0.12.5
vendor.mod: github.com/microsoft/hcsshim v0.12.5
2024-08-19 18:17:42 +02:00
Sebastiaan van Stijn
1804f0c911 integration/container: rename var that collided with import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-19 13:28:17 +02:00
Sebastiaan van Stijn
62bcc6ef50 libcontainerd/supervisor: consolidate platform-specific defaults
Commit a0009345f5 updated the default
MaxRecvMsgSize and MaxSendMsgSize for Linux, but did not modify the
defaults for Windows. Those options should not be platform-specific,
which means that the only difference between the Linux and Windows
config are the addresses for GRPC and Debug (Windows defaulting
to a named pipe, whereas Linux sockets within exec-root).

This patch

- implements functions to return the default addresses for each platform
- moves the defaults into `supervisor.Start()`
- removes the now redundant `remote.setDefaults()` method

It's worth noting that prior to this path, `remove.setDefaults()` would
be applied _after_ any (custom) `DaemonOpt` was applied. However, none of
the existing `DaemonOpt` options currently mutates these options. `remote`
is also a non-exported type, so no external implementations can currently
be created. It is therefore safe to set these defaults before options are
applied.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-19 13:03:34 +02:00
Sebastiaan van Stijn
5efbb60a4e Merge pull request #48334 from 7sunarni/master
feat(stream): log the event when stream copy failed
2024-08-19 11:58:56 +02:00
Akihiro Suda
f49fad75eb vendor.mod: github.com/microsoft/hcsshim v0.12.5
https://github.com/microsoft/hcsshim/compare/v0.11.7...v0.12.5

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-08-18 04:38:57 +09:00
Paweł Gronowski
0d0d4ee3df Merge pull request #48345 from vvoland/c8d-manifests-containers-always
c8d/list: Don't require `opts.ContainerCount` for manifest containers
2024-08-16 15:07:07 +02:00
Paweł Gronowski
b93cf37dcd c8d/list: Don't require opts.ContainerCount for manifest containers
The `GET /images/json` requires an optional `container-count` parameter
which set the `Containers` property of in the ImageSummary to a number
of containers using that image.

This was also propagated to the new manifest list property which
includes a list of all the container IDs that are using this specific
image manifest.

Disconnect the `ImageData.Containers` property from this option and
always include it by default without an explicit opt-in.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-16 13:31:18 +02:00
7sunarni
cd148d39d9 feat(stream): log the event when stream copy failed
Signed-off-by: 7sunarni <710720732@qq.com>
2024-08-16 17:16:42 +08:00
Paweł Gronowski
9fc7b51235 Merge pull request #48324 from thaJeztah/typo_fixes2
fix deprecation comments, and update some godoc
2024-08-16 10:59:47 +02:00
Akihiro Suda
14de409e52 Merge pull request #48340 from tonistiigi/update-buildkit-v0.15.2
vendor: update buildkit to v0.15.2
2024-08-16 03:46:19 +09:00
Tonis Tiigi
c459986399 vendor: update buildkit to v0.15.2
Also brings in fix for moby/buildkit#5242

Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-08-15 18:14:56 +03:00
Paweł Gronowski
1c282d1f1b Merge pull request #48330 from vvoland/c8d-list-multiplatform-fixsize
c8d/list: Fix `Total` size calculation
2024-08-14 16:14:06 +02:00
Paweł Gronowski
6bb6befc37 c8d: Rename readConfig to readJSON
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-14 14:12:23 +02:00
Paweł Gronowski
495fab8e66 c8d/list: Add test for total and content size
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-14 14:12:22 +02:00
Paweł Gronowski
469c2ef3ec c8d/list: Fix Total size calculation
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-14 14:12:20 +02:00
Rob Murray
0f341c4cd5 Merge pull request #48322 from robmry/64bit_iprange_fix
Allow 64-bit --ip-range
2024-08-13 15:24:59 +01:00
Sebastiaan van Stijn
e77e543b58 api/types/registry: fix godoc, and add some doc-links
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-13 14:36:55 +02:00
Sebastiaan van Stijn
218c08b283 plugin: fix deprecation comments
These must have a whitespace before them, otherwise they are ignored.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-13 14:36:54 +02:00
Rob Murray
771377f9fa Test ipvlan IPv6-only
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-13 11:50:38 +01:00
Rob Murray
390713607f Allow ipvlan containers with no address
An address can be assigned in the container (maybe by DHCP).
DNS lookups work once there's an address and a route, before
that, there's no source address for lookups made by the
internal resolver from the container's network namespace.

In this case, don't want to hook it up to docker_gwbridge, so
disable it in joinInfo - this currently means no DNS entry for
the container's name is set up in the internal DNS. (Even once
the interface has a user-assigned address, there won't be an
internal-DNS entry for the container until it's connected to
a with-IPAM network as well.)

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-13 11:50:22 +01:00
Rob Murray
b95f8e7799 Fix some ipvlan error types for the API
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-13 11:50:21 +01:00
Rob Murray
660e8118a4 Allow no-IPv4 on an ipvlan network
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-13 11:50:21 +01:00
Rob Murray
8427de3bac Test macvlan IPv6-only
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-13 11:50:21 +01:00
Rob Murray
d599cc5842 Allow macvlan containers with no address
An address can be assigned in the container (maybe by DHCP).
DNS lookups work once there's an address and a route, before
that, there's no source address for lookups made by the
internal resolver from the container's network namespace.

In this case, don't want to hook it up to docker_gwbridge, so
disable it in joinInfo - this currently means no DNS entry for
the container's name is set up in the internal DNS. (Even once
the interface has a user-assigned address, there won't be an
internal-DNS entry for the container until it's connected to
a with-IPAM network as well.)

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-13 11:46:54 +01:00
Rob Murray
f57e0dc2ff Fix some macvlan error types for the API
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-12 16:16:15 +01:00
Rob Murray
a7a5de676d Allow no-IPv4 on a macvlan network
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-12 16:16:15 +01:00
Rob Murray
496b457ad8 Allow --ip-range ending on a 64-bit boundary
When defaultipam.newPoolData is asked for a pool of 64-bits
or more, it ends up with an overflowed u64 - so, it just
subtracts one to get a nearly-big-enough range (for a 64-bit
subnet).

When defaultipam.getAddress is called with an ipr (sub-pool
range), the range it calls bitmask.SetAnyInRange with is
exclusive of end. So, its end param can't be MaxUint64,
because that's the max value for the top end of the range
and, when checking the range, SetAnyInRange fails.

When fixed-cidr-v6 behaves more like fixed-cidr, it will ask
for a 64-bit range if that's what fixed-cidr-v6 needs. So,
it hits the bug when allocating an address for, for example:

  docker network create --ipv6 --subnet fddd::/64 --ip-range fddd::/64 b46

The additional check for "ipr == base" avoids the issue in
this case, by ignoring the ipr/sub-pool range if ipr is the
same as the pool itself (not really a sub-pool).

But, it still fails when ipr!=base. For example:

  docker network create --ipv6 --subnet fddd::/56 --ip-range fddd::/64 b46

So, also subtract one from 'end' if it's going to hit the max
value allowed by the Bitmap.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-12 15:36:32 +01:00
Rob Murray
1d8ff115d8 Merge pull request #48290 from robmry/v6only/dns
IPv6 only: DNS changes
2024-08-12 15:17:53 +01:00
Sebastiaan van Stijn
ae1c95ccc7 Merge pull request #48318 from thaJeztah/windows_proxy_leftovers
remove leftovers for building docker-proxy on Windows
2024-08-12 10:05:20 +02:00
Sebastiaan van Stijn
9c6d30481d remove leftovers for building docker-proxy on Windows
commit e0c7a839a8 stopped building the
docker-proxy on Windows as it's not used on that platform.

This removes some leftovers for building it on Windows.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-10 14:58:27 +02:00
Sebastiaan van Stijn
7650efed2e Merge pull request #48310 from thaJeztah/austin_curator
add Austin Vazquez (austinvazquez) to curators
2024-08-09 20:06:28 +02:00
Sebastiaan van Stijn
bffb44a556 Merge pull request #48311 from crazy-max/govulncheck
govulncheck to report known vulnerabilities
2024-08-09 17:19:13 +02:00
CrazyMax
3cd28504de govulncheck to report known vulnerabilities
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-08-09 10:56:09 +02:00
Paweł Gronowski
d770efd851 Merge pull request #48275 from thaJeztah/swagger_fix_nullable
api/swagger: fix x-nullable for SystemInfo.Containerd (api v1.46)
2024-08-09 09:59:56 +02:00
Sebastiaan van Stijn
8d06e70f34 Merge pull request #48132 from robmry/bind_socket_for_docker_proxy
Create docker-proxy TCP/UDP listener sockets in the daemon
2024-08-08 20:30:58 +02:00
Sebastiaan van Stijn
2269acc7a3 Merge pull request #48307 from thaJeztah/migrate_userns
migrate to github.com/moby/sys/userns
2024-08-08 12:34:29 +02:00
Sebastiaan van Stijn
a308f12ed8 add Austin Vazquez (austinvazquez) to curators
Austin has been helping maintain the project for some time, and we discussed
adding Austin as a curator to grant permissions to do triage tasks.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-08 12:17:15 +02:00
Paweł Gronowski
f3cf9359bd Merge pull request #47526 from vvoland/c8d-list-multiplatform
c8d: Multi-platform image list
2024-08-08 11:38:31 +02:00
Paweł Gronowski
b7eeb4986e Merge pull request #48303 from vvoland/makefile-bindgit
Makefile: Add BIND_GIT variable
2024-08-08 10:57:46 +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
Tianon Gravi
6b2b54c7f2 Merge pull request #48300 from vvoland/update-go-1.21.13
update to go1.21.13
2024-08-07 16:16:07 -07:00
Paweł Gronowski
8411ecb5e3 Makefile: Add BIND_GIT variable
Defining BIND_GIT will bind mount the common .git directory into the dev
container.
This makes it possible to run some hack/* scripts which rely on `git`
when running the container in a git worktree.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-07 16:05:20 +02:00
Paweł Gronowski
050afe1e1a api/list: Expose manifests
Add `Manifests` field to `ImageSummary` which exposes all image
manifests (which includes other blobs using the image media type, like
buildkit attestations).

There's also a new `manifests` query field that needs to be set in order
for the response to contain the new information.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-07 13:48:54 +02:00
Paweł Gronowski
f8b638b98f c8d/list: Use ReadConfig helper
Use a helper from `ImageManifest` which reads the config instead.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-07 13:48:52 +02:00
Paweł Gronowski
85e9102dc9 api: Bump default version to 1.47
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-07 13:48:51 +02:00
Paweł Gronowski
efb3c50799 swagger: Disable ImageSummary model generation
Our version of go-swagger doesn't handle the `omitempty` correctly for
the new field.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-07 13:48:50 +02:00
Paweł Gronowski
b24c2e95e5 update to go1.21.13
- https://github.com/golang/go/issues?q=milestone%3AGo1.21.13+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.21.12...go1.21.13

go1.21.13 (released 2024-08-06) includes fixes to the go command, the
covdata command, and the bytes package. See the Go 1.21.13 milestone on
our issue tracker for details.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-07 11:45:08 +02:00
Rob Murray
1dd102e9b6 Merge pull request #48281 from robmry/remove_sysctl_migration_limit
Migrate per-endpoint sysctls until 28.0.0
2024-08-06 18:11:00 +01:00
Sebastiaan van Stijn
a1bcba8d67 Merge pull request #48276 from vvoland/c8d-image-refactor
c8d/image: Simplify `presentImages` and better "platform not found" error
2024-08-06 16:44:18 +02:00
Rob Murray
925b484a40 No fallback nameservers for internal resolver
The internal resolver now uses any namesever found in the host's
/etc/resolv.conf as an external nameserver, and it's accessed
from the host's network namespace.

Before this change, when no external nameservers were found (so
the host had no entries in /etc/resolv.conf) Google's DNS servers
were used as fallbacks, always accessed from the container's
network namespace. If a container's initial set of endpoints had
IPv6 enabled, the IPv6 nameservers were included.

Now we have IPv6-only networks, a similar exception would be
needed for Google's IPv4 nameservers... don't include them if
there are no IPv4 endpoints.

However, only the initial set of endpoints was considered. As
networks are connected/disconnected, IPv4 or IPv6 connectivity
may be lost.

Unlike nameservers read from the host's /etc/resolv.conf, there
is no way to tell which fallback nameservers (v4/v6) might work
from the host's namespace. So, using the host's namespace isn't
a good solution.

Since we want to get away from using fallback nameservers anyway,
this change removes them.

If a host has no /etc/resolv.conf entries, but a container does
need to use DNS, it'll need to be configured with servers via
'--dns'.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-06 10:33:05 +01:00
Rob Murray
d29767431c Use host netns for host's ext-dns servers
The internal resolver needs to know whether to make requets
to external DNS servers from the container's network namespace
or the host's.

The original rule was that requests were always made from the
container's namespace, unless the nameserver was on a localhost
address on the host. IPv6 nameservers were left in the container's
/etc/resolv.conf.

Commit 4e8d9a4 modified that so that IPv6 nameservers were also
used as external nameservers. The internal resolver accessed
them from the host namespace if the container's initial set of
endpoints were IPv4-only, or the nameserver address contained
a zone-id, (or the nameserver was on the IPv6 loopback address).

That would break if initial IPv6 endpoints were disconnected from
the container, leaving it with no IPv6 address.

Once IPv6-only networks are allowed, another exception would need
to be made for IPv4 nameservers (they'd need to be accessed from
the host's namespace).

Instead of doing that ... this change simplifies things, if a
nameserver address is read from the host's /etc/resolv.conf, it'll
work in the host's namespace. So, the rule is now simply that
nameservers read from the host's resolv.conf are accessed from the
host's namespace. DNS servers added as overrides ('--dns') are
accessed from the container's namespace (as before).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-06 10:33:04 +01:00
Rob Murray
344039b9ae Populate DNS records for IPv6-only endpoints
Also, return IPv6 records from Network.getSvcRecords()
so that /etc/hosts entries are deleted when an IPv6-only
endpoint is removed.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-06 10:33:04 +01:00
Rob Murray
265f0a7fa7 Merge pull request #48284 from robmry/v6only/libnetwork
IPv6 only: gateway, IPAM and address configuration
2024-08-06 08:58:41 +01:00
Grace Choi
b4cee5c3ee Removed all mentions of "please" from docs and messages
Signed-off-by: Grace Choi <gracechoi@utexas.edu>
Signed-off-by: Pranjal Rai <pranjalrai@utexas.edu>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-05 17:38:50 -04:00
David Karlsson
f1ec84314d docs: add default-network-opt daemon option
Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com>
2024-08-05 17:38:50 -04:00
Sebastiaan van Stijn
23812190c3 docs: remove devicemapper
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-05 17:38:50 -04:00
Kir Kolyshkin
690d166632 man/dockerd.8: assorted formatting fixes
Mostly, this makes sure that literals (such as true, false, host,
private, examples of options usage etc.) are typeset in bold, except for
filenames, which are typeset in italic.

While at it,
 - remove some default values from synopsis as it should not
   be there;
 - fix man pages references (page name in bold, volume number in
   regular).

This is not a complete fix, but a step in the right direction.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-05 17:38:50 -04:00
Kir Kolyshkin
374b779dd1 man/dockerd.8: escape asterisks and underscores
1. Escape asterisks and underscores, that have special meaning in
   Markdown. While most markdown processors are smart enough to
   distinguish whether it's a literal * or _ or a formatting directive,
   escaping makes things more explicit.

2. Fix using wrong level of headings in some dm options (most are ####,
   but some were #####).

3. Do not use sub-heading for examples in some dm options (this is how
   it's done in the rest of the man page).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-05 17:38:50 -04:00
Sebastiaan van Stijn
386d0c0fbc docs: update dockerd usage output for new proxy-options
Adds documentation for the options that were added in
427c7cc5f8

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-05 17:38:49 -04:00
Ashly Mathew
54971ac807 Fix styling of arguments
Signed-off-by: Ashly Mathew <ashlymathew93@gmail.com>
2024-08-05 17:38:49 -04:00
Luis Henrique Mulinari
a8b8f9b288 Fix the max-concurrent-downloads and max-concurrent-uploads configs documentation
This fix tries to address issues raised in moby/moby#44346.
The max-concurrent-downloads and max-concurrent-uploads limits are applied for the whole engine and not for each pull/push command.

Signed-off-by: Luis Henrique Mulinari <luis.mulinari@gmail.com>
2024-08-05 17:38:49 -04:00
Sebastiaan van Stijn
68e9223289 docs: remove documentation about deprecated cluster-store
This removes documentation related to legacy overlay networks using
an external k/v store.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-05 17:38:49 -04:00
Anca Iordache
6c702167bf Document --validate daemon option
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
2024-08-05 17:38:49 -04:00
Sebastiaan van Stijn
af45195a21 Update man-page source MarkDown to work with go-md2man v2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-05 17:38:49 -04:00
Akihiro Suda
562a6d2b13 docs: update for cgroup v2 and rootless
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-08-05 17:38:49 -04:00
Rob Gulewich
7cf2132655 docker run: specify cgroup namespace mode with --cgroupns
Signed-off-by: Rob Gulewich <rgulewich@netflix.com>
2024-08-05 17:38:49 -04:00
Lukas Heeren
1cbcd5d47a daemon: document --max-download-attempts option
update docs based on PR 39949

Signed-off-by: Lukas Heeren <lukas-heeren@hotmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-05 17:38:49 -04:00
taiji-tech
3cfa74724c Update document links and title.
Signed-off-by: taiji-tech <csuhqg@foxmail.com>
2024-08-05 17:38:49 -04:00
selansen
462f38bd8b Allow user to specify default address pools for docker networks This is separate commit for CLI files to address PR 36054
Signed-off-by: selansen <elango.siva@docker.com>
2024-08-05 17:38:49 -04:00
Sebastiaan van Stijn
13ff896b38 Update docs and completion-scripts for deprecated features
- the `--disable-legacy-registry` daemon flag was removed
- duplicate keys with conflicting values for engine labels
  now produce an error instead of a warning.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-05 17:38:49 -04:00
Renaud Gaubert
f3c3b05b50 Added docs for dockerd
Signed-off-by: Renaud Gaubert <renaud.gaubert@gmail.com>
2024-08-05 17:38:49 -04:00
Abdur Rehman
20f8455562 fix a number of minor typos
Fix 19 typos, grammatical errors and duplicated words.

These fixes have minimal impact on the code as these are either in the
doc files or in comments inside the code files.

Signed-off-by: Abdur Rehman <abdur_rehman@mentor.com>
2024-08-05 17:38:49 -04:00
Kir Kolyshkin
c23d4b017a Introduce/document new IPC modes
This builds (and depends) on https://github.com/moby/moby/pull/34087

Version 2:
 - remove --ipc argument validation (it is now done by daemon)
 - add/document 'none' value
 - docs/reference/run.md: add a table with better modes description
 - dockerd(8) typesetting fixes

Version 3:
 - remove ipc mode tests from cli/command/container/opts_test.go

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-08-05 17:38:49 -04:00
Aleksa Sarai
25baee8ab9 docs: add documentation for dm.libdm_log_level
This is a new option added specifically to allow for debugging of bugs
in Docker's storage drivers or libdm itself.

Signed-off-by: Aleksa Sarai <asarai@suse.de>
2024-08-05 17:38:49 -04:00
Cory Snider
7d3f09a9c3 Restore dockerd man page
Prepare to move the dockerd man page back to this repository from
docker/cli, retaining history.

This partially reverts commit b5579a4ce3.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-08-05 17:32:15 -04:00
Rob Murray
ea914a66a2 Use retErr in Network.ipamAllocate
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-05 15:45:05 +01:00
Rob Murray
cdea750966 Tell RootlessKit about port mappings when --userland-proxy=false
The daemon was modified to tell RootlessKit about host port
mappings directly, rather than by running rootlesskit-docker-proxy
to make those updates.

DNAT rules created in rootless mode referred to the host IP address,
rather than the address seen as host address in the rootless network
namespace.

With these changes, port mappings work in rootless mode when
--userland-proxy=false - so, don't gate the RootlessKit API calls
on starting docker-proxy.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-05 14:04:05 +01:00
Rob Murray
b3fabedecc Create docker-proxy TCP/UDP listener sockets in the daemon
Before commit 4f09af6, when allocating host ports for a new
port mapping, iptables rules were set up then docker-proxy was
started. If the host port was already in-use, docker-proxy exited
with an error, and the iptables rules were removed. That could
potentially interfere with a non-docker service that was already
using the host port for something unrelated.

Commit 4f09af6 swapped that problem for a different one... in
order to check that a port was available before creating iptables
rules, it attempted to start docker-proxy first. If it failed, it
could then try a different host port, without interfering with
any other service. The problem with that is docker-proxy would
start listening before the iptables rules were in place, so it
could accept connections then become unusable because new NAT
rules diverted packets directly to the container. This would leave
the client with a broken connection, causing at-least a delay
while it figured that out and reconnected.

This change creates and binds the socket in the daemon, before
creating iptables rules. If the bind fails, it may try a different
port. When or if the bind succeeds, iptables rules are created,
then the daemon calls listen on the socket. If docker-proxy is
needed, the socket is handed over to it at that point.

In rootless mode, the ports have to be bound to an address in the
rootless network namespace (where dockerd is running). DNAT rules
now use the same address.

If docker-proxy is not needed ("--userland-proxy=false"), the daemon
still listens on TCP sockets as the old dummyProxy would have done.
This makes the socket show up in "netstat" output.

The dummyProxy is no longer needed on Linux. Its job was to bind the
host ports if docker-proxy was disabled, but that's now already
handled by binding the sockets early.

This change doesn't affect SCTP, because it's not currently possible
for docker-proxy to convert the file descriptor into an SCTPListener.
So, docker-proxy is still started early, and the window for lost
connections remains.

If the user has an old docker-proxy in their path and it's given a
listener docker with '-use-listen-fd', it'll fail because of the
unknown option. In this case, the daemon's error message suggests
checking $PATH.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-05 14:04:05 +01:00
Rob Murray
dac7ffa340 Remove rootlesskit-docker-proxy
It's not needed, now the daemon tells RootlessKit about port
mappings directly.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-05 14:04:05 +01:00
Rob Murray
f1e0746c08 Tell RootlessKit about docker-proxy port mappings
Before this change, when running rootless, instead of running
docker-proxy the daemon would run rootlesskit-docker-proxy.

The job of rootlesskit-docker-proxy was to tell RootlessKit
about mapped host ports before starting docker-proxy, and then
to remove the mapping when it was stopped.

So, rootlesskit-docker-proxy would need to be kept in-step
with changes to docker-proxy (particuarly the upcoming change
to bind TCP/UDP ports in the daemon and pass them to the proxy,
but also possible-future changes like running proxy per-container
rather than per-port-mapping).

This change runs the docker-proxy in rootless mode, instead of
rootlesskit-docker-proxy, and the daemon itself tells RootlessKit
about changes in host port mappings.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-05 14:04:05 +01:00
Rob Murray
384ca56d90 Fix error type used for ProgramExternalConnectivity
Get rid of "FIXME: Got an API for which error does not match
any expected type!!!  error="driver failed programming external
connectivity on endpoint..." from debug logs.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-05 14:04:05 +01:00
Cory Snider
7a8663c9ea cmd/docker-proxy: drop FrontendAddr() method
It was only used in tests.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-08-05 14:04:05 +01:00
Cory Snider
88fb0c9fec cmd/docker-proxy: drop unused BackendAddr() method
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-08-05 14:04:05 +01:00
Rob Murray
ba2f3c0a98 cmd/docker-proxy: pass open listener to proxy impl
In preparation for the daemon passing a listen fd, add command line
option -use-listen-fd to indicate that the fd is present (as fd 4).

If the new flag isn't given, open the listener as normal.

Refactor the TCP and UDP proxies to be constructed with an existing
TCPListener or UDPConn, respectively. Lift the responsibilty of opening
the listener to the entrypoint. Per the Single Responsibility Principle,
this structure affords changing how the listener is created without
having to touch the proxy implementations.

Co-authored-by: Cory Snider <csnider@mirantis.com>
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-05 14:04:04 +01:00
Rob Murray
e0c7a839a8 Only build docker-proxy for Linux
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-05 14:04:04 +01:00
Paweł Gronowski
ee766ae7b1 c8d: Wrap matchRequestedOrDefault result with a platform
Allowing it to obtain a specific `ocispec.Platform` used to create this
platform matcher.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-05 14:30:17 +02:00
Paweł Gronowski
842c5c584e c8d/image: Add matchRequestedOrDefault
Refactor a pattern where a passed `*ocispec.Platform` was used to
create a platform matcher that matches the passed platform if not nil
and uses a default host platform otherwise into a separate function.

Also add some basic unit tests for its behavior.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-05 14:30:14 +02:00
Paweł Gronowski
6617cdc66b daemon/c8d: Fill wanted platform in GetImageManifest
When `getBestPresentImageManifest` fails with `errPlatformNotFound` -
fill the requested platform.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-05 14:30:12 +02:00
Paweł Gronowski
427b111943 c8d/history: Unmarshal only a subset of ImageConfig
Only two fields from the whole image config are used, so only unmarshal
these.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-05 14:30:11 +02:00
Paweł Gronowski
b9d04c07c4 c8d: Simplify presentImages into getBestPresentImageManifest
All two usages only care about the "first" result from the slice sorted
according to the platform preference.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-05 14:30:10 +02:00
Paweł Gronowski
23d565cae3 c8d: Improve error message for platform not found
Return a similar error as the graphdrivers implementation when an image
was found, but the requested platform is not present locally or in the
image.

The message doesn't include the "actual" platform, as it doesn't make
sense with the multi-platform images. With graphdrivers all images were
single platform.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-05 14:30:08 +02:00
Paweł Gronowski
e73c2a05b2 daemon/c8d: Simplify presentImages signature
The `refOrId` parameter is only needed to construct an error in case
where the doesn't have the matching platform.

Move the responsibility of creating the error message to the caller.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-08-05 14:30:07 +02:00
Paweł Gronowski
20d5f062b4 Merge pull request #48288 from thaJeztah/bump_nydus
vendor: github.com/containerd/nydus-snapshotter v0.14.0
2024-08-05 13:40:10 +02:00
Sebastiaan van Stijn
af84ddec13 vendor: github.com/containerd/nydus-snapshotter v0.14.0
- removes use of deprecated github.com/containerd/containerd/errdefs package
- removes use of deprecated github.com/containerd/containerd/platforms package
- removes use of deprecated github.com/containerd/containerd/reference/docker package
- switch to dario.cat/mergo v1.0.0 dependency
- remove use of deprecated CRI Alpha API

full diff: https://github.com/containerd/nydus-snapshotter/compare/v0.13.14...v0.14.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-05 11:38:58 +02:00
Sebastiaan van Stijn
1e5c0c4d77 vendor: github.com/containerd/nydus-snapshotter v0.13.14
- removes use of deprecated github.com/containerd/containerd/log package

full diff: https://github.com/containerd/nydus-snapshotter/compare/v0.13.7...v0.13.14

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-05 11:38:57 +02:00
Sebastiaan van Stijn
27b322e56b Merge pull request #48280 from thaJeztah/touchup_security
touch-up security policy
2024-08-02 18:43:58 +02:00
Sebastiaan van Stijn
dfe36fa226 touch-up security policy
Slightly touch-up the security policy in this repository to describe
the process in more details.

- Describe process around reporting, triage, and review.
- Describe timelines for acknowledging reports.
- Refer to supported versions / branches.

Some of this wording was adopted from containerd's policy, adjusting
where needed (e.g. the project currently does not have an embargoed
security announce list, and no formal definition of security advisors).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-02 10:01:48 +02:00
Rob Murray
3b1341972b Only assign an IPv4 address if required
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-01 16:21:26 +01:00
Rob Murray
15e5f6868a Don't auto-allocate IPv4 IPAM if !enableIPv4
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-01 16:21:20 +01:00
Rob Murray
c0a6145f6d Enable IPv4 in the unit tests that will need it.
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-01 16:14:55 +01:00
Rob Murray
b42f4b96aa Check for an IPv6 gateway before connecting to docker_gwbridge
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-01 16:01:02 +01:00
Sebastiaan van Stijn
ddea6b0fa8 Merge pull request #48278 from robmry/v6only/not_windows_or_swarm
IPv6 only: IPv4 is required for Windows and Swarm networks
2024-08-01 16:59:00 +02:00
Rob Murray
034a5a8986 Reject swarm n/w creation with IPv4 disabled.
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-01 14:20:27 +01:00
Rob Murray
c91dc7e6dc Reject Windows network creation with IPv4 disabled.
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-01 14:20:27 +01:00
Sebastiaan van Stijn
dc39e47483 Merge pull request #48283 from thaJeztah/bump_hcsshim_deps
vendor: golang.org/x/time v0.5.0, google.golang.org/grpc v1.62.0
2024-08-01 14:09:14 +02:00
Rob Murray
a86a9e3aa4 API 1.46: end per-interface sysctl migration in major release
Rather than in API 1.47.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-01 10:51:24 +01:00
Rob Murray
17adc1478b Migrate per-endpoint sysctls until 28.0.0
Commit 0071832226 introduced
per-endpoint sysctls, and migration to them from the top-level
'--sysctl' option.

The migration was intended to be short-term, disabled in the
next major release and code was added to check for the next
API version. But now, the API version will be bumped in a
minor release - this breaking change needs to wait until the
next major release, and we don't yet know the API version
number for that.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-08-01 10:26:06 +01:00
Sebastiaan van Stijn
d44f869a2d vendor: google.golang.org/grpc v1.62.0
diffs:

- https://github.com/grpc/grpc-go/compare/v1.59.0...v1.62.0
- 83a465c022...ef4313101c
- https://github.com/googleapis/google-api-go-client/compare/v0.149.0...v0.155.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-01 11:12:06 +02:00
Sebastiaan van Stijn
716ec490db vendor: golang.org/x/time v0.5.0
full diff: https://github.com/golang/time/compare/v0.3.0...v0.5.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-08-01 11:05:22 +02:00
Sebastiaan van Stijn
bd1d35d721 Merge pull request #48279 from thaJeztah/typo_fixes
plugin, api/types: fix typos and GoDoc
2024-08-01 00:32:08 +02:00
Sebastiaan van Stijn
ac145a82fd api/types: NewHijackedResponse: fix typo in GoDoc
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-31 22:42:55 +02:00
Sebastiaan van Stijn
80822715cd plugin: fix typos in GoDoc
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-31 22:42:52 +02:00
Rob Murray
a43ed47441 Merge pull request #48271 from robmry/v6only/add_option_enable_ipv4
IPv6 only: add API option enable/disable IPv4
2024-07-31 19:21:42 +01:00
Rob Murray
1f542d5d6c Set EnableIPv4 for predefined networks
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-31 18:38:43 +01:00
Rob Murray
903daa4dc4 Add flag 'enableIPv4' to libnetwork.Network
Similar to EnableIPv6:
- Set it if EnableIPv4 is specified in a create request.
- Otherwise, set it if included in `default-network-opts`.
  - Apart from in a config-from network, so that it doesn't look
    like the API request set the field.
- Include the new field in  Network marshalling/unmarshalling test.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-31 18:38:43 +01:00
Rob Murray
d4d8611164 Added API create/inspect option EnableIPv4
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-31 18:38:43 +01:00
Sebastiaan van Stijn
376a699830 Merge pull request #48157 from thaJeztah/libnetwork_immutable_radix_v2
libnetwork/networkdb: switch to go-immutable-radix v2
2024-07-31 15:33:16 +02:00
Sebastiaan van Stijn
c7dec1c67a docs/api: swagger: fix x-nullable for SystemInfo.Containerd (api v1.46)
This field was added in 812f319a57, but it
looks like redoc doesn't like the field in this location, producing a
warning.

Rendering the docs (`make swagger-docs`) showed a warning:

> Warning: Other properties are defined at the same level as $ref at
> "#/definitions/SystemInfo/properties/Containerd". They are IGNORED
> according to the JsonSchema spec

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-31 12:39:07 +02:00
Sebastiaan van Stijn
66b5b8bfa8 api/swagger: fix x-nullable for SystemInfo.Containerd
This field was added in 812f319a57, but it
looks like redoc doesn't like the field in this location, producing a
warning.

Rendering the docs (`make swagger-docs`) showed a warning:

> Warning: Other properties are defined at the same level as $ref at
> "#/definitions/SystemInfo/properties/Containerd". They are IGNORED
> according to the JsonSchema spec

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-31 12:33:56 +02:00
Akihiro Suda
fe875a9449 Merge pull request #48272 from kolyshkin/not-mounted
hack/make: suppress "not mounted" message
2024-07-31 07:34:56 +09:00
Kir Kolyshkin
3279b4f8f4 hack/make: suppress "not mounted" message
The "not mounted" error from .integration-daemon-stop is not an error,
so let's suppress that one (this is the only effect of -q option, at
least according to its man page).

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-07-30 13:39:23 -07:00
Rob Murray
a23dcf4798 Bump API version to 1.47
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-30 14:30:26 +01:00
Paweł Gronowski
89bca301be Merge pull request #46772 from neersighted/project_docs
Improve documentation around maintenance, building, and packaging
2024-07-30 10:28:20 +02:00
Sebastiaan van Stijn
0c513d2849 Merge pull request #48244 from thaJeztah/cleanup_cleanups
daemon: assorted cleanups and minor improvements
2024-07-29 19:50:28 +02:00
Sebastiaan van Stijn
4742c060a3 Merge pull request #48252 from thaJeztah/remove_oom_leftovers
libcontainerd/supervisor: remove remnants of adjusting oom-score
2024-07-29 19:08:57 +02:00
Paweł Gronowski
403f9dbc42 project: update supported release branches
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-07-29 18:10:55 +02:00
Sebastiaan van Stijn
32c33dbfd5 Merge pull request #48248 from robmry/ipv6_related_refactoring
IPv6 related refactoring
2024-07-29 17:00:31 +02:00
Sebastiaan van Stijn
47a0193470 Merge pull request #48262 from thaJeztah/gha_permissions
gha: set permissions to read-only by default
2024-07-29 16:49:18 +02:00
Albin Kerouanton
078c9afc2f Merge pull request #48247 from robmry/split_bridge_and_nat_tests
Split Linux/bridge and Windows/nat integration tests
2024-07-29 16:37:20 +02:00
Sebastiaan van Stijn
96762a28c7 libcontainerd/supervisor: remove remnants of adjusting oom-score
In docker versions before v24.0, the dockerd daemon allowed adjusting
its own oom-score; in that case we would forward the configuration to
containerd (when running as child process) for it to do the same.

This feature was deprecated in 5a922dc162,
and removed in fb96b94ed0, but some fields
were left behind in the supervisor package.

This patch removes the oomScore field and adjustOOMScore method from
the remove type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-29 16:34:16 +02:00
Sebastiaan van Stijn
6e32c2e50c Merge pull request #48263 from thaJeztah/daemon_fix_import
daemon: remove unused import
2024-07-29 16:32:02 +02:00
Sebastiaan van Stijn
2a71815b83 daemon: remove unused import
This probably broke because 2ce811e632
and 6d0b508699 were merged out of order.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-29 16:19:01 +02:00
Paweł Gronowski
92e10e8274 Merge pull request #48251 from thaJeztah/daemon_reduce_c8d_imports
daemon: isPermissibleC8dRuntimeName: use local utility to reduce c8d deps
2024-07-29 15:58:13 +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
9716e06845 Merge pull request #48240 from vvoland/imageservice-imageinspect
images: Extract ImageInspect from GetImage
2024-07-29 15:00:33 +02:00
Sebastiaan van Stijn
2b5ffa0b63 gha: set permissions to read-only by default
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-29 14:53:38 +02:00
Sebastiaan van Stijn
7a92f21445 daemon: isPermissibleC8dRuntimeName: use local utility to reduce c8d deps
The `shim.BinaryName()` function used from containerd is part of the
"github.com/containerd/containerd/runtime/v2/shim" packaqge, which comes
with a large number of dependencies.

This patch implements a local variant of the check so that we can remove
the dependency.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-27 00:05:57 +02:00
Sebastiaan van Stijn
2847c4b7fe libnetwork/networkdb: switch to go-immutable-radix v2
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-26 23:11:53 +02:00
Rob Murray
fca57ac32f Split Linux/bridge and Windows/nat integration tests
Most tests in integration/networking/bridge_test.go are
skipped on Windows - and I want to add a test that uses
helpers that aren't implemented on Windows.

So, move it to bridge_linux_test.go, remove the skips
and put the couple of Windows/nat tests in their own file.
(TestPortMappedHairpin was the only dual-platform test,
it's now got two versions.)

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-26 19:06:12 +01:00
Rob Murray
ef8e2fe282 Use retErr in Endpoint.sbJoin
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-26 16:26:34 +01:00
Rob Murray
58808e7748 Remove code to update Network.enableIPv6 if false
Commit 4b9dc647 (from 2016) added this in response to a
review comment, but I don't think it can ever have worked
because n.enableIPv6 = netMap["enableIPv6"].(bool), added
in 2015, would already have panic'd if the field wasn't
stored.

In any case, it's no longer needed.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-26 16:26:34 +01:00
Rob Murray
8f1989556a Trivial tidy-up of Endpoint.assignAddress()
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-26 16:26:34 +01:00
Rob Murray
6fe26e0629 Add IPv6 to the null IPAM driver
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-26 16:26:34 +01:00
Sebastiaan van Stijn
dcf922e266 daemon: openContainerFS: log cleanup errors
These errors were unhandled; log them (at debug level for now).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-26 13:50:46 +02:00
Sebastiaan van Stijn
aa60f7891b daemon: openContainerFS: rename output var
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-26 13:50:46 +02:00
Sebastiaan van Stijn
3539fef440 daemon: setupMounts: rename var that shadowed import
The cleanups var collided with the cleanups import; rename it to use
the same name as is used in the Windows implementation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-26 13:50:45 +02:00
Sebastiaan van Stijn
a19c2ccc7b daemon: rename "mounts" type to reduce shadowing
Use a more distinct name, so that local variables can use it. While
at it, also added GoDoc to describe its functionality.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-26 13:50:39 +02:00
Sebastiaan van Stijn
39c79e08e4 daemon: move sortMounts to a platform-agnostic file
The same code was used both on Linux and Windows; move it to a platform-
agnostic file so that both can use this function, which contains GoDoc
describing the functionality.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-26 13:50:13 +02:00
Sebastiaan van Stijn
50c3d19179 Merge pull request #48242 from thaJeztah/buildkit_fix_grpc_control_api_sizes
api/server/router/grpc: NewRouter: set correct MaxRecvMsgSize, MaxSendMsgSize
2024-07-26 13:34:44 +02:00
Sebastiaan van Stijn
08d7b56169 Merge pull request #48209 from thaJeztah/remove_deprecated_cors_headers
remove support for setting CORS headers (deprecated)
2024-07-26 12:11:20 +02:00
Sebastiaan van Stijn
cdbfae1d3e api/server/router/grpc: NewRouter: set correct MaxRecvMsgSize, MaxSendMsgSize
[buildkit@29b4b1a537][1] applied changes to `buildkitd` to set the correct
defaults, which should be 16MB, but used the library defaults. Without that
change, builds using large Dockerfiles would fail with a `ResourceExhausted`
error;

    => [internal] load build definition from Dockerfile
     => => transferring dockerfile: 896.44kB
    ERROR: failed to receive status: rpc error: code = ResourceExhausted desc = grpc: received message larger than max (44865299 vs. 16777216)

However those changes were applied to the `buildkitd` code, which is the
daemon when running BuildKit standalone (or in a container through the
`container` driver). When running a build with the BuildKit builder compiled
into the Docker Engine, that code is not used, so the BuildKit changes did
not fix the issue.

This patch applies the same changes as were made in [buildkit@29b4b1a537][1]
to the gRPC endpoint provided by the dockerd daemon.

[1]: 29b4b1a537

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-26 11:15:46 +02:00
Paweł Gronowski
cd11843df8 images: Extract ImageInspect from GetImage
Remove a special `Details` parameter from the `GetImage` options and
extract its behavior to a `ImageInspect` method as it was only used by
the `/images/{name}/json` endpoint (`docker image inspect`).

This makes it easier for the containerd image service to output an image
inspect output without having to use the same data structures as the
graphdrivers.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-07-25 20:13:41 +02:00
Paweł Gronowski
951a04cc01 Merge pull request #48239 from crazy-max/update-buildkit
vendor: update buildkit to v0.15.1
2024-07-25 18:42:52 +02:00
CrazyMax
1baf8f9e60 vendor: update buildkit to v0.15.1
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-07-25 17:18:15 +02:00
Sebastiaan van Stijn
2b1097f080 Merge pull request #48170 from thaJeztah/migrate_userns
migrate to github.com/moby/sys/userns
2024-07-25 14:06:54 +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
91dfc326cf vendor: github.com/moby/sys/user v0.2.0
full diff: https://github.com/moby/sys/compare/user/v0.1.0...user/v0.2.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-25 11:43:42 +02:00
Akihiro Suda
d25a728327 Merge pull request #48234 from thaJeztah/vendor_flock
vendor: github.com/gofrs/flock v0.12.1
2024-07-25 17:49:29 +09:00
Sebastiaan van Stijn
1e2ccf8046 vendor: github.com/gofrs/flock v0.12.1
- fix: missing read-write flag in reopenFDOnError
  fixes a regression that could result in a `ERROR: bad file descriptor`.

b659e1e00a
introduced a regression where `f.flag` would not be in read-write mode
[1]  but read-only [2] which breaks people using NFS protocol.

[1]: b659e1e00a (diff-87c2c4fe0fb43f4b38b4bee45c1b54cfb694c61e311f93b369caa44f6c1323ffR192)
[2]: b659e1e00a (diff-22145325dded38eb5288ed3321a113d8260ccc70747ee04d4551bfd2fba975fdR69)

full diff: https://github.com/gofrs/flock/compare/v0.12.0...v0.12.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-25 00:42:23 +02:00
Sebastiaan van Stijn
077b32ac4e vendor: golang.org/x/sys v0.22.0
full diff: https://github.com/golang/sys/compare/v0.21.0...v0.22.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-25 00:37:04 +02:00
Sebastiaan van Stijn
be7470ce58 Merge pull request #48216 from AkihiroSuda/docker-install-417
dockerd-rootless-setuptool.sh: move RootlessKit smoke test
2024-07-24 15:10:44 +02:00
Rob Murray
48877c682d Merge pull request #48217 from robmry/network_test_cleanup
Clean up networks in 'integration/network' tests
2024-07-24 09:09:34 +01:00
Tianon Gravi
70eca41910 Merge pull request #48212 from thaJeztah/burning_them_with_fire
contrib/check-config.sh: remove special case for userns on CentOS/RHEL 7
2024-07-23 15:17:36 -07:00
Tianon Gravi
67c5cf07ea Merge pull request #47789 from williamh/47770-control-enable-journald-driver
hack: explicitly control enabling the journald logging driver
2024-07-23 15:00:27 -07:00
Sebastiaan van Stijn
bed37b6152 Merge commit from fork
[master] AuthZ plugin security fixes
2024-07-23 21:36:28 +02:00
Rob Murray
4c97ff777d Clean up networks in 'integration/network' tests
Makes TestDaemonDefaultNetworkPools re-runnable, and stops the
accumulation of bridges from the others.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-23 10:38:57 +01:00
Akihiro Suda
e2237240f5 dockerd-rootless-setuptool.sh: move RootlessKit smoke test
`dockerd-rootless-setuptool.sh check` now skips the smoke test for
running RootlessKit.

Fix docker/docker-install issue 417

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-07-23 14:35:02 +09:00
Akihiro Suda
c98f01ecf2 Merge pull request #48198 from thaJeztah/bump_moby_sys
vendor: github.com/moby/sys/sequential v0.6.0
2024-07-23 13:56:45 +09:00
Sebastiaan van Stijn
a3efa3026b contrib/check-config.sh: remove special case for userns on CentOS/RHEL 7
This check was added in 2355151556 to handle
non-standard behavior in CentOS/RHEL 7;

> Add check for RHEL7/CentOS7 experimental userns disabled
>
> Add a check in `check-config.sh` to see if we are running on a RHEL7 or
> CentOS7 system, which may report that CONFIG_USERNS is OK/enabled, but
> user namespaces still won't work because of the experimental feature
> flag added by Redhat.
>
> This will add a warning if it is actually disabled and notes what has to
> be added to the grub/boot command line to enable it.

Now that CentOS/RHEL 7 reached EOL, we can remove this special case.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-22 23:48:33 +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
Sebastiaan van Stijn
ae96ce866f remove support for setting CORS headers (deprecated)
Configuring CORS headers was deprecated in docker 27.0 through
7ea9acc97f, which disabled them by default
with a temporary `DOCKERD_DEPRECATED_CORS_HEADER` env-var to allow using
the option.

This patch removes the feature altogether; the flag is kept for one more
release to allow printing a more informative error, but can be removed in
the next release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-22 21:29:44 +02:00
Brian Goff
dbf6873f45 Logfile: Add tracing spans
This plumbs a context down the stack and handles cancellation as needed
so that we can have correlated traces from the API.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-07-22 19:20:12 +00:00
Brian Goff
1b46faf233 Logfile: skip files that are corrupted
When there is an error in parsing an individual log file just close the
log and move on to the next one instead of erroring our the entire
request.

I investigated trying to error correct and scan ahead for corrupted log
files but found this is too much of a risk of parsing things we
shouldn't be and hence why this is just dropping the rest of the file.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-07-22 19:20:12 +00:00
Brian Goff
77f2d90e27 Refactor logfile reads
This simplifies how we manage log files, especially rotated ones.
It also fixes a long-standing issue to lazily open rotated files so we
don't needlessly start decompressing files that we don't need.

Much of this is just setting things up for commits following this one.

It uses ReaderAtSize for managing all files to be tailed and manages
cleanups by passing closures.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-07-22 19:20:12 +00:00
Brian Goff
b37c8a03c0 Fix time comparison in sharedtemp implementation
Times cannot be compared with `==` and instead should use the `t.Equal`
function.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-07-22 19:20:12 +00:00
Sebastiaan van Stijn
21fd5a3f30 vendor: github.com/moby/sys/sequential v0.6.0
full diff: https://github.com/moby/sys/compare/sequential/v0.5.0...sequential/v0.6.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-19 21:28:27 +02:00
Akihiro Suda
733755d7cb Merge pull request #48189 from thaJeztah/bump_moby_sys
vendor: update moby/sys modules
2024-07-20 00:33:12 +09:00
Sebastiaan van Stijn
adbc4bc9ef Merge pull request #48188 from thaJeztah/vendor_containerd_1.7.20
vendor: github.com/containerd/containerd v1.7.20
2024-07-19 12:51:01 +02:00
Sebastiaan van Stijn
490721871b Merge pull request #48190 from thaJeztah/update_containerd_binary_1.7.20
update containerd binary to v1.7.20
2024-07-19 12:34:48 +02:00
Sebastiaan van Stijn
155dd66753 Merge pull request #48194 from thaJeztah/fix_pr_title_check
gha: check-pr-branch: fix branch check regression
2024-07-19 12:33:59 +02:00
Sebastiaan van Stijn
e0b98a3222 gha: check-pr-branch: fix branch check regression
This check was updated in f460110ef5, but
introduced some bugs;

- the regular expressions were meant to define a capturing group, but
  the braces (`(`, `)`) were escaped (they previously were used by
  `sed`, which requires different escaping), so no value was captured.
- the check itself was not updated to use the resulting `$target_branch`
  env-var, so was comparing against the `$GITHUB_BASE_REF` (which is
  the branch name before stripping minor versions).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-19 12:26:17 +02:00
Paweł Gronowski
30749b6a7b Merge pull request #48186 from thaJeztah/bump_buildx_compose
Dockerfile: update buildx to v0.16.1, compose to v2.29.0
2024-07-19 10:05:00 +02:00
Sebastiaan van Stijn
fbbda057ac update containerd binary to v1.7.20
Update the containerd binary that's used in CI and for the static packages.

release notes: https://github.com/containerd/containerd/releases/tag/v1.7.20
full diff: https://github.com/containerd/containerd/compare/v1.7.18...v1.7.19

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-19 02:32:27 +02:00
Sebastiaan van Stijn
cb7c976456 Merge pull request #48177 from thaJeztah/relax_pr_check
gha: check-pr-branch: verify major version only
2024-07-19 02:25:50 +02:00
Sebastiaan van Stijn
f460110ef5 gha: check-pr-branch: verify major version only
We'll be using release branches for minor version updates, so instead
of (e.g.) a 27.0 branch, we'll be using 27.x and continue using the
branch for minor version updates.

This patch changes the validation step to only compare against the
major version.

Co-authored-by: Cory Snider <corhere@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-19 01:20:40 +02:00
Sebastiaan van Stijn
6a6b49f2de vendor: github.com/moby/sys/symlink v0.3.0
full diff: https://github.com/moby/sys/compare/symlink/v0.2.0...symlink/v0.3.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-19 00:58:43 +02:00
Sebastiaan van Stijn
68636d56fc vendor: github.com/moby/sys/signal v0.7.1
full diff: https://github.com/moby/sys/compare/signal/v0.7.0...signal/v0.7.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-19 00:57:30 +02:00
Sebastiaan van Stijn
44b266ab59 vendor: github.com/moby/sys/mount v0.3.4
full diff: https://github.com/moby/sys/compare/mount/v0.3.3...mount/v0.3.4

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-19 00:56:52 +02:00
Sebastiaan van Stijn
dc4a12874e vendor: github.com/moby/sys/mountinfo v0.7.2
full diff: https://github.com/moby/sys/compare/mountinfo/v0.7.1...mountinfo/v0.7.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-19 00:53:31 +02:00
Sebastiaan van Stijn
55a5f3fcaa vendor: github.com/containerd/containerd v1.7.20
full diff: https://github.com/containerd/containerd/compare/v1.7.19...v1.7.20

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-19 00:41:20 +02:00
Sebastiaan van Stijn
a42f7fd717 Dockerfile: update compose to v2.29.0
This is the version used in the dev-container, and for testing.

release notes: https://github.com/docker/compose/releases/tag/v2.29.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-19 00:08:01 +02:00
Sebastiaan van Stijn
97b51c6b72 Dockerfile: update buildx to v0.16.1
This is the version used in the dev-container, and for testing.

release notes:
https://github.com/docker/buildx/releases/tag/v0.16.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-19 00:05:18 +02:00
Sebastiaan van Stijn
f39409f80d Merge pull request #48078 from vvoland/c8d-buildkit-tag-event
c8d/build: Log `image tag` event when image was built with Buildkit
2024-07-18 21:46:49 +02:00
Sebastiaan van Stijn
c9d76ec00d Merge pull request #48176 from corhere/readme-commercial-support
README: replace obsolete Docker EE mention
2024-07-18 18:41:13 +02:00
Cory Snider
b37c983d31 README: replace obsolete Docker EE mention
Docker EE is no more. Point users looking for commercial support at the
currently-maintained commercial products based on the Moby project:
Docker Desktop and Mirantis Container Runtime.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-17 18:01:50 -04:00
Paweł Gronowski
3a62d4917b Merge pull request #48169 from kolyshkin/layer-regexp
rm regexp use
2024-07-17 11:52:23 +02:00
Kir Kolyshkin
508939821b daemon/containerd: rm use of regexp
Replace the regexp check with a function.

Keep the use of regexp.QuoteMeta.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-07-16 13:06:01 -07:00
Kir Kolyshkin
b66d4b567a image/v1: rm regexp use
Replace the regexp checking ID validity with a for loop.

The benefits are:
 - faster (up to 10x faster with less allocations);
 - no init overhead to compile the regexp.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-07-16 12:46:57 -07:00
Kir Kolyshkin
1c0dc8a94f layer: rm regexp use
Replace the regexp checking ID validity with a function. The benefits
are:

 - function is faster (up to 10x faster with less allocations);
 - no init overhead to compile the regexp;

Add a test case.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2024-07-16 12:30:17 -07:00
William Hubbs
499c842c52 hack: explicitly control enabling the journald logging driver
Without this, the dependency on systemd is said to be "automagic", which
can lead to breakage, for example, if a binary package of docker is
built on a system that has systemd installed then installed on a system
that does not have systemd installed.

for example: https://bugs.gentoo.org/914076

Signed-off-by: William Hubbs <w.d.hubbs@gmail.com>
2024-07-16 11:00:29 -05:00
Sebastiaan van Stijn
aae044039c Merge pull request #48165 from thaJeztah/bump_google_deps
vendor: cloud.google.com/go/logging v1.9.0
2024-07-15 23:52:14 +02:00
Sebastiaan van Stijn
fb5acc4377 Merge pull request #48143 from thaJeztah/graphdriver_remove_capabilities
daemon/graphdriver: remove Capabilities, CapabilityDriver
2024-07-15 21:25:24 +02:00
Jameson Hyde
5282cb25d0 If url includes scheme, urlPath will drop hostname, which would not match the auth check
Signed-off-by: Jameson Hyde <jameson.hyde@docker.com>
(cherry picked from commit 754fb8d9d03895ae3ab60d2ad778152b0d835206)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-07-15 18:43:48 +02:00
Jameson Hyde
2ac8a479c5 Authz plugin security fixes for 0-length content and path validation
Signed-off-by: Jameson Hyde <jameson.hyde@docker.com>

fix comments

(cherry picked from commit 9659c3a52bac57e615b5fb49b0652baca448643e)
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-07-15 18:43:43 +02:00
Sebastiaan van Stijn
20a0102c5f Merge pull request #48139 from corhere/go119atomics
all: switch to Go 1.19 atomics
2024-07-15 18:03:41 +02:00
Sebastiaan van Stijn
0fa71a4cfc vendor: cloud.google.com/go/logging v1.9.0
removes dependency on appengine, among others

full diff: https://github.com/googleapis/google-cloud-go/compare/logging/v1.0.1...logging/v1.9.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-15 13:30:37 +02:00
Sebastiaan van Stijn
eafad2cb86 vendor: golang.org/x/oauth2 v0.21.0
removes dependency on appengine, among others

full diff: https://github.com/golang/oauth2/compare/v0.11.0...v0.21.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-15 13:12:58 +02:00
Sebastiaan van Stijn
9b782b8ff7 vendor: cloud.google.com/go/compute/metadata v0.3.0
full diff: https://github.com/googleapis/google-cloud-go/compare/compute/metadata/v0.2.3...compute/metadata/v0.3.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-15 12:57:46 +02:00
Akihiro Suda
2cfc2a57a8 Merge pull request #48159 from tonistiigi/vendor-buildkit-v0.15.0
vendor: update buildkit to v0.15.0
2024-07-12 14:47:34 +09:00
Tonis Tiigi
68bd630830 vendor: update buildkit to v0.15.0
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-11 16:41:16 -07:00
Akihiro Suda
c287997802 Merge pull request #48150 from tonistiigi/vendor-buildkit-v0.15.0-rc2
vendor: update buildkit to v0.15.0-rc2
2024-07-11 23:23:01 +09:00
Akihiro Suda
bdecfc587e Merge pull request #48154 from vvoland/docs-fix-typo
docs/api: Add missing `
2024-07-11 23:22:07 +09:00
Rob Murray
6c8bf8d816 Merge pull request #48156 from robmry/fix_api_version_in_TestSetInterfaceSysctl
Fix API version in TestSetInterfaceSysctl
2024-07-11 15:02:20 +01:00
Rob Murray
f649fd0c97 Fix API version in TestSetInterfaceSysctl
The test checks that it's possible to set a per-interface sysctl
using '--sysctl' - but, after API v1.46, it's not (and driver option
'com.docker.network.endpoint.sysctls' must be used instead).

Test added in commit fde80fe2
Per-interface sysctls added, with API changes, in commit 00718322

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-11 14:02:46 +01:00
Paweł Gronowski
7f04a603f6 docs/api: Add missing `
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-07-11 14:24:25 +02:00
Tonis Tiigi
89781912c1 vendor: update buildkit to v0.15.0-rc2
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-10 16:01:03 -07:00
Brian Goff
5ac29d0e1a Merge pull request #48149 from robmry/47952_remove_sctp_checksum_iptables_rule
By-default, don't create an iptables rule to checksum SCTP
2024-07-10 22:07:45 +00:00
Rob Murray
8be292a7bb By-default, don't create an iptables rule to checksum SCTP
For SCTP port mappings, an iptables mangle rule was create to fix
the checksum. The code comment says it was done to fix a problem
caused by the veth driver reporting NETIF_F_SCTP_CRC since kernel
4.9, when used with NICs that do not support NETIF_F_SCTP_CRC.

But the checksum rule fills in the checksum in the IP header,
not an SCTP checksum, so it doesn't seem related. And, quoting
from the github issue, "since kernel v4.19, the xt_CHECKSUM.c
explicitly states it should only be used for UDP and only in the
OUTPUT chain - while docker is using it for SCTP in the PREROUTING
chain".

Furthermore, the rule is reported to be causing errors for SCTP
between containers.

Because we don't entirely understand why the rule exists, it
is now only added if the daemon's env has
DOCKER_IPTABLES_SCTP_CHECKSUM=1. If no problems are reported, that
escape-hatch and the code to add the rule will be removed in a
future release.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-10 18:53:54 +01:00
Tõnis Tiigi
767503d462 Merge pull request #48126 from tonistiigi/vendor-buildkit-v0.15.0-rc1
vendor: update buildkit to v0.15.0-rc1
2024-07-10 10:28:32 -07:00
Tonis Tiigi
1787c364e0 vendor: update buildkit to v0.15.0-rc1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-07-08 20:35:36 -07:00
Sebastiaan van Stijn
688301caf4 daemon/graphdriver: remove Capabilities, CapabilityDriver
Capabilities were implemented in aa96c3176b,
as part of work on an external graphdriver-plugin. Given that none of
the builtin graphdrivers use this option, and support for graphdriver-
plugins has been removed in 555dac5e14,
we can remove this functionality.

This patch:

- removes the CapabilityDriver interface, which has no implementations
- removes the Capabilities type
- layer: remove layerStore.useTarSplit. This field was previously set
  through the driver's Capabilities, but always enabled for the builtin
  graphdrivers,

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-08 18:23:21 -05:00
Sebastiaan van Stijn
c4dcaa0d9a Merge pull request #48092 from thaJeztah/fsmagic_internal
daemon/graphdriver: split, internalize packages to separate snapshotters and graphdrivers
2024-07-08 16:09:59 -05:00
Cory Snider
185b1e3d69 Add lint rule to forbid old-style atomic ops
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-08 11:09:56 -04:00
Cory Snider
5e64a7a003 volume/service: switch to Go 1.19 atomics
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-08 11:09:56 -04:00
Cory Snider
1c102140f8 libnetwork: switch to Go 1.19 atomics
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-08 11:09:56 -04:00
Cory Snider
46133bdb8e libnetwork/diagnostic: drop unsound use of atomics
It was unnecessary; access to the variable was synchronized through a
mutex in all cases but one, where synchonizing through the mutex would
work just fine without any chance of deadlocks.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-08 11:09:56 -04:00
Cory Snider
5044778433 distribution: switch to Go 1.19 atomics
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-08 11:09:56 -04:00
Cory Snider
2ab618696a daemon/images: switch to Go 1.19 atomics
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-05 19:05:22 -04:00
Cory Snider
30d740ada0 daemon/logger/ring: switch to Go 1.19 atomics
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-05 19:05:18 -04:00
Cory Snider
7ef0c7acbe d/logger/loggerutils: switch to Go 1.19 atomics
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-05 19:05:18 -04:00
Cory Snider
e612990994 daemon/logger/journald: switch to Go 1.19 atomics
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-05 19:05:15 -04:00
Cory Snider
78893cdc05 daemon/logger/gcplogs: switch to Go 1.19 atomics
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-05 19:05:15 -04:00
Cory Snider
508f51044d daemon/containerd: switch to Go 1.19 atomics
Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-07-05 19:05:15 -04: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
7496f11a46 Merge pull request #48134 from AkihiroSuda/rootless-check-dbus
rootless: add `Requires=dbus.socket`
2024-07-05 17:12:00 +02:00
Albin Kerouanton
1bf2e03636 Merge pull request #48135 from robmry/remove_ipv6_bridge_route_add
Remove IPv6 bridge RouteAdd() that always fails
2024-07-05 14:58:20 +02:00
Akihiro Suda
206445fa4f rootless: add Requires=dbus.socket
On a cgroup v2 host with systemd, dbus is needed to avoid the following error:
```
docker: Error response from daemon: failed to create task for container: failed to create shim task: OCI runtime create failed: runc create failed
: unable to start container process: unable to apply cgroup configuration: unable to start unit "docker-170a4183e351e69835b82cc3134b97c8cbb0e6d3a6
16d5a0fb0ea473075062ad.scope" (properties [{Name:Description Value:"libcontainer container 170a4183e351e69835b82cc3134b97c8cbb0e6d3a616d5a0fb0ea47
3075062ad"} {Name:Slice Value:"user.slice"} {Name:Delegate Value:true} {Name:PIDs Value:@au [2872]} {Name:MemoryAccounting Value:true} {Name:CPUAc
counting Value:true} {Name:IOAccounting Value:true} {Name:TasksAccounting Value:true} {Name:DefaultDependencies Value:false}]): Interactive authen
tication required.: unknown.
```

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-07-05 02:59:47 +09:00
Rob Murray
4776e6dd60 Remove IPv6 bridge RouteAdd() that always fails
The netlink.RouteAdd in setupBridgeIPv6 always failed, because
the bridge is always 'down' when it's called.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-07-04 18:28:37 +01:00
Akihiro Suda
1205a90733 Merge pull request #47142 from thaJeztah/migrate_to_platforms_module
vendor: github.com/containerd/containerd v1.7.19, migrate to github.com/containerd/platforms module
2024-07-04 10:59:16 +09:00
Akihiro Suda
961ba670de Merge pull request #48127 from thaJeztah/bump_bk_deps
vendor: update dependencies in preparation of BuildKit v0.15
2024-07-04 10:57:14 +09:00
Sebastiaan van Stijn
066b7fa83c vendor: golang.org/x/net v0.25.0
full diff: https://github.com/golang/net/compare/v0.24.0...v0.25.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-04 02:33:04 +02:00
Sebastiaan van Stijn
7721408db7 vendor: golang.org/x/crypto v0.23.0
full diff: https://github.com/golang/crypto/compare/v0.22.0...v0.23.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-04 02:32:10 +02:00
Sebastiaan van Stijn
f43436e6b8 vendor: golang.org/x/text v0.15.0
no changes in vendored files

full diff: https://github.com/golang/text/compare/v0.14.0...v0.15.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-04 02:30:17 +02:00
Sebastiaan van Stijn
342ce515ab vendor: golang.org/x/sys v0.21.0
full diff: https://github.com/golang/sys/compare/v0.19.0...v0.21.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-04 02:27:19 +02:00
Sebastiaan van Stijn
2e58a29023 vendor: github.com/klauspost/compress v1.17.9
full diff: https://github.com/klauspost/compress/compare/v1.17.4...v1.17.9

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-04 02:23:13 +02:00
Sebastiaan van Stijn
508cc7c612 Merge pull request #48124 from thaJeztah/api_types_inspectbase
api/types/container: InspectResponse: keep old name for embedded type
2024-07-04 01:49:35 +02:00
Sebastiaan van Stijn
99edfd549a Merge pull request #48121 from vvoland/update-go
update to go1.21.12 [part 2]
2024-07-03 17:15:37 +02:00
Sebastiaan van Stijn
fb18966aa5 api/types/container: InspectResponse: keep old name for embedded type
This is a follow-up to 1abc8f6158, which
moved the ContainerJSONBase to api/types/container, but also renamed it
to container.InspectBase. This field is embedded into the InspectResponse
type, which meant that renaming the type also implicitly renamed the
field when creating this type from a struct-literal.

While we're planning to merge these types (which would be a breaking
change for users constructing it through struct-literals), let's keep
it backward-compatible for now (other than deprecating the old names).

We can continue the other changes separately.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-03 17:14:03 +02:00
Paweł Gronowski
837289ba62 update to go1.21.12 [part 2]
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-07-03 14:09:42 +02:00
Sebastiaan van Stijn
0c71dfc58e Merge pull request #48120 from vvoland/update-go
update to go1.21.12
2024-07-03 13:46:05 +02:00
Paweł Gronowski
4d6be67be8 Merge pull request #48115 from thaJeztah/journald_nolint
daemon/logger/journald: add //nolint:unused for readSyncTimeout
2024-07-03 11:12:55 +02:00
Paweł Gronowski
4d1d7c3ebe update to go1.21.12
- https://github.com/golang/go/issues?q=milestone%3AGo1.21.12+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.21.11...go1.21.12

These minor releases include 1 security fixes following the security policy:

net/http: denial of service due to improper 100-continue handling

The net/http HTTP/1.1 client mishandled the case where a server responds to a request with an "Expect: 100-continue" header with a non-informational (200 or higher) status. This mishandling could leave a client connection in an invalid state, where the next request sent on the connection will fail.

An attacker sending a request to a net/http/httputil.ReverseProxy proxy can exploit this mishandling to cause a denial of service by sending "Expect: 100-continue" requests which elicit a non-informational response from the backend. Each such request leaves the proxy with an invalid connection, and causes one subsequent request using that connection to fail.

Thanks to Geoff Franks for reporting this issue.

This is CVE-2024-24791 and Go issue https://go.dev/issue/67555.

View the release notes for more information:
https://go.dev/doc/devel/release#go1.21.12

**- Description for the changelog**

```markdown changelog
Update Go runtime to 1.21.12
```

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-07-03 10:28:59 +02:00
Akihiro Suda
1ecc48f4c3 Merge pull request #48117 from thaJeztah/update_containerd_binary_1.7.19
update containerd binary to v1.7.19
2024-07-03 11:17:05 +09:00
Sebastiaan van Stijn
398e15b7de update containerd binary to v1.7.19
Update the containerd binary that's used in CI and for the static packages.

- release notes: https://github.com/containerd/containerd/releases/tag/v1.7.19
- full diff: https://github.com/containerd/containerd/compare/v1.7.18...v1.7.19

Welcome to the v1.7.19 release of containerd!

The nineteenth patch release for containerd 1.7 contains various updates and
splits the main module from the api module in preparation for the same change
in containerd 2.0. Splitting the modules will allow 1.7 and 2.x to both exist
as transitive dependencies without running into API registration errors.
Projects should use this version as the minimum 1.7 version in preparing to
use containerd 2.0 or to be imported alongside it.

Highlights

- Fix support for OTLP config
- Add API go module
- Remove overlayfs volatile option on temp mounts
- Update runc binary to v1.1.13
- Migrate platforms package to github.com/containerd/platforms
- Migrate reference/docker package to github.com/distribution/reference

Container Runtime Interface (CRI)

- Fix panic in NRI from nil CRI reference
- Fix Windows HPC working directory

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 21:45:56 +02:00
Sebastiaan van Stijn
d0aa3eaccf Migrate to github.com/containerd/platforms module
Switch to use github.com/containerd/platforms module, because containerd's
platforms package has moved to a separate module. This allows updating the
platforms parsing independent of the containerd module itself.

The package in containerd is deprecated, but kept as an alias to provide
compatibility between codebases.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 21:20:29 +02:00
Sebastiaan van Stijn
8983957ac5 vendor: github.com/containerd/containerd v1.7.19
Highlights

- Fix support for OTLP config
- Add API go module
- Remove overlayfs volatile option on temp mounts
- Update runc binary to v1.1.13
- Migrate platforms package to github.com/containerd/platforms
- Migrate reference/docker package to github.com/distribution/reference

Container Runtime Interface (CRI)

- Fix panic in NRI from nil CRI reference
- Fix Windows HPC working directory

full diff: https://github.com/containerd/containerd/compare/v1.7.18...v1.7.19

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 21:19:57 +02:00
Sebastiaan van Stijn
73979f3f04 daemon/logger/journald: add //nolint:unused for readSyncTimeout
Same applies to this field as for journalReadDir above it.

    daemon/logger/journald/journald.go:66:2: field `readSyncTimeout` is unused (unused)
        readSyncTimeout time.Duration
        ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 20:00:57 +02:00
Sebastiaan van Stijn
eea3800ab4 Merge pull request #48107 from thaJeztah/remove_deprecated_api_types
api/types: remove aliases for deprecated types
2024-07-02 17:51:17 +02:00
Sebastiaan van Stijn
ef356c53ba api/types: remove deprecated ContainerNode, ContainerJSONBase.Node
It was moved and deprecated in 1fc9236119
(4587688258 for v27.0). This patch removes the
temporary alias and removes the relocated  api/types/container.ContainerNode
as well as the Node field on the api/types/container.Base struct.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:20:38 +02:00
Sebastiaan van Stijn
5b9ed8081b api/types: remove deprecated ImageLoadResponse
It moved to api/types/image.LoadResponse in 6c2934f373.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:56 +02:00
Sebastiaan van Stijn
d3defe9140 api/types: remove deprecated ImageImportSource
It moved to api/types/image.ImportSource in eb675cce71.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:55 +02:00
Sebastiaan van Stijn
6cdb123b6f api/types: remove deprecated ImageSearchOptions
It moved to api/types/registry.SearchOptions in f6cc76ceb9.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:55 +02:00
Sebastiaan van Stijn
67b7b15674 api/types: remove deprecated EventsOptions
It moved to api/types/events.ListOptions in b5f15bc0aa.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:55 +02:00
Sebastiaan van Stijn
3cbc166d2e api/types: remove deprecated container stats types
These types were moved to api/types/container in 0a4277abf4.

This removes the temporary aliases for:

- ThrottlingData
- CPUUsage
- CPUStats
- MemoryStats
- BlkioStatEntry
- BlkioStats
- StorageStats
- NetworkStats
- PidsStats
- Stats
- StatsJSON (moved/renamed to api/types/container.StatsResponse)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:55 +02:00
Sebastiaan van Stijn
ec5cede0a2 api/types: remove deprecated ContainerStats
It moved to api/types/container.StatsResponseReader in 17c3269a37.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:55 +02:00
Sebastiaan van Stijn
4ffe497ba4 api/types: remove deprecated CopyToContainerOptions
It moved to api/types/container.CopyToContainerOptions in fd1d8f323b.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:54 +02:00
Sebastiaan van Stijn
345e31ab96 api/types: remove deprecated ContainerPathStat
It moved to api/types/container.PathStat in 47d7c9e31d.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:54 +02:00
Sebastiaan van Stijn
2bceb34717 api/types: remove deprecated ContainersPruneReport
It moved to api/types/container.PruneReport in db2f1acd5d.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:54 +02:00
Sebastiaan van Stijn
0e64c9e93b api/types: remove deprecated ContainerExecInspect
It moved to api/types/container.ExecInspect in 5b27e71521.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:54 +02:00
Sebastiaan van Stijn
6f0caec226 api/types: remove deprecated ExecStartCheck
It's replaced by api/types/container.ExecStartOptions and ExecAttachOptions
in cd76e3e7f8. This patch removes the temporary
alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:54 +02:00
Sebastiaan van Stijn
13fbd394ee api/types: remove deprecated ExecConfig
It moved to api/types/container.ExecOptions in cd76e3e7f8.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:53 +02:00
Sebastiaan van Stijn
665eef54db api/types: remove deprecated NetworksPruneReport
It moved to api/types/network.PruneReport in e5f9484ab6.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:53 +02:00
Sebastiaan van Stijn
d2256faa0e api/types: remove deprecated NetworkResource
It's replaced by api/types/network.Inspect and api/types/network.Summary in
68bf0e7625. This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:53 +02:00
Sebastiaan van Stijn
ffdd2de674 api/types: remove deprecated EndpointResource
It moved to api/types/network.EndpointResource in 68bf0e7625.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:53 +02:00
Sebastiaan van Stijn
f0f2b8f7cb api/types: remove deprecated NetworkDisconnect
It moved to api/types/network.DisconnectOptions in 245d12175f.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:53 +02:00
Sebastiaan van Stijn
cf9d9ff50d api/types: remove deprecated NetworkConnect
It moved to api/types/network.ConnectOptions in 245d12175f.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:52 +02:00
Sebastiaan van Stijn
39c7b5f3e3 api/types: remove deprecated NetworkInspectOptions
It moved to api/types/network.InspectOptions in 5bea0c38bc.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:52 +02:00
Sebastiaan van Stijn
64583771f0 api/types: remove deprecated NetworkCreateResponse
It moved to api/types/network.CreateResponse in 89624e09e6.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:52 +02:00
Sebastiaan van Stijn
c99e0bc8ae api/types: remove deprecated NetworkListOptions
It moved to api/types/network.ListOptions in f78dac35e5.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:52 +02:00
Sebastiaan van Stijn
48f147e8d3 api/types: remove deprecated NetworkCreate
It moved to api/types/network.CreateOptions in 162ef4f8d1.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:52 +02:00
Sebastiaan van Stijn
ff1f1c58d5 api/types: remove deprecated NetworkCreateRequest
It moved to api/types/network.CreateRequest in 162ef4f8d1.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:51 +02:00
Sebastiaan van Stijn
4117a9308d api/types: remove deprecated VolumesPruneReport
It moved to api/types/volume in 162ef4f8d1.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:51 +02:00
Sebastiaan van Stijn
e0156f0f16 api/types: remove deprecated ImagesPruneReport
It moved to api/types/image in ecb24afaaf.
This patch removes the temporary alias.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 14:19:51 +02:00
Paweł Gronowski
d071d70ae1 Merge pull request #48057 from thaJeztah/migrate_more_types
api/types: migrate more types to separate packages
2024-07-02 14:10:38 +02:00
Sebastiaan van Stijn
1abc8f6158 api/types: move container-inspect types to api/types/container
This moves the `ContainerJSONBase`, `ContainerJSON` and `ContainerNode`
types to the api/types/container package and deprecates the old location.

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

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 12:46:48 +02:00
Sebastiaan van Stijn
84ffc644ef api/types: move ContainerState to api/types/image
This moves the `ContainerState` type to the container package,
renames it to `State`, 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
7053007f71 api/types: move ImageInspect and RootFS to api/types/image
This moves the `ImageInspect` and `RootFS` types to the image package,
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
da039ca918 api/types: move GraphDriverData to api/types/storage
The `GraphDriverData` type is shared between images and containers, and
putting it in either package would result in a circular import, so adding
a new package for this type.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 12:46:47 +02:00
Sebastiaan van Stijn
e12b7493b9 api/types: move Port to api/types/container
This moves the `Port` type to the container package, and
deprecates the old location.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 12:46:47 +02:00
Sebastiaan van Stijn
5517322cf9 api/types: move MountPoint to api/types/container
This moves the `MountPoint` type to the container package, and
deprecates the old location.

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 12:46:47 +02:00
Sebastiaan van Stijn
df22a511cb api/types: move container-networksettings types to api/types/container
This moves the NetworkSettings, NetworkSettingsBase, DefaultNetworkSettings,
and SummaryNetworkSettings types to the api/types/container package, and
deprecates the old location.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 12:46:45 +02:00
Paweł Gronowski
53bc396ef4 c8d/build: Log image tag event when image was built with Buildkit
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-07-02 12:34:53 +02:00
Paweł Gronowski
1506bbcfe8 builder-next: Add ImageNamedByBuildkit callback
When image is built with buildkit with containerd integration the image
service has no way of knowing that the image was tagged because buildkit
creates the image directly in containerd image store.

Add a callback that is called by the exporter wrapper.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-07-02 12:34:52 +02:00
Paweł Gronowski
bce76d486e builder-next: Don't return error from exported callback
This is only a callback that notifies about event so there is no way to
react to the error.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-07-02 12:34:51 +02:00
Akihiro Suda
a045f9e65d Merge pull request #48111 from thaJeztah/rm_deprecated_executiondriver
api/types/system: remove deprecated Info.ExecutionDriver
2024-07-02 15:53:31 +09:00
Akihiro Suda
7083f1fb55 Merge pull request #48108 from thaJeztah/internalize_pkg_directory
pkg/directory: deprecate, and move to internal
2024-07-02 15:52:56 +09:00
Akihiro Suda
9db812f691 Merge pull request #48109 from thaJeztah/remove_pkg_dmesg
pkg/dmesg: remove deprecated package
2024-07-02 15:52:29 +09:00
Akihiro Suda
c206809e58 Merge pull request #48110 from thaJeztah/internalize_rootless_specconv
pkg/rootless/specconv: move to internal
2024-07-02 15:52:12 +09:00
Sebastiaan van Stijn
e4d792a06d api/types/system: remove Info.ExecutionDriver
The execution-driver was replaced with containerd since docker 1.11 (API
v1.23) in 9c4570a958, after which the value
was no longer set. The field was left in the type definition.
Commit 1fb1136fec removed its use from the
CLI and [docker/engine-api@39c7d7e] removed it from the API type, followed
by an update to the API docs in 3c6ef4c29d.

Changes to the API types were not pulled into the engine until v1.13, and
probably because of that gated it on API version < 1.25 instead of < 1.24
(see 6d98e344c7); setting a "not supported"
value for older versions.

Based on the above; this field was deprecated in API v1.23, and empty
since then. Given that the minimum API version supported by the engine
is not v1.24, we can safely remove it.

[docker/engine-api@39c7d7e]: 39c7d7ec19

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-02 01:29:36 +02:00
Sebastiaan van Stijn
0f3273e71a daemon/graphdriver: move RefCounter to an internal package
The RefCounter is used in both graphdrivers and snapshotters. Move it
to a separate package to help decoupling snapshotters and graphdrivers,
and make it internal, as it's not intended to be used as a generic utility
package (we can still make it public if there would be a need).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 23:53:28 +02:00
Sebastiaan van Stijn
efdaca2792 pkg/rootless/specconv: move to internal
This package is only used by the daemon, so move it to the internal
rootless package instead.

Note that technically this could be in daemon/internal, but as there's
already an existing internal/rootless package (which needs to be in the
top-level internal package because it's also used by /plugin), I'm moving
it there.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 21:05:19 +02:00
Sebastiaan van Stijn
b7d26f2f8f pkg/dmesg: remove deprecated package
This package was deprecated in 805ccd2365
and is no longer used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 20:55:06 +02:00
Sebastiaan van Stijn
3a3bb1cb50 pkg/directory: deprecate, and move to internal
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 20:44:31 +02:00
Sebastiaan van Stijn
80900bdbcd pkg/directory: fix comment, and remove import comments
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 20:43:27 +02:00
Sebastiaan van Stijn
e55897977c daemon/graphdriver: simplify Checker, remove NewFsChecker, NewDefaultChecker
The Checker interface was introduced in 1ba05cdb6a
as an optimization to allow passing a simplified check for situations that
don't require mountinfo.Mounted to be executed (as that may result in parsing
 `/proc/self/mountinfo`).

The Checker was defined as an interface with a single `IsMounted` method,
possibly with the intent to allow for additional kind of checks to be added.
No new additions were made since its inception 9 Years ago, and if a need would
arrive, could probably be implemented as part of the check.

This patch simplifies the definition to a function, removing the need to
implement a wrapper struct just to satisfy the interface. The `Checker`
type definition is somewhat redundant, but is kept to have a place to
provide GoDoc.

The `NewFsChecker` and `NewDefaultChecker` utilities are removed as part
of this change, favoring a local definition for storage-drivers that
used them.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 19:15:26 +02:00
Sebastiaan van Stijn
554db8f113 daemon/internal/fstype: make FsMagic values not platform-dependent
While detection of filesystem-types may not be supported on all platforms,
it should be ok to define the types; this would allow for these types to
be used to print names (e.g.) in cross-platform situations.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 19:15:26 +02:00
Sebastiaan van Stijn
49f6e004f1 daemon/graphdriver: move FsMagic utilities to an internal package
These utilities were used in both graphdrivers and snapshotters. Move them
to a separate package, to help decoupling snapshotters and graphdrivers,
and make it internal, as it's not intended to be used as a generic utility
package (we can still make it public if there would be a need).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 19:15:20 +02:00
Brian Goff
f3d377e422 Merge pull request #48097 from thaJeztah/internalize_containerfs
pkg/containerfs: move to internal
2024-07-01 16:09:48 +00:00
Paweł Gronowski
2427c4bf92 Merge pull request #48101 from thaJeztah/capabilities_internal
pkg/capabilities move to daemon/internal
2024-07-01 17:40:09 +02:00
Paweł Gronowski
27f0a59390 Merge pull request #48070 from thaJeztah/build_next_nits
builder/builder-next: applySourcePolicies: remove redundant check and vars
2024-07-01 17:18:52 +02:00
Sebastiaan van Stijn
c0dd5c18f6 Merge pull request #48081 from thaJeztah/gofumpt
do another run of gofumpt
2024-07-01 16:17:54 +02:00
Sebastiaan van Stijn
71a99f24e2 Merge pull request #48091 from thaJeztah/vendor_hcsshim_0.11.7
vendor: github.com/microsoft/hcsshim v0.11.7
2024-07-01 12:26:15 +02:00
Akihiro Suda
d91ae493d0 Merge pull request #48100 from thaJeztah/errdefs_fromstatuscode
errdefs: FromStatusCode(): use early returns
2024-07-01 14:52:25 +09:00
Akihiro Suda
46127730d0 Merge pull request #48098 from thaJeztah/remove_plugingetter_aliases
daemon/logger, volume/drivers: remove redundant import-aliases
2024-07-01 14:51:05 +09:00
Akihiro Suda
e738d3be43 Merge pull request #48102 from thaJeztah/runconfig_remove_deprecated
runconfig, runconfig/opts: remove deprecated types and functions
2024-07-01 14:50:22 +09:00
Sebastiaan van Stijn
09f62a8a61 runconfig/opts: remove deprecated ConvertKVStringsToMap
It was deprecated in 437e1ae15e, which is
part of v27.0, and is no longer in use. This was the remaining code
in the runconfig/opts package, which is now removed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 01:12:17 +02:00
Sebastiaan van Stijn
4a30231d05 runconfig: remove deprecated IsPreDefinedNetwork
It was deprecated in d22d8a78f1, which is
part of v27.0, and is no longer in use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 01:09:59 +02:00
Sebastiaan van Stijn
ed712ad0b9 runconfig: remove deprecated DefaultDaemonNetworkMode
It was deprecated in 8e91b64e07, which is
part of v27.0, and is no longer in use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 01:08:12 +02:00
Sebastiaan van Stijn
13984ef185 runconfig: remove deprecated SetDefaultNetModeIfBlank
It was deprecated in afdfe4ff86, which is
part of v27.0, and is no longer in use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 01:05:55 +02:00
Sebastiaan van Stijn
6e2b6399d7 runconfig: remove deprecated ContainerConfigWrapper
It was deprecated in c692af36c3, which is
part of v27.0, and is no longer in use.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 01:02:38 +02:00
Sebastiaan van Stijn
d80a3f2e48 pkg/capabilities move to daemon/internal
This package was added in 8f936ae8cf, and
never had external consumers. Let's move it internal.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 00:49:15 +02:00
Sebastiaan van Stijn
625c795785 errdefs: FromStatusCode(): use early returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-07-01 00:43:45 +02:00
Sebastiaan van Stijn
81be279c6b daemon/logger, volume/drivers: remove redundant import-aliases
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-30 19:22:17 +02:00
Sebastiaan van Stijn
f2970e5358 pkg/containerfs: move to internal
The only external consumer are the `graphdriver` and `graphdriver/shim`
packages in github.com/docker/go-plugins-helpers, which depended on
[ContainerFS][1], which was removed in 9ce2b30b81.

graphdriver-plugins were deprecated in 6da604aa6a,
and support for them removed in 555dac5e14,
so removing this should not be an issue.

Ideally this package would've been moved inside `daemon/internal`, but it's used
by the `daemon` (cleanupContainer), `plugin` package, and by `graphdrivers`,
so needs to be in the top-level `internal/` package.

[1]: 6eecb7beb6/graphdriver/api.go (L218)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-30 19:13:23 +02:00
Sebastiaan van Stijn
a3e6ce95c4 pkg/containerfs: cleanup GoDoc, and make Windows a proper wrapper
- Improve some GoDoc to use docs links
- Change the Windows stub to an actual wrapper function, as we don't
  want it to be updateable, and it currently shows as "variable" on
  pkg.go.dev, which is confusing.
- Remove "import" comments in preparation of moving this package

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-30 19:13:16 +02:00
Sebastiaan van Stijn
e2ae6907c6 pkg/containerfs: remove CleanScopedPath and make it internal
The container package is the only consumer of this function in our code
and there's no known external users;
https://grep.app/search?q=.CleanScopedPath%28&filter[lang][0]=Go

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-30 18:18:02 +02:00
Sebastiaan van Stijn
47a959ee50 Merge pull request #48095 from coolljt0725/remove_unnecessary_return
cleanup: Remove unnecessary return value
2024-06-30 18:03:19 +02:00
Lei Jitang
fa150ca759 cleanup: Remove unnecessary return value
The return error of `installCommonConfigFlags` is unnecessary since
it only return nil.

Signed-off-by: Lei Jitang <leijitang@outlook.com>
2024-06-30 17:34:34 +08:00
Sebastiaan van Stijn
a2fe103f0d vendor: github.com/microsoft/hcsshim v0.11.7
- Fix process handle leak when launching a job container
- Add EndpointState attribute to the HNSEndpoint struct to support
  hyperv containers for k8s
- Add support for loadbalancer policy update in hns
- Changes for checking the global version for modify policy version support
- OutBoundNATPolicy Schema changes (add MaxPortPoolUsage to OutboundNatPolicySetting)

full diff: https://github.com/microsoft/hcsshim/compare/v0.11.5...v0.11.7

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-29 21:04:16 +02:00
Sebastiaan van Stijn
c94586d8ee Merge pull request #48088 from robmry/48067_fix_specific_ipv6_portmap_proxy_to_ipv4
Fix incorrect validation of port mapping
2024-06-28 21:05:26 +02:00
Sebastiaan van Stijn
0d16821922 Merge pull request #48083 from thaJeztah/fix_rootless_pull
daemon/graphdriver/overlay2: set TarOptions.InUserNS for native differ (fix "failed to Lchown "/dev/console")
2024-06-28 19:33:15 +02:00
Rob Murray
dfbcddb9f5 Fix incorrect validation of port mapping
Regression introduced in 01eecb6.

A port mapping from a specific IPv6 host address can be used
by a container on an IPv4-only network, docker-proxy makes the
connection.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-28 17:32:15 +01:00
Sebastiaan van Stijn
6226988c1e Merge pull request #48080 from thaJeztah/gofmt
fix some gofmt issues reported by goreportcard
2024-06-28 17:04:04 +02:00
Sebastiaan van Stijn
d2886f15f5 Merge pull request #48084 from robmry/48069_fix_overlapping_subnets
Fix duplicate subnet allocations
2024-06-28 16:54:41 +02:00
Rob Murray
4de54ee14c Fix duplicate subnet allocations
Keep allocated subnets in-order, so that they're not mistakenly
reallocated due to a gap in the list where misplaced subnets should
have been.

Introduced in 9d288b5.

The iterator over allocated subnets was incremented too early, this
change moves it past three clauses in addrSpace.allocatePredefinedPool().
The three new unit tests correspond to a separate failure caused by
incrementing before each of them.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-28 13:34:35 +01:00
Sebastiaan van Stijn
4d867d4806 Merge pull request #48079 from thaJeztah/graphdriver_deprecate_GetDriver
daemon/graphdriver: deprecate GetDriver(), and remove its use
2024-06-28 13:18:21 +02:00
Sebastiaan van Stijn
6521057bb2 daemon/graphdriver/overlay2: set TarOptions.InUserNS for native differ
Commits b2fd67de77 (and the follow-up commit
f6b80253b8) updated doesSupportNativeDiff to
detect whether the host can support native overlay diffing with userns
enabled.

As a result, [useNaiveDiff] would now return "false" in cases where it
previously would return "true" (and thus skip). However, [overlay2],
unlike [fuse-overlay] did not take user namespaces into account, when
using the native differ, and it therefore did not set the InUserNS option
in TarOptions.

As a result pkg/archive.createTarFile would attempt tocreate [device-nodes]
through [handleTarTypeBlockCharFifo] which would fail, but the resulting
error `EPERM` would be discarded, and `createTarFile` would not return
early, therefor attempting to [os.LChown] the missing file, ultimately
resulting in an error:

    failed to Lchown "/dev/console" for UID 0, GID 0: lchown /dev/console: no such file or directory

This patch fixes the missing option in overlay.

[useNaiveDiff]: 47eebd718f/daemon/graphdriver/overlay2/overlay.go (L248-L256)
[overlay2]: 47eebd718f/daemon/graphdriver/overlay2/overlay.go (L684-L689)
[fuse-overlay]: 47eebd718f/daemon/graphdriver/fuse-overlayfs/fuseoverlayfs.go (L456-L462)
[device-nodes]: ff1e2c0de7/pkg/archive/archive.go (L713-L720)
[handleTarTypeBlockCharFifo]: 47eebd718f/pkg/archive/archive_unix.go (L110-L114)
[os.LChown]: ff1e2c0de7/pkg/archive/archive.go (L762-L773)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-28 12:38:40 +02:00
Sebastiaan van Stijn
969993a729 pkg/archive: createTarFile: consistently use the same value for userns
createTarFile accepts a opts (TarOptions) argument to specify whether
userns is enabled; whe should consider always detecting locally, but
at least make sure we're consistently working with the same value within
this function.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-28 12:21:03 +02:00
Sebastiaan van Stijn
379ce56cd8 pkg/archive: handleTarTypeBlockCharFifo: don't discard EPERM errors
This function was discarding EPERM errors if it detected that userns was
enabled; move such checks to the caller-site, so that they can decide
how to handle the error (which, in case of userns may be to log and ignore).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-28 12:11:52 +02:00
Sebastiaan van Stijn
af85e47343 pkg/archive: getWhiteoutConverter: don't error with userns enabled
Since 838047a1f5, the overlayWhiteoutConverter
is supported with userns enabled, so we no longer need this check.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-28 12:05:13 +02:00
Sebastiaan van Stijn
080a8e1b6b libcontainerd: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:49 +02:00
Sebastiaan van Stijn
56fa45773f pkg/plugins: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:49 +02:00
Sebastiaan van Stijn
0e2d40c24a pkg/archive: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:49 +02:00
Sebastiaan van Stijn
84e43da752 libnetwork: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:48 +02:00
Sebastiaan van Stijn
bb1b766ddb layer: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:48 +02:00
Sebastiaan van Stijn
07469b4509 internal: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:48 +02:00
Sebastiaan van Stijn
8e50a96a78 integration: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:48 +02:00
Sebastiaan van Stijn
c3ac7fee26 integration-cli: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:48 +02:00
Sebastiaan van Stijn
e765dd90ee daemon: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:47 +02:00
Sebastiaan van Stijn
181101c4a8 daemon/containerd: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:47 +02:00
Sebastiaan van Stijn
46b0102da4 daemon/config: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:47 +02:00
Sebastiaan van Stijn
4a89963f1e builder: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:46 +02:00
Sebastiaan van Stijn
8768145519 api/types: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:46 +02:00
Sebastiaan van Stijn
92346bcec6 api/server: gofumpt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:18:46 +02:00
Sebastiaan van Stijn
6ada1cff02 fix some gofmt issues reported by goreportcard
https://goreportcard.com/report/github.com/docker/docker

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 23:02:00 +02:00
Sebastiaan van Stijn
84cabde357 daemon/graphdriver: deprecate GetDriver(), and remove its use
The exported function was only used in tests, and identical in use when
using New with a name provided. Deprecate it, and remove the uses of it
in our (integration-)tests.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 20:05:44 +02:00
Sebastiaan van Stijn
b7896056c1 daemon/graphdriver: New(): update GoDoc
Better describe what this function does (currently), and add a TODO for
consideration to extract some of its magic.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 20:05:43 +02:00
Sebastiaan van Stijn
25d12b54d3 daemon/graphdriver: combine GetDriver and getBuiltinDriver
Now that support for external graphdriver-plugins is removed, these functions
are now identical in functionality; combine them, but use a non-exported
variant for internal use to get visibility into where it's used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 20:05:38 +02:00
Paweł Gronowski
47eebd718f Merge pull request #48072 from thaJeztah/remove_graphdriver_plugins
daemon/graphdriver: remove support for external graphdriver plugins
2024-06-27 19:53:32 +02:00
Sebastiaan van Stijn
abba059cbb Merge pull request #48073 from vvoland/dockerfile-update-cli
Dockerfile: update compose to v2.28.1, update cli to v27.0.2
2024-06-27 17:59:19 +02:00
Paweł Gronowski
72c78ee628 Merge pull request #48071 from thaJeztah/graphdriver_noshadow
daemon/graphdriver, layer: rename vars that shadowed imports
2024-06-27 16:19:50 +02:00
Paweł Gronowski
3928165cf7 Dockerfile: update docker CLI to v27.0.2
Update the Docker CLI used in the dev-container

full diff: https://github.com/docker/cli/compare/v26.1.0...v27.0.2

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-27 14:53:34 +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
bc4991e443 layer: rename vars that shadowed imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 14:03:47 +02:00
Sebastiaan van Stijn
0ed172b700 daemon/graphdriver: rename vars that shadowed imports
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 14:03:43 +02:00
Sebastiaan van Stijn
bbced07f96 builder/builder-next: applySourcePolicies: remove redundant check and vars
- the check for `ok` was redundant as the line above it would return early
- the `t` and `ok` variable declaration was redundant, as all variables to
  the left of the `strings.Cut` were locally scoped variables.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-27 13:15:17 +02:00
Paweł Gronowski
790035f754 Dockerfile: update compose to v2.28.1
Update the compose cli plugin used in the dev-container

full diff: https://github.com/docker/cli/compare/v2.27.1...v2.28.1

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-26 21:01:24 +02:00
Paweł Gronowski
c083aae0f3 Merge pull request #48055 from thaJeztah/api_deprecate_ContainerJSONBase_Node
api/types: deprecate ContainerJSONBase.Node, ContainerNode
2024-06-26 20:30:39 +02:00
Sebastiaan van Stijn
f6d0d2f92f Merge pull request #48058 from thaJeztah/bump_golangci_lint
update golangci-lint to v1.59.1
2024-06-26 15:48:08 +02:00
Sebastiaan van Stijn
95fae036ae update golangci-lint to v1.59.1
full diff: https://github.com/golangci/golangci-lint/compare/v1.55.2...v1.59.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-26 02:08:43 +02:00
Sebastiaan van Stijn
d4160d5aa7 pkg/archive: reformat code to make #nosec comment work again
Looks like the way it picks up #nosec comments changed, causing the
linter error to re-appear;

    pkg/archive/archive_linux.go:57:17: G305: File traversal when extracting zip/tar archive (gosec)
                    Name:       filepath.Join(hdr.Name, WhiteoutOpaqueDir),
                                ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-26 02:08:00 +02:00
Sebastiaan van Stijn
04bf0e3d69 builder/remotecontext: reformat code to make #nosec comment work again
Looks like the way it picks up #nosec comments changed, causing the
linter error to re-appear;

    builder/remotecontext/remote.go:48:17: G107: Potential HTTP request made with variable url (gosec)
        if resp, err = http.Get(address); err != nil {
                       ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-26 02:04:13 +02:00
Sebastiaan van Stijn
1fc9236119 api/types: deprecate ContainerJSONBase.Node, ContainerNode
The `Node` field and related `ContainerNode` type were used by the classic
(standalone) Swarm API. API documentation for this field was already removed
in 234d5a78fe (API 1.41 / docker 20.10), and
as the Docker Engine didn't implement these fields for the Swarm API, it
would always have been unset / nil.

Let's do a quick deprecation, and remove it on the next release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-25 18:47:59 +02:00
Paweł Gronowski
ff1e2c0de7 Merge pull request #48050 from thaJeztah/deprecate_graphdriver_plugins
deprecate experimental Graphdriver plugins, and disable by default
2024-06-21 15:12:12 +02:00
Sebastiaan van Stijn
6da604aa6a deprecate experimental Graphdriver plugins, and disable by default
Graphdriver plugins] are an experimental feature that allow extending the
Docker Engine with custom storage drivers for storing images and containers.
This feature was not maintained since its inception, and will no longer be
supported in upcoming releases.

Users of this feature are recommended to instead configure the Docker Engine
to use the [containerd image store], and a custom [snapshotter].

This patch:

- Disables loading graphdriver plugins by default, producing an error instead.
- Introduces a temporary `DOCKERD_DEPRECATED_GRAPHDRIVER_PLUGINS` environment
  variable to re-enable the deprecated features; this allows users to still
  use the feature on a v27.0 daemon, but disabling it by default will give a
  strong message that it will no longer be supported.

[Graphdriver plugins]: https://github.com/docker/cli/blob/v26.1.4/docs/extend/plugins_graphdriver.md
[containerd image store]: https://docs.docker.com/storage/containerd/
[snapshotter]: https://github.com/containerd/containerd/tree/v1.7.18/docs/snapshotters

Before this patch (ignore the "Unable to load plugin" errors, as there's no plugin);

    dockerd --experimental -s my-driver
    ...
    INFO[2024-06-21T10:42:49.574901255Z] containerd successfully booted in 0.011384s
    INFO[2024-06-21T10:42:50.575891922Z] [graphdriver] trying configured driver: my-driver
    WARN[2024-06-21T10:42:50.576121547Z] Unable to locate plugin: my-driver, retrying in 1s
    WARN[2024-06-21T10:42:51.577131506Z] Unable to locate plugin: my-driver, retrying in 2s
    WARN[2024-06-21T10:42:53.582637715Z] Unable to locate plugin: my-driver, retrying in 4s

With this patch:

    dockerd --experimental -s my-driver
    ...
    INFO[2024-06-21T10:32:35.123078845Z] [graphdriver] trying configured driver: my-driver
    ERRO[2024-06-21T10:32:35.123127012Z] Failed to GetDriver graph                     driver=my-driver error="DEPRECATED: Experimental graphdriver plugins are deprecated, and disabled by default. This feature will be removed in the next release. See https://docs.docker.com/go/deprecated/" home-dir=/var/lib/docker
    INFO[2024-06-21T10:32:35.124735595Z] stopping healthcheck following graceful shutdown  module=libcontainerd
    INFO[2024-06-21T10:32:35.124743137Z] stopping event stream following graceful shutdown  error="context canceled" module=libcontainerd namespace=plugins.moby
    failed to start daemon: error initializing graphdriver: driver not supported: my-driver

With the `DOCKERD_DEPRECATED_GRAPHDRIVER_PLUGINS` env-var set:

    DOCKERD_DEPRECATED_GRAPHDRIVER_PLUGINS=1 dockerd --experimental -s my-driver
    ...
    INFO[2024-06-21T10:35:04.149901970Z] containerd successfully booted in 0.013614s
    INFO[2024-06-21T10:35:05.148195845Z] [graphdriver] trying configured driver: my-driver
    WARN[2024-06-21T10:35:05.150647679Z] Unable to locate plugin: my-driver, retrying in 1s
    WARN[2024-06-21T10:35:06.152531221Z] Unable to locate plugin: my-driver, retrying in 2s
    WARN[2024-06-21T10:35:08.158452389Z] Unable to locate plugin: my-driver, retrying in 4s
    WARN[2024-06-21T10:35:12.163699293Z] Unable to locate plugin: my-driver, retrying in 8s

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-21 13:08:31 +02:00
Paweł Gronowski
81b2027979 Merge pull request #48049 from thaJeztah/fix_swagger_tmpfsopts
api: swagger: fix definition of TmpFsOptions (API v1.46)
2024-06-21 12:22:26 +02:00
Paweł Gronowski
97f6a9d005 Merge pull request #48045 from thaJeztah/bump_ttrpc_1.2.5
vendor: github.com/containerd/ttrpc v1.2.5
2024-06-21 12:19:51 +02:00
Paweł Gronowski
3aace758b9 Merge pull request #48046 from thaJeztah/daemon_no_logrus
cmd/dockerd: initMiddlewares: use containerd/logs
2024-06-21 12:19:31 +02:00
Sebastiaan van Stijn
ce5571f343 api: swagger: fix definition of TmpFsOptions (API v1.46)
Since it's a [][]string, there should only be two levels of array
in the OpenAPI spec. Also, the outermost level array shouldn't have
properties: (it should have items: instead).

Co-authored-by: Mark Yen <mark.yen@suse.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-21 09:17:57 +02:00
Sebastiaan van Stijn
a9ab04603e cmd/dockerd: initMiddlewares: use containerd/logs
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-20 23:06:40 +02:00
Tianon Gravi
418eed6e4e Merge pull request #47804 from cpuguy83/more_paths_docker_proxy
Lookup docker-proxy in libexec paths
2024-06-20 13:52:21 -07:00
Sebastiaan van Stijn
e355e10011 vendor: github.com/containerd/ttrpc v1.2.5
full diff: https://github.com/containerd/ttrpc/compare/v1.2.4...v1.2.5

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-20 22:52:19 +02:00
Brian Goff
f8c088be05 Lookup docker-proxy in libexec paths
This allows distros to put docker-proxy under libexec paths as is done
for docker-init.

Also expands the lookup to to not require a `docker/` subdir in libexec
subdir.
Since it is a generic helper that may be used for something else in the
future, this is only done for binaries with a `docker-`.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-06-20 19:26:54 +00:00
Paweł Gronowski
018d93decf Merge pull request #47961 from gtomitsuka/gabriel/data-races
client: Make version negotiation thread-safe
2024-06-20 13:55:10 +02:00
Albin Kerouanton
1a1f3cff45 Merge pull request #48011 from thaJeztah/deprecate_runconfig_IsPreDefinedNetwork
runconfig: deprecate IsPreDefinedNetwork
2024-06-20 12:59:08 +02:00
Sebastiaan van Stijn
202de333a4 Merge pull request #48040 from thaJeztah/move_stats
api/types: move stats-types to api/types/container
2024-06-20 11:30:31 +02:00
Sebastiaan van Stijn
d22d8a78f1 runconfig: deprecate IsPreDefinedNetwork
Move the function internal to the daemon, where it's used. Deliberately
not mentioning the new location, as this function should not be used
externally.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-20 11:10:54 +02:00
Sebastiaan van Stijn
a24af26aba Merge pull request #48037 from thaJeztah/registry_cleanups
registry: minor cleanups
2024-06-20 10:27:16 +02:00
Sebastiaan van Stijn
b5d3c47a37 Merge pull request #48033 from thaJeztah/api_update_examples
docs/api: update some example values to be more accurate (API v1.46)
2024-06-20 10:26:52 +02:00
Sebastiaan van Stijn
0a4277abf4 api/types: move stats-types to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-20 10:21:42 +02:00
Paweł Gronowski
fe60fa241b Merge pull request #48039 from thaJeztah/fixo_typo
api/types: fix typo in GoDoc
2024-06-20 10:15:35 +02:00
Paweł Gronowski
5ace798cab Merge pull request #48041 from thaJeztah/rename_statsresponse
api/types: rename container.StatsResponse to StatsResponseReader
2024-06-20 10:12:17 +02:00
Sebastiaan van Stijn
91a2a574d7 api/types: rename container.StatsResponse to StatsResponseReader
commit 17c3269a37 moved the ContainerStats
type to the container package, and renamed it to StatsResponse. However,
this name is chosen poorly, as it documents it to be the response of
the API endpoint, but is more accurately a wrapper around a reader,
used to read a (stream of) StatsJSON. We want to change StatsJSON
to StatsResponse, as it's more consistent with other response types.

As 17c3269a37 did not make it into a
non-pre-release, we can still change this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-20 08:54:52 +02:00
Akihiro Suda
485e1c7be7 Merge pull request #48035 from thaJeztah/more_mailmap
update one more entry in mailmap and AUTHORS
2024-06-20 09:16:16 +09:00
Sebastiaan van Stijn
6fafc8762f api/types: fix typo in GoDoc
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-20 01:39:32 +02:00
Brian Goff
3a36cad0bd Merge pull request #48034 from cyphar/volume-atomic-write
volume: use AtomicWriteFile to save volume options
2024-06-19 18:39:49 +00:00
Sebastiaan van Stijn
42cb29f6ea registry: Search.searchUnfiltered: inline variable
The scopes variable was used in one location; inline it where it's used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-19 17:05:48 +02:00
Sebastiaan van Stijn
43d4a4c63e registry: v2AuthHTTPClient: inline some vars and slight refactor
- inline the auth.TokenHandlerOptions in the auth.NewTokenHandlerWithOptions call
- construct a authHandlers slice to make it more clear that this is a variadic
  list of authentication-handlers.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-19 17:04:59 +02:00
Sebastiaan van Stijn
bf35f3d8c8 update one more entry in mailmap and AUTHORS
Found back the PR related to this contributors, and they addressed
their name in an intermediate rebase, but it got lost in a later one.

While at it, also fixed an entry next to it :)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-19 12:48:41 +02:00
Aleksa Sarai
b4c20da143 volume: use AtomicWriteFile to save volume options
If the system (or Docker) crashes while saivng the volume options, on
restart the daemon will error out when trying to read the options file
because it doesn't contain valid JSON.

In such a crash scenario, the new volume will be treated as though it
has the default options configuration. This is not ideal, but volumes
created on very old Docker versions (pre-1.11[1], circa 2016) do not
have opts.json and so doing some kind of cleanup when loading the volume
store (even if we take care to only delete empty volumes) could delete
existing volumes carried over from very old Docker versions that users
would not expect to disappear.

Ultimately, if a user creates a volume and the system crashes, a volume
that has the wrong config is better than Docker not being able to start.

[1]: commit b05b237075 ("Support mount opts for `local` volume driver")

Signed-off-by: Aleksa Sarai <cyphar@cyphar.com>
2024-06-19 18:57:51 +10:00
Akihiro Suda
11179de64c Merge pull request #48031 from thaJeztah/bump_cobra
vendor: github.com/spf13/cobra v1.8.1
2024-06-19 14:19:41 +09:00
Akihiro Suda
9e85d1cb41 Merge pull request #48032 from thaJeztah/update_mailmap
update .mailmap and AUTHORS
2024-06-19 14:19:09 +09:00
Sebastiaan van Stijn
39b4448e12 docs/api: update some example values to be more accurate (API v1.46)
Update daemon versions, and minimum supported API version to be more
representative to what the API would return.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-19 00:51:14 +02:00
Sebastiaan van Stijn
37b57c2ae0 api: swagger: update some example values to be more accurate
Update daemon versions, and minimum supported API version to be more
representative to what the API would return.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-19 00:50:23 +02:00
Sebastiaan van Stijn
2a7bb2a7bd update .mailmap and AUTHORS
I noticed some duplicates made their way in, in
084219a5f9 and some authors
didn't have git configured properly to include the name
they used for the sign-off

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 23:31:38 +02:00
Sebastiaan van Stijn
e7347f8a8c Merge pull request #48030 from thaJeztah/bump_buildx
Dockerfile: update buildx to v0.15.1
2024-06-18 22:59:07 +02:00
Sebastiaan van Stijn
68b8e97849 vendor: github.com/spf13/cobra v1.8.1
- release notes: https://github.com/spf13/cobra/releases/tag/v1.8.1
- full diff: https://github.com/spf13/cobra/compare/v1.8.0...v1.8.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 22:17:41 +02:00
Sebastiaan van Stijn
b5cc61a243 Dockerfile: update buildx to v0.15.1
This is the version used in the dev-container, and for testing.

release notes:
https://github.com/docker/buildx/releases/tag/v0.15.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 21:36:25 +02:00
Sebastiaan van Stijn
59b119f94e Merge pull request #47994 from thaJeztah/simplify_getDummyName
libnetwork: ipvlan, macvlan: cleanup getDummyName utility
2024-06-18 21:25:55 +02:00
Albin Kerouanton
3e85c9d517 Merge pull request #48025 from robmry/fix_port_mapped_hairpin
Fix hairpin between networks with mapped port
2024-06-18 19:46:16 +02:00
Sebastiaan van Stijn
f741ca857c libnetwork/drivers/macvlan: getDummyName don't use stringid.TruncateID
The stringid.TruncateID utility is used to provide a consistent length
for "short IDs" (containers, networks). While the dummy interfaces need
a short identifier, they use their own format and don't have to follow
the same length as is used for "short IDs" elsewhere.

In addition, stringid.TruncateID has an additional check for the given
ID to contain colons (":"), which won't be the case for network-IDs that
are passed to it, so this check is redundant.

This patch moves the truncating local to the getDummyName function, so
that it can define its own semantics, independent of changes elsewhere.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 19:40:15 +02:00
Sebastiaan van Stijn
d241862f36 libnetwork/drivers/macvlan: move truncating ID to getDummyName
The function description mentions that the returned value will contain
a truncated ID, but the function was only prepending the prefix, which
meant that callers had to be aware that truncating is necessary.

This patch moves truncating the ID into the utility to make its use
less error-prone, and to make the code a bite more DRY.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 19:40:12 +02:00
Sebastiaan van Stijn
dab918b2b0 libnetwork/drivers/ipvlan: getDummyName don't use stringid.TruncateID
The stringid.TruncateID utility is used to provide a consistent length
for "short IDs" (containers, networks). While the dummy interfaces need
a short identifier, they use their own format and don't have to follow
the same length as is used for "short IDs" elsewhere.

In addition, stringid.TruncateID has an additional check for the given
ID to contain colons (":"), which won't be the case for network-IDs that
are passed to it, so this check is redundant.

This patch moves the truncating local to the getDummyName function, so
that it can define its own semantics, independent of changes elsewhere.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 19:34:25 +02:00
Sebastiaan van Stijn
b8c80b19de libnetwork/drivers/ipvlan: move truncating ID to getDummyName
The function description mentions that the returned value will contain
a truncated ID, but the function was only prepending the prefix, which
meant that callers had to be aware that truncating is necessary.

This patch moves truncating the ID into the utility to make its use
less error-prone, and to make the code a bite more DRY.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 19:34:23 +02:00
Albin Kerouanton
fb8d8a9fe5 Merge pull request #47318 from andrewbaxter/47317-allow-macvlan-dup-parent
Allow multiple macvlan networks to share a parent
2024-06-18 19:32:24 +02:00
Sebastiaan van Stijn
b5b7ddfdd5 Merge pull request #48028 from tonistiigi/update-buildkit-v0.14.1
vendor: update buildkit to v0.14.1
2024-06-18 19:12:51 +02:00
Tonis Tiigi
8599213b52 vendor: update buildkit to v0.14.1
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-18 09:12:55 -07:00
Rob Murray
2df4391473 Fix hairpin between networks with mapped port
Following changes to the port mapping code, the DNAT iptables rule was
inserted into the nat table rather than appended.

This meant DNAT was applied before the rule that should have skipped
it when a packet was from a bridge network.

So, packets sent from a container on one network to a mapped port on
the host's address were DNAT'd before docker-proxy could pick them up,
then they were dropped by a rule intended to isolate the networks.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-18 16:14:16 +01:00
Sebastiaan van Stijn
fd71cbfab5 Merge pull request #48026 from thaJeztah/api_v1.46_docs
docs: add API documentation for API v1.46
2024-06-18 15:28:03 +02:00
Sebastiaan van Stijn
9402ea1c8e Merge pull request #48023 from thaJeztah/local_ulimits_alias
api/types/container: provide alias for github.com/docker/go-units.Ulimit
2024-06-18 14:19:43 +02:00
Sebastiaan van Stijn
b06b6b3648 docs: add API documentation for API v1.46
This is the API version to be released with v27.0, and the API
is now frozen for this release, so we can create the documentation.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 14:15:13 +02:00
Sebastiaan van Stijn
f174059a25 Merge pull request #48019 from thaJeztah/executor_err_handling
daemon/cluster/executor/container: fix error-handling
2024-06-18 14:13:46 +02:00
Paweł Gronowski
ea48d90399 Merge pull request #48024 from vvoland/update-authors
update AUTHORS
2024-06-18 14:13: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
Sebastiaan van Stijn
f160cd0087 Merge pull request #48016 from thaJeztah/deprecate_runconfig_opts
runconfig/opts: deprecate ConvertKVStringsToMap and move internal
2024-06-18 14:10:58 +02:00
Sebastiaan van Stijn
517fb0991e api/types/container: provide alias for github.com/docker/go-units.Ulimit
This type is included in various types used in the API, but comes from
a separate module. The go-units module may be moving to the moby org,
and it is yet to be decided if the Ulimit type is a good fit for that
module (which deals with more generic units, such as "size" and "duration"
otherwise).

This patch introduces an alias to help during the transition of this type
to it's new location. The alias makes sure that existing code continues
to work (at least for now), but we need to start updating such code after
this PR is merged.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 13:18:20 +02:00
Sebastiaan van Stijn
c3217300e2 Merge pull request #48022 from thaJeztah/leftover_nits
daemon, daemon/cluster, integration/container: minor linting issues and cleanups
2024-06-18 13:17:41 +02:00
Sebastiaan van Stijn
ad716b223b integration/container: use consistent alias for import
The canonical alias is "containertypes" for this import.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 13:11:37 +02:00
Sebastiaan van Stijn
25f44885ed daemon/cluster/executor/container: use consistent alias for import
The canonical alias is "containertypes" for this import.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 13:11:34 +02:00
Paweł Gronowski
084219a5f9 update AUTHORS
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-18 13:01:11 +02:00
Sebastiaan van Stijn
f09f756851 daemon/cluster: minor linting issues and cleanup
- rename variables that shadowed imports
- remove some intermediate vars
- slight reformating for readability

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-18 10:42:56 +02:00
Rob Murray
9e389b1eac Merge pull request #48020 from robmry/revert_internal_resolver_for_default_bridge
Revert internal resolver for default bridge
2024-06-18 09:04:57 +01:00
Sebastiaan van Stijn
4ea464d1a7 Merge pull request #47950 from psaintlaurent/ENGINE-903
Add OOMScoreAdj to the moby API
2024-06-17 22:58:24 +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
Rob Murray
6d35673504 Revert "No default nameservers for internal resolver"
This reverts commit d365702dbd.

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:10 +01:00
Sebastiaan van Stijn
01efb9a5ab daemon/cluster/executor/container: fix error-handling
While working on this file, I noticed the `isContainerCreateNameConflict`,
`isUnknownContainer`, and `isStoppedContainer` utilities, which are used
to perform error-type detection through string-matching.

These utilities were added in 534a90a993,
as part of the initial implementation of the Swarm executor in Docker.
At that time, the Docker API client did not return typed errors, and
various part of the code depended on string matching, which is brittle,
and it looks like `isContainerCreateNameConflict` at least is already
broken since c9d0a77657, which changed
the error-message.

Starting with ebcb7d6b40, we use typed
errors through the errdefs package, so we can replace these utilities:

The `isUnknownContainer` utility is replace by `errdefs.IsNotFound`,
which is returned if the object is not found. Interestingly, this utility
was checking for containers only (`No such container`), but was also
used for an `removeNetworks` call. Tracking back history of that use to
verify if it was _intentionally_ checking for a "container not found"
error;

- This check added in the initial implementation 534a90a993
- Moved from `controller.Remove` to `container.Shutdown` to make sure the
  sandbox was removed in 680d0ba4ab
- And finally touched again in 70fa7b6a3f,
  which was a follow-up to the previous one, and fixed the conditions
  to prevent returning early before the network was removed.

None of those patches mention that these errors are related to containers,
and checking the codepath that's executed, we can only expect a
`libmetwork.ErrNoSuchNetwork` to be returned, so this looks to have been
a bug.

The `isStoppedContainer` utility is replaced by `errdefs.IsNotModified`,
which is the error (status) returned in situations where the container
is already stopped; caf502a0bc/daemon/stop.go (L30-L35)
This is the only

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 21:14:47 +02:00
plaurent
b640582436 Add OomScoreAdj options
Signed-off-by: plaurent <patrick@saint-laurent.us>
2024-06-17 12:01:06 -04: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
Paweł Gronowski
caf502a0bc Merge pull request #47239 from cpuguy83/containerd_image_info
Set containerd container image ref
2024-06-17 17:02:24 +02:00
Sebastiaan van Stijn
d88ae86a16 Merge pull request #48014 from thaJeztah/daemon_rename_imports
daemon: rename some inconsistent import aliases
2024-06-17 16:40:53 +02:00
Paweł Gronowski
9f4cd92e07 Merge pull request #47929 from vvoland/image-create
daemon: Emit Image Create event when image is built
2024-06-17 16:30:35 +02:00
Sebastiaan van Stijn
437e1ae15e runconfig/opts: deprecate ConvertKVStringsToMap and move internal
This utility is only used in two places, and simple enough to duplicate.
There's no external consumers, and a copy of this utility exists in docker/cli
for use on the client side, so we could consider skipping deprecation,
but just to be on the safe side ':)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 16:23:39 +02:00
Sebastiaan van Stijn
b3e236d3b5 daemon: rename some inconsistent import aliases
These used aliases that weren't used elsewhere, so renaming / removing
to keep some consistency. Some local variables were renamed to prevent
shadowing.

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

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 14:45:17 +02:00
Brian Goff
812f319a57 Add containerd connection info to info endpoint (API v1.46)
This will be used in the next commit to test that changes are propagated
to the containerd store.
It is also just generally useful for debugging purposes.

- docs/api: update version history
- daemon: add fillContainerdInfo utility
- api: update swagger file with new types

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 14:43:39 +02:00
Paweł Gronowski
1327342b14 hack: Ignore deprecate-integration-cli validation
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-17 14:05:15 +02:00
Paweł Gronowski
7b8f4922a5 daemon: Emit Image Create event when image is built
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-17 14:05:12 +02:00
Paweł Gronowski
09eb6ec4f1 builder/exporter: Wrap exporter to hook the image export
Buildkit doesn't call the engine API when it builds an image without
tag. Wrap the exporter returned by the worker that calls a callback when
a new image is exported from buildkit.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-17 14:05:11 +02:00
Paweł Gronowski
0e84482ef5 builder-next: Move exporter wrapper to exporter package
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-17 14:05:09 +02:00
Sebastiaan van Stijn
eb360efeb5 Merge pull request #48013 from thaJeztah/reformat_networkmodes
api/types/container: reformat to align windows and unix implementations
2024-06-17 13:20:56 +02:00
Sebastiaan van Stijn
7012c4a129 Merge pull request #47996 from thaJeztah/pkg_longpath_deprecate_Prefix
pkg/longpath: deprecate Prefix const, and use early returns in AddPrefix
2024-06-17 13:18:33 +02:00
Sebastiaan van Stijn
b2441c7419 Merge pull request #45052 from cpuguy83/attach_fd_leak
Fix attach goroutine/fd leak when no I/O is ready
2024-06-17 13:16:08 +02:00
Sebastiaan van Stijn
08aebce331 Merge pull request #48012 from thaJeztah/daemon_less_shadow
daemon: rename variables that shadowed imports
2024-06-17 12:59:09 +02:00
Sebastiaan van Stijn
53c521bdc9 Merge pull request #47993 from thaJeztah/builder_dockerfile_cleanups
builder/dockerfile: assorted linting fixes, and remove LCOW leftover
2024-06-17 12:06:25 +02:00
Sebastiaan van Stijn
48ff86ec64 pkg/longpath: AddPrefix: use early returns
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 12:04:26 +02:00
Sebastiaan van Stijn
424c22390e pkg/longpath: deprecate Prefix const
This const was exported because it was in use by pkg/symlink. This
dependency was removed in a48c6e3005,
after which this const was only used internally.

This patch deprecates the const and introduces a non-exported const
to use.

There are no known external consumers of this const, so we may skip
deprecating it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 12:03:27 +02:00
Sebastiaan van Stijn
2f45cbf69f api/types/container: NetworkMode align code between Windows and Linux
Change the order of declarations betwen both implementations for easier
comparing of differences.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 11:53:19 +02:00
Sebastiaan van Stijn
7b56fa8dc0 api/types/container: NetworkMode.NetworkName: use switch
- Use a switch instead of if/else for readability and to reduce
  the risk of duplicates in the checks.
- Align order between Windows and Linux implementation for easier
  comparing of differences in the implementation.
- Add a check for `IsHost()` in the Windows implementation which
  would never occur currently, but is implemented.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 11:49:37 +02:00
Sebastiaan van Stijn
680e6d6e1c Merge pull request #48000 from thaJeztah/nosec_comments
pkg/archive. pkg/tarsum: format #nosec comments to standard format
2024-06-17 11:46:25 +02:00
Sebastiaan van Stijn
c114b5e6f0 Merge pull request #47997 from thaJeztah/pkg_archive_no_longpath
pkg/archive, pkg/chrootarchive: remove dependency on pkg/longpath
2024-06-17 11:43:59 +02:00
Sebastiaan van Stijn
4014b893e4 Merge pull request #48007 from thaJeztah/runconfig_drop_old_api_versions
runconfig: remove code for API < v1.18, deprecate SetDefaultNetModeIfBlank, ContainerConfigWrapper
2024-06-17 11:43:15 +02:00
Sebastiaan van Stijn
9c7f20e255 Merge pull request #48003 from thaJeztah/pkg_archive_cleanup
pkg/archive: assorted minor refactors and cleanups
2024-06-17 11:11:42 +02:00
Sebastiaan van Stijn
7b438c5c31 daemon: rename variables that shadowed imports
Not a full list yet, but renaming to prevent shadowing, and to use a more
consistent short form (ctr for container).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 11:06:06 +02:00
Sebastiaan van Stijn
21a7686862 Merge pull request #47995 from thaJeztah/stringid_cleanups
pkg/stringid: deprecate ValidateID, IsShortID
2024-06-17 10:55:06 +02:00
Sebastiaan van Stijn
e788628e2e Merge pull request #48005 from thaJeztah/pkg_archive_rm_kernelversion_check
pkg/archive: TestChangesDirsEmpty, TestChangesDirsMutated: no kernel-version check
2024-06-17 10:34:36 +02:00
Albin Kerouanton
a5fede8a51 Merge pull request #48006 from thaJeztah/libnetwork_nosversion
libnetwork: remove special handling for Windows 14393 (RS1, V1607, LTSC2016)
2024-06-17 10:25:28 +02:00
Sebastiaan van Stijn
4c7228663c api/server/router/container.postCommit: add TODO about use of CreateRequest
The commit endpoint accepts a container.Config, but uses the decoder to
unmarshal the request. The decoder uses a CreateRequest, which is a superset,
and also contains HostConfig and network.NetworkConfig. Those structs are
discarded in the router, but decoder.DecodeConfig also performs validation,
so a request containing those additional fields would result in a validation
error.

We should rewrite this code to only unmarshal what's expected.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 00:26:46 +02:00
Sebastiaan van Stijn
c692af36c3 runconfig: deprecate ContainerConfigWrapper, move to api/types/container
Move the type to api/types/container.CreateRequest, together with other
types used by the container API endpoints.

The Decoder, and related validation code is kept in the runconfig package
for now, but should likely be moved elsewhere (inside the API).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 00:26:46 +02:00
Sebastiaan van Stijn
afdfe4ff86 runconfig: deprecate SetDefaultNetModeIfBlank
Remove uses of this function and mark it deprecated. There's no known
consumers of this function, but let's stay on the safe side, and mark
it deprected for 1 release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 00:26:46 +02:00
Sebastiaan van Stijn
4af9f418a3 runconfig: remove ContainerConfigWrapper.getHostConfig() utility
This utility used to be responsible for backward compatibility with old
API versions, but was reduced to a single line. Inline the code, and
inline the SetDefaultNetModeIfBlank code, which in itself also was
just 3 lines of code.

A platform check was added to only set the default network conditionally,
but other paths in the codebase don't perform this conditionally, so a
TODO was added, to verify if this behavior is needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 00:26:46 +02:00
Sebastiaan van Stijn
98bd08c534 runconfig: remove redundant import-alias
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 00:26:46 +02:00
Sebastiaan van Stijn
e42503213d runconfig: ContainerConfigWrapper: unify Linux and Windows implementations
Now that the backward-compatibility code has been removed, the Linux and
Windows implementations of this struct are identical, so the platform-
specific code can be removed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 00:26:45 +02:00
Sebastiaan van Stijn
2954b05b03 runconfig: remove conversion code for API < v1.18
The runconfig package contained compatibility code to unmarshal API
requests on API < v1.18, and to convert them to current API versions.
These fields were marked as deprecated, but didn't mention relevant API
versions, so some digging was needed to track back history;

API versions before 1.18 accepted top-level `Memory`, `MemorySwap`,
`CpuShares`, and `Cpuset` fields as part of the container create requests.
These fields were not considered "portable", and therefore moved to the
`HostConfig` struct in 837eec064d. The
API version at that time was [v1.18]. For backward-compatibility, the
existing top-level fields were kept, and conversion code was added in
[ContainerHostConfigFromJob] to copy their values to `HostConfig` if
present.

A refactor in 767df67e31 introduced a new
`ContainerConfigWrapper` struct, which embedded the container-config and
a (non-exported) `hostConfigWrapper`. This resulted in an incompatibility
when compiling with gccgo, sn eb97de7dee
removed the non-exported `hostConfigWrapper`, instead embedding the
`HostConfig` and adding a `CpuSet` field. The API version at that time
was [v1.19].

With the introduction of Windows containers, which did not need conversion
code as it never supported previous API versions, the `ContainerConfigWrapper`
was split to Linux and Windows implementation in f6ed590596.
This change introduced a `SetDefaultNetModeIfBlank` function to set the
default network-mode on Linux. Windows did not have a default network,
but did require a separate `ValidateNetMode` implemenation.

The `ContainerConfigWrapper` was expanded to include `NetworkingConfig`
in 2bb3fc1bc5 for API [v1.22], but did
not involve backward-compatiblity / conversion code.

Based on the above, all conversion code present in runconfig is related
to API versions [v1.18] or before. 19a04efa2f,
and other commits in [moby PR 47155] removed support for API < v1.24, so
this conversion code is no longer needed.

This patch removes the legacy fields from the `ContainerConfigWrapper`,
and removes the corresponding conversion code. The `InnerHostConfig` field
is also renamed, as it is no longer shadowed by the `container.HostConfig`
that was embedded for backward-compatibility.

[v1.18]: 837eec064d/api/common.go (L18)
[v1.19]: 767df67e31/api/common.go (L20)
[v1.22]: 2bb3fc1bc5/api/common.go (L21)
[moby PR 47155]: https://github.com/moby/moby/pull/47155
[ContainerHostConfigFromJob]: 837eec064d/runconfig/hostconfig.go (L149-L162)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 00:26:45 +02:00
Sebastiaan van Stijn
37f4616751 integration-cli: fix TestCreateWithTooLowMemoryLimit: using deprecated API fields
This test was depending on top-level fields that were deprecated since
API v1.18. These fields are no longer sent by current clients.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-17 00:26:31 +02:00
Sebastiaan van Stijn
964aba696c libnetwork: windows/overlay: remove endpointRequest wrapper
This wrapper is now a plain alias for hcsshim.HNSEndpointRequest, so let's
remove the extra abstraction.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 19:02:18 +02:00
Sebastiaan van Stijn
c316ed0c22 libnetwork: remove special handling for Windows 14393 (RS1, V1607, LTSC2016)
This synchronisation was added in [libnetwork@0a61693]:

> Adding synchronization around peerAdd and peerDelete to prevent network
> connectivity issue
>
> When multiple networks are present in a Swarm Cluster, multiple peerAdd
> or peerDelete calls are an issue for different remote endpoints. These
> threads are updating the remote endpoint to HNS parallelly. In 2016 HNS
> code base, we don't have synchronization around remoteEndpoint addition
> and deletion. So serializing the peerAdd and peerDelete calls from docker
> network driver.

We no longer support and test Windows 2016, as it reached EOL / end of
[standard support][1], so we can remove this special condition.

[libnetwork@0a61693]: c90114ce7c
[1]: https://en.wikipedia.org/wiki/Windows_10,_version_1607

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 18:59:21 +02:00
Akihiro Suda
ec4bac431c Merge pull request #47999 from thaJeztah/deprecate_pkg_dmesg
pkg/dmesg: deprecate, and use internal utility instead
2024-06-17 01:50:53 +09:00
Akihiro Suda
ff652c82e9 Merge pull request #48001 from thaJeztah/pkg_archive_deprecate_CanonicalTarNameForPath
pkg/archive: deprecate CanonicalTarNameForPath
2024-06-17 01:50:21 +09:00
Akihiro Suda
19257effaa Merge pull request #48002 from thaJeztah/pkg_archive_deprecate_TempArchive
pkg/archive: deprecate NewTempArchive, TempArchive
2024-06-17 01:49:58 +09:00
Sebastiaan van Stijn
3108165c94 pkg/archive: TestChangesDirsEmpty, TestChangesDirsMutated: no kernel-version check
TestChangesDirsEmpty and TestChangesDirsMutated fail on Windows V19H1 (1903)
and up, possibly due to changes in the kernel:

    === FAIL: github.com/docker/docker/pkg/archive TestChangesDirsEmpty (0.21s)
    changes_test.go:261: Reported changes for identical dirs: [{\dirSymlink C}]

    === FAIL: github.com/docker/docker/pkg/archive TestChangesDirsMutated (0.14s)
    changes_test.go:391: unexpected change "C \\dirSymlink" "\\dirnew"

commit 8f4b3b0ad4 added a version-dependent
skip for those tests, but as we no longer run CI on versions before V19H1,
we can remove the kernel-version check, and skip it on Windows unconditionally.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 18:40:50 +02:00
Sebastiaan van Stijn
17ca8b62bd pkg/archive: remove uses of iota
While using iota can be convenient, it can also make it harder to grasp
what value is assigned. Use of iota also makes changing values implicit;
changing the order of these consts implicitly means their value changes.

This can be problematic, as some of these consts are a plain `int` and
while golang is strong-typed, it does allow plain `int` values to be
used for such values.

For example, `archive.Tar` accepts a `Compression` as second argument,
but allows a plain int to be passed, so both of these are equivalent;

    archive.Tar(contextDir, archive.Uncompressed)
    archive.Tar(contextDir, 0)

This patch removes the use of `iota`, and instead explicitly setting a
value for each to prevent accidental changes in their value, which can
be hard to discover.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 17:14:49 +02:00
Sebastiaan van Stijn
94caeeb401 pkg/archive: don't call system.Lgetxattr on unsupported platforms
[pkg/system.Lgetxattr] is only implemented on Linux, and always produces
an ErrNotSupportedPlatform on other platforms.

This patch removes the call to this function, but intentionally leaves
it commented-out as a reminder to include this code if this would ever
be refactored and implemented on other platforms.

[pkg/system.Lgetxattr]: d1273b2b4a/pkg/system/xattrs_unsupported.go (L1-L8)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 17:14:49 +02:00
Sebastiaan van Stijn
c565a3a1fe pkg/archive: collectFileInfo: don't create FileInfo if unused
The system.Lstat may fail, in which case it would be discarded,
so let's move it later.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 17:14:49 +02:00
Sebastiaan van Stijn
7ce1edd7c6 pkg/archive: deprecate NewTempArchive, TempArchive
These were added in baacae8345, but are
currently only used in tests inside pkg/archive. There are no external
users of this function, so we should deprecated them.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 17:07:47 +02:00
Sebastiaan van Stijn
92b8d93f47 pkg/archive: deprecate CanonicalTarNameForPath
Commit d59758450b changed this function to
be a wrapper for `filepath.ToSlash`. It was used in the CLI for the classic
builder, but is no longer used in our codebase.

However, there may still be some consumers that copied the CLI code for the
classic builder that didn't synchronise their implementation yet, so let's
deprecate this function to give them a warning that they should no longer
use this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 16:56:25 +02:00
Sebastiaan van Stijn
0ffc0c95e6 pkg/tarsum: format #nosec comments to standard format
gosec uses a non-standard format for "automated" comments to suppress
false positives (such comments should not have a leading space, but
are not allowed to start with a non-alphabetical character). However,
current versions of gosec do allow a leading space.

This patch reformats the comments to prevent them from being changed
by IDEs when reformating code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 14:31:27 +02:00
Sebastiaan van Stijn
cb19b59b65 pkg/archive: format #nosec comments to standard format
gosec uses a non-standard format for "automated" comments to suppress
false positives (such comments should not have a leading space, but
are not allowed to start with a non-alphabetical character). However,
current versions of gosec do allow a leading space.

This patch reformats the comments to prevent them from being changed
by IDEs when reformating code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 14:31:18 +02:00
Sebastiaan van Stijn
805ccd2365 pkg/dmesg: deprecate, and use internal utility instead
This package was originally added in 46833ee1c3
for use in the devicemapper graphdriver. The devicemapper graphdriver was
deprecated and has been removed. The only remaining consumer is an integration
test.

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

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 12:41:39 +02:00
Sebastiaan van Stijn
c7f4abc14a pkg/dmesg: use unix.SYSLOG_ACTION_READ_ALL instead of local variable
This value was originally added in 46833ee1c3,
at which time golang.org/x/sys/unix didn't have utilities for this syscall.
A later patch switched the implementation to use the golang/x/sys/unix
implementation in 2841b05b71, but kept the
local variable.

golang.org/x/sys now has a const for this, so let's use it.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-16 12:41:39 +02:00
Sebastiaan van Stijn
d1273b2b4a Merge pull request #46809 from dperny/add-exec-option-to-tmpfs
Rebase #36720 "Add exec option to tmpfs"
2024-06-15 22:32:59 +02:00
andrew
528ffa9cae Allow multiple macvlan networks to share a parent
The only case where macvlan interfaces are unable to share a parent is
when the macvlan mode is passthru. This change tightens the check to
that situation.

It also makes the error message more specific to avoid suggesting that
sharing parents is never correct.

Signed-off-by: Andrew Baxter <423qpsxzhh8k3h@s.rendaw.me>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-15 19:42:11 +02:00
Sebastiaan van Stijn
9389f76f6d pkg/chrootarchive: remove dependency on pkg/longpath
Copy the function to the package, so that we don't have a dependency
on pkg/longpath.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-15 17:32:08 +02:00
Sebastiaan van Stijn
f657a75bf6 pkg/archive: remove dependency on pkg/longpath
Copy the function to the package, so that we don't have a dependency
on pkg/longpath.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-15 17:30:13 +02:00
Sebastiaan van Stijn
2100a70741 pkg/stringid: deprecate IsShortID
This function is no longer used, and has no external users. Deprecated
the function and mark if for removal for the next release.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-15 15:35:07 +02:00
Sebastiaan van Stijn
e19e6cf7f4 pkg/stringid: deprecate ValidateID
This function is only used for the legacy v1 image format.

Deprecate the function, and make image/v1 self-contained.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-15 15:34:38 +02:00
Sebastiaan van Stijn
0fb6360fa7 builder/dockerfile: createDestInfo: remove platform arg (LCOW left-over)
This was added in 7a7357dae1 as part of the
LCOW implementation. LCOW has been removed, and this option was no longer
in use because of that.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-15 14:03:01 +02:00
Sebastiaan van Stijn
c5d95fdb04 builder/dockerfile: fix some minor linting issues
- explicitly suppress some errors
- use fmt.Fprintln instead of manually appending a newline
- remove an outdated TODO; looking at the suggestion, it's not a
  realistic option

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-15 14:02:55 +02:00
Sebastiaan van Stijn
6fa6812c51 builder/dockerfile: rename vars that shadowed types and builtins
- imageMount was shadowing the imageMount type
- copy was shadowing the copy builtin
- container was shadowing the container import

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-15 14:01:46 +02:00
Sebastiaan van Stijn
074932966d builder/dockerfile: remove endsInSlash utility
It was only used in a single location, and other locations were shadowing
the function through local variables. As it's a one-liner, inlining the
code may be just as transparent.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-15 13:51:44 +02:00
Sebastiaan van Stijn
98fecb0d54 Merge pull request #47991 from corhere/healthcheck-startinterval-swarm
api: adjust health start interval on swarm update
2024-06-15 10:30:57 +02:00
Cory Snider
c8e7fcf91a api: adjust health start interval on swarm update
The health-check start interval added in API v1.44, and the start
interval option is ignored when creating a Swarm service using an older
API version. However, due to an oversight, the option is not ignored
when older API clients _update_ a Swarm service. Fix this oversight by
moving the adjustment code into the adjustForAPIVersion function used by
both the createService and updateService handler functions.

Signed-off-by: Cory Snider <csnider@mirantis.com>
2024-06-14 18:05:55 -04:00
Paweł Gronowski
ba69bd9c1e Merge pull request #47984 from akerouanton/daemon-restore-clear-net-state
daemon: restore: clear net state for stopped containers
2024-06-14 21:36:52 +02:00
Arash Deshmeh
dd1ca95ef9 Add exec option to API TmpfsOptions
Includes two commits from Arash Deshmeh:

add exec option to API TmpfsOptions and the related volume functions

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>

feature: daemon handles tmpfs mounts exec option

Signed-off-by: Arash Deshmeh <adeshmeh@ca.ibm.com>

Updated by Drew Erny

Signed-off-by: Drew Erny <derny@mirantis.com>
2024-06-14 12:11:20 -05:00
Albin Kerouanton
c467e4f08d Merge pull request #47989 from robmry/ipv6_bridge_route_noerrlog
Don't log an error about route-add for IPv6 bridge
2024-06-14 18:50:20 +02:00
Albin Kerouanton
07053a0991 testutil/daemon: Wait() until the daemon is Kill()'ed
`Daemon.Kill()` was sending a SIGKILL to the daemon process but wasn't
waiting until the process was really killed. While the race window is
really small, better safe than sorry.

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

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

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

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

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

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

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-14 18:35:31 +02:00
Rob Murray
17a59a7506 Don't log an error about route-add for IPv6 bridge
setupBridgeIPv6 attempts to add a route to a new network while
the bridge device is 'down', so it always fails (and the route
is added anyway when the bridge is set 'up').

I'm almost sure the RouteAdd can be removed but, this close to
the moby 27.0 release, only sure-enough to demote the log message
from error to debug.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-14 16:34:23 +01:00
Paweł Gronowski
34c3569768 Merge pull request #47985 from vvoland/bk-patchimageconfig-panic
builder/mobyexporter: Add missing nil check
2024-06-14 17:05:21 +02:00
Albin Kerouanton
1882da852e Merge pull request #47906 from akerouanton/libnet-add-otel-spans-v3
api, daemon, libnet: Create OTel spans at various places
2024-06-14 17:03:56 +02:00
Albin Kerouanton
57c6a5e691 libnet: SetKey: propagate traces from API to SetKey reexec
The `Sandbox.SetKey()` method is called through an OCI prestart hook
which then calls back the daemon through a UNIX socket. This method is
responsible for provisioning interfaces, etc... into the sandbox.

A new EnvironCarrier is used to propagate the trace context to the
prestart hook, which then marhsals an OTel MapCarrier into the JSON
payload sent back to the daemon. That way, every spans created from
`SetKey()` are correctly parented to the original `ContainerStart` API
call.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-14 15:25:08 +02:00
Albin Kerouanton
b7186bdfc8 libnet: Sandbox: add ctx to SetKey
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-14 15:25:08 +02:00
Albin Kerouanton
6c71ebd82c libcontainerd: Start: add ctx
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-14 15:25:07 +02:00
Albin Kerouanton
2d8c4265c7 libcontainerd: NewTask: add ctx
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-14 15:25:07 +02:00
Albin Kerouanton
19f72d6fc4 libnet: add more OTel spans
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-14 15:25:07 +02:00
Albin Kerouanton
224d7291df container: add a span to CheckpointTo
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-14 15:25:07 +02:00
Paweł Gronowski
642242a26b builder/mobyexporter: Add missing nil check
Add a nil check to handle a case where the image config JSON would
deserialize into a nil map.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-14 15:25:04 +02:00
Sebastiaan van Stijn
076c976e28 Merge pull request #47981 from gtomitsuka/move-debug-to-dockerd
cli/debug: move to "cmd/dockerd/debug"
2024-06-14 09:53:34 +02:00
Gabriel Tomitsuka
44f19518f9 move the cli/debug package to cmd/dockerd/debug
Signed-off-by: Gabriel Tomitsuka <gabriel@tomitsuka.com>
2024-06-13 21:53:44 +00:00
Sebastiaan van Stijn
078c3a237c Merge pull request #47979 from thaJeztah/gofmt_builder
builder/builder-next: gofmt
2024-06-13 23:35:04 +02:00
Sebastiaan van Stijn
fef34669f6 Merge pull request #47976 from thaJeztah/bump_runc_1.1.13
update runc binary and vendor to v1.1.13
2024-06-13 23:06:31 +02:00
Sebastiaan van Stijn
e4e40558ba builder/builder-next: gofmt
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 21:50:12 +02:00
Gabriel Tomitsuka
88e5e4cfb4 Prevent data race during version negotiation
Signed-off-by: Gabriel Tomitsuka <gabriel@tomitsuka.com>
2024-06-13 19:37:11 +00:00
Sebastiaan van Stijn
9101392309 update runc binary to v1.1.13
Update the runc binary that's used in CI and for the static packages.

full diff: https://github.com/opencontainers/runc/compare/v1.1.12...v1.1.13

Release notes:

* If building with Go 1.22.x, make sure to use 1.22.4 or a later version.

* Support go 1.22.4+.
* runc list: fix race with runc delete.
* Fix set nofile rlimit error.
* libct/cg/fs: fix setting rt_period vs rt_runtime.
* Fix a debug msg for user ns in nsexec.
* script/*: fix gpg usage wrt keyboxd.
* CI fixes and misc backports.
* Fix codespell warnings.

* Silence security false positives from golang/net.
* libcontainer: allow containers to make apps think fips is enabled/disabled for testing.
* allow overriding VERSION value in Makefile.
* Vagrantfile.fedora: bump Fedora to 39.
* ci/cirrus: rm centos stream 8.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 21:25:10 +02:00
Sebastiaan van Stijn
ec24e19d69 vendor: github.com/opencontainers/runc v1.1.13
full diff: https://github.com/opencontainers/runc/compare/v1.1.12...v1.1.13

Release notes:

* If building with Go 1.22.x, make sure to use 1.22.4 or a later version.

* Support go 1.22.4+.
* runc list: fix race with runc delete.
* Fix set nofile rlimit error.
* libct/cg/fs: fix setting rt_period vs rt_runtime.
* Fix a debug msg for user ns in nsexec.
* script/*: fix gpg usage wrt keyboxd.
* CI fixes and misc backports.
* Fix codespell warnings.

* Silence security false positives from golang/net.
* libcontainer: allow containers to make apps think fips is enabled/disabled for testing.
* allow overriding VERSION value in Makefile.
* Vagrantfile.fedora: bump Fedora to 39.
* ci/cirrus: rm centos stream 8.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 21:25:06 +02:00
Sebastiaan van Stijn
ff5cc18482 Merge pull request #47977 from thaJeztah/bump_runc_deps
vendor: golang.org/x/sys v0.19.0, golang.org/x/crypto v0.22.0, golang.org/x/net v0.24.0
2024-06-13 21:11:12 +02:00
Sebastiaan van Stijn
7106a96be2 Merge pull request #47973 from thaJeztah/fix_gocompat
Add more go:build statements to prevent downgrading Go language version, and update to go1.21
2024-06-13 20:54:45 +02:00
Tianon Gravi
b5bc84119e Merge pull request #47960 from robmry/dev_container_ip6_tables
Dev container: try to load kernel module ip6_tables
2024-06-13 11:22:45 -07:00
Sebastiaan van Stijn
d20739b6fe vendor: golang.org/x/net v0.24.0
no changes in vendored files

full diff: https://github.com/golang/net/compare/v0.23.0...v0.24.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 17:48:51 +02:00
Sebastiaan van Stijn
535898dd9a vendor: golang.org/x/crypto v0.22.0
full diff: https://github.com/golang/crypto/compare/v0.21.0...v0.22.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 17:48:03 +02:00
Sebastiaan van Stijn
4b2aa9f875 vendor: golang.org/x/sys v0.19.0
full diff: https://github.com/golang/sys/compare/v0.18.0...v0.19.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 17:47:00 +02:00
Albin Kerouanton
cec0d50361 libnet: add ctx to Sandbox.Destroy()
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-13 17:13:43 +02:00
Albin Kerouanton
af23a024a1 libnet: Endpoint: add ctx to Join and Leave
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-13 17:00:05 +02:00
Albin Kerouanton
566026af8f libnet: Controller: add ctx to store methods
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-13 16:59:05 +02:00
Albin Kerouanton
9391052700 libnet: Add ctx to NewSandbox
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-13 16:52:48 +02:00
Albin Kerouanton
4924f56e7b libnet/driverapi: Add ctx to ProgramExternalConnectivity
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-13 16:51:55 +02:00
Albin Kerouanton
c5c1d133ef libnet/driverapi: Add ctx to Join
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-13 16:45:54 +02:00
Albin Kerouanton
8dcded102e libnet: add OTel spans to CreateEndpoint
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-13 16:45:31 +02:00
Sebastiaan van Stijn
450f18d3ca Merge pull request #47971 from thaJeztah/vendor_no_gocompat
hack/vendor.sh: remove redundant  -compat 1.18
2024-06-13 15:13:18 +02:00
Sebastiaan van Stijn
cf376170ed Add more go:build statements to prevent downgrading Go language version
Looks like some packages fail in go module mode, because they require
recent Go versions:

    GO111MODULE=on go test -v
    # github.com/docker/docker/libnetwork/ipamutils
    ../../libnetwork/ipamutils/utils.go:46:9: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/ipamutils/utils.go:51:9: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    # github.com/docker/docker/libnetwork/portallocator
    ../../libnetwork/portallocator/portallocator.go:179:7: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    # github.com/docker/docker/libnetwork/netutils
    ../../libnetwork/netutils/utils_linux.go:66:14: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/netutils/utils_linux.go:75:2: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    # github.com/docker/docker/api/server/router/grpc
    ../../api/server/router/grpc/grpc.go:56:48: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)
    # github.com/docker/docker/container
    ../../container/view.go:335:47: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)

    # github.com/docker/docker/libnetwork/ipams/defaultipam
    ../../libnetwork/ipams/defaultipam/address_space.go:33:2: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/ipams/defaultipam/address_space.go:53:2: clear requires go1.21 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/ipams/defaultipam/address_space.go:124:10: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/ipams/defaultipam/address_space.go:125:21: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/ipams/defaultipam/address_space.go:146:22: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/ipams/defaultipam/address_space.go:310:14: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/ipams/defaultipam/address_space.go:311:22: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    # github.com/docker/docker/libnetwork/drivers/bridge
    ../../libnetwork/drivers/bridge/port_mapping_linux.go:76:15: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)
    ../../libnetwork/drivers/bridge/port_mapping_linux.go:201:2: implicit function instantiation requires go1.18 or later (-lang was set to go1.16; check go.mod)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 14:59:54 +02:00
Sebastiaan van Stijn
b7d5a42168 Update go:build comments to go1.21
Match the minimum version that's specified on our vendor.mod.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 14:59:54 +02:00
Sebastiaan van Stijn
c0c0bed9ab Merge pull request #47970 from thaJeztah/replace_compatcontext
remove internal/compatcontext and use context instead
2024-06-13 14:43:29 +02:00
Sebastiaan van Stijn
5343c7b451 remove internal/compatcontext and use context instead
This internal package was added in f6e44bc0e8
to preserve compatibility with go1.20 and older. At the time, our vendor.mod
still had go1.18 as minimum version requirement (see [1]), which got updated to go1.20
in 16063c7456, and go1.21 in f90b03ee5d

The version of BuildKit we use already started using context.WithoutCancel,
without a fallback, so we no longer can provide compatibility with older
versions of Go, which makes our compatiblity package redundant.

This patch removes the package, and updates our code to use stdlib's context
instead.

[1]: f6e44bc0e8/vendor.mod (L7)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 13:29:39 +02:00
Sebastiaan van Stijn
13c3384303 hack/vendor.sh: remove redundant -compat 1.18
This was added to use a specific format for the vendor.mod/go.mod
file, but we should no longer need this, as go1.21 is now the
minimum.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-13 13:24:07 +02:00
Albin Kerouanton
f20fd3c8a0 golangci-lint: ignore ineffassign & staticcheck on ctx shadowing
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-13 11:29:35 +02:00
Rob Murray
52333f3a34 Merge pull request #47871 from robmry/portmapper_fixes_and_nonat
Portmapper improvements, and options to disable NAT
2024-06-13 09:12:53 +01:00
Rob Murray
09777ade5a Merge pull request #47963 from robmry/47773_remove_ipv6_disable_escape_hatch
Remove ipv6 disable escape hatch
2024-06-12 19:13:31 +01:00
Rob Murray
d0790fd03e Trivial tidying in osl.setIPv6()
- Removed unnecessary variable 'enable'.
- Replaced a couple of fmt's with string concatenation.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-12 16:53:15 +01:00
Rob Murray
b7f1036cd9 Remove the option to ignore failure to disable ipv6
26.1.1 added env var DOCKER_ALLOW_IPV6_ON_IPV4_INTERFACE to make it
possible to create an IPv4-only network, even with a read-only
"/proc/sys/net" that meant IPv6 could not be disabled on an
interface.

In 27.0 it's easier to enable IPv6, just '--ipv6' when creating the
network - in particular, there's no need to allocate a subnet, because
a unique-local prefix will be assigned by default).

So, this change removes the env-var workaround. Now, the workarounds
are to enable IPv6, mount "/proc/sys/net" read-write, disable IPv6
by default in OS configuration, or remove support for IPv6 from the
kernel.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-12 16:28:29 +01:00
Rob Murray
44d00e3b9b Dev container: try to load kernel module ip6_tables
On an nftables host, the ip6_tables kernel module may not be loaded,
but it needs to be for dockerd to run (with ip6tables now enabled by
default).

If ip6tables doesn't work, try the dind official image's trick for
loading the module using "ip link show".

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-12 14:34:20 +01:00
Sebastiaan van Stijn
4fec999c11 Merge pull request #47956 from thaJeztah/cleanup_getDefaultNetworkSettings
daemon: cleanup getDefaultNetworkSettings
2024-06-12 13:47:55 +02:00
Paweł Gronowski
bcd280a3ed Merge pull request #47959 from vvoland/buildkit-update
Dockerfile: update buildx to v0.15.0
2024-06-12 10:35:59 +02:00
Paweł Gronowski
d0a135772e Dockerfile: update buildx to v0.15.0
- 0.15.0 release notes: https://github.com/docker/buildx/releases/tag/v0.15.0

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-12 09:42:18 +02:00
Sebastiaan van Stijn
c6b12f72a0 Merge pull request #47954 from tonistiigi/update-buildkit-v0.14.0
vendor: update buildkit to v0.14.0
2024-06-11 23:46:56 +02:00
Sebastiaan van Stijn
215410316f daemon: cleanup getDefaultNetworkSettings
Small cleanup of this function;

- change to a regular function, as it does not depend on the daemon
- use an early return
- explicitly refer to EndpointSettings.EndpointSettings, not the top-
  level EndpointSettings.
- use a struct-literal.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-11 23:40:35 +02:00
Rob Murray
01eecb6cdf Validate port bindings for gateway_mode=routed
When bridge driver opt com.docker.network.bridge.gatway_mode_ipv[46]
is set to "routed", there is no NAT.

When there's no NAT, there's no meaning to the HostPort field in a
port mapping (all the port mapping does is open the container's port),
and the HostIP field is only used to determine the address family.

So, check port bindings, and raise errors if fields are unexpectedly
set when the mapping only applies to a gateway_mode=routed network.
Zero-addresses are allowed, to say the mapping/open-port should be
IPv4-only or IPv6-only, and host ports are not allowed.

A mapping with no host address, so it applies to IPv4 and IPv6 when
the default binding is 0.0.0.0, may include a host port if either
uses NAT. The port number is ignored for the directly-routed family.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-11 22:33:58 +01:00
Rob Murray
2a291c1855 Improve PortBinding.String()
Display a PortBinding in a format that's more like the one
used in the CLI, but includes the container IP if known.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-11 22:33:58 +01:00
Rob Murray
a1f8bbeeef Remove unused bridge.driver.portAllocator
It was added so that tests could replace it before it was picked
up and used by a new network's PortMapper, so that tests were isolated
from each other. Now the PortMapper is not used by the bridge driver,
neither is driver's portAllocator.

Instead of replacing the driver.portAllocator in tests, reset the
singleton instance using its ReleaseAll().

Un-export portallocator.NewInstance, now the tests aren't using it.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-11 22:33:58 +01:00
Rob Murray
043db3be68 Bind the same port for multiple addresses
Without this change, if a port mapping did not specify a host address
and the network was IPv6-enabled, the same port would be allocated for
mappings from '0.0.0.0' and '::'. But, if the port mapping was specified
with explicit addresses even, for example:
  -p 0.0.0.0:8080-8083:80 -p '[::]:8083-8080:80'

This change looks for port mappings that only differ in the host IP
address, and makes sure it allocates the same port for all of them. If
it can't, it fails with an error.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-11 22:33:58 +01:00
Rob Murray
20c99e4156 Option to disable NAT for IPv4/IPv6 for a bridge network.
Add bridge driver options...
  com.docker.network.bridge.gateway_mode_ipv4=<nat|routed>
  com.docker.network.bridge.gateway_mode_ipv6=<nat|routed>

If set to "routed", no NAT or masquerade rules are set up for port
mappings.

When NAT is disabled, the mapping is shown in 'inspect' output with
no host port number. For example, for "-p 80" with NAT disabled for
IPv6 but not IPv4:

    "80/tcp": [
        {
            "HostIp": "0.0.0.0",
            "HostPort": "32768"
        },
        {
            "HostIp": "::",
            "HostPort": ""
        }

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-11 22:33:58 +01:00
Tonis Tiigi
18ff5ef537 vendor: update buildkit to v0.14.0
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-11 12:08:34 -07:00
Rob Murray
e05848c002 Set up bridge-specific iptables rules in the bridge driver
Use the bridge driver's iptables types to set up portmapping related
iptables rules - instead of using iptables.Forward, which is bridge
specific code in the iptables package.

Remove iptables.Forward() and its unit test, the bridge driver's
version is covered by TestAddPortMappings.

Remove hairpinMode from iptables.ChainInfo hairpinMode relates to bridge
driver specific behaviour, that is now implemented in the bridge driver.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-11 16:50:16 +00:00
Rob Murray
4f09af6267 Allocate same port for IPv4/IPv6 for 'any interface' mappings.
The bridge driver now does its own port-mapping, rather than using the
portmapper module (which ran as two completely separate instances, for
IPv4 and IPv6).

When asked for a mapping from any host address (0.0.0.0/0) with a range
of host ports, the same port will be allocated for IPv4 and IPv6, or the
mapping will fail with an error if that's not possible.

The bridge driver now manages its own port mappings. So, remove
linux-specific PortMapper code and make what's left Windows-only.

Also, replace the portmapper.userlandProxy interface with StartProxy().

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-11 16:50:15 +00:00
Rob Murray
03577884d9 Retry port mapping for a range if ports are in-use
For a port mapping like '-p 8080-8083:80', when some non-docker process
is using a port in the range, try other ports in the range. And, don't
do that on live-restore.

Because the port mapping may fail on live-restore, leaving no ports
mapped for the endpoint - update the view of mapped ports shown in
'inspect' output. (The wrong mappings will still be shown in 'docker ps',
the container will be left running and connected to the network, it just
won't work. There's plenty of scope for better error handling here.)

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-11 16:50:15 +00:00
Rob Murray
931eea20ff Add portallocator.RequestPortsInRange()
Similar to portallocator.RequestPortInRange(), but it attempts to
allocate the same port for multiple IP addresses.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-11 16:50:15 +00:00
Sebastiaan van Stijn
87794b3030 Merge pull request #47946 from thaJeztah/remove_platforms_platform_alias
remove uses of platforms.Platform alias
2024-06-11 13:38:13 +02:00
Sebastiaan van Stijn
e0b762ed1b daemon/containerd: fix duplicate import
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-11 11:49:57 +02:00
Sebastiaan van Stijn
7f2ed139fe remove uses of platforms.Platform alias
It's an alias for the OCI-spec type, which was only there for
convenience, but will be deprecated.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-11 11:48:01 +02:00
Sebastiaan van Stijn
9d9488468f Merge pull request #47943 from vvoland/c8d-multiplatform-push-2
c8d/push: Fix small whoopsies
2024-06-10 22:14:18 +02:00
Akihiro Suda
89431adcd1 Merge pull request #47500 from AkihiroSuda/fix-47499
seccomp: allow specifying a custom profile with `--privileged`
2024-06-11 05:07:53 +09:00
Akihiro Suda
896de6d426 seccomp: allow specifying a custom profile with --privileged
`--privileged --security-opt seccomp=<CUSTOM.json>` was ignoring
`<CUSTOM.json>`.

Fix issue 47499

Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
2024-06-11 03:37:54 +09:00
Sebastiaan van Stijn
22c212d208 Merge pull request #47941 from thaJeztah/api_image_inspect_deprecate_fields
api: deprecate erroneous Config fields in `GET /images/{name}/json` response
2024-06-10 19:19:04 +02:00
Paweł Gronowski
2ccce36d10 c8d/progress: Allow updating "Unavailable" ids
They might still change to "Mounted from" or "Already exists" when
containerd updates the status in tracker.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-10 19:14:23 +02:00
Paweł Gronowski
e2326c27b5 c8d/push: Fix wrong Originalindex descriptor in aux error
The target variable was already overwritten with the new value. Use the
original value instead.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-10 19:14:21 +02:00
Sebastiaan van Stijn
0566e38cbf Merge pull request #47605 from jonasgeiler/43626-rootless-native-overlay-diff
rootless: overlay2: support native overlay diff when using rootless-mode in kernel 5.11 and above
2024-06-10 18:57:19 +02:00
Sebastiaan van Stijn
1513068d8c Merge pull request #47679 from vvoland/c8d-multiplatform-push
c8d/push: Support `--platform` switch
2024-06-10 18:38:47 +02:00
Sebastiaan van Stijn
af0cdc36c7 api: deprecate erroneous Config fields in GET /images/{name}/json response
The `Config` field returned by this endpoint (used for "image inspect") returns
additional fields that are not part of the image's configuration and not part of
the [Docker Image Spec] and the [OCI Image Spec].

These additional fields are included in the response, due to an
implementation detail, where the [api/types.ImageInspec] type used
for the response is using the [container.Config] type.

The [container.Config] type is a superset of the image config, and while the
image's Config is used as a _template_ for containers created from the image,
the additional fields are set at runtime (from options passed when creating
the container) and not taken from the image Config.

These fields are never set (and always return the default value for the type),
but are not omitted in the response when left empty. As these fields were not
intended to be part of the image configuration response, they are deprecated,
and will be removed from the API.

The following fields are currently included in the API response, but
are not part of the underlying image's Config, and deprecated:

- `Hostname`
- `Domainname`
- `AttachStdin`
- `AttachStdout`
- `AttachStderr`
- `Tty`
- `OpenStdin`
- `StdinOnce`
- `Image`
- `NetworkDisabled` (already omitted unless set)
- `MacAddress` (already omitted unless set)
- `StopTimeout` (already omitted unless set)

[Docker image spec]: https://github.com/moby/docker-image-spec/blob/v1.3.1/specs-go/v1/image.go#L19-L32
[OCI Image Spec]: https://github.com/opencontainers/image-spec/blob/v1.1.0/specs-go/v1/config.go#L24-L62
[api/types.ImageInspec]: https://github.com/moby/moby/blob/v26.1.4/api/types/types.go#L87-L104
[container.Config]: https://github.com/moby/moby/blob/v26.1.4/api/types/container/config.go#L47-L82

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 16:56:17 +02:00
Sebastiaan van Stijn
a736d0701c Merge pull request #47936 from thaJeztah/api_types_container_types
api/types: move more types to sub-packages
2024-06-10 16:51:49 +02:00
Sebastiaan van Stijn
4d40d770cd Merge pull request #47942 from thaJeztah/api_swagger_update_image_config
docs: api: use separate definition for Image.Config (api v1.39 - v1.45)
2024-06-10 16:45:52 +02:00
Sebastiaan van Stijn
58641c7b5c docs: api: use separate definition for Image.Config (api v1.39 - v1.45)
The Image.Config field currently reuses the ContainerConfig definition,
matching the Go implementation, which also uses that type.

However, the ContainerConfig type contains various fields that are not
part of the image config, and would never be set. The Image.Config is
used as template / default values for containers started from the image,
but will only use the fields that are part of the [Docker image spec].

This patch updates the swagger files used in the documentation to use a
separate `ImageConfig` definition for the Image.Config field. The new
definition is a copy of the existing `ContainerConfig` type, but with
updated descriptions for fields, and with an example response that omits
the fields that should not be used.

The following fields are currently included in the `Config` field of the API
response, but are not part of the underlying image's config:

- `Hostname`
- `Domainname`
- `AttachStdin`
- `AttachStdout`
- `AttachStderr`
- `Tty`
- `OpenStdin`
- `StdinOnce`
- `Image`
- `NetworkDisabled` (already omitted unless set)
- `MacAddress` (already omitted unless set)
- `StopTimeout` (already omitted unless set)

[Docker image spec]: https://github.com/moby/docker-image-spec/blob/v1.3.1/specs-go/v1/image.go#L19-L32

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 15:38:18 +02:00
Sebastiaan van Stijn
5e0e34fafd api: swagger: use separate definition for Image.Config
The Image.Config field currently reuses the ContainerConfig definition,
matching the Go implementation, which also uses that type.

However, the ContainerConfig type contains various fields that are not
part of the image config, and would never be set. The Image.Config is
used as template / default values for containers started from the image,
but will only use the fields that are part of the [Docker image spec].

This patch updates the swagger files used in the documentation to use a
separate `ImageConfig` definition for the Image.Config field. The new
definition is a copy of the existing `ContainerConfig` type, but with
updated descriptions for fields, and with an example response that omits
the fields that should not be used.

The following fields are currently included in the `Config` field of the API
response, but are not part of the underlying image's config:

- `Hostname`
- `Domainname`
- `AttachStdin`
- `AttachStdout`
- `AttachStderr`
- `Tty`
- `OpenStdin`
- `StdinOnce`
- `Image`
- `NetworkDisabled` (already omitted unless set)
- `MacAddress` (already omitted unless set)
- `StopTimeout` (already omitted unless set)

[Docker image spec]: https://github.com/moby/docker-image-spec/blob/v1.3.1/specs-go/v1/image.go#L19-L32

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 15:37:27 +02:00
Sebastiaan van Stijn
a24e3f2ac6 Merge pull request #47799 from j2walker/47648-dameon-health-start-interval-default-value-fix
Changed default value of the startInterval to 5s
2024-06-10 14:36:02 +02:00
Paweł Gronowski
8d96d759bb c8d/image_manifest: IsPseudoImage return true for unknown/unknown platform
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-10 13:35:17 +02:00
Paweł Gronowski
b4d2283c89 api/push: Ignore Platform on older APIs
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-10 13:35:15 +02:00
Paweł Gronowski
68a63d0611 c8d/push: Extract missing content note to an Aux progress
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-10 13:35:14 +02:00
Paweł Gronowski
0a31437208 c8d/push: Support platform selection
Add a OCI platform fields as parameters to the `POST /images/{id}/push`
that allow to specify a specific-platform manifest to be pushed instead
of the whole image index.

When no platform was requested and pushing whole index failed, fallback
to pushing a platform-specific manifest with a best candidate (if it's
possible to choose one).

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-10 13:35:13 +02:00
Paweł Gronowski
999f1c63db testutils/specialimage: Add MultiPlatform
Add utility that allows to construct an image with the specified
platforms.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-10 13:35:12 +02:00
Paweł Gronowski
c16d676266 c8d/blobsDirContentStore: Return ErrNotExists
Translate os.ErrNotExist into cerrdefs.ErrNotExists

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-10 13:35:11 +02:00
Paweł Gronowski
85249a8401 c8d/image_manifest: Add helper functions
This adds the common helper functions used by the recent
multiplatform-related PRs.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-10 13:35:10 +02:00
Jack Walker
c514952774 Changed default value of the startInterval to 5s
Co-authored-by: Sebastiaan van Stijn <github@gone.nl>
Signed-off-by: Jack Walker <90711509+j2walker@users.noreply.github.com>
2024-06-10 13:23:26 +02:00
Paweł Gronowski
ac064904b8 Merge pull request #47927 from crazy-max/ci-buildkit-debug
ci: enable debug for buildkit container builder
2024-06-10 11:57:41 +02:00
Sebastiaan van Stijn
04110fa774 Merge pull request #47919 from laurazard/fix-deprecated-otel
otel: remove deprecated usages of `otelgrpc`
2024-06-10 11:53:26 +02:00
Sebastiaan van Stijn
6e514e8993 Merge pull request #47932 from thaJeztah/reexec_clean
pkg/reexec: cleanup and remove some dependencies
2024-06-10 11:31:01 +02:00
Sebastiaan van Stijn
aa22d137e9 Merge pull request #47937 from thaJeztah/client_fix_test_typos
client: fix typos in test-names and godoc
2024-06-10 10:37:28 +02:00
Sebastiaan van Stijn
b6ee4b66ad Merge pull request #47931 from thaJeztah/graphdriver_remove_Mounted
daemon/graphdriver: remove redundant Mounted function
2024-06-10 10:22:11 +02:00
Sebastiaan van Stijn
6c2934f373 api/types: move ImageLoadResponse to api/types/image
This moves the type, but we should consider removing this type, and just
returning an io.ReadCloser

This type was added in 9fd2c0feb0c131d01d727d50baa7183b976c7bdc;

> Make docker load to output json when the response content type is json
> Swarm hijacks the response from docker load and returns JSON rather
> than plain text like the Engine does. This makes the API library to return
> information to figure that out.

However the "load" endpoint unconditionally returns JSON;
7b9d2ef6e5/api/server/router/image/image_routes.go (L248-L255)

Commit 96d7db665b made the response-type depend
on whether "quiet" was set, but this logic got changed in a follow-up
2f27632cde, which made the JSON response-type
unconditionally, but the output produced depend on whether"quiet" was set.

We should deprecated the "quiet" option, as it's really a client
responsibility.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:21:25 +02:00
Sebastiaan van Stijn
eb675cce71 api/types: move ImageImportSource to api/types/image
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:21:25 +02:00
Sebastiaan van Stijn
f6cc76ceb9 api/types: move ImageSearchOptions to api/types/registry
Note that RequestPrivilegeFunc could not be referenced, as it would
introduce a circular import, so copying the definition instead.

Also combining the other search-related types in the package to be in
the same file.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:21:24 +02:00
Sebastiaan van Stijn
b5f15bc0aa api/types: move EventsOptions to api/types/events
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:21:24 +02:00
Sebastiaan van Stijn
ecb24afaaf api/types: move ImagesPruneReport to api/types/image
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:21:24 +02:00
Sebastiaan van Stijn
162ef4f8d1 api/types: move VolumesPruneReport to api/types/volume
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:21:24 +02:00
Sebastiaan van Stijn
17c3269a37 api/types: move ContainerStats to api/types/container
This is the response type; other types related to stats are left
for now, but should be moved (as well as utilities ported from
the CLI repository).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:21:22 +02:00
Sebastiaan van Stijn
fd1d8f323b api/types: move CopyToContainerOptions to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:20:47 +02:00
Sebastiaan van Stijn
47d7c9e31d api/types: move ContainerPathStat to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:20:45 +02:00
Sebastiaan van Stijn
db2f1acd5d api/types: move ContainersPruneReport to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:19:47 +02:00
Sebastiaan van Stijn
5b27e71521 api/types: move ContainerExecInspect to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:19:46 +02:00
Sebastiaan van Stijn
d91638e295 api/types: move ExecStartCheck to api/types/container
This moves the type to api/types/container and creates an alias for
exec attach; ContainerExecAttach currently uses the same type as
ContainerExecStart, but does not all the same options (and some
options cannot be used).

We need to split the actual types, but lets start with aliasing.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:19:46 +02:00
Sebastiaan van Stijn
452e134001 api/types: move ExecStartOptions to api/types/backend
It's a type used by the backend, so moving it there.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:19:46 +02:00
Sebastiaan van Stijn
cd76e3e7f8 api/types: move ExecConfig to api/types/container
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-10 10:19:46 +02:00
Paweł Gronowski
3d2ee590a0 Merge pull request #47935 from thaJeztah/remove_TestContainerAPICopyNotExistsAnyMore
integration-cli: remove DockerAPISuite.TestContainerAPICopyNotExistsAnyMore
2024-06-10 10:18:00 +02:00
Sebastiaan van Stijn
8c34c63d81 Merge pull request #47939 from thaJeztah/api_remove_container_containerconfig
docs: api: image inspect: remove Container and ContainerConfig
2024-06-10 10:06:08 +02:00
Sebastiaan van Stijn
3434a8ef6e Merge pull request #47938 from thaJeztah/vendor_pty
vendor: github.com/creack/pty v1.1.21
2024-06-10 10:05:43 +02:00
Sebastiaan van Stijn
e314cbdab8 Merge pull request #47862 from thaJeztah/exec_router_nits
api/server/router/container: minor nits in exec router
2024-06-10 10:05:18 +02:00
Sebastiaan van Stijn
ac27a5379b docs: api: image inspect: remove Container and ContainerConfig
The Container and ContainerConfig fields have been deprecated, and removed
since API v1.45 in commit 03cddc62f4.

This patch fixes the swagger and documentation to no longer mention them
as they are no longer returned by API v1.45 and higher.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-09 23:17:37 +02:00
Sebastiaan van Stijn
52580b2673 vendor: github.com/creack/pty v1.1.21
full diff: https://github.com/creack/pty/compare/v1.1.18...v1.1.21

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-09 22:39:33 +02:00
Sebastiaan van Stijn
fa95f8a070 client: fix typos in test-names and godoc
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-09 22:35:04 +02:00
Sebastiaan van Stijn
311c949871 Merge pull request #47731 from racequite/master
chore: fix function names in comment
2024-06-09 22:33:09 +02:00
Akihiro Suda
7b9d2ef6e5 Merge pull request #47934 from thaJeztah/vendor_reference_0.6
vendor: github.com/distribution/reference v0.6.0
2024-06-09 05:15:13 +09:00
Akihiro Suda
59875a9218 Merge pull request #47933 from thaJeztah/bump_bbolt_1.3.10
vendor: go.etcd.io/bbolt v1.3.10
2024-06-09 05:14:57 +09:00
Sebastiaan van Stijn
08939f21ad integration-cli: remove DockerAPISuite.TestContainerAPICopyNotExistsAnyMore
This test was added in 428328908dc529b1678fb3d8b033fb0591a294e3;

> Deprecate /containers/(id or name)/copy endpoint
> This endpoint has been deprecated since 1.8. Return an error starting
> from this API version (1.24) in order to make sure it's not used for the
> next API version and so that we can remove it sometimes later.

We deprecated and removed those older API versions, and the test was
effectively only verifying that a non-existing endpoint returns a 404,
so let's remove it.

This also removes api/types.CopyConfig, which was only used in this
test.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-08 21:00:25 +02:00
Sebastiaan van Stijn
75843620a6 api/server/router/container: minor nits in exec router
- remove intermediate variable
- format a "todo" comment as an actual todo ':)
- explicitly suppress some unhandled errors to keep linters happy

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-08 20:54:38 +02:00
Sebastiaan van Stijn
18e1afd1a1 vendor: github.com/distribution/reference v0.6.0
full diff: https://github.com/distribution/reference/compare/v0.5.0...v0.6.0

- remove deprecated SplitHostname
- refactor splitDockerDomain to include more documentation
- fix typo in readme
- Exclude domain from name length check

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-08 17:51:50 +02:00
Sebastiaan van Stijn
7529e95f6f Merge pull request #47918 from robmry/allow_startup_with_no_ip6tables
Allow startup with no kernel support for ip6_tables
2024-06-08 16:10:54 +02:00
Sebastiaan van Stijn
7501b90a22 vendor: go.etcd.io/bbolt v1.3.10
- Remove deprecated UnsafeSlice and use unsafe.Slice
- Stabilize the behaviour of Prev when the cursor already points to
  the first element
    - Fix Cursor.Prev() out of range issues in v1.3.9
    - Relates to boltdb/bolt/issues/357 (Cursor inconsistent when mixing
      cursor.Delete() with Put() in same transaction)
- Bump go version to 1.21.9

full diff: https://github.com/etcd-io/bbolt/compare/v1.3.9...v1.3.10

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-08 15:16:45 +02:00
Sebastiaan van Stijn
cf796aa56a pkg/reexec: touch-up GoDoc, and remove "import" comments
Touch-up some GoDoc in the package, and remove "import" comments.

This package is used in BuildKit, and could be a potential candidate
for moving to a separate module. The "import" comments are ignored when
used in go module mode so have little benefit. Let's remove them.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-08 14:18:13 +02:00
Sebastiaan van Stijn
d20a074f33 pkg/reexec: remove gotest.tools from tests
This package is used in BuildKit, and could be a potential candidate
for moving to a separate module. While it's not too problematic to have
this dependency, the tests only used basic assertions from gotest.tools,
which could be easily re-implemented without the dependency.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-08 14:18:12 +02:00
Sebastiaan van Stijn
defd5a08f4 pkg/reexec: unify non-Linux implementation of Command
The Windows, Darwin, and FreeBSD implementations were identical, other
than their GoDoc to be different. Unify them so that we don't have to
maintain separate GoDoc for each.

It's worth noting that FreeBSD also supports Pdeathsig, so could be
using the same implementation as Linux. However, we don't test/maintain
the FreeBSD implementation, and it would require updating to GoDoc to
be more specific about the use of `/proc/self/exe`, so keeping the
status quo for now.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-08 14:18:12 +02:00
Sebastiaan van Stijn
004451c812 pkg/reexec: unify implementation of Self() and remove stub
This combines the implementations of the Self function, to allow having
a single GoDoc to document the behavior. The naiveSelf function is kept,
because it's used in unit-tests.

There is a minor change in behavior, as this patch removes the stub for
unsupported platforms (non-linux, windows, freebsd or darwin), which will
now use `os.Args[0]`. The stub was added in 21537b818d
to fix compilation of https://github.com/ethereum/go-ethereum on OpenBSD,
which had docker/docker as dependency. It looks like that repository no
longer has this dependency, and as this was only to make the code
compilable, is unlikely to be a problem.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-08 14:18:11 +02:00
Sebastiaan van Stijn
79bff9461c pkg/reexec: don't mix syscall and golang.org/x/sys package
commit 069fdc8a08 changed most uses of
the syscall package to switch utsname from unsigned to signed (see
069fdc8a08). Those don't seem to be
impacting the code used here, so either stdlib or golang.org/x/sys/unix
should work for this case.

I chose stdlib's syscall package for this case, in case we'd decide to
move this package to a separate module (and want to limit its dependencies).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-08 14:18:11 +02:00
Sebastiaan van Stijn
a445f7fa8a daemon/graphdriver: fix GoDoc for ProtoDriver.GetMetadata
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-08 12:20:55 +02:00
Sebastiaan van Stijn
a76b768fea daemon/graphdriver: remove redundant Mounted function
This function largely identical to GetFSMagic, except for suppressing
ENOENT errors. The only consumer of this function was fsChecker.IsMounted,
which would ignore errors either way, and only use the "success" case to
check if the detected filesystem-type was the expected one.

This patch;

- rewrites fsChecker.IsMounted to use GetFSMagic instead
- removes the now unused Mounted function

As we consider daemon/graphdriver to be "internal", and as there are no
public consumers of this, we can remove this function without deprecating
first.

The freebsd implementation also seemed to be broken, as it mixed syscall
with golang.org/x/sys/unix, which used incompatible types. I left the file
in place for now, but we can consider removing it altogether as there's no
active development on making freebsd functional.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-08 12:13:56 +02:00
Rob Murray
837b3f9576 Allow startup with no kernel support for ip6_tables
Before "ip6tables" was enabled by default, dockerd would start normally
when:
- the kernel had no IPv6 support, or
- docker is running as docker-in-docker, and the host doesn't have kernel
  module 'ip6_tables' loaded.

Now, the bridge driver will try to set up its ip6tables chains and it'll
fail. By not treating that as an error, the daemon will start and IPv4
will work normally.

A subsequent attempt to create an IPv6 network will fail with an error
about ip6tables. At that point, the user's options are:
- set "ip6tables":false in daemon config
- in the DinD case, "modprobe ip6_tables" on the host, or start dockerd
  on the host with ip6tables enabled (causing the kernel module load).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-07 17:40:38 +01:00
Sebastiaan van Stijn
4fb17cb3af Merge pull request #47928 from akerouanton/rob-maintainer
Add Rob Murray (@robmry) as maintainer
2024-06-07 17:54:39 +02:00
Albin Kerouanton
4df4f83f23 Merge pull request #47926 from akerouanton/revert-47837
Revert "libnet/i/defaultipam: Disambiguate PoolID string format"
2024-06-07 16:32:39 +02:00
Albin Kerouanton
fd3fa4b28a Add Rob Murray (@robmry) as maintainer
Rob is currently a curator, and has been actively contributing to this
repo for 7 months now.

Beside day-to-day triaging and bug fixing, Rob is an instrumental
contributor to libnetwork, and amongst other things, to the ongoing work
on IPv6 improvements.

I nominated Rob as maintainer, and votes passed, so opening a PR to make
it official.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-07 16:18:46 +02:00
Laura Brehm
854130eee0 deps: remove grpc-ecosystem/go-grpc-middleware
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-06-07 14:35:52 +01:00
Laura Brehm
49ca0d0d03 otel: remove deprecated usages of otelgrpc
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
2024-06-07 14:35:51 +01:00
Albin Kerouanton
1243f9da6d Revert "libnet/i/defaultipam: Disambiguate PoolID string format"
This reverts commit 9369132879.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-07 15:32:13 +02:00
Albin Kerouanton
6af0646236 Revert "libnet/i/defaultipam: Use InternalErrorf instead of InvalidParameterErrof"
This reverts commit 5a2fa59688.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-07 15:31:54 +02:00
CrazyMax
4aa85cd159 ci: enable debug for buildkit container builder
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com>
2024-06-07 15:30:22 +02:00
Sebastiaan van Stijn
59996a493c Merge pull request #47866 from cncal/return_container_annotations
api/server: ContainerList returns container annotations
2024-06-07 14:14:12 +02:00
Sebastiaan van Stijn
aa2c7de9b9 Merge pull request #47924 from thaJeztah/api_checkduplicates_optional
api/types/network: make CheckDuplicate optional
2024-06-07 13:35:07 +02:00
Sebastiaan van Stijn
fc9dd6acb4 api/types/network: make CheckDuplicate optional
The CheckDuplicate option is no longer part of the current API; it's
only used by the client when connecting to old API versions, which need
to have this field set.

This patch:

- Removes the CheckDuplicate from the API documentation, as the API
  describes the current version of the API (which does not have this
  field).
- Moves the CheckDuplicate field to the CreateRequest type; this is
  the type used for the network create request. The CheckDuplicate
  is not an option that's set by the user, and set internally by
  the client, so removing it from the CreateOptions struct moves
  it entirely internal.
- Change the CheckDuplicate field to be a pointer; this makes the
  "omitempty" become active, and the client will no longer include
  the field in the request JSON unless it's set (API < 1.44).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-07 12:06:39 +02:00
Sebastiaan van Stijn
f6d8ac04ba Merge pull request #47921 from thaJeztah/api_move_network_create
api/types: move NetworkCreate, NetworkCreateRequest, NetworksPruneReport to api/types/network
2024-06-07 12:06:28 +02:00
Sebastiaan van Stijn
e5f9484ab6 api/types: move NetworksPruneReport to api/types/network
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-07 11:14:52 +02:00
Sebastiaan van Stijn
ad6edc139f api/types: move NetworkCreate, NetworkCreateRequest to api/types/network
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-07 11:11:15 +02:00
Sebastiaan van Stijn
b75bca3868 Merge pull request #47922 from tonistiigi/20240606-update-buildkit
vendor: update buildkit to v0.14.0-rc2
2024-06-07 08:47:43 +02:00
Tonis Tiigi
4f61fa21cb vendor: update buildkit to v0.14.0-rc2
Signed-off-by: Tonis Tiigi <tonistiigi@gmail.com>
2024-06-06 18:59:02 -07:00
cncal
ca0529f984 api/server: ContainerList returns container annotations
Allow clients (e.g. cri-dockerd) to fetch container annotations in
ContainerList api.

Signed-off-by: cncal <flycalvin@qq.com>
2024-06-07 09:50:11 +08:00
Sebastiaan van Stijn
181e70cc07 Merge pull request #47920 from thaJeztah/bump_appengine
vendor: google.golang.org/appengine v1.6.8
2024-06-06 20:47:26 +02:00
Sebastiaan van Stijn
00f18ef7a4 Merge pull request #47867 from akerouanton/api-EnableIPv6-override
api: Make EnableIPv6 optional (impl #1 - pointer-based)
2024-06-06 20:20:29 +02:00
Sebastiaan van Stijn
6f32dc19f1 Merge pull request #47683 from vvoland/buildkit-update
vendor: github.com/moby/buildkit v0.14.0-rc2-dev
2024-06-06 16:59:14 +02:00
Sebastiaan van Stijn
b3c8216873 vendor: google.golang.org/appengine v1.6.8
removes use of the deprecated "golang.org/x/net/context" package

full diff: https://github.com/golang/appengine/compare/v1.6.7...v1.6.8

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-06 15:28:58 +02:00
Paweł Gronowski
0b5f7b9ff8 builder-next: Adjust NewGatewayFrontend invocation
b5c50afa882e2b34aba880fd5028615e2ef94e07 changed the signature of
NewGatewayFrontend to include a slice of allowed repositories.

Docker does not allow to specify this option, so don't place any
restrictions by passing an empty slice.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-06 11:20:18 +02:00
Jonathan A. Sternberg
fa03db1b82 builder: Update detect usage for new detect API from buildkit
Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-06 11:20:17 +02:00
Paweł Gronowski
995604236e builder: Adjust usage of shlex.ProcessWord
1b1c5bc08ad81add007eb647e66ed0929693f3a0 extended the function signature
with one additional return value.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-06 11:20:16 +02:00
Paweł Gronowski
438371e1fe builder: Pass nil linter to instructions.Parse
eea0b41bf4fb1d69e109ff5ff8045c63f0c0d510 added a new argument to
`instructions.Parse` to support issuing linter warnings.

Classic builder uses it to parse the Dockerfile instructions and its
usage needs adjustment.

The classic builder is deprecated and we won't be adding any new
features to it, so we just pass a nil linter callback.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-06 11:20:15 +02:00
Paweł Gronowski
3bcbb561ad vendor: update github.com/moby/buildkit to v0.14.0-rc2-dev
- full diff: https://github.com/moby/buildkit/compare/v0.13.1...v0.14.0-rc2

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-06-06 11:20:13 +02:00
Albin Kerouanton
f3f20c3a86 Merge pull request #47602 from robmry/internal_resolver_for_default_bridge
Add resolver for default bridge, remove default nameservers
2024-06-06 10:39:24 +02:00
Rob Murray
d365702dbd No default nameservers for internal resolver
Don't fall-back to Google's DNS servers in a network that has an
internal resolver.

Now the default bridge uses the internal resolver, the only reason a
network started by the daemon should end up without any upstream
servers is if the host's resolv.conf doesn't list any.  In this case,
the '--dns' option can be used to explicitly configure nameservers
for a container if necessary.

(Note that buildkit's containers do not have an internal resolver, so
they will still set up Google's nameservers if the host has no
resolvers that can be used in the container's namespace.)

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-05 20:27:24 +01:00
Rob Murray
18f4f775ed Internal resolver for default bridge network
Until now, containers on the default bridge network have been configured
to talk directly to external DNS servers - their resolv.conf files have
either been populated with nameservers from the host's resolv.conf, or
with servers from '--dns' (or with Google's nameservers as a fallback).

This change makes the internal bridge more like other networks by using
the internal resolver.  But, the internal resolver is not populated with
container names or aliases - it's only for external DNS lookups.

Containers on the default network, on a host that has a loopback
resolver (like systemd's on 127.0.0.53) will now use that resolver
via the internal resolver. So, the logic used to find systemd's current
set of resolvers is no longer needed by the daemon.

Legacy links work just as they did before, using '/etc/hosts' and magic.

(Buildkit does not use libnetwork, so it can't use the internal resolver.
But it does use libnetwork/resolvconf's logic to configure resolv.conf.
So, code to set up resolv.conf for a legacy networking without an internal
resolver can't be removed yet.)

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-06-05 20:27:24 +01:00
Albin Kerouanton
c6aaabc9fc Merge pull request #47887 from thaJeztah/move_more_network_api_types_2
api/types: migrate NetworkResource to api/types/network
2024-06-05 15:48:24 +02:00
Sebastiaan van Stijn
c5c4abbf59 Merge pull request #47909 from thaJeztah/vendor_containerd_1.7.18
vendor: github.com/containerd/containerd v1.7.18
2024-06-05 12:33:04 +02:00
Paweł Gronowski
1a4efd2c74 Merge pull request #47910 from thaJeztah/bump_containerd_binary_1.7.18
update containerd binary to v1.7.18
2024-06-05 11:56:40 +02:00
Sebastiaan van Stijn
5318c38eae update containerd binary to v1.7.18
Update the containerd binary that's used in CI and for the static packages.

- release notes: https://github.com/containerd/containerd/releases/tag/v1.7.18
- full diff: https://github.com/containerd/containerd/compare/v1.7.17...v1.7.18

Welcome to the v1.7.18 release of containerd!

The eighteenth patch release for containerd 1.7 contains various updates along
with an updated version of Go. Go 1.22.4 and 1.21.11 include a fix for a symlink
time of check to time of use race condition during directory removal.

Highlights

- Update Go version to 1.21.11
- Remove uses of platforms.Platform alias
- Migrate log imports to github.com/containerd/log
- Migrate errdefs package to github.com/containerd/errdefs
- Fix usage of "unknown" platform

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-05 10:18:42 +02:00
Paweł Gronowski
189dc1b47e Merge pull request #47902 from thaJeztah/bump_go1.21.11
update to go1.21.11
2024-06-05 10:14:19 +02:00
Sebastiaan van Stijn
86f7762d48 vendor: github.com/containerd/containerd v1.7.18
Update to containerd 1.7.18, which now migrated to the errdefs module. The
existing errdefs package is now an alias for the module, and should no longer
be used directly.

This patch:

- updates the containerd dependency: https://github.com/containerd/containerd/compare/v1.7.17...v1.7.18
- replaces uses of the old package in favor of the new module
- adds a linter check to prevent accidental re-introduction of the old package
- adds a linter check to prevent using the "log" package, which was also
  migrated to a separate module.

There are still some uses of the old package in (indirect) dependencies,
which should go away over time.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-05 09:21:00 +02:00
Sebastiaan van Stijn
91e2c29865 update to go1.21.11
go1.21.11 (released 2024-06-04) includes security fixes to the archive/zip
and net/netip packages, as well as bug fixes to the compiler, the go command,
the runtime, and the os package. See the Go 1.21.11 milestone on our issue
tracker for details;

- https://github.com/golang/go/issues?q=milestone%3AGo1.21.11+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.21.10...go1.21.11

From the security announcement;

We have just released Go versions 1.22.4 and 1.21.11, minor point releases.
These minor releases include 2 security fixes following the security policy:

- archive/zip: mishandling of corrupt central directory record

  The archive/zip package's handling of certain types of invalid zip files
  differed from the behavior of most zip implementations. This misalignment
  could be exploited to create an zip file with contents that vary depending
  on the implementation reading the file. The archive/zip package now rejects
  files containing these errors.

  Thanks to Yufan You for reporting this issue.

  This is CVE-2024-24789 and Go issue https://go.dev/issue/66869.

- net/netip: unexpected behavior from Is methods for IPv4-mapped IPv6 addresses

  The various Is methods (IsPrivate, IsLoopback, etc) did not work as expected
  for IPv4-mapped IPv6 addresses, returning false for addresses which would
  return true in their traditional IPv4 forms.

  Thanks to Enze Wang of Alioth and Jianjun Chen of Zhongguancun Lab
  for reporting this issue.

  This is CVE-2024-24790 and Go issue https://go.dev/issue/67680.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-04 23:23:27 +02:00
Albin Kerouanton
216e426ec2 Merge pull request #47901 from thaJeztah/cluster_remove_getRequestContext
daemon/cluster: remove Cluster.getRequestContext()
2024-06-04 22:18:50 +02:00
Albin Kerouanton
163c6ca9ad api: Make EnableIPv6 optional
Currently, starting dockerd with
`--default-network-opt=bridge=com.docker.network.enable_ipv6=true` has
no effect as `NetworkCreateRequest.EnableIPv6` is a basic bool.

This change makes it a `*bool` to make it optional. If clients don't
specify it, the default-network-opt will be applied.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-06-04 21:36:18 +02:00
Sebastiaan van Stijn
83c532c9b7 daemon/cluster: remove Cluster.getRequestContext()
This method was added in 534a90a993 as
part of adding the Swarm cluster backend, and later updated in commit
85b1fdf15c to use a swarmRequestTimeout
const for the timeout.

Nothing in this utility depends on the Cluster struct, and the abstraction
makes it appear as more than it is, which is just a wrapper for
context.WithTimeout().

Let's remove the abstraction to make it less magical.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-04 18:09:58 +02:00
Sebastiaan van Stijn
69b2a05d27 api/types: migrate NetworkResource to api/types/network
This moves the type to the api/types/network package, but also introduces
a "Summary" alias; the intent here is to allow diverging the types used
for "list" and "inspect" operations, as list operations may only be
producing a subset of the fields available.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-04 17:44:46 +02:00
Sebastiaan van Stijn
a865453b1a Merge pull request #47900 from thaJeztah/api_types_rm_deprecated_aliases
api/types: remove aliases for deprecated Image types
2024-06-04 17:17:32 +02:00
Sebastiaan van Stijn
3306034c64 api/types: remove aliases for deprecated Image types
These aliases were added in ac2a028dcc,
which was part of the v26.0 and v26.1 releases. We can remove the
aliases, assuming users that depended on this have migrated to the
new location of these types.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-04 16:01:22 +02:00
Sebastiaan van Stijn
989426d303 Merge pull request #47897 from thaJeztah/rm_deprecated_inspectoptions
integration/network: remove used of deprecated NetworkInspectOptions
2024-06-04 14:13:51 +02:00
Sebastiaan van Stijn
70bac42113 integration/network: remove used of deprecated NetworkInspectOptions
The types.NetworkInspectOptions type was moved to the networks package
in 5bea0c38bc and deprecated, but use of it
was re-introduced in cd3804655a, which was
merged out-of-order.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-04 11:53:00 +02:00
Albin Kerouanton
cd3804655a Merge pull request #47853 from akerouanton/libnet-ipam-default-ula
libnet/i/defaultipam: use ULA prefix by default
2024-06-04 00:05:41 +02:00
Lei Jitang
58aac7773d Merge pull request #47888 from thaJeztah/opts_remove_alias
opts: remove alias for ipamutils
2024-06-03 19:17:07 +08:00
Sebastiaan van Stijn
8c400f4f37 Merge pull request #47886 from thaJeztah/cleanup_httpstatus_fromerror
api/server/httpstatus: FromError: remove redundant checks and cleanup
2024-06-03 12:35:55 +02:00
Sebastiaan van Stijn
1ec92ea60b opts: remove alias for ipamutils
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-03 12:27:40 +02:00
Sebastiaan van Stijn
1f359403fe Merge pull request #47881 from thaJeztah/client_cleanups
client: minor cleanup, linting- and bug-fixes
2024-06-03 11:43:27 +02:00
Sebastiaan van Stijn
e6f41e22a7 client: Client.doRequest: fix closing filehandle and reversed errors
commit 1a5dafb31e improved the error messages
produced by adding a check if the client is using as an elevated user. For
this, it attempts to open `\\.\PHYSICALDRIVE0`.

However, it looks like closing the file landed in the wrong branch of the
condition, so the file-handle would not be closed when the os.Open succeeded.

Looking further into this check, it appears the conditions were reversed;
if the check _fails_, it means the user is not running with elevated
permissions, but the check would use elevatedErr == nil.

Fix both by changing the condition to `elevatedErr != nil`.

While at it, also changing the string to use a string-literal, to reduce
the amount of escaping needed.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-03 10:52:15 +02:00
Sebastiaan van Stijn
9110ef1eec client: ensureReaderClosed: make linters happier
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-03 10:52:15 +02:00
Sebastiaan van Stijn
57f597b866 client: Client.NetworkInspectWithRaw: minor cleanup
Make this code slightly more idiomatic, and make it clear in what cases
we don't return an actual response, but an empty / default struct.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-03 10:52:15 +02:00
Sebastiaan van Stijn
42f4db26c7 api/server/httpstatus: FromError: remove redundant checks and cleanup
- remove redundant `if statusCode == 0 {` check, which would always be true
- use early returns in the switch
- move all conditions into the switch, and scope the `statusCode` variable
  to conditions where it's used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-06-03 09:47:50 +02:00
Sebastiaan van Stijn
4318ab0b33 Merge pull request #47882 from thaJeztah/move_more_network_api_types
api/types: migrate NetworkListOptions to api/types/network
2024-06-01 15:50:40 +02:00
Sebastiaan van Stijn
f78dac35e5 api/types: migrate NetworkListOptions to api/types/network
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-31 17:41:31 +02:00
Sebastiaan van Stijn
e622cea556 Merge pull request #47873 from thaJeztah/move_more_network_api_types
api/types: move more networking-types to api/types/network
2024-05-30 21:56:42 +02:00
Albin Kerouanton
d18b88fd32 daemon: add ULA prefix by default
So far, Moby only had IPv4 prefixes in its 'default-address-pools'. To
get dynamic IPv6 subnet allocations, users had to redefine this
parameter to include IPv6 base network(s). This is needlessly complex
and against Moby's 'batteries-included' principle.

This change generates a ULA base network by deriving a ULA Global ID
from the Engine's Host ID and put that base network into
'default-address-pools'. This Host ID is stable over time (except if
users remove their '/var/lib/docker/engine-id') and thus the GID is
stable too.

This ULA base network won't be put into 'default-address-pools' if users
have manually configured it.

This is loosely based on https://datatracker.ietf.org/doc/html/rfc4193#section-3.2.2.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-29 22:38:27 +02:00
Sebastiaan van Stijn
68bf0e7625 api/types: migrate EndpointResource to api/types/network
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-29 19:22:37 +02:00
Sebastiaan van Stijn
5bea0c38bc api/types: migrate NetworkInspectOptions to api/types/network
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-29 19:22:37 +02:00
Sebastiaan van Stijn
245d12175f api/types: migrate NetworkConnect, NetworkDisconnect to api/types/network
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-29 19:22:37 +02:00
Sebastiaan van Stijn
89624e09e6 api/types: migrate NetworkCreateResponse to network.CreateResponse
Migrate the type to the network package, and generate it from swagger.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-29 19:22:34 +02:00
Albin Kerouanton
2ebf19129f Merge pull request #47686 from robmry/47639_per-interface-sysctls
Per-interface sysctls
2024-05-29 10:54:05 +02:00
Albin Kerouanton
32418e9753 daemon: set the default local addr pool if none configured
Until this commit, the default local address pool was initialized by the
defaultipam driver if none was provided by libnet / the daemon.

Now, defaultipam errors out if none is passed and instead the daemon is
made responsible for initializing it with the default values if the user
don'te set the related config parameter.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-29 10:47:59 +02:00
Rob Murray
0071832226 Add per-endpoint sysctls to DriverOpts
Until now it's been possible to set per-interface sysctls using, for
example, '--sysctl net.ipv6.conf.eth0.accept_ra=2'. But, the index in
the interface name is allocated serially, and the numbering in a container
with more than one interface may change when a container is restarted.
The change to make it possible to connect a container to more than one
network when it's created increased the ambiguity.

This change adds label "com.docker.network.endpoint.sysctls" to the
DriverOpts in EndpointSettings. This option is explicitly associated
with the interface.

Settings in "--sysctl" for "eth0" are migrated to DriverOpts.

Because using "--sysctl" with any interface apart from "eth0" would have
unpredictable results, it is now an error to use any other interface name
in the top level "--sysctl" option. The error message includes a hint at
how to use the new per-interface setting.

The per-endpoint sysctl name has the interface name replaced by
"IFNAME". For example:
    net.ipv6.conf.eth0.accept_ra=2
becomes:
    net.ipv6.conf.IFNAME.accept_ra=2

The value of DriverOpts["com.docker.network.endpoint.sysctls"] is a
comma separated list.

Settings from '--sysctl' are applied by the runtime lib during task
creation. So, task creation fails if the endpoint does not exist.
Applying per-endpoint settings during interface configuration means the
endpoint can be created later, which paves the way for removal of the
SetKey OCI prestart hook.

Unlike other DriverOpts, the sysctl label itself is not driver-specific,
but each driver has a chance to check settings/values and raise an error
if a setting would cause it a problem - no such checks have been added
in this initial version. As a future extension, if required, it would be
possible for the driver to echo back valid/extended/modified settings to
libnetwork for it to apply to the interface. (At that point, the syntax
for the options could become driver specific to allow, for example, a
driver to create more than one interface).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-29 08:59:48 +01:00
Sebastiaan van Stijn
56a43a7618 Merge pull request #47865 from thaJeztah/api_docs_network_config_only
api: networking: document Scope, ConfigOnly, ConfigFrom, Peers
2024-05-28 23:52:05 +02:00
Sebastiaan van Stijn
ce0ccc09ff Merge pull request #45313 from akerouanton/deprecate-cors-headers
Deprecate dockerd api-cors-header parameter
2024-05-28 23:42:53 +02:00
Sebastiaan van Stijn
4e07c49336 Merge pull request #47092 from thaJeztah/bump_docker_py
update docker-py to 7.1.0
2024-05-28 20:42:00 +02:00
Sebastiaan van Stijn
e5532c52aa Merge pull request #47861 from thaJeztah/integration_nits
integration/system, integration/container: minor cleanups
2024-05-28 19:56:41 +02:00
Sebastiaan van Stijn
c96a2dbb54 Merge pull request #47860 from thaJeztah/test_nits
integration/internal/swarm, testutil/fakestorage: fix minor (linting) issues
2024-05-28 19:55:06 +02:00
Bjorn Neergaard
9a7d8c8660 Merge pull request #47863 from thaJeztah/platforms_err_handling
don't depend on containerd platform.Parse to return a typed error
2024-05-28 08:01:52 -06:00
Sebastiaan van Stijn
347bb4122a update docker-py to 7.1.0
full diff: https://github.com/docker/docker-py/compare/7.0.0...7.1.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-28 11:38:54 +02:00
Sebastiaan van Stijn
69f1e2a923 docs/api: add Scope, ConfigOnly, ConfigFrom, Peers (v1.41 - v1.45)
- api: swagger: Network: inline examples, and add ConfigOnly, ConfigFrom

  These fields were added in 9ee7b4dda9, but
  not documented in the API docs / swagger.

  Also move the example values per-field to reduce the risk of the example
  given from diverging with the actual struct that's used for the request.

- api: swagger: POST /networks/create: document Scope, ConfigOnly, ConfigFrom

  Adds missing documentation for Scope, ConfigOnly, and ConfigFrom. The ConfigOnly
  and ConfigFrom fields were added in 9ee7b4dda9,
  but not documented in the API docs / swagger.

- api: swagger: Network: add Peers

  Add documentation for the Peers field.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-27 21:30:28 +02:00
Sebastiaan van Stijn
53542fefd5 api: swagger: Network: add Peers
Add documentation for the Peers field.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-27 21:28:48 +02:00
Sebastiaan van Stijn
44125530bf api: swagger: POST /networks/create: document Scope, ConfigOnly, ConfigFrom
Adds missing documentation for Scope, ConfigOnly, and ConfigFrom. The ConfigOnly
and ConfigFrom fields were added in 9ee7b4dda9,
but not documented in the API docs / swagger.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-27 21:28:48 +02:00
Sebastiaan van Stijn
8b7a54f622 api: swagger: Network: inline examples, and add ConfigOnly, ConfigFrom
These fields were added in 9ee7b4dda9, but
not documented in the API docs / swagger.

Also move the example values per-field to reduce the risk of the example
given from diverging with the actual struct that's used for the request.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-27 21:28:41 +02:00
Sebastiaan van Stijn
6cab6d0302 docs/api: POST /networks/create: inline examples per-field (v1.41 - v1.45)
Move the example values per-field to reduce the risk of the example given
from diverging with the actual struct that's used for the request.

This patch updates older API versions (went back to v1.41).

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-27 17:49:06 +02:00
Sebastiaan van Stijn
51885166b9 api: swagger: POST /networks/create: inline examples per-field
Move the example values per-field to reduce the risk of the example given
from diverging with the actual struct that's used for the request.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-27 17:36:05 +02:00
Sebastiaan van Stijn
d64e220afb api/types: NetworkCreate: add GoDoc
GoDoc is mostly copied from NetworkResource, which is the equivalent for
retrieving the information.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-27 16:25:18 +02:00
Sebastiaan van Stijn
cd1ed46d73 don't depend on containerd platform.Parse to return a typed error
We currently depend on the containerd platform-parsing to return typed
errdefs errors; the new containerd platforms module does not return such
errors, and documents that errors returned should not be used as sentinel
errors; c1438e911a/errors.go (L21-L30)

Let's type these errors ourselves, so that we don't depend on the error-types
returned by containerd, and consider that eny platform string that results in
an error is an invalid parameter.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-27 10:18:29 +02:00
Sebastiaan van Stijn
56086c9952 integration/container: remove redundant type-conversion, and minor cleanup
- Remove redundant conversion to strslice.StrSlice
- Use assert.Check where possible to not fail early
- Remove instances of types.ExecStartCheck that used default values
- Minor code-formatting cleanup

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-25 14:58:52 +02:00
Sebastiaan van Stijn
070e90a94c integration/system: remove redundant type-conversion, and minor cleanup
- Remove redundant conversion to strslice.StrSlice
- Use assert.Assert instead of assert.Check to fail early if value is nil
- Minor code-formatting cleanup

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-25 14:56:44 +02:00
Sebastiaan van Stijn
667094924d testutil/fakestorage: fix minor (linting) issues
- fix typo in comment
- rename variable that collided with an import
- add log for an unhandled error
- slightly improve error-logs

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-25 14:00:09 +02:00
Sebastiaan van Stijn
4a074c809e integration/internal/swarm: remove unused ContainerPoll
This was added in ee6959addc to account
for arm (32) requiring a longer timeout at the time, but it was never
used.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-25 13:57:39 +02:00
Sebastiaan van Stijn
fe78d6d9da integration/internal/swarm: rename vars that collided with imports
- rename the client var to not collide with the imported client package
- remove an intermediate startCheck variable

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-25 13:55:59 +02:00
Brian Goff
4619b14403 refactor: rename attach config var
This var for the incoming attach request.
Just within this one function we also have `cfg`, and `ctr` already, so
`c` just makes things more confusing.
Not to mention `c` is usually referencing a container object in other
parts of the code.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-05-24 21:32:18 +00:00
Brian Goff
2d134c5abd Fix goroutine/fd leak when client disconnects
In cases where the client disconnects and there is nothing to read from
a stdio stream after that disconnect, the copy goroutines and file
descriptors are leaked because `io.Copy` is just blocked waiting for
data from the container's I/O stream.

This fix only applies to Linux.
Windows will need a separate fix.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-05-24 21:32:15 +00:00
Sebastiaan van Stijn
ceefb7d0b9 Merge pull request #47855 from thaJeztah/bump_buildx
Dockerfile: update buildx to v0.14.1, compose v2.27.1
2024-05-24 19:00:37 +02:00
Albin Kerouanton
62ddd3dea8 Merge pull request #47747 from robmry/non-experimental-ip6tables
Enable 'ip6tables' by default, don't require 'experimental'.
2024-05-24 18:38:16 +02:00
Sebastiaan van Stijn
8361baf8d9 Dockerfile: update compose to v2.27.1
release notes: https://github.com/docker/compose/releases/tag/v2.27.1

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-24 14:53:58 +02:00
Sebastiaan van Stijn
387be6ec91 Dockerfile: update buildx to v0.14.1
- 0.14.1 release notes: https://github.com/docker/buildx/releases/tag/v0.14.1
- 0.14.0 release notes: https://github.com/docker/buildx/releases/tag/v0.14.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-24 14:44:01 +02:00
Brian Goff
ca396dfaaa awslogs: Prevent close from being blocked on log
Before this change a call to `Close` could be blocked if the the channel
used to buffer logs is full.
When this happens the container state will end up wedged causing a
deadlock on anything that needs to lock the container state.

This removes the use of a channel which has semantics which are
difficult to manage to something more suitable for the situation.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-05-23 19:15:22 +00:00
Sebastiaan van Stijn
5cd2e6a1b7 Merge pull request #47854 from dperny/fix-manager-promote-race
Fix issue where node promotion could fail
2024-05-23 21:14:58 +02:00
Brian Goff
b0f7117b31 Merge pull request #47850 from weebney/patch-1
Replace dead RFC8878 hyperlink in documentation
2024-05-23 15:57:40 +00:00
Albin Kerouanton
d16a425f0f Merge pull request #47768 from akerouanton/libnet-ipam-linear-allocator
libnet/ipams/default: introduce a linear allocator
2024-05-23 11:07:12 +02:00
Albin Kerouanton
500eff0ae9 libnet/i/defaultipam: improve address pools validation
Nothing was validating whether address pools' `base` prefix
were larger than the target subnet `size` they're associated to. As
such invalid address pools would yield no subnet, the error could go
unnoticed.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-23 08:26:07 +02:00
Albin Kerouanton
0c022307e9 libnet/i/defaultipam: Unmap IPv4-mapped IPv6 addrs
This ensures such address pools are part of the IPv4 address space.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-23 08:26:00 +02:00
Albin Kerouanton
9d288b5b43 libnet/i/defaultipam: introduce a linear allocator
The previous allocator was subnetting address pools eagerly
when the daemon started, and would then just iterate over that
list whenever RequestPool was called. This was leading to high
memory usage whenever IPv6 pools were configured with a target
subnet size too different from the pools prefix size.

For instance: pool = fd00::/8, target size = /64 -- 2 ^ (64-8)
subnets would be generated upfront. This would take approx.
9 * 10^18 bits -- way too much for any human computer in 2024.

Another noteworthy issue, the previous implementation was allocating
a subnet, and then in another layer was checking whether the
allocation was conflicting with some 'reserved networks'. If so,
the allocation would be retried, etc... To make it worse, 'reserved
networks' would be recomputed on every iteration. This is totally
ineffective as there could be 'reserved networks' that fully overlap
a given address pool (or many!).

To fix this issue, a new field `Exclude` is added to `RequestPool`.
It's up to each driver to take it into account. Since we don't know
whether this retry loop is useful for some remote IPAM driver, it's
reimplemented bug-for-bug directly in the remote driver.

The new allocator uses a linear-search algorithm. It takes advantage
of all lists (predefined pools, allocated subnets and reserved
networks) being sorted and logically combines 'allocated' and
'reserved' through a 'double cursor' to iterate on both lists at the
same time while preserving the total order. At the same time, it
iterates over 'predefined' pools and looks for the first empty space
that would be a good fit.

Currently, the size of the allocated subnet is still dictated by
each 'predefined' pools. We should consider hardcoding that size
instead, and let users specify what subnet size they want. This
wasn't possible before as the subnets were generated upfront. This
new allocator should be able to deal with this easily.

The method used for static allocation has been updated to make sure
the ascending order of 'allocated' is preserved. It's bug-for-bug
compatible with the previous implementation.

One consequence of this new algorithm is that we don't keep track
of where the last allocation happened, we just allocate the first
free subnet we find.

Before:

- Allocate: 10.0.1.0/24, 10.0.2.0/24 ; Deallocate: 10.0.1.0/24 ;
Allocate 10.0.3.0/24.

Now, the 3rd allocation would yield 10.0.1.0/24 once again.

As it doesn't change the semantics of the allocator, there's no
reason to worry about that.

Finally, about 'reserved networks'. The heuristics we use are
now properly documented. It was discovered that we don't check
routes for IPv6 allocations -- this can't be changed because
there's no such thing as on-link routes for IPv6.

(Kudos to Rob Murray for coming up with the linear-search idea.)

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-23 08:24:51 +02:00
Albin Kerouanton
5f183b9b3a Merge pull request #47837 from akerouanton/libnet-ipam-disambiguate-PoolID
libnet/i/defaultipam: Disambiguate PoolID string format
2024-05-22 22:52:15 +02:00
weebney
a9ebb0c267 Replace dead RFC8878 go doc hyperlink
Fixes #45952

Signed-off-by: weebney <weebney@gmail.com>
2024-05-22 14:27:15 -04:00
Sebastiaan van Stijn
274b2932a1 Merge pull request #47838 from dmcgowan/update-containerd-v1.7.17
Update containerd to v1.7.17
2024-05-22 17:36:21 +02:00
Drew Erny
16e5c41591 Fix issue where node promotion could fail
If a node is promoted right after another node is demoted, there exists
the possibility of a race, by which the newly promoted manager attempts
to connect to the newly demoted manager for its initial Raft membership.
This connection fails, and the whole swarm Node object exits.

At this point, the daemon nodeRunner sees the exit and restarts the
Node.

However, if the address of the no-longer-manager is recorded in the
nodeRunner's config.joinAddr, the Node again attempts to connect to the
no-longer-manager, and crashes again. This repeats. The solution is to
remove the node entirely and rejoin the Swarm as a new node.

This change erases config.joinAddr from the restart of the nodeRunner,
if the node has previously become Ready. The node becoming Ready
indicates that at some point, it did successfully join the cluster, in
some fashion. If it has successfully joined the cluster, then Swarm has
its own persistent record of known manager addresses. If no joinAddr is
provided, then Swarm will choose from its persisted list of managers to
join, and will join a functioning manager.

Signed-off-by: Drew Erny <derny@mirantis.com>
2024-05-22 08:48:03 -05:00
Albin Kerouanton
5a2fa59688 libnet/i/defaultipam: Use InternalErrorf instead of InvalidParameterErrof
InvalidParameterErrorf was used whenever an invalid value was found
during PoolID unmarshaling. This error is converted to a 400 HTTP code
by the HTTP server.

However, users never provide PoolIDs directly -- these are constructed
from user-supplied values which are already validated when the PoolID is
marshaled. Hence, if such erroneous value is found, it's an internal
error and should be converted to a 500.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-22 10:02:20 +02:00
Albin Kerouanton
9369132879 libnet/i/defaultipam: Disambiguate PoolID string format
Prior to this change PoolID microformat was using slashes to separate
fields. Those fields include subnet prefixes in CIDR notation, which
also include a slash. This makes future evolution harder than it should
be.

This change introduces a 'v2' microformat based on JSON. This has two
advantages:

1. Fields are clearly named to ensure each value is associated to the
right field.
2. Field values and separators are clearly distinguished to remove any
ambiguity.

The 'v1' encoding will be kept until the next major MCR LTS is released.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-22 10:02:19 +02:00
Sebastiaan van Stijn
8470add2fe Merge pull request #47840 from vvoland/update-containerd
Dockerfile: update containerd binary to v1.7.17 (static binaries and CI only)
2024-05-21 23:16:00 +02:00
Albin Kerouanton
081f6ba39a Merge pull request #47826 from robmry/windns_proxy_default
Default to "windows-dns-proxy":true
2024-05-21 17:19:09 +02:00
Sebastiaan van Stijn
c3a40873f9 Merge pull request #47820 from akerouanton/libnet-store-is-never-nil-followup
libnet: Controller: more c.store clean-ups
2024-05-21 15:27:40 +02:00
Albin Kerouanton
6d21574535 libnet: Controller: drop getStore()
This method does nothing more than `return c.store`. It has no value and
adds an unecessary level of indirection. Let's ditch it.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-21 12:54:57 +02:00
Albin Kerouanton
49888559cc libnet: Controller: drop closeStores
Previous commit made it clear that c.store can't be nil. Hence,
`c.store.Close()` can be called without checking if c.store is nil.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-21 12:43:48 +02:00
Albin Kerouanton
2336363e28 libnet: init datastore in ctrler constructor
This was done in a separate method, called by the ctrler constructor.
This method was returning a nil datastore when c.cfg was nil -- but that
can't happen in practice!

This was giving the impression that the controller could be run without
a datastore properly configured. It's not the case, so make it explicit
by instantiating the datastore before `Controller`.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-21 12:43:48 +02:00
Paweł Gronowski
3847da374b integration/TestDiskUsage: Make 4096 also a 'empty' value
Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-05-21 12:35:01 +02:00
Albin Kerouanton
145a73a36c Merge pull request #47818 from akerouanton/libnet-d-bridge-dont-parse-MacAddress-netlabel
libnet/d/bridge: don't parse the MacAddress netlabel
2024-05-21 10:12:16 +02:00
Rob Murray
1e29f9b12f Move EndpointSettings.DriverOpts from op-state to config
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-17 11:30:14 +01:00
Rob Murray
a35716f5b9 Factor out selection of endpoint for config migration
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-17 11:30:14 +01:00
Paweł Gronowski
4f0cb7d964 Dockerfile: update containerd binary to v1.7.17 (static binaries and CI only)
Update the containerd binary that's used in CI and static binaries

- full diff: https://github.com/containerd/containerd/compare/v1.7.15...v1.7.17
- release notes: https://github.com/containerd/containerd/releases/tag/v1.7.17

```markdown changelog
Update containerd (static binaries only) to [v1.7.17](https://github.com/containerd/containerd/releases/tag/v1.7.17)
```

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-05-17 11:07:11 +02:00
Derek McGowan
e459487feb Update containerd to v1.7.17
Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-05-16 15:24:38 -07:00
Sebastiaan van Stijn
06e3a49d66 Merge pull request #47796 from cpuguy83/fix_superfluous_write_header
Explicity write http headers on streaming endpoints
2024-05-16 23:12:57 +02:00
Brian Goff
707ab48cbb Explicity write http headers on streaming endpoints
This works around issues with the otel http handler wrapper causing
multiple calls to `WriteHeader` when a `Flush` is called before `Write`.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-05-16 18:00:02 +00:00
Brian Goff
50d3028464 Fix fd leak/goroutine when attaching stdin only
When only stdin is attached the goroutine can only ever exit if:

1. The container pipe is closed while trying to write to it
2. The client closes the stdin read pipe

This is because `io.Copy` does a read on the read side then a write to
the write side.
If reading from the client's stdin pipe blocks, the goroutine will never
get notified that the container pipe is closed.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-05-16 16:49:07 +00:00
Sebastiaan van Stijn
ae976b998b Merge pull request #47629 from vvoland/tarexport-tracing-ctx-cancel
tarexport: Plumb ctx, add OTEL spans, handle cancellation
2024-05-14 14:14:51 +02:00
Paweł Gronowski
ad0f263eb5 tarexport: Plumb ctx, add OTEL spans, handle cancellation
Pass `context.Context` through `tarexport.Load` and `tarexport.Save`.
Create OTEL spans for the most time consuming operations.

Also, handle context cancellations to actually end saving/loading when
the operation is cancelled - before this PR the daemon would still be
performing the operation even though the user already cancelled it.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-05-14 13:08:33 +02:00
Albin Kerouanton
5505c851f1 Merge pull request #47821 from robmry/internal_network_with_dns
Forward DNS requests into --internal networks
2024-05-14 12:22:49 +02:00
Rob Murray
33f9a5329a Default to "windows-dns-proxy":true
In 26.1, we added daemon feature flag "windows-dns-proxy" which could
be set to "true" to make "nslookup" work in Windows containers, by
forwarding requests from the internal resolver to the container's
external DNS servers.

This changes the default to forwarding-enabled - it can be disabled by
via daemon.json using ...
  "features": { "windows-dns-proxy": false }

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-13 11:11:20 +01:00
Rob Murray
77a47dba3b Forward DNS requests into --internal networks
A recent change to prevent containers only connected to --internal
networks from communicating with external DNS servers inadvertently
prevented the daemon's internal DNS server from forwarding requests
within an internal network to a containerised DNS server.

Relax the check, so that only requests that need to be forwarded
from the host's network namespace are dropped.

External DNS servers remain unreachable from the internal network.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-10 19:36:55 +01:00
Albin Kerouanton
cd08d377c5 Merge pull request #47819 from akerouanton/libnet-d-remote-replace-errorWithRollback
libnet/d/remote: replace errorWithRollback
2024-05-10 13:26:41 +02:00
Albin Kerouanton
6fbae5ff26 libnet/d/bridge: don't parse the MacAddress netlabel
Libnet's method `(*Network).createEndpoint()` is already parsing this
netlabel to set the field `ep.iface.mac`. Later on, this same method
invoke the driver's method `CreateEndpoint` with an `InterfaceInfo` arg
and an `options` arg (an opaque map of driver otps).

The `InterfaceInfo` interface contains a `MacAddress()` method that
returns `ep.iface.mac`. And the opaque map may contain the key
`netlabel.MacAddress`.

Prior to this change, the bridge driver was calling `MacAddress()`. If
no value was returned, it'd fall back to the option set in the `options`
map, or generate a MAC address based on the IP address.

However, the expected type of the `options` value is a `net.HardwareAddr`.
This is what's set by the daemon when handing over the endpoint config
to libnet controller. If the value is a string, as is the case if the
MAC address is provided through `EndpointsSettings.DriverOpts`, it
produces an error.

As such, the opaque option and the `MacAddress()` are necessarily the
same -- either nothing or a `net.HardwareAddr`. No need to keep both.

Moreover, the struct `endpointConfiguration` was only used to store that
netlabel value. Drop it too.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-10 12:45:12 +02:00
Rob Murray
41ddc47bbf Don't explicitly enable ip6tables in tests
Tests no longer need to use "--experimental --ip6tables", now ip6tables
is the default behaviour.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-10 10:17:30 +01:00
Rob Murray
07ccaf028d Enable 'ip6tables' by default, don't require 'experimental'.
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-10 09:21:21 +01:00
Rob Murray
5705cbf6e3 Make it an error to set up filtering on an unnamed bridge
In setupIPv6BridgeNetFiltering(), the bridge should always be named.
Don't fall back to checking the "default" setting for a new bridge.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-10 09:21:21 +01:00
Rob Murray
d6b6a5122f Enable filtering on IPv6 bridges with no IPv6 address
Check forwarding, then set bridge-nf-call-ip6tables, on a bridge
if IPv6 is enabled - even if no IPv6 address has been assigned.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-10 09:21:21 +01:00
Rob Murray
4df97f2e1e Gate setting of bridge-nf-call-ip6tables on "--ip6tables=true".
The code to enable "bridge-nf-call-iptables" or "bridge-nf-call-ip6tables"
was gated on "--iptables=true", it didn't check "--ip6tables=true".

So, split the top level call into IPv4/IPv6 so that the iptables-enable
settings can be checked independently, and simplfied the implementation.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-10 09:21:21 +01:00
Rob Murray
8751562d3f Set up IPv6 n/w isolation rules when --ip6tables=true
bridgeNetwork.isolateNetwork() checks "--iptables=true" and
"--ip6tables=true" before doing anything with IPv4 and IPv6
respectively.  But, it was only called if "--iptables=true".

Now, it's called if "--ip6tables=true", even if "--iptables=false".

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-10 09:21:21 +01:00
Rob Murray
23fd15985b Allow "--ip6tables=true" when "--iptables=false"
The bridge driver's setupIPChains() had an initial sanity check that
"--iptables=true".

But, it's called with "version=IPv6" when "--iptables=false" and
"--ip6tables=true" - the sanity test needed to allow for that.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-10 09:21:21 +01:00
Rob Murray
9a8ffe38fc Disable ip6tables in tests that disable iptables
Tests that start a daemon disable iptables, to avoid conflicts with
other tests running in parallel and also creating iptables chains.

Do the same for ip6tables, in prep for them being enabled by-default.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-10 09:21:21 +01:00
Albin Kerouanton
75821a7d9a Merge pull request #47787 from robmry/47778_preserve_kernel_ll_addrs
Preserve kernel-assigned IPv6 link-local addresses on a bridge network's bridge
2024-05-10 10:18:11 +02:00
Albin Kerouanton
a9ded90030 Merge pull request #47788 from robmry/bad_integration-cli_ipv6_tests
Fix/remove broken integration-cli IPv6 tests
2024-05-10 10:17:48 +02:00
Albin Kerouanton
5952920380 libnet/d/remote: replace errorWithRollback
Use defer funcs instead.

For no apparant reasons, a few error cases in the Join method were not
triggering a rollback. This is now fixed.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-10 10:15:11 +02:00
Sebastiaan van Stijn
64da0e0b13 Merge pull request #47810 from akerouanton/libnet-store-is-never-nil
libnet: don't check if ctrler store is nil
2024-05-09 13:10:12 +02:00
Albin Kerouanton
7216541b17 libnet: don't check if ctrler store is nil
Since commit befff0e1, `(*Controller).getStore()` never returns nil
except if `c.store` isn't initialized yet. This can't happen unless
`New()` returned an error and it wasn't proper caught.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-05-08 12:37:30 +02:00
Albin Kerouanton
7ea9acc97f cmd/dockerd: deprecate api-cors-header
CORS headers were originally added by 6d5bdff.

These headers could be set without any Authz plugin enabled
beforehand, making this feature quite dangerous.

This commit marks the daemon flag `api-cors-header` as deprecated
and requires the env var `DOCKERD_DEPRECATED_CORS_HEADER` to be
set. When enabled, the daemon will write a deprecation warning to
the logs and the endpoint `GET /info` will return the same
deprecation warning.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-05-08 12:12:09 +02:00
Paweł Gronowski
4554d871d7 Merge pull request #47805 from vvoland/update-go
update to go1.21.10
2024-05-08 10:58:54 +02:00
Paweł Gronowski
6c97e0e0b5 update to go1.21.10
- https://github.com/golang/go/issues?q=milestone%3AGo1.21.10+label%3ACherryPickApproved
- full diff: https://github.com/golang/go/compare/go1.21.9...go1.21.10

These minor releases include 2 security fixes following the security policy:

- cmd/go: arbitrary code execution during build on darwin
On Darwin, building a Go module which contains CGO can trigger arbitrary code execution when using the Apple version of ld, due to usage of the -lto_library flag in a "#cgo LDFLAGS" directive.
Thanks to Juho Forsén of Mattermost for reporting this issue.
This is CVE-2024-24787 and Go issue https://go.dev/issue/67119.

- net: malformed DNS message can cause infinite loop
A malformed DNS message in response to a query can cause the Lookup functions to get stuck in an infinite loop.
Thanks to long-name-let-people-remember-you on GitHub for reporting this issue, and to Mateusz Poliwczak for bringing the issue to our attention.
This is CVE-2024-24788 and Go issue https://go.dev/issue/66754.

View the release notes for more information:
https://go.dev/doc/devel/release#go1.22.3

**- Description for the changelog**

```markdown changelog
Update Go runtime to 1.21.10
```

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-05-08 09:31:46 +02:00
Albin Kerouanton
4d525c9009 Merge pull request #47744 from robmry/47716_no_dns_req_to_self
Do not forward DNS requests to self.
2024-05-07 18:24:41 +02:00
Albin Kerouanton
da3f60bfe4 Merge pull request #47745 from robmry/firewalld_forwarding_policy
Add firewalld policy "docker-forwarding".
2024-05-07 15:52:26 +02:00
Paweł Gronowski
440836a8cf Merge pull request #47003 from LarsSven/fix-container-start-time
Move StartedAt time to before starting the container
2024-05-07 14:58:27 +02:00
Paweł Gronowski
8e14f278c4 Merge pull request #47651 from vvoland/api-bump
API: bump version to 1.46
2024-05-07 10:40:07 +02:00
Sebastiaan van Stijn
9314eaff2f Merge pull request #47797 from cpuguy83/bundles_aint_phony
Makefile: bundles is not PHONY
2024-05-06 08:02:24 +02:00
Brian Goff
ac71ac1c92 Merge pull request #47664 from crazybolillo/47516-crazybolillo 2024-05-03 14:23:15 -07:00
Brian Goff
72eb615490 Makefile: bundles is not PHONY
This was changed recently so that the bundles target is always run, but
`mkdir bundles` fails when bundles exists...

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2024-05-03 21:01:12 +00:00
Sebastiaan van Stijn
a73e63cfa6 Merge pull request #47656 from imalasong/pr/1
Makefile: refactoring .PHONY
2024-05-03 00:19:31 +02:00
Sebastiaan van Stijn
5d03db29d8 Merge pull request #47749 from woky/apparmor-runc
apparmor: Allow confined runc to kill containers
2024-05-02 20:50:06 +02:00
Rob Murray
fda708f55d Delete broken/unused test requirement helper "IPv6"
It'd only return true on a host with no IPv6 in its kernel.

So, removed, having fixed the two tests that used it.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-01 19:28:16 +01:00
Rob Murray
4aff2fbc98 Remove integration-cli TestDaemonSuite/TestDaemonIPv6Enabled
The test hadn't been running, because it used testRequires(c, IPv6)
and predicate "IPv6" returns the opposite of the expected result.

TestDaemonIPv6Enabled tried to run with IPv6 on the default bridge,
but didn't set up a "fixed-cidr-v6" - so the daemon wouldn't start.

It then tried to check the bridge had address "fe80::1", which it
expected to work because it had just used setupV6() to add that
address.

Then it  checked that "LinkLocalIPv6Address" was set in container
inspect output, but it wouldn't be (the field is deprecated).

There are working IPv6 tests in the suite (TestDaemonIPv6FixedCIDR,
TestDaemonIPv6FixedCIDRAndMac, TestDaemonIPv6HostMode) - and there's
more coverage in the network integration tests.

So, deleted the test as it didn't seem worth salvaging.

Also deleted now-unused helper functions setupV6(), teardownV6().

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-01 19:26:06 +01:00
Rob Murray
346a7c07a0 Fix TestDockerSwarmSuite/TestSwarmInitIPv6
The test hadn't been running, because it used testRequires(c, IPv6)
and predicate "IPv6" returns the opposite of the expected result.

If the test had run, it'd have failed because:
- it used "--listen-add", but the option is "--listen-addr"
  - so, the daemon wouldn't have started
- it tried to use "--join ::1"
  - address "::1" was interpreted as host:port so the Dial() failed,
    it needed to be "[::1]".
  - it didn't supply a  join token

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-01 19:09:54 +01:00
Rob Murray
b11e95f5bc Don't delete IPv6 multicast addresses from a bridge
Multicast addresses aren't added by the daemon so, if they're present,
it's because they were explicitly added - possibly to a user-managed
bridge. So, don't remove.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-01 17:46:08 +01:00
Rob Murray
a5f82ba4bf Disallow IPv6 multicast as bridge n/w subnet
Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-01 17:20:56 +01:00
Rob Murray
aa3a86c038 Refactor IPv6 subnet validation
- Remove package variable bridge.bridgeIPv6
- Use netip in more places
- Improve error messages from fixed-cidr-v6 checks

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-01 17:20:56 +01:00
Rob Murray
f46473b29c Do not remove kernel-ll addresses from bridges
Make the behaviour enabled by env var DOCKER_BRIDGE_PRESERVE_KERNEL_LL
the default...
- don't remove kernel assigned link-local addresses
  - or any address in fe80::/64
- don't assign fe80::1 to a bridge

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-05-01 17:20:56 +01:00
Paweł Gronowski
9d07820b22 Merge pull request #47771 from robmry/dont_delete_kernel_ll_addrs
Option to avoid deleting the kernel_ll address from bridges.
2024-04-30 11:27:30 +02:00
Sebastiaan van Stijn
22892d2210 Merge pull request #47572 from avoidaway/master
chore: remove repetitive words
2024-04-30 08:53:53 +02:00
Sebastiaan van Stijn
8cbd20246c Merge pull request #47769 from robmry/47751_readonly_procsysnet
Allow for a read-only "/proc/sys/net".
2024-04-29 21:43:45 +02:00
Rob Murray
01ea18f1e3 Allow for a read-only "/proc/sys/net".
If dockerd runs on a host with a read-only /proc/sys/net filesystem,
it isn't able to enable or disable IPv6 on network interfaces when
attaching a container to a network (including initial networks during
container creation).

In release 26.0.2, a read-only /proc/sys/net meant container creation
failed in all cases.

So, don't attempt to enable/disable IPv6 on an interface if it's already
set appropriately.

If it's not possible to enable IPv6 when it's needed, just log (because
that's what libnetwork has always done if IPv6 is disabled in the
kernel).

If it's not possible to disable IPv6 when it needs to be disabled,
refuse to create the container and raise an error that suggests setting
environment variable "DOCKER_ALLOW_IPV6_ON_IPV4_INTERFACE=1", to tell
the daemon it's ok to ignore the problem.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-04-29 16:17:06 +01:00
Rob Murray
57ada4b848 Option to avoid deleting the kernel_ll address from bridges.
If env var DOCKER_BRIDGE_PRESERVE_KERNEL_LL=1, don't assign fe80::1/64
to a bridge, and don't delete any link local address with prefix fe80::/64.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-04-28 17:01:59 +01:00
Albin Kerouanton
48d769bf2f Merge pull request #47727 from akerouanton/libnet-ipam-cleanup
libnet/ipam: Various clean-ups
2024-04-26 22:42:53 +02:00
Albin Kerouanton
c5376e534c libnet/ipams/null: move driver name to its pkg
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 17:28:29 +02:00
Albin Kerouanton
f2387f3632 libnet/ipams/defaultipam: move driver name to its pkg
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 17:28:29 +02:00
Albin Kerouanton
0db56de78e libnet/ipamutils: no more global state
Prior to this change, cnmallocator would call
`ConfigGlobalScopeDefaultNetworks` right before initializing its
IPAM drivers. This function was mutating some global state used
during drivers init.

This change just remove the global state, and adds an arg to
ipams.Register and defaultipam.Register to pass the global pools
by arguments instead.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 17:28:29 +02:00
Albin Kerouanton
3c9718144f libnet/ipams: register all drivers
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 17:28:29 +02:00
Albin Kerouanton
eda47500fc libnet/ipams: Unconditionally call windowsipam.Register
This function is made a no-op on non-windows platform.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 17:28:29 +02:00
Albin Kerouanton
ae9e4319b0 libnet/ipams/windowsipam: that driver knows its name
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 17:28:29 +02:00
Albin Kerouanton
8cec9f0dca libnet/ipams/defaultipam: add a Register fn
All drivers except the default have a Register function. Before this
change, default's registration was handled by another package. Move
this logic into the driver pkg.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 17:28:29 +02:00
Albin Kerouanton
218394cada libnet/ipams/builtin: move to libnet/ipams
Packages in libnet/ipams are drivers, except builtin -- it's used
to register drivers. Move files one level up and delete this pkg.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 17:28:29 +02:00
Albin Kerouanton
29f2ca04e0 libnet: move ipam pkg to ipam/defaultipam
All drivers except the default ipam driver are stored in ipams/.
Since `default` isn't a valid Go pkg name, this package is
renamed to `defaultipam`, following `windowsipam` example.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 17:28:29 +02:00
Albin Kerouanton
e8644c3e0e libnet/ipam: default-address-pools as Register arg
Prior to this change, daemon's `default-address-pools` param would
be passed to `SetDefaultIPAddressPool()` to set a global var named
`defaultAddressPool`. This var would then be retrieved during the
`default` IPAM driver registration. Both steps were executed in
close succession during libnet's controller initialization.

This change removes the global var and just pass the user-defined
`default-address-pools` to the `default` driver's `Register` fn.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 17:28:29 +02:00
Albin Kerouanton
1d5a12dfb1 integration-cli: createNetwork: add t.Helper()
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 17:28:29 +02:00
Albin Kerouanton
115de5ff3d libnet/ipamapi: add in/out structs for RequestPool
The `RequestPool` method has many args and named returns. This
makes the code hard to follow at times. This commit adds one struct,
`PoolRequest`, to replace these args, and one struct, `AllocatedPool`,
to replace these named returns.

Both structs' fields are properly documented to better define their
semantics, and their relationship with address allocation.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 17:28:26 +02:00
Albin Kerouanton
82aae0fe50 libnet/netutils: remove dead util NetworkRange
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 16:10:39 +02:00
Albin Kerouanton
37a81cd04d libnet/ipam: split v4/v6 address spaces
Address spaces are a continuum of addresses that can be used for a
specific purpose (ie. 'local' for unmanaged containers, 'global for
Swarm). v4 and v6 addresses aren't of the same size -- hence
combining them into a single address space doesn't form a continuum.
Better set them apart into two different address spaces.

Also, the upcoming rewrite of `addrSpace` will benefit from that
split.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 16:07:57 +02:00
Albin Kerouanton
199c72cb5d libnet/ipam: remove dead DumpDatabase()
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 16:06:40 +02:00
Albin Kerouanton
df88857e6c libnet/ipam: put addrSpace into a separate file
`addrSpace` methods are currently scattered in two different files.
As upcoming work will rewrite some of these methods, better put them
into a separate file.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 16:06:40 +02:00
Albin Kerouanton
a047d4b1df libnet/ipam: un-embed mutex from addrSpace
Embedding `sync.Mutex` into a struct is considered a bad practice
as it makes the mutex methods part of the embedding struct's API.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2024-04-26 16:06:40 +02:00
Sebastiaan van Stijn
16b2c223ce Merge pull request #47536 from Benehiko/docker-client-ctx-reduced
feat: ctx to client API
2024-04-26 15:21:00 +02:00
Paweł Gronowski
dda4fec99a Merge pull request #47763 from dmcgowan/update-containerd-1.7.16
vendor: update containerd to v1.7.16
2024-04-26 11:00:28 +02:00
Derek McGowan
eeec716e33 Update containerd to v1.7.16
Includes fix for HTTP fallback

Signed-off-by: Derek McGowan <derek@mcg.dev>
2024-04-25 15:35:15 -07:00
Jonas Geiler
efca9303a4 refactor: updated native diff error message
Signed-off-by: Jonas Geiler <git@jonasgeiler.com>
Co-authored-by: Akihiro Suda <suda.kyoto@gmail.com>
2024-04-25 21:30:10 +02:00
Rob Murray
ff8de5e156 Add firewalld policy "docker-forwarding".
Allow forwarding from any firewalld zone to the 'docker' zone.

This makes it possible to use routable IPv6 addresses on a bridge
network, with masquerading disabled, and have the host forward packets
to it.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-04-24 16:44:43 +01:00
Tomáš Virtus
5ebe2c0d6b apparmor: Allow confined runc to kill containers
/usr/sbin/runc is confined with "runc" profile[1] introduced in AppArmor
v4.0.0. This change breaks stopping of containers, because the profile
assigned to containers doesn't accept signals from the "runc" peer.
AppArmor >= v4.0.0 is currently part of Ubuntu Mantic (23.10) and later.

In the case of Docker, this regression is hidden by the fact that
dockerd itself sends SIGKILL to the running container after runc fails
to stop it. It is still a regression, because graceful shutdowns of
containers via "docker stop" are no longer possible, as SIGTERM from
runc is not delivered to them. This can be seen in logs from dockerd
when run with debug logging enabled and also from tracing signals with
killsnoop utility from bcc[2] (in bpfcc-tools package in Debian/Ubuntu):

  Test commands:

    root@cloudimg:~# docker run -d --name test redis
    ba04c137827df8468358c274bc719bf7fc291b1ed9acf4aaa128ccc52816fe46
    root@cloudimg:~# docker stop test

  Relevant syslog messages (with wrapped long lines):

    Apr 23 20:45:26 cloudimg kernel: audit:
      type=1400 audit(1713905126.444:253): apparmor="DENIED"
      operation="signal" class="signal" profile="docker-default" pid=9289
      comm="runc" requested_mask="receive" denied_mask="receive"
      signal=kill peer="runc"
    Apr 23 20:45:36 cloudimg dockerd[9030]:
      time="2024-04-23T20:45:36.447016467Z"
      level=warning msg="Container failed to exit within 10s of kill - trying direct SIGKILL"
      container=ba04c137827df8468358c274bc719bf7fc291b1ed9acf4aaa128ccc52816fe46
      error="context deadline exceeded"

  Killsnoop output after "docker stop ...":

    root@cloudimg:~# killsnoop-bpfcc
    TIME      PID      COMM             SIG  TPID     RESULT
    20:51:00  9631     runc             3    9581     -13
    20:51:02  9637     runc             9    9581     -13
    20:51:12  9030     dockerd          9    9581     0

This change extends the docker-default profile with rules that allow
receiving signals from processes that run confined with either runc or
crun profile (crun[4] is an alternative OCI runtime that's also confined
in AppArmor >= v4.0.0, see [1]). It is backward compatible because the
peer value is a regular expression (AARE) so the referenced profile
doesn't have to exist for this profile to successfully compile and load.

Note that the runc profile has an attachment to /usr/sbin/runc. This is
the path where the runc package in Debian/Ubuntu puts the binary. When
the docker-ce package is installed from the upstream repository[3], runc
is installed as part of the containerd.io package at /usr/bin/runc.
Therefore it's still running unconfined and has no issues sending
signals to containers.

[1] https://gitlab.com/apparmor/apparmor/-/commit/2594d936
[2] https://github.com/iovisor/bcc/blob/master/tools/killsnoop.py
[3] https://download.docker.com/linux/ubuntu
[4] https://github.com/containers/crun

Signed-off-by: Tomáš Virtus <nechtom@gmail.com>
2024-04-24 13:07:48 +02:00
Rob Murray
87506142d8 Do not forward DNS requests to self.
If a container is configured with the internal DNS resolver's own
address as an external server, try the next ext server rather than
recursing (return SERVFAIL if there are no other servers).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2024-04-24 09:15:35 +01:00
Sebastiaan van Stijn
faf84d7f0a Merge pull request #47743 from thaJeztah/bump_go_winio
vendor: github.com/Microsoft/go-winio v0.6.2 (for go1.22 compatibility)
2024-04-23 14:47:40 +02:00
Paweł Gronowski
70475b371b Merge pull request #47739 from thaJeztah/vendor_ebpf
vendor: github.com/cilium/ebpf v0.12.3
2024-04-23 12:58:02 +02:00
Paweł Gronowski
c95b0a97c5 Merge pull request #47742 from vvoland/update-cli
Dockerfile: update docker CLI to v26.1.0
2024-04-23 12:52:47 +02:00
racequite
147f701bd1 chore: fix function names in comment
Signed-off-by: Rui JingAn <quiterace@gmail.com>
2024-04-23 17:49:41 +08:00
Sebastiaan van Stijn
e3c59640d5 vendor: github.com/Microsoft/go-winio v0.6.2
- fileinfo: internally fix FileBasicInfo memory alignment (fixes compatibility
  with go1.22)

full diff: https://github.com/Microsoft/go-winio/compare/v0.6.1...v0.6.2

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-04-23 11:00:52 +02:00
Sebastiaan van Stijn
2140e7e0f5 vendor: golang.org/x/tools v0.16.0
It's not used in our code, but some dependencies have a "tools.go" to
force it; updating to a version that doesn't depend on golang.org/x/sys/execabs

full diff: https://github.com/golang/tools/compare/v0.14.0...v0.16.0

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-04-23 11:00:03 +02:00
Sebastiaan van Stijn
85c9900377 vendor: golang.org/x/mod v0.17.0
no changes in vendored codee

full diff: https://github.com/golang/mod/compare/v0.13.0...v0.17.0

- modfile: do not collapse if there are unattached comments within blocks
- modfile: fix crash on AddGoStmt in empty File
- modfile: improve directory path detection and error text consistency
- modfile: use new go version string format in WorkFile.add error
- sumdb: replace globsMatchPath with module.MatchPrefixPatterns
- sumdb/tlog: make NewTiles only generate strictly necessary tiles

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-04-23 10:53:17 +02:00
Paweł Gronowski
e314113ad7 Dockerfile: update docker CLI to v26.1.0
Update the CLI that's used in the dev-container

- full diff: https://github.com/docker/cli/compare/v26.0.0...v26.1.0

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-04-23 10:47:49 +02:00
Sebastiaan van Stijn
df831c943f vendor: github.com/cilium/ebpf v0.12.3
full diff: https://github.com/cilium/ebpf/compare/v0.11.0...v0.12.3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2024-04-22 13:52:44 +02:00
imalasong
194cbd6e7d Makefile: refactoring .PHONY
Signed-off-by: xiaochangbai <704566072@qq.com>
2024-04-09 09:26:31 +08:00
Antonio Aguilar
57a12a372f Update GoDoc for ioutils on atomic writers
Unlike its stdlib counterparts, AtomicFileWriter does not take into
consideration umask due to its use of chmod. Failure to recognize this
may cause subtle problems like the one described in #47498.

Therefore the documentation has been updated to let users know that
umask is not taken into consideration when using AtomicFileWriter.

Closes #47516.

Signed-off-by: Antonio Aguilar <antonio@zoftko.com>
2024-04-02 23:27:04 -06:00
avoidaway
98d51b510d chore: remove repetitive words
chore: remove repetitive words

Signed-off-by: avoidaway <cmoman@126.com>
2024-03-30 22:17:47 +08:00
Paweł Gronowski
8bbba6315f API: bump version to 1.46
Docker 26.0 was released with API v1.45, so any change in the API should
now target v1.46.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-03-29 11:07:35 +01:00
Alano Terblanche
80d92fd450 feat: ctx to client API
Signed-off-by: Alano Terblanche <18033717+Benehiko@users.noreply.github.com>
2024-03-22 13:06:43 +01:00
Jonas Geiler
838047a1f5 archive: fix ConvertRead/ConvertWrite functions for rootless docker & native diff overlay
Signed-off-by: Jonas Geiler <git@jonasgeiler.com>
2024-03-22 01:25:21 +01:00
Jonas Geiler
aef6905e01 overlay2: better documentation of user namespace behavior when checking native diff support
Signed-off-by: Jonas Geiler <git@jonasgeiler.com>
2024-03-21 22:17:54 +01:00
Jonas Geiler
f6b80253b8 overlay2: get rid of unnecessary kernel version check
Signed-off-by: Jonas Geiler <git@jonasgeiler.com>
2024-03-21 20:44:44 +01:00
Jonas Geiler
b2fd67de77 overlay2: support rootless native overlay diff in kernel 5.11 and above
Signed-off-by: Jonas Geiler <git@jonasgeiler.com>
2024-03-21 01:40:38 +01:00
Paweł Gronowski
9893520c62 libnetwork: Mark flaky tests
Mark the following tests as flaky:
- TestNetworkDBCRUDTableEntry
- TestNetworkDBCRUDTableEntries
- TestNetworkDBIslands
- TestNetworkDBNodeLeave

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-03-19 12:35:28 +01:00
Paweł Gronowski
d0d8d5d97d hack/unit: Rerun failed flaky libnetwork tests
libnetwork tests tend to be flaky (namely `TestNetworkDBIslands` and
`TestNetworkDBCRUDTableEntries`).

Move execution of tests which name has `TestFlaky` prefix to a separate
gotestsum pass which allows them to be reran 4 times.

On Windows, the libnetwork test execution is not split into a separate
pass.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2024-03-19 12:35:26 +01:00
Lars Andringa
d4f61f92fd Move StartedAt time to before starting the container
Signed-off-by: Lars Andringa <l.s.andringa@rug.nl>
Signed-off-by: LarsSven <l.s.andringa@rug.nl>

Replaced boolean parameter by IsZero check

Signed-off-by: LarsSven <l.s.andringa@rug.nl>

Separated SetRunning into two functions

Signed-off-by: LarsSven <l.s.andringa@rug.nl>

Apply suggestions from code review

Documentation fixes

Co-authored-by: Paweł Gronowski <me@woland.xyz>
Signed-off-by: LarsSven <l.s.andringa@rug.nl>
2024-03-12 16:20:21 +01:00
Bjorn Neergaard
a52aab8598 project,vendor.mod: document more clearly that we are not a Go module
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-11-03 10:27:48 -06:00
Bjorn Neergaard
1e28299f77 project: document currently known packagers
Note that this entire document needs a modernization pass, both for
current best practices as well as something approximating
s/Docker/Moby/.

In the interest of making some forward progress, we'll make minimal
changes for now, however.

Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-11-03 10:27:47 -06:00
Bjorn Neergaard
f502f49e49 project: document modern branch and tag practices
Signed-off-by: Bjorn Neergaard <bjorn.neergaard@docker.com>
2023-11-03 10:27:44 -06:00
4698 changed files with 362467 additions and 178804 deletions

View File

@@ -19,11 +19,14 @@ Please provide the following information:
**- How to verify it**
**- Description for the changelog**
**- Human readable description for the release notes**
<!--
Write a short (one line) summary that describes the changes in this
pull request for inclusion in the changelog.
It must be placed inside the below triple backticks section:
It must be placed inside the below triple backticks section.
NOTE: Only fill this section if changes introduced in this PR are user-facing.
The PR must have a relevant impact/ label.
-->
```markdown changelog

View File

@@ -3,15 +3,25 @@ name: .dco
# TODO: hide reusable workflow from the UI. Tracked in https://github.com/community/community/discussions/12025
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
on:
workflow_call:
env:
ALPINE_VERSION: 3.16
ALPINE_VERSION: "3.21"
jobs:
run:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 10 # guardrails timeout for the whole job
steps:
-
name: Checkout
@@ -39,10 +49,12 @@ jobs:
name: Validate
run: |
docker run --rm \
-v "$(pwd):/workspace" \
--quiet \
-v ./:/workspace \
-w /workspace \
-e VALIDATE_REPO \
-e VALIDATE_BRANCH \
alpine:${{ env.ALPINE_VERSION }} sh -c 'apk add --no-cache -q bash git openssh-client && git config --system --add safe.directory /workspace && cd /workspace && hack/validate/dco'
alpine:${{ env.ALPINE_VERSION }} sh -c 'apk add --no-cache -q bash git openssh-client && git config --system --add safe.directory /workspace && hack/validate/dco'
env:
VALIDATE_REPO: ${{ github.server_url }}/${{ github.repository }}.git
VALIDATE_BRANCH: ${{ steps.base-ref.outputs.result }}

View File

@@ -3,6 +3,15 @@ name: .test-prepare
# TODO: hide reusable workflow from the UI. Tracked in https://github.com/community/community/discussions/12025
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
on:
workflow_call:
outputs:
@@ -12,7 +21,8 @@ on:
jobs:
run:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
outputs:
matrix: ${{ steps.set.outputs.matrix }}
steps:

View File

@@ -3,6 +3,15 @@ name: .test
# TODO: hide reusable workflow from the UI. Tracked in https://github.com/community/community/discussions/12025
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
on:
workflow_call:
inputs:
@@ -12,19 +21,57 @@ on:
default: "graphdriver"
env:
GO_VERSION: "1.21.9"
GO_VERSION: "1.23.7"
GOTESTLIST_VERSION: v0.3.1
TESTSTAT_VERSION: v0.1.25
ITG_CLI_MATRIX_SIZE: 6
DOCKER_EXPERIMENTAL: 1
DOCKER_GRAPHDRIVER: ${{ inputs.storage == 'snapshotter' && 'overlayfs' || 'overlay2' }}
TEST_INTEGRATION_USE_SNAPSHOTTER: ${{ inputs.storage == 'snapshotter' && '1' || '' }}
SETUP_BUILDX_VERSION: edge
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
jobs:
unit:
runs-on: ubuntu-20.04
unit-prepare:
runs-on: ubuntu-24.04
timeout-minutes: 10 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
timeout-minutes: 120
outputs:
includes: ${{ steps.set.outputs.includes }}
steps:
-
name: Create matrix includes
id: set
uses: actions/github-script@v7
with:
script: |
let includes = [
{ mode: '' },
{ mode: 'rootless' },
{ mode: 'systemd' },
];
if ("${{ inputs.storage }}" == "snapshotter") {
includes.push({ mode: 'firewalld' });
}
await core.group(`Set matrix`, async () => {
core.info(`matrix: ${JSON.stringify(includes)}`);
core.setOutput('includes', JSON.stringify(includes));
});
-
name: Show matrix
run: |
echo ${{ steps.set.outputs.includes }}
unit:
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
needs:
- unit-prepare
strategy:
fail-fast: false
matrix:
include: ${{ fromJson(needs.unit-prepare.outputs.includes) }}
steps:
-
name: Checkout
@@ -32,12 +79,25 @@ jobs:
-
name: Set up runner
uses: ./.github/actions/setup-runner
-
name: Prepare
run: |
CACHE_DEV_SCOPE=dev
if [[ "${{ matrix.mode }}" == *"firewalld"* ]]; then
echo "DOCKER_FIREWALLD=true" >> $GITHUB_ENV
CACHE_DEV_SCOPE="${CACHE_DEV_SCOPE}firewalld"
fi
echo "CACHE_DEV_SCOPE=${CACHE_DEV_SCOPE}" >> $GITHUB_ENV
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dev image
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
targets: dev
set: |
@@ -68,14 +128,14 @@ jobs:
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-unit-${{ inputs.storage }}
name: test-reports-unit-${{ inputs.storage }}-${{ matrix.mode }}
path: /tmp/reports/*
retention-days: 1
unit-report:
runs-on: ubuntu-20.04
continue-on-error: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-24.04
timeout-minutes: 10
continue-on-error: ${{ github.event_name != 'pull_request' }}
if: always()
needs:
- unit
@@ -85,11 +145,12 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: Download reports
uses: actions/download-artifact@v4
with:
name: test-reports-unit-${{ inputs.storage }}
pattern: test-reports-unit-${{ inputs.storage }}-*
path: /tmp/reports
-
name: Install teststat
@@ -101,9 +162,9 @@ jobs:
find /tmp/reports -type f -name '*-go-test-report.json' -exec teststat -markdown {} \+ >> $GITHUB_STEP_SUMMARY
docker-py:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
timeout-minutes: 120
steps:
-
name: Checkout
@@ -117,9 +178,13 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dev image
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
targets: dev
set: |
@@ -127,7 +192,7 @@ jobs:
-
name: Test
run: |
make -o build test-docker-py
make TEST_SKIP_INTEGRATION_CLI=1 -o build test-docker-py
-
name: Prepare reports
if: always()
@@ -155,8 +220,8 @@ jobs:
integration-flaky:
runs-on: ubuntu-20.04
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
timeout-minutes: 120
steps:
-
name: Checkout
@@ -167,9 +232,13 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dev image
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
targets: dev
set: |
@@ -181,21 +250,52 @@ jobs:
env:
TEST_SKIP_INTEGRATION_CLI: 1
integration-prepare:
runs-on: ubuntu-24.04
timeout-minutes: 10 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
outputs:
includes: ${{ steps.set.outputs.includes }}
steps:
-
name: Create matrix includes
id: set
uses: actions/github-script@v7
with:
script: |
let includes = [
{ os: 'ubuntu-20.04', mode: '' },
{ os: 'ubuntu-20.04', mode: 'rootless' },
{ os: 'ubuntu-20.04', mode: 'systemd' },
{ os: 'ubuntu-24.04', mode: '' },
{ os: 'ubuntu-22.04', mode: 'rootless' },
// { os: 'ubuntu-24.04', mode: 'rootless' }, // FIXME: https://github.com/moby/moby/pull/49579#issuecomment-2698622223
{ os: 'ubuntu-24.04', mode: 'systemd' },
// { os: 'ubuntu-20.04', mode: 'rootless-systemd' }, // FIXME: https://github.com/moby/moby/issues/44084
// { os: 'ubuntu-24.04', mode: 'rootless-systemd' }, // FIXME: https://github.com/moby/moby/issues/44084
];
if ("${{ inputs.storage }}" == "snapshotter") {
includes.push({ os: 'ubuntu-24.04', mode: 'firewalld' });
}
await core.group(`Set matrix`, async () => {
core.info(`matrix: ${JSON.stringify(includes)}`);
core.setOutput('includes', JSON.stringify(includes));
});
-
name: Show matrix
run: |
echo ${{ steps.set.outputs.includes }}
integration:
runs-on: ${{ matrix.os }}
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
timeout-minutes: 120
needs:
- integration-prepare
strategy:
fail-fast: false
matrix:
os:
- ubuntu-20.04
- ubuntu-22.04
mode:
- ""
- rootless
- systemd
#- rootless-systemd FIXME: https://github.com/moby/moby/issues/44084
include: ${{ fromJson(needs.integration-prepare.outputs.includes) }}
steps:
-
name: Checkout
@@ -217,13 +317,21 @@ jobs:
echo "SYSTEMD=true" >> $GITHUB_ENV
CACHE_DEV_SCOPE="${CACHE_DEV_SCOPE}systemd"
fi
if [[ "${{ matrix.mode }}" == *"firewalld"* ]]; then
echo "DOCKER_FIREWALLD=true" >> $GITHUB_ENV
CACHE_DEV_SCOPE="${CACHE_DEV_SCOPE}firewalld"
fi
echo "CACHE_DEV_SCOPE=${CACHE_DEV_SCOPE}" >> $GITHUB_ENV
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dev image
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
targets: dev
set: |
@@ -276,9 +384,9 @@ jobs:
retention-days: 1
integration-report:
runs-on: ubuntu-20.04
continue-on-error: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-24.04
timeout-minutes: 10
continue-on-error: ${{ github.event_name != 'pull_request' }}
if: always()
needs:
- integration
@@ -288,6 +396,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: Download reports
uses: actions/download-artifact@v4
@@ -305,10 +414,11 @@ jobs:
find /tmp/reports -type f -name '*-go-test-report.json' -exec teststat -markdown {} \+ >> $GITHUB_STEP_SUMMARY
integration-cli-prepare:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
outputs:
matrix: ${{ steps.tests.outputs.matrix }}
matrix: ${{ steps.set.outputs.matrix }}
steps:
-
name: Checkout
@@ -318,12 +428,13 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: Install gotestlist
run:
go install github.com/crazy-max/gotestlist/cmd/gotestlist@${{ env.GOTESTLIST_VERSION }}
-
name: Create matrix
name: Create test matrix
id: tests
working-directory: ./integration-cli
run: |
@@ -335,20 +446,53 @@ jobs:
matrix="$(gotestlist -d ${{ env.ITG_CLI_MATRIX_SIZE }} -o "./..." -o "DockerSwarmSuite" -o "DockerNetworkSuite|DockerExternalVolumeSuite" ./...)"
echo "matrix=$matrix" >> $GITHUB_OUTPUT
-
name: Show matrix
name: Create gha matrix
id: set
uses: actions/github-script@v7
with:
script: |
let matrix = {
test: ${{ steps.tests.outputs.matrix }},
include: [],
};
// For some reasons, GHA doesn't combine a dynamically defined
// 'include' with other matrix variables that aren't part of the
// include items.
// Moreover, since the goal is to run only relevant tests with
// firewalld enabled to minimize the number of CI jobs, we
// statically define the list of test suites that we want to run.
if ("${{ inputs.storage }}" == "snapshotter") {
matrix.include.push({
'mode': 'firewalld',
'test': 'DockerCLINetworkSuite|DockerCLIPortSuite|DockerDaemonSuite'
});
matrix.include.push({
'mode': 'firewalld',
'test': 'DockerSwarmSuite'
});
matrix.include.push({
'mode': 'firewalld',
'test': 'DockerNetworkSuite'
});
}
await core.group(`Set matrix`, async () => {
core.info(`matrix: ${JSON.stringify(matrix)}`);
core.setOutput('matrix', JSON.stringify(matrix));
});
-
name: Show final gha matrix
run: |
echo ${{ steps.tests.outputs.matrix }}
echo ${{ steps.set.outputs.matrix }}
integration-cli:
runs-on: ubuntu-20.04
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
timeout-minutes: 120
needs:
- integration-cli-prepare
strategy:
fail-fast: false
matrix:
test: ${{ fromJson(needs.integration-cli-prepare.outputs.matrix) }}
matrix: ${{ fromJson(needs.integration-cli-prepare.outputs.matrix) }}
steps:
-
name: Checkout
@@ -359,12 +503,25 @@ jobs:
-
name: Set up tracing
uses: ./.github/actions/setup-tracing
-
name: Prepare
run: |
CACHE_DEV_SCOPE=dev
if [[ "${{ matrix.mode }}" == *"firewalld"* ]]; then
echo "DOCKER_FIREWALLD=true" >> $GITHUB_ENV
CACHE_DEV_SCOPE="${CACHE_DEV_SCOPE}firewalld"
fi
echo "CACHE_DEV_SCOPE=${CACHE_DEV_SCOPE}" >> $GITHUB_ENV
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dev image
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
targets: dev
set: |
@@ -416,9 +573,9 @@ jobs:
retention-days: 1
integration-cli-report:
runs-on: ubuntu-20.04
continue-on-error: ${{ github.event_name != 'pull_request' }}
runs-on: ubuntu-24.04
timeout-minutes: 10
continue-on-error: ${{ github.event_name != 'pull_request' }}
if: always()
needs:
- integration-cli
@@ -428,6 +585,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: Download reports
uses: actions/download-artifact@v4

View File

@@ -3,6 +3,15 @@ name: .windows
# TODO: hide reusable workflow from the UI. Tracked in https://github.com/community/community/discussions/12025
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
on:
workflow_call:
inputs:
@@ -19,7 +28,7 @@ on:
default: false
env:
GO_VERSION: "1.21.9"
GO_VERSION: "1.23.7"
GOTESTLIST_VERSION: v0.3.1
TESTSTAT_VERSION: v0.1.25
WINDOWS_BASE_IMAGE: mcr.microsoft.com/windows/servercore
@@ -33,6 +42,7 @@ env:
jobs:
build:
runs-on: ${{ inputs.os }}
timeout-minutes: 120 # guardrails timeout for the whole job
env:
GOPATH: ${{ github.workspace }}\go
GOBIN: ${{ github.workspace }}\go\bin
@@ -112,7 +122,7 @@ jobs:
unit-test:
runs-on: ${{ inputs.os }}
timeout-minutes: 120
timeout-minutes: 120 # guardrails timeout for the whole job
env:
GOPATH: ${{ github.workspace }}\go
GOBIN: ${{ github.workspace }}\go\bin
@@ -193,7 +203,8 @@ jobs:
retention-days: 1
unit-test-report:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
if: always()
needs:
- unit-test
@@ -203,6 +214,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: Download artifacts
uses: actions/download-artifact@v4
@@ -219,7 +231,8 @@ jobs:
find /tmp/artifacts -type f -name '*-go-test-report.json' -exec teststat -markdown {} \+ >> $GITHUB_STEP_SUMMARY
integration-test-prepare:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
outputs:
matrix: ${{ steps.tests.outputs.matrix }}
steps:
@@ -231,6 +244,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: Install gotestlist
run:
@@ -253,8 +267,8 @@ jobs:
integration-test:
runs-on: ${{ inputs.os }}
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ inputs.storage == 'snapshotter' && github.event_name != 'pull_request' }}
timeout-minutes: 120
needs:
- build
- integration-test-prepare
@@ -335,33 +349,12 @@ jobs:
$ErrorActionPreference = "Stop"
Write-Host "Service removed"
}
-
name: Starting containerd
if: matrix.runtime == 'containerd'
run: |
Write-Host "Generating config"
& "${{ env.BIN_OUT }}\containerd.exe" config default | Out-File "$env:TEMP\ctn.toml" -Encoding ascii
Write-Host "Creating service"
New-Item -ItemType Directory "$env:TEMP\ctn-root" -ErrorAction SilentlyContinue | Out-Null
New-Item -ItemType Directory "$env:TEMP\ctn-state" -ErrorAction SilentlyContinue | Out-Null
Start-Process -Wait "${{ env.BIN_OUT }}\containerd.exe" `
-ArgumentList "--log-level=debug", `
"--config=$env:TEMP\ctn.toml", `
"--address=\\.\pipe\containerd-containerd", `
"--root=$env:TEMP\ctn-root", `
"--state=$env:TEMP\ctn-state", `
"--log-file=$env:TEMP\ctn.log", `
"--register-service"
Write-Host "Starting service"
Start-Service -Name containerd
Start-Sleep -Seconds 5
Write-Host "Service started successfully!"
-
name: Starting test daemon
run: |
Write-Host "Creating service"
If ("${{ matrix.runtime }}" -eq "containerd") {
$runtimeArg="--containerd=\\.\pipe\containerd-containerd"
$runtimeArg="--default-runtime=io.containerd.runhcs.v1"
echo "DOCKER_WINDOWS_CONTAINERD_RUNTIME=1" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append
}
New-Item -ItemType Directory "$env:TEMP\moby-root" -ErrorAction SilentlyContinue | Out-Null
@@ -401,6 +394,17 @@ jobs:
Start-Sleep -Seconds 1
}
Write-Host "Test daemon started and replied!"
If ("${{ matrix.runtime }}" -eq "containerd") {
$containerdProcesses = Get-Process -Name containerd -ErrorAction:SilentlyContinue
If (-not $containerdProcesses) {
Throw "containerd process is not running"
} else {
foreach ($process in $containerdProcesses) {
$processPath = (Get-Process -Id $process.Id -FileVersionInfo).FileName
Write-Output "Running containerd instance binary Path: $($processPath)"
}
}
}
env:
DOCKER_HOST: npipe:////./pipe/docker_engine
-
@@ -429,6 +433,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: Test integration
if: matrix.test == './...'
@@ -464,19 +469,6 @@ jobs:
& "${{ env.BIN_OUT }}\docker" info
env:
DOCKER_HOST: npipe:////./pipe/docker_engine
-
name: Stop containerd
if: always() && matrix.runtime == 'containerd'
run: |
$ErrorActionPreference = "SilentlyContinue"
Stop-Service -Force -Name containerd
$ErrorActionPreference = "Stop"
-
name: Containerd logs
if: always() && matrix.runtime == 'containerd'
run: |
Copy-Item "$env:TEMP\ctn.log" -Destination ".\bundles\containerd.log"
Get-Content "$env:TEMP\ctn.log" | Out-Host
-
name: Stop daemon
if: always()
@@ -512,7 +504,8 @@ jobs:
retention-days: 1
integration-test-report:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ inputs.storage == 'snapshotter' && github.event_name != 'pull_request' }}
if: always()
needs:
@@ -534,6 +527,7 @@ jobs:
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: Download reports
uses: actions/download-artifact@v4

276
.github/workflows/arm64.yml vendored Normal file
View File

@@ -0,0 +1,276 @@
name: arm64
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
push:
branches:
- 'master'
- '[0-9]+.[0-9]+'
- '[0-9]+.x'
pull_request:
env:
GO_VERSION: "1.23.7"
TESTSTAT_VERSION: v0.1.25
DESTDIR: ./build
SETUP_BUILDX_VERSION: edge
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
DOCKER_EXPERIMENTAL: 1
jobs:
validate-dco:
uses: ./.github/workflows/.dco.yml
build:
runs-on: ubuntu-24.04-arm
timeout-minutes: 20 # guardrails timeout for the whole job
needs:
- validate-dco
strategy:
fail-fast: false
matrix:
target:
- binary
- dynbinary
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build
uses: docker/bake-action@v6
with:
targets: ${{ matrix.target }}
-
name: List artifacts
run: |
tree -nh ${{ env.DESTDIR }}
-
name: Check artifacts
run: |
find ${{ env.DESTDIR }} -type f -exec file -e ascii -- {} +
build-dev:
runs-on: ubuntu-24.04-arm
timeout-minutes: 120 # guardrails timeout for the whole job
needs:
- validate-dco
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dev image
uses: docker/bake-action@v6
with:
targets: dev
set: |
*.cache-from=type=gha,scope=dev-arm64
*.cache-to=type=gha,scope=dev-arm64,mode=max
*.output=type=cacheonly
test-unit:
runs-on: ubuntu-24.04-arm
timeout-minutes: 120 # guardrails timeout for the whole job
needs:
- build-dev
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up runner
uses: ./.github/actions/setup-runner
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dev image
uses: docker/bake-action@v6
with:
targets: dev
set: |
dev.cache-from=type=gha,scope=dev-arm64
-
name: Test
run: |
make -o build test-unit
-
name: Prepare reports
if: always()
run: |
mkdir -p bundles /tmp/reports
find bundles -path '*/root/*overlay2' -prune -o -type f \( -name '*-report.json' -o -name '*.log' -o -name '*.out' -o -name '*.prof' -o -name '*-report.xml' \) -print | xargs sudo tar -czf /tmp/reports.tar.gz
tar -xzf /tmp/reports.tar.gz -C /tmp/reports
sudo chown -R $(id -u):$(id -g) /tmp/reports
tree -nh /tmp/reports
-
name: Send to Codecov
uses: codecov/codecov-action@v4
with:
directory: ./bundles
env_vars: RUNNER_OS
flags: unit
token: ${{ secrets.CODECOV_TOKEN }} # used to upload coverage reports: https://github.com/moby/buildkit/pull/4660#issue-2142122533
-
name: Upload reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-unit-arm64-graphdriver
path: /tmp/reports/*
retention-days: 1
test-unit-report:
runs-on: ubuntu-24.04
timeout-minutes: 10
continue-on-error: ${{ github.event_name != 'pull_request' }}
if: always()
needs:
- test-unit
steps:
-
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: Download reports
uses: actions/download-artifact@v4
with:
pattern: test-reports-unit-arm64-*
path: /tmp/reports
-
name: Install teststat
run: |
go install github.com/vearutop/teststat@${{ env.TESTSTAT_VERSION }}
-
name: Create summary
run: |
find /tmp/reports -type f -name '*-go-test-report.json' -exec teststat -markdown {} \+ >> $GITHUB_STEP_SUMMARY
test-integration:
runs-on: ubuntu-24.04-arm
timeout-minutes: 120 # guardrails timeout for the whole job
continue-on-error: ${{ github.event_name != 'pull_request' }}
needs:
- build-dev
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up runner
uses: ./.github/actions/setup-runner
-
name: Set up tracing
uses: ./.github/actions/setup-tracing
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dev image
uses: docker/bake-action@v6
with:
targets: dev
set: |
dev.cache-from=type=gha,scope=dev-arm64
-
name: Test
run: |
make -o build test-integration
env:
TEST_SKIP_INTEGRATION_CLI: 1
TESTCOVERAGE: 1
-
name: Prepare reports
if: always()
run: |
reportsPath="/tmp/reports/arm64-graphdriver"
mkdir -p bundles $reportsPath
find bundles -path '*/root/*overlay2' -prune -o -type f \( -name '*-report.json' -o -name '*.log' -o -name '*.out' -o -name '*.prof' -o -name '*-report.xml' \) -print | xargs sudo tar -czf /tmp/reports.tar.gz
tar -xzf /tmp/reports.tar.gz -C $reportsPath
sudo chown -R $(id -u):$(id -g) $reportsPath
tree -nh $reportsPath
curl -sSLf localhost:16686/api/traces?service=integration-test-client > $reportsPath/jaeger-trace.json
-
name: Send to Codecov
uses: codecov/codecov-action@v4
with:
directory: ./bundles/test-integration
env_vars: RUNNER_OS
flags: integration
token: ${{ secrets.CODECOV_TOKEN }} # used to upload coverage reports: https://github.com/moby/buildkit/pull/4660#issue-2142122533
-
name: Test daemon logs
if: always()
run: |
cat bundles/test-integration/docker.log
-
name: Upload reports
if: always()
uses: actions/upload-artifact@v4
with:
name: test-reports-integration-arm64-graphdriver
path: /tmp/reports/*
retention-days: 1
test-integration-report:
runs-on: ubuntu-24.04
timeout-minutes: 10
continue-on-error: ${{ github.event_name != 'pull_request' }}
if: always()
needs:
- test-integration
steps:
-
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: Download reports
uses: actions/download-artifact@v4
with:
path: /tmp/reports
pattern: test-reports-integration-arm64-*
merge-multiple: true
-
name: Install teststat
run: |
go install github.com/vearutop/teststat@${{ env.TESTSTAT_VERSION }}
-
name: Create summary
run: |
find /tmp/reports -type f -name '*-go-test-report.json' -exec teststat -markdown {} \+ >> $GITHUB_STEP_SUMMARY

View File

@@ -1,5 +1,14 @@
name: bin-image
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@@ -10,6 +19,7 @@ on:
branches:
- 'master'
- '[0-9]+.[0-9]+'
- '[0-9]+.x'
tags:
- 'v*'
pull_request:
@@ -21,6 +31,8 @@ env:
PLATFORM: Moby Engine - Nightly
PRODUCT: moby-bin
PACKAGER_NAME: The Moby Project
SETUP_BUILDX_VERSION: edge
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
jobs:
validate-dco:
@@ -28,7 +40,8 @@ jobs:
uses: ./.github/workflows/.dco.yml
prepare:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 20 # guardrails timeout for the whole job
outputs:
platforms: ${{ steps.platforms.outputs.matrix }}
steps:
@@ -46,7 +59,7 @@ jobs:
## push semver tag v23.0.0
# moby/moby-bin:23.0.0
# moby/moby-bin:latest
## push semver prelease tag v23.0.0-beta.1
## push semver prerelease tag v23.0.0-beta.1
# moby/moby-bin:23.0.0-beta.1
## push on master
# moby/moby-bin:master
@@ -80,7 +93,8 @@ jobs:
echo "matrix=$(docker buildx bake bin-image-cross --print | jq -cr '.target."bin-image-cross".platforms')" >>${GITHUB_OUTPUT}
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
needs:
- validate-dco
- prepare
@@ -90,16 +104,16 @@ jobs:
matrix:
platform: ${{ fromJson(needs.prepare.outputs.platforms) }}
steps:
-
name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Prepare
run: |
platform=${{ matrix.platform }}
echo "PLATFORM_PAIR=${platform//\//-}" >> $GITHUB_ENV
-
name: Download meta bake definition
uses: actions/download-artifact@v4
@@ -112,6 +126,10 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Login to Docker Hub
if: github.event_name != 'pull_request' && github.repository == 'moby/moby'
@@ -122,8 +140,9 @@ jobs:
-
name: Build
id: bake
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
source: .
files: |
./docker-bake.hcl
/tmp/bake-meta.json
@@ -150,7 +169,8 @@ jobs:
retention-days: 1
merge:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
needs:
- build
if: always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') && github.event_name != 'pull_request' && github.repository == 'moby/moby'
@@ -171,6 +191,10 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Login to Docker Hub
uses: docker/login-action@v3

View File

@@ -1,5 +1,14 @@
name: buildkit
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@@ -10,30 +19,35 @@ on:
branches:
- 'master'
- '[0-9]+.[0-9]+'
- '[0-9]+.x'
pull_request:
env:
GO_VERSION: "1.21.9"
GO_VERSION: "1.23.7"
DESTDIR: ./build
SETUP_BUILDX_VERSION: edge
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
jobs:
validate-dco:
uses: ./.github/workflows/.dco.yml
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
needs:
- validate-dco
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
targets: binary
-
@@ -46,8 +60,8 @@ jobs:
retention-days: 1
test:
runs-on: ubuntu-20.04
timeout-minutes: 120
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
needs:
- build
env:
@@ -87,6 +101,12 @@ jobs:
uses: actions/checkout@v4
with:
path: moby
-
name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ env.GO_VERSION }}
cache-dependency-path: vendor.sum
-
name: BuildKit ref
run: |
@@ -105,6 +125,10 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Download binary artifacts
uses: actions/download-artifact@v4
@@ -120,8 +144,9 @@ jobs:
docker info
-
name: Build test image
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
source: .
workdir: ./buildkit
targets: integration-tests
set: |

View File

@@ -1,5 +1,14 @@
name: ci
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@@ -10,17 +19,21 @@ on:
branches:
- 'master'
- '[0-9]+.[0-9]+'
- '[0-9]+.x'
pull_request:
env:
DESTDIR: ./build
SETUP_BUILDX_VERSION: edge
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
jobs:
validate-dco:
uses: ./.github/workflows/.dco.yml
build:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 20 # guardrails timeout for the whole job
needs:
- validate-dco
strategy:
@@ -30,17 +43,16 @@ jobs:
- binary
- dynbinary
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
targets: ${{ matrix.target }}
-
@@ -53,7 +65,8 @@ jobs:
find ${{ env.DESTDIR }} -type f -exec file -e ascii -- {} +
prepare-cross:
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
timeout-minutes: 20 # guardrails timeout for the whole job
needs:
- validate-dco
outputs:
@@ -74,7 +87,8 @@ jobs:
echo ${{ steps.platforms.outputs.matrix }}
cross:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 20 # guardrails timeout for the whole job
needs:
- validate-dco
- prepare-cross
@@ -83,11 +97,6 @@ jobs:
matrix:
platform: ${{ fromJson(needs.prepare-cross.outputs.matrix) }}
steps:
-
name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
-
name: Prepare
run: |
@@ -96,9 +105,13 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
targets: all
set: |
@@ -111,3 +124,33 @@ jobs:
name: Check artifacts
run: |
find ${{ env.DESTDIR }} -type f -exec file -e ascii -- {} +
govulncheck:
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
permissions:
# required to write sarif report
security-events: write
# required to check out the repository
contents: read
steps:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Run
uses: docker/bake-action@v6
with:
targets: govulncheck
env:
GOVULNCHECK_FORMAT: sarif
-
name: Upload SARIF report
if: ${{ github.event_name != 'pull_request' && github.repository == 'moby/moby' }}
uses: github/codeql-action/upload-sarif@v3
with:
sarif_file: ${{ env.DESTDIR }}/govulncheck.out

71
.github/workflows/codeql.yml vendored Normal file
View File

@@ -0,0 +1,71 @@
name: codeql
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
on:
push:
branches:
- 'master'
- '[0-9]+.[0-9]+'
- '[0-9]+.x'
tags:
- 'v*'
pull_request:
# The branches below must be a subset of the branches above
branches: ["master"]
schedule:
# ┌───────────── minute (0 - 59)
# │ ┌───────────── hour (0 - 23)
# │ │ ┌───────────── day of the month (1 - 31)
# │ │ │ ┌───────────── month (1 - 12)
# │ │ │ │ ┌───────────── day of the week (0 - 6) (Sunday to Saturday)
# │ │ │ │ │
# │ │ │ │ │
# │ │ │ │ │
# * * * * *
- cron: '0 9 * * 4'
jobs:
codeql:
runs-on: ubuntu-24.04
timeout-minutes: 10
permissions:
actions: read
contents: read
security-events: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 2
# CodeQL 2.16.4's auto-build added support for multi-module repositories,
# and is trying to be smart by searching for modules in every directory,
# including vendor directories. If no module is found, it's creating one
# which is ... not what we want, so let's give it a "go.mod".
# see: https://github.com/docker/cli/pull/4944#issuecomment-2002034698
- name: Create go.mod
run: |
ln -s vendor.mod go.mod
ln -s vendor.sum go.sum
- name: Update Go
uses: actions/setup-go@v5
with:
go-version: "1.23.7"
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: go
- name: Autobuild
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:go"

View File

@@ -1,5 +1,14 @@
name: test
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@@ -10,19 +19,23 @@ on:
branches:
- 'master'
- '[0-9]+.[0-9]+'
- '[0-9]+.x'
pull_request:
env:
GO_VERSION: "1.21.9"
GO_VERSION: "1.23.7"
GIT_PAGER: "cat"
PAGER: "cat"
SETUP_BUILDX_VERSION: edge
SETUP_BUILDKIT_IMAGE: moby/buildkit:latest
jobs:
validate-dco:
uses: ./.github/workflows/.dco.yml
build-dev:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
needs:
- validate-dco
strategy:
@@ -38,15 +51,16 @@ jobs:
if [ "${{ matrix.mode }}" = "systemd" ]; then
echo "SYSTEMD=true" >> $GITHUB_ENV
fi
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dev image
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
targets: dev
set: |
@@ -70,7 +84,8 @@ jobs:
storage: ${{ matrix.storage }}
validate-prepare:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 10 # guardrails timeout for the whole job
needs:
- validate-dco
outputs:
@@ -91,8 +106,8 @@ jobs:
echo ${{ steps.scripts.outputs.matrix }}
validate:
runs-on: ubuntu-20.04
timeout-minutes: 120
runs-on: ubuntu-24.04
timeout-minutes: 30 # guardrails timeout for the whole job
needs:
- validate-prepare
- build-dev
@@ -112,9 +127,13 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Build dev image
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
targets: dev
set: |
@@ -125,7 +144,8 @@ jobs:
make -o build validate-${{ matrix.script }}
smoke-prepare:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 10 # guardrails timeout for the whole job
needs:
- validate-dco
outputs:
@@ -146,7 +166,8 @@ jobs:
echo ${{ steps.platforms.outputs.matrix }}
smoke:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 20 # guardrails timeout for the whole job
needs:
- smoke-prepare
strategy:
@@ -154,9 +175,6 @@ jobs:
matrix:
platform: ${{ fromJson(needs.smoke-prepare.outputs.matrix) }}
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Prepare
run: |
@@ -168,9 +186,13 @@ jobs:
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
version: ${{ env.SETUP_BUILDX_VERSION }}
driver-opts: image=${{ env.SETUP_BUILDKIT_IMAGE }}
buildkitd-flags: --debug
-
name: Test
uses: docker/bake-action@v4
uses: docker/bake-action@v6
with:
targets: binary-smoketest
set: |

View File

@@ -1,12 +1,22 @@
name: validate-pr
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
on:
pull_request:
types: [opened, edited, labeled, unlabeled]
types: [opened, edited, labeled, unlabeled, synchronize]
jobs:
check-area-label:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
steps:
- name: Missing `area/` label
if: contains(join(github.event.pull_request.labels.*.name, ','), 'impact/') && !contains(join(github.event.pull_request.labels.*.name, ','), 'area/')
@@ -17,9 +27,10 @@ jobs:
run: exit 0
check-changelog:
if: contains(join(github.event.pull_request.labels.*.name, ','), 'impact/')
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
env:
HAS_IMPACT_LABEL: ${{ contains(join(github.event.pull_request.labels.*.name, ','), 'impact/') }}
PR_BODY: |
${{ github.event.pull_request.body }}
steps:
@@ -31,32 +42,47 @@ jobs:
# Strip empty lines
desc=$(echo "$block" | awk NF)
if [ -z "$desc" ]; then
echo "::error::Changelog section is empty. Please provide a description for the changelog."
exit 1
fi
if [ "$HAS_IMPACT_LABEL" = "true" ]; then
if [ -z "$desc" ]; then
echo "::error::Changelog section is empty. Please provide a description for the changelog."
exit 1
fi
len=$(echo -n "$desc" | wc -c)
if [[ $len -le 6 ]]; then
echo "::error::Description looks too short: $desc"
exit 1
len=$(echo -n "$desc" | wc -c)
if [[ $len -le 6 ]]; then
echo "::error::Description looks too short: $desc"
exit 1
fi
else
if [ -n "$desc" ]; then
echo "::error::PR has a changelog description, but no changelog label"
echo "::error::Please add the relevant 'impact/' label to the PR or remove the changelog description"
exit 1
fi
fi
echo "This PR will be included in the release notes with the following note:"
echo "$desc"
check-pr-branch:
runs-on: ubuntu-20.04
runs-on: ubuntu-24.04
timeout-minutes: 120 # guardrails timeout for the whole job
env:
PR_TITLE: ${{ github.event.pull_request.title }}
steps:
# Backports or PR that target a release branch directly should mention the target branch in the title, for example:
# [X.Y backport] Some change that needs backporting to X.Y
# [X.Y] Change directly targeting the X.Y branch
- name: Get branch from PR title
id: title_branch
run: echo "$PR_TITLE" | sed -n 's/^\[\([0-9]*\.[0-9]*\)[^]]*\].*/branch=\1/p' >> $GITHUB_OUTPUT
- name: Check release branch
if: github.event.pull_request.base.ref != steps.title_branch.outputs.branch && !(github.event.pull_request.base.ref == 'master' && steps.title_branch.outputs.branch == '')
run: echo "::error::PR title suggests targetting the ${{ steps.title_branch.outputs.branch }} branch, but is opened against ${{ github.event.pull_request.base.ref }}" && exit 1
id: title_branch
run: |
# get the intended major version prefix ("[27.1 backport]" -> "27.") from the PR title.
[[ "$PR_TITLE" =~ ^\[([0-9]*\.)[^]]*\] ]] && branch="${BASH_REMATCH[1]}"
# get major version prefix from the release branch ("27.x -> "27.")
[[ "$GITHUB_BASE_REF" =~ ^([0-9]*\.) ]] && target_branch="${BASH_REMATCH[1]}" || target_branch="$GITHUB_BASE_REF"
if [[ "$target_branch" != "$branch" ]] && ! [[ "$GITHUB_BASE_REF" == "master" && "$branch" == "" ]]; then
echo "::error::PR is opened against the $GITHUB_BASE_REF branch, but its title suggests otherwise."
exit 1
fi

View File

@@ -1,5 +1,14 @@
name: windows-2019
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

View File

@@ -1,5 +1,14 @@
name: windows-2022
# Default to 'contents: read', which grants actions to read commits.
#
# If any permission is set, any permission not included in the list is
# implicitly set to "none".
#
# see https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#permissions
permissions:
contents: read
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@@ -10,6 +19,7 @@ on:
branches:
- 'master'
- '[0-9]+.[0-9]+'
- '[0-9]+.x'
pull_request:
jobs:

View File

@@ -1,50 +1,51 @@
linters:
enable:
- asasalint # Detects "[]any" used as argument for variadic "func(...any)".
- copyloopvar # Detects places where loop variables are copied.
- depguard
- dupword # Checks for duplicate words in the source code.
- dogsled # Detects assignments with too many blank identifiers.
- dupword # Detects duplicate words.
- durationcheck # Detect cases where two time.Duration values are being multiplied in possibly erroneous ways.
- errchkjson # Detects unsupported types passed to json encoding functions and reports if checks for the returned error can be omitted.
- exhaustive # Detects missing options in enum switch statements.
- exptostd # Detects functions from golang.org/x/exp/ that can be replaced by std functions.
- fatcontext # Detects nested contexts in loops and function literals.
- gocheckcompilerdirectives # Detects invalid go compiler directive comments (//go:).
- goimports
- gosec
- gosec # Detects security problems.
- gosimple
- govet
- forbidigo
- iface # Detects incorrect use of interfaces. Currently only used for "identical" interfaces in the same package.
- importas
- ineffassign
- misspell
- revive
- makezero # Finds slice declarations with non-zero initial length.
- mirror # Detects wrong mirror patterns of bytes/strings usage.
- misspell # Detects commonly misspelled English words in comments.
- nakedret # Detects uses of naked returns.
- nilnesserr # Detects returning nil errors. It combines the features of nilness and nilerr,
- nosprintfhostport # Detects misuse of Sprintf to construct a host with port in a URL.
- reassign # Detects reassigning a top-level variable in another package.
- revive # Metalinter; drop-in replacement for golint.
- spancheck # Detects mistakes with OpenTelemetry/Census spans.
- staticcheck
- typecheck
- unconvert
- unconvert # Detects unnecessary type conversions.
- unused
- wastedassign # Detects wasted assignment statements.
disable:
- errcheck
run:
concurrency: 2
modules-download-mode: vendor
skip-dirs:
- docs
run:
# prevent golangci-lint from deducting the go version to lint for through go.mod,
# which causes it to fallback to go1.17 semantics.
go: "1.23.7"
concurrency: 2
# Only supported with go modules enabled (build flag -mod=vendor only valid when using modules)
# modules-download-mode: vendor
linters-settings:
dupword:
ignore:
- "true" # some tests use this as expected output
- "false" # some tests use this as expected output
- "root" # for tests using "ls" output with files owned by "root:root"
importas:
# Do not allow unaliased imports of aliased packages.
no-unaliased: true
alias:
# Enforce alias to prevent it accidentally being used instead of our
# own errdefs package (or vice-versa).
- pkg: github.com/containerd/containerd/errdefs
alias: cerrdefs
- pkg: github.com/opencontainers/image-spec/specs-go/v1
alias: ocispec
govet:
check-shadowing: false
depguard:
rules:
main:
@@ -57,15 +58,110 @@ linters-settings:
desc: Use "gotest.tools/v3/assert" instead
- pkg: "github.com/stretchr/testify/suite"
desc: Do not use
- pkg: "github.com/containerd/containerd/errdefs"
desc: The errdefs package has moved to a separate module, https://github.com/containerd/errdefs
- pkg: "github.com/containerd/containerd/log"
desc: The logs package has moved to a separate module, https://github.com/containerd/log
- pkg: "github.com/containerd/containerd/pkg/userns"
desc: Use github.com/moby/sys/userns instead.
- pkg: "github.com/tonistiigi/fsutil"
desc: The fsutil module does not have a stable API, so we should not have a direct dependency unless necessary.
dupword:
ignore:
- "true" # some tests use this as expected output
- "false" # some tests use this as expected output
- "root" # for tests using "ls" output with files owned by "root:root"
exhaustive:
# Program elements to check for exhaustiveness.
# Default: [ switch ]
check:
- switch
# - map # TODO(thaJeztah): also enable for maps
# Presence of "default" case in switch statements satisfies exhaustiveness,
# even if all enum members are not listed.
# Default: false
#
# TODO(thaJeztah): consider not allowing this to catch new values being added (and falling through to "default")
default-signifies-exhaustive: true
forbidigo:
forbid:
- pkg: ^sync/atomic$
p: ^atomic\.(Add|CompareAndSwap|Load|Store|Swap).
msg: Go 1.19 atomic types should be used instead.
- pkg: ^regexp$
p: ^regexp\.MustCompile
msg: Use internal/lazyregexp.New instead.
- pkg: github.com/vishvananda/netlink$
p: ^netlink\.(Handle\.)?(AddrList|BridgeVlanList|ChainList|ClassList|ConntrackTableList|ConntrackDeleteFilter$|ConntrackDeleteFilters|DevLinkGetDeviceList|DevLinkGetAllPortList|DevlinkGetDeviceParams|FilterList|FouList|GenlFamilyList|GTPPDPList|LinkByName|LinkByAlias|LinkList|LinkSubscribeWithOptions|NeighList$|NeighProxyList|NeighListExecute|NeighSubscribeWithOptions|LinkGetProtinfo|QdiscList|RdmaLinkList|RdmaLinkByName|RdmaLinkDel|RouteList|RouteListFilteredIter|RuleListFiltered$|RouteSubscribeWithOptions|RuleList$|RuleListFiltered|SocketGet|SocketDiagTCPInfo|SocketDiagTCP|SocketDiagUDPInfo|SocketDiagUDP|UnixSocketDiagInfo|UnixSocketDiag|VDPAGetDevConfigList|VDPAGetDevList|VDPAGetMGMTDevList|XfrmPolicyList|XfrmStateList)
msg: Use internal nlwrap package for EINTR handling.
- pkg: github.com/docker/docker/internal/nlwrap$
p: ^nlwrap.Handle.(BridgeVlanList|ChainList|ClassList|ConntrackDeleteFilter$|DevLinkGetDeviceList|DevLinkGetAllPortList|DevlinkGetDeviceParams|FilterList|FouList|GenlFamilyList|GTPPDPList|LinkByAlias|LinkSubscribeWithOptions|NeighList$|NeighProxyList|NeighListExecute|NeighSubscribeWithOptions|LinkGetProtinfo|QdiscList|RdmaLinkList|RdmaLinkByName|RdmaLinkDel|RouteListFilteredIter|RuleListFiltered$|RouteSubscribeWithOptions|RuleList$|RuleListFiltered|SocketGet|SocketDiagTCPInfo|SocketDiagTCP|SocketDiagUDPInfo|SocketDiagUDP|UnixSocketDiagInfo|UnixSocketDiag|VDPAGetDevConfigList|VDPAGetDevList|VDPAGetMGMTDevList)
msg: Add a wrapper to nlwrap.Handle for EINTR handling and update the list in .golangci.yml.
analyze-types: true
gosec:
excludes:
- G104 # G104: Errors unhandled; (TODO: reduce unhandled errors, or explicitly ignore)
- G113 # G113: Potential uncontrolled memory consumption in Rat.SetString (CVE-2022-23772); (only affects go < 1.16.14. and go < 1.17.7)
- G115 # G115: integer overflow conversion; (TODO: verify these: https://github.com/moby/moby/issues/48358)
- G204 # G204: Subprocess launched with variable; too many false positives.
- G301 # G301: Expect directory permissions to be 0750 or less (also EXC0009); too restrictive
- G302 # G302: Expect file permissions to be 0600 or less (also EXC0009); too restrictive
- G304 # G304: Potential file inclusion via variable.
- G306 # G306: Expect WriteFile permissions to be 0600 or less (too restrictive; also flags "0o644" permissions)
- G307 # G307: Deferring unsafe method "*os.File" on type "Close" (also EXC0008); (TODO: evaluate these and fix where needed: G307: Deferring unsafe method "*os.File" on type "Close")
- G504 # G504: Blocklisted import net/http/cgi: Go versions < 1.6.3 are vulnerable to Httpoxy attack: (CVE-2016-5386); (only affects go < 1.6.3)
govet:
enable-all: true
disable:
- fieldalignment # TODO: evaluate which ones should be updated.
importas:
# Do not allow unaliased imports of aliased packages.
no-unaliased: true
alias:
# Enforce alias to prevent it accidentally being used instead of our
# own errdefs package (or vice-versa).
- pkg: github.com/containerd/errdefs
alias: cerrdefs
- pkg: github.com/containerd/containerd/images
alias: c8dimages
- pkg: github.com/opencontainers/image-spec/specs-go/v1
alias: ocispec
# Enforce that gotest.tools/v3/assert/cmp is always aliased as "is"
- pkg: gotest.tools/v3/assert/cmp
alias: is
nakedret:
# Disallow naked returns if func has more lines of code than this setting.
# Default: 30
max-func-lines: 0
revive:
rules:
# FIXME make sure all packages have a description. Currently, there's many packages without.
- name: package-comments
disabled: true
spancheck:
# Default: ["end"]
checks:
- end # check that `span.End()` is called
- record-error # check that `span.RecordError(err)` is called when an error is returned
- set-status # check that `span.SetStatus(codes.Error, msg)` is called when an error is returned
issues:
# The default exclusion rules are a bit too permissive, so copying the relevant ones below
exclude-use-default: false
exclude-dirs:
- docs
exclude-rules:
# We prefer to use an "exclude-list" so that new "default" exclusions are not
# automatically inherited. We can decide whether or not to follow upstream
@@ -74,50 +170,25 @@ issues:
# (unlike the "include" option), the "exclude" option does not take exclusion
# ID's.
#
# These exclusion patterns are copied from the default excluses at:
# https://github.com/golangci/golangci-lint/blob/v1.46.2/pkg/config/issues.go#L10-L104
# These exclusion patterns are copied from the default excludes at:
# https://github.com/golangci/golangci-lint/blob/v1.61.0/pkg/config/issues.go#L11-L104
#
# The default list of exclusions can be found at:
# https://golangci-lint.run/usage/false-positives/#default-exclusions
# EXC0001
- text: "Error return value of .((os\\.)?std(out|err)\\..*|.*Close|.*Flush|os\\.Remove(All)?|.*print(f|ln)?|os\\.(Un)?Setenv). is not checked"
linters:
- errcheck
# EXC0006
- text: "Use of unsafe calls should be audited"
linters:
- gosec
# EXC0007
- text: "Subprocess launch(ed with variable|ing should be audited)"
linters:
- gosec
# EXC0008
# TODO: evaluate these and fix where needed: G307: Deferring unsafe method "*os.File" on type "Close" (gosec)
- text: "(G104|G307)"
linters:
- gosec
# EXC0009
- text: "(Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)"
linters:
- gosec
# EXC0010
- text: "Potential file inclusion via variable"
linters:
- gosec
# Looks like the match in "EXC0007" above doesn't catch this one
# TODO: consider upstreaming this to golangci-lint's default exclusion rules
- text: "G204: Subprocess launched with a potential tainted input or cmd arguments"
linters:
- gosec
# Looks like the match in "EXC0009" above doesn't catch this one
# TODO: consider upstreaming this to golangci-lint's default exclusion rules
- text: "G306: Expect WriteFile permissions to be 0600 or less"
linters:
- gosec
# Exclude some linters from running on tests files.
- path: _test\.go
linters:
- errcheck
- text: "G404: Use of weak random number generator"
path: _test\.go
linters:
- gosec
# Suppress golint complaining about generated types in api/types/
@@ -125,11 +196,49 @@ issues:
path: "api/types/(volume|container)/"
linters:
- revive
# FIXME temporarily suppress these (see https://github.com/gotestyourself/gotest.tools/issues/272)
- text: "SA1019: (assert|cmp|is)\\.ErrorType is deprecated"
# FIXME: ignoring unused assigns to ctx for now; too many hits in libnetwork/xxx functions that setup traces
- text: "assigned to ctx, but never used afterwards"
linters:
- wastedassign
- text: "ineffectual assignment to ctx"
source: "ctx[, ].*=.*\\(ctx[,)]"
linters:
- ineffassign
- text: "SA4006: this value of `ctx` is never used"
source: "ctx[, ].*=.*\\(ctx[,)]"
linters:
- staticcheck
# Ignore "nested context in function literal (fatcontext)" as we intentionally set up tracing on a base-context for tests.
# FIXME(thaJeztah): see if there's a more iodiomatic way to do this.
- text: 'nested context in function literal'
path: '((main|check)_(linux_|)test\.go)|testutil/helpers\.go'
linters:
- fatcontext
- text: '^shadow: declaration of "(ctx|err|ok)" shadows declaration'
linters:
- govet
- text: '^shadow: declaration of "(out)" shadows declaration'
path: _test\.go
linters:
- govet
- text: 'use of `regexp.MustCompile` forbidden'
path: _test\.go
linters:
- forbidigo
- text: 'use of `regexp.MustCompile` forbidden'
path: "internal/lazyregexp"
linters:
- forbidigo
- text: 'use of `regexp.MustCompile` forbidden'
path: "libnetwork/cmd/networkdb-test/dbclient"
linters:
- forbidigo
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
max-issues-per-linter: 0

View File

@@ -7,6 +7,7 @@
#
# For an explanation of this file format, consult gitmailmap(5).
Aaron Yoshitake <airandfingers@gmail.com>
Aaron L. Xu <liker.xu@foxmail.com>
Aaron L. Xu <liker.xu@foxmail.com> <likexu@harmonycloud.cn>
Aaron Lehmann <alehmann@netflix.com>
@@ -30,9 +31,11 @@ Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp> <suda.akihiro@lab.ntt.co.jp>
Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp> <suda.kyoto@gmail.com>
Akshay Moghe <akshay.moghe@gmail.com>
Alano Terblanche <alano.terblanche@docker.com>
Alano Terblanche <alano.terblanche@docker.com> <18033717+Benehiko@users.noreply.github.com>
Albin Kerouanton <albinker@gmail.com>
Albin Kerouanton <albinker@gmail.com> <albin@akerouanton.name>
Albin Kerouanton <albinker@gmail.com> <557933+akerouanton@users.noreply.github.com>
Albin Kerouanton <albinker@gmail.com> <albin@akerouanton.name>
Aleksa Sarai <asarai@suse.de>
Aleksa Sarai <asarai@suse.de> <asarai@suse.com>
Aleksa Sarai <asarai@suse.de> <cyphar@cyphar.com>
@@ -59,6 +62,8 @@ Allen Sun <allensun.shl@alibaba-inc.com> <allen.sun@daocloud.io>
Allen Sun <allensun.shl@alibaba-inc.com> <shlallen1990@gmail.com>
Anca Iordache <anca.iordache@docker.com>
Andrea Denisse Gómez <crypto.andrea@protonmail.ch>
Andrew Baxter <423qpsxzhh8k3h@s.rendaw.me>
Andrew Baxter <423qpsxzhh8k3h@s.rendaw.me> andrew <>
Andrew Kim <taeyeonkim90@gmail.com>
Andrew Kim <taeyeonkim90@gmail.com> <akim01@fortinet.com>
Andrew Weiss <andrew.weiss@docker.com> <andrew.weiss@microsoft.com>
@@ -89,6 +94,8 @@ Arnaud Rebillout <arnaud.rebillout@collabora.com>
Arnaud Rebillout <arnaud.rebillout@collabora.com> <elboulangero@gmail.com>
Arthur Gautier <baloo@gandi.net> <superbaloo+registrations.github@superbaloo.net>
Artur Meyster <arthurfbi@yahoo.com>
Austin Vazquez <macedonv@amazon.com>
Austin Vazquez <macedonv@amazon.com> <55906459+austinvazquez@users.noreply.github.com>
Avi Miller <avi.miller@oracle.com> <avi.miller@gmail.com>
Ben Bonnefoy <frenchben@docker.com>
Ben Golub <ben.golub@dotcloud.com>
@@ -119,6 +126,7 @@ Brian Goff <cpuguy83@gmail.com> <bgoff@cpuguy83-mbp.home>
Brian Goff <cpuguy83@gmail.com> <bgoff@cpuguy83-mbp.local>
Brian Goff <cpuguy83@gmail.com> <brian.goff@microsoft.com>
Brian Goff <cpuguy83@gmail.com> <cpuguy@hey.com>
Calvin Liu <flycalvin@qq.com>
Cameron Sparr <gh@sparr.email>
Carlos de Paula <me@carlosedp.com>
Chander Govindarajan <chandergovind@gmail.com>
@@ -130,6 +138,7 @@ Chen Mingjie <chenmingjie0828@163.com>
Chen Qiu <cheney-90@hotmail.com>
Chen Qiu <cheney-90@hotmail.com> <21321229@zju.edu.cn>
Chengfei Shang <cfshang@alauda.io>
Chentianze <cmoman@126.com>
Chris Dias <cdias@microsoft.com>
Chris McKinnel <chris.mckinnel@tangentlabs.co.uk>
Chris Price <cprice@mirantis.com>
@@ -138,6 +147,8 @@ Chris Telfer <ctelfer@docker.com>
Chris Telfer <ctelfer@docker.com> <ctelfer@users.noreply.github.com>
Christopher Biscardi <biscarch@sketcht.com>
Christopher Latham <sudosurootdev@gmail.com>
Christopher Petito <chrisjpetito@gmail.com>
Christopher Petito <chrisjpetito@gmail.com> <47751006+krissetto@users.noreply.github.com>
Christy Norman <christy@linux.vnet.ibm.com>
Chun Chen <ramichen@tencent.com> <chenchun.feed@gmail.com>
Corbin Coleman <corbin.coleman@docker.com>
@@ -341,6 +352,8 @@ John Howard <github@lowenna.com> <john.howard@microsoft.com>
John Howard <github@lowenna.com> <john@lowenna.com>
John Stephens <johnstep@docker.com> <johnstep@users.noreply.github.com>
Jon Surrell <jon.surrell@gmail.com> <jon.surrell@automattic.com>
Jonathan A. Sternberg <jonathansternberg@gmail.com>
Jonathan A. Sternberg <jonathansternberg@gmail.com> <jonathan.sternberg@docker.com>
Jonathan Choy <jonathan.j.choy@gmail.com>
Jonathan Choy <jonathan.j.choy@gmail.com> <oni@tetsujinlabs.com>
Jordan Arentsen <blissdev@gmail.com>
@@ -483,19 +496,20 @@ Mikael Davranche <mikael.davranche@corp.ovh.com> <mikael.davranche@corp.ovh.net>
Mike Casas <mkcsas0@gmail.com> <mikecasas@users.noreply.github.com>
Mike Goelzer <mike.goelzer@docker.com> <mgoelzer@docker.com>
Milas Bowman <devnull@milas.dev>
Milas Bowman <devnull@milas.dev> <milasb@gmail.com>
Milas Bowman <devnull@milas.dev> <milas.bowman@docker.com>
Milas Bowman <devnull@milas.dev> <milasb@gmail.com>
Milind Chawre <milindchawre@gmail.com>
Misty Stanley-Jones <misty@docker.com> <misty@apache.org>
Mohammad Banikazemi <MBanikazemi@gmail.com>
Mohammad Banikazemi <MBanikazemi@gmail.com> <mb@us.ibm.com>
Mohd Sadiq <mohdsadiq058@gmail.com> <mohdsadiq058@gmail.com>
Mohd Sadiq <mohdsadiq058@gmail.com> <42430865+msadiq058@users.noreply.github.com>
Mohd Sadiq <mohdsadiq058@gmail.com> <mohdsadiq058@gmail.com>
Mohit Soni <mosoni@ebay.com> <mohitsoni1989@gmail.com>
Moorthy RS <rsmoorthy@gmail.com> <rsmoorthy@users.noreply.github.com>
Moysés Borges <moysesb@gmail.com>
Moysés Borges <moysesb@gmail.com> <moyses.furtado@wplex.com.br>
mrfly <mr.wrfly@gmail.com> <wrfly@users.noreply.github.com>
Myeongjoon Kim <kimmj8409@gmail.com>
Nace Oroz <orkica@gmail.com>
Natasha Jarus <linuxmercedes@gmail.com>
Nathan LeClaire <nathan.leclaire@docker.com> <nathan.leclaire@gmail.com>
@@ -515,8 +529,11 @@ Olli Janatuinen <olli.janatuinen@gmail.com> <olljanat@users.noreply.github.com>
Onur Filiz <onur.filiz@microsoft.com>
Onur Filiz <onur.filiz@microsoft.com> <ofiliz@users.noreply.github.com>
Ouyang Liduo <oyld0210@163.com>
Patrick St. laurent <patrick@saint-laurent.us>
Patrick Stapleton <github@gdi2290.com>
Paul Liljenberg <liljenberg.paul@gmail.com> <letters@paulnotcom.se>
Paweł Gronowski <pawel.gronowski@docker.com>
Paweł Gronowski <pawel.gronowski@docker.com> <me@woland.xyz>
Pavel Tikhomirov <ptikhomirov@virtuozzo.com> <ptikhomirov@parallels.com>
Pawel Konczalski <mail@konczalski.de>
Peter Choi <phkchoi89@gmail.com> <reikani@Peters-MacBook-Pro.local>
@@ -538,16 +555,21 @@ Qin TianHuan <tianhuan@bingotree.cn>
Ray Tsang <rayt@google.com> <saturnism@users.noreply.github.com>
Renaud Gaubert <rgaubert@nvidia.com> <renaud.gaubert@gmail.com>
Richard Scothern <richard.scothern@gmail.com>
Rob Murray <rob.murray@docker.com>
Rob Murray <rob.murray@docker.com> <148866618+robmry@users.noreply.github.com>
Robert Terhaar <rterhaar@atlanticdynamic.com> <robbyt@users.noreply.github.com>
Roberto G. Hashioka <roberto.hashioka@docker.com> <roberto_hashioka@hotmail.com>
Roberto Muñoz Fernández <robertomf@gmail.com> <roberto.munoz.fernandez.contractor@bbva.com>
Robin Thoni <robin@rthoni.com>
Rodrigo Campos <rodrigoca@microsoft.com>
Rodrigo Campos <rodrigoca@microsoft.com> <rodrigo@kinvolk.io>
Roman Dudin <katrmr@gmail.com> <decadent@users.noreply.github.com>
Rong Zhang <rongzhang@alauda.io>
Rongxiang Song <tinysong1226@gmail.com>
Rony Weng <ronyweng@synology.com>
Ross Boucher <rboucher@gmail.com>
Rui Cao <ruicao@alauda.io>
Rui JingAn <quiterace@gmail.com>
Runshen Zhu <runshen.zhu@gmail.com>
Ryan Stelly <ryan.stelly@live.com>
Ryoga Saito <contact@proelbtn.com>

52
AUTHORS
View File

@@ -2,7 +2,9 @@
# This file lists all contributors to the repository.
# See hack/generate-authors.sh to make modifications.
7sunarni <710720732@qq.com>
Aanand Prasad <aanand.prasad@gmail.com>
Aarni Koskela <akx@iki.fi>
Aaron Davidson <aaron@databricks.com>
Aaron Feng <aaron.feng@gmail.com>
Aaron Hnatiw <aaron@griddio.com>
@@ -10,6 +12,8 @@ Aaron Huslage <huslage@gmail.com>
Aaron L. Xu <liker.xu@foxmail.com>
Aaron Lehmann <alehmann@netflix.com>
Aaron Welch <welch@packet.net>
Aaron Yoshitake <airandfingers@gmail.com>
Abdur Rehman <abdur_rehman@mentor.com>
Abel Muiño <amuino@gmail.com>
Abhijeet Kasurde <akasurde@redhat.com>
Abhinandan Prativadi <aprativadi@gmail.com>
@@ -23,9 +27,11 @@ Adam Avilla <aavilla@yp.com>
Adam Dobrawy <naczelnik@jawnosc.tk>
Adam Eijdenberg <adam.eijdenberg@gmail.com>
Adam Kunk <adam.kunk@tiaa-cref.org>
Adam Lamers <adam.lamers@wmsdev.pl>
Adam Miller <admiller@redhat.com>
Adam Mills <adam@armills.info>
Adam Pointer <adam.pointer@skybettingandgaming.com>
Adam Simon <adamsimon85100@gmail.com>
Adam Singer <financeCoding@gmail.com>
Adam Thornton <adam.thornton@maryville.com>
Adam Walz <adam@adamwalz.net>
@@ -62,6 +68,7 @@ alambike <alambike@gmail.com>
Alan Hoyle <alan@alanhoyle.com>
Alan Scherger <flyinprogrammer@gmail.com>
Alan Thompson <cloojure@gmail.com>
Alano Terblanche <alano.terblanche@docker.com>
Albert Callarisa <shark234@gmail.com>
Albert Zhang <zhgwenming@gmail.com>
Albin Kerouanton <albinker@gmail.com>
@@ -117,6 +124,7 @@ amangoel <amangoel@gmail.com>
Amen Belayneh <amenbelayneh@gmail.com>
Ameya Gawde <agawde@mirantis.com>
Amir Goldstein <amir73il@aquasec.com>
AmirBuddy <badinlu.amirhossein@gmail.com>
Amit Bakshi <ambakshi@gmail.com>
Amit Krishnan <amit.krishnan@oracle.com>
Amit Shukla <amit.shukla@docker.com>
@@ -141,6 +149,7 @@ Andreas Tiefenthaler <at@an-ti.eu>
Andrei Gherzan <andrei@resin.io>
Andrei Ushakov <aushakov@netflix.com>
Andrei Vagin <avagin@gmail.com>
Andrew Baxter <423qpsxzhh8k3h@s.rendaw.me>
Andrew C. Bodine <acbodine@us.ibm.com>
Andrew Clay Shafer <andrewcshafer@gmail.com>
Andrew Duckworth <grillopress@gmail.com>
@@ -165,6 +174,7 @@ Andrey Kolomentsev <andrey.kolomentsev@docker.com>
Andrey Petrov <andrey.petrov@shazow.net>
Andrey Stolbovsky <andrey.stolbovsky@gmail.com>
André Martins <aanm90@gmail.com>
Andrés Maldonado <maldonado@codelutin.com>
Andy Chambers <anchambers@paypal.com>
andy diller <dillera@gmail.com>
Andy Goldstein <agoldste@redhat.com>
@@ -193,6 +203,7 @@ Anton Löfgren <anton.lofgren@gmail.com>
Anton Nikitin <anton.k.nikitin@gmail.com>
Anton Polonskiy <anton.polonskiy@gmail.com>
Anton Tiurin <noxiouz@yandex.ru>
Antonio Aguilar <antonio@zoftko.com>
Antonio Murdaca <antonio.murdaca@gmail.com>
Antonis Kalipetis <akalipetis@gmail.com>
Antony Messerli <amesserl@rackspace.com>
@@ -215,13 +226,13 @@ Artur Meyster <arthurfbi@yahoo.com>
Arun Gupta <arun.gupta@gmail.com>
Asad Saeeduddin <masaeedu@gmail.com>
Asbjørn Enge <asbjorn@hanafjedle.net>
Ashly Mathew <ashly.mathew@sap.com>
Austin Vazquez <macedonv@amazon.com>
averagehuman <averagehuman@users.noreply.github.com>
Avi Das <andas222@gmail.com>
Avi Kivity <avi@scylladb.com>
Avi Miller <avi.miller@oracle.com>
Avi Vaid <avaid1996@gmail.com>
ayoshitake <airandfingers@gmail.com>
Azat Khuyiyakhmetov <shadow_uz@mail.ru>
Bao Yonglei <baoyonglei@huawei.com>
Bardia Keyoumarsi <bkeyouma@ucsc.edu>
@@ -316,6 +327,7 @@ Burke Libbey <burke@libbey.me>
Byung Kang <byung.kang.ctr@amrdec.army.mil>
Caleb Spare <cespare@gmail.com>
Calen Pennington <cale@edx.org>
Calvin Liu <flycalvin@qq.com>
Cameron Boehmer <cameron.boehmer@gmail.com>
Cameron Sparr <gh@sparr.email>
Cameron Spear <cameronspear@gmail.com>
@@ -341,6 +353,7 @@ Chance Zibolski <chance.zibolski@gmail.com>
Chander Govindarajan <chandergovind@gmail.com>
Chanhun Jeong <keyolk@gmail.com>
Chao Wang <wangchao.fnst@cn.fujitsu.com>
Charity Kathure <ckathure@microsoft.com>
Charles Chan <charleswhchan@users.noreply.github.com>
Charles Hooper <charles.hooper@dotcloud.com>
Charles Law <claw@conduce.com>
@@ -362,6 +375,7 @@ Chen Qiu <cheney-90@hotmail.com>
Cheng-mean Liu <soccerl@microsoft.com>
Chengfei Shang <cfshang@alauda.io>
Chengguang Xu <cgxu519@gmx.com>
Chentianze <cmoman@126.com>
Chenyang Yan <memory.yancy@gmail.com>
chenyuzhu <chenyuzhi@oschina.cn>
Chetan Birajdar <birajdar.chetan@gmail.com>
@@ -409,6 +423,7 @@ Christopher Crone <christopher.crone@docker.com>
Christopher Currie <codemonkey+github@gmail.com>
Christopher Jones <tophj@linux.vnet.ibm.com>
Christopher Latham <sudosurootdev@gmail.com>
Christopher Petito <chrisjpetito@gmail.com>
Christopher Rigor <crigor@gmail.com>
Christy Norman <christy@linux.vnet.ibm.com>
Chun Chen <ramichen@tencent.com>
@@ -474,6 +489,7 @@ Daniel Farrell <dfarrell@redhat.com>
Daniel Garcia <daniel@danielgarcia.info>
Daniel Gasienica <daniel@gasienica.ch>
Daniel Grunwell <mwgrunny@gmail.com>
Daniel Guns <danbguns@gmail.com>
Daniel Helfand <helfand.4@gmail.com>
Daniel Hiltgen <daniel.hiltgen@docker.com>
Daniel J Walsh <dwalsh@redhat.com>
@@ -757,6 +773,7 @@ Frank Macreery <frank@macreery.com>
Frank Rosquin <frank.rosquin+github@gmail.com>
Frank Villaro-Dixon <frank.villarodixon@merkle.com>
Frank Yang <yyb196@gmail.com>
François Scala <github@arcenik.net>
Fred Lifton <fred.lifton@docker.com>
Frederick F. Kautz IV <fkautz@redhat.com>
Frederico F. de Oliveira <FreddieOliveira@users.noreply.github.com>
@@ -777,6 +794,7 @@ Gabriel L. Somlo <gsomlo@gmail.com>
Gabriel Linder <linder.gabriel@gmail.com>
Gabriel Monroy <gabriel@opdemand.com>
Gabriel Nicolas Avellaneda <avellaneda.gabriel@gmail.com>
Gabriel Tomitsuka <gabriel@tomitsuka.com>
Gaetan de Villele <gdevillele@gmail.com>
Galen Sampson <galen.sampson@gmail.com>
Gang Qiao <qiaohai8866@gmail.com>
@@ -791,7 +809,9 @@ GennadySpb <lipenkov@gmail.com>
Geoff Levand <geoff@infradead.org>
Geoffrey Bachelet <grosfrais@gmail.com>
Geon Kim <geon0250@gmail.com>
George Adams <georgeadams1995@gmail.com>
George Kontridze <george@bugsnag.com>
George Ma <mayangang@outlook.com>
George MacRorie <gmacr31@gmail.com>
George Xie <georgexsh@gmail.com>
Georgi Hristozov <georgi@forkbomb.nl>
@@ -818,6 +838,7 @@ Gopikannan Venugopalsamy <gopikannan.venugopalsamy@gmail.com>
Gosuke Miyashita <gosukenator@gmail.com>
Gou Rao <gou@portworx.com>
Govinda Fichtner <govinda.fichtner@googlemail.com>
Grace Choi <grace.54109@gmail.com>
Grant Millar <rid@cylo.io>
Grant Reaber <grant.reaber@gmail.com>
Graydon Hoare <graydon@pobox.com>
@@ -913,6 +934,7 @@ Illo Abdulrahim <abdulrahim.illo@nokia.com>
Ilya Dmitrichenko <errordeveloper@gmail.com>
Ilya Gusev <mail@igusev.ru>
Ilya Khlopotov <ilya.khlopotov@gmail.com>
imalasong <2879499479@qq.com>
imre Fitos <imre.fitos+github@gmail.com>
inglesp <peter.inglesby@gmail.com>
Ingo Gottwald <in.gottwald@gmail.com>
@@ -930,6 +952,7 @@ J Bruni <joaohbruni@yahoo.com.br>
J. Nunn <jbnunn@gmail.com>
Jack Danger Canty <jackdanger@squareup.com>
Jack Laxson <jackjrabbit@gmail.com>
Jack Walker <90711509+j2walker@users.noreply.github.com>
Jacob Atzen <jacob@jacobatzen.dk>
Jacob Edelman <edelman.jd@gmail.com>
Jacob Tomlinson <jacob@tom.linson.uk>
@@ -956,6 +979,7 @@ James Nugent <james@jen20.com>
James Sanders <james3sanders@gmail.com>
James Turnbull <james@lovedthanlost.net>
James Watkins-Harvey <jwatkins@progi-media.com>
Jameson Hyde <jameson.hyde@docker.com>
Jamie Hannaford <jamie@limetree.org>
Jamshid Afshar <jafshar@yahoo.com>
Jan Breig <git@pygos.space>
@@ -989,6 +1013,7 @@ Jason Shepherd <jason@jasonshepherd.net>
Jason Smith <jasonrichardsmith@gmail.com>
Jason Sommer <jsdirv@gmail.com>
Jason Stangroome <jason@codeassassin.com>
Jasper Siepkes <siepkes@serviceplanet.nl>
Javier Bassi <javierbassi@gmail.com>
jaxgeller <jacksongeller@gmail.com>
Jay <teguhwpurwanto@gmail.com>
@@ -1053,13 +1078,16 @@ Jim Perrin <jperrin@centos.org>
Jimmy Cuadra <jimmy@jimmycuadra.com>
Jimmy Puckett <jimmy.puckett@spinen.com>
Jimmy Song <rootsongjc@gmail.com>
jinjiadu <jinjiadu@aliyun.com>
Jinsoo Park <cellpjs@gmail.com>
Jintao Zhang <zhangjintao9020@gmail.com>
Jiri Appl <jiria@microsoft.com>
Jiri Popelka <jpopelka@redhat.com>
Jiuyue Ma <majiuyue@huawei.com>
Jiří Župka <jzupka@redhat.com>
jjimbo137 <115816493+jjimbo137@users.noreply.github.com>
Joakim Roubert <joakim.roubert@axis.com>
Joan Grau <grautxo.dev@proton.me>
Joao Fernandes <joao.fernandes@docker.com>
Joao Trindade <trindade.joao@gmail.com>
Joe Beda <joe.github@bedafamily.com>
@@ -1100,6 +1128,7 @@ Jon Johnson <jonjohnson@google.com>
Jon Surrell <jon.surrell@gmail.com>
Jon Wedaman <jweede@gmail.com>
Jonas Dohse <jonas@dohse.ch>
Jonas Geiler <git@jonasgeiler.com>
Jonas Heinrich <Jonas@JonasHeinrich.com>
Jonas Pfenniger <jonas@pfenniger.name>
Jonathan A. Schweder <jonathanschweder@gmail.com>
@@ -1143,6 +1172,7 @@ Josiah Kiehl <jkiehl@riotgames.com>
José Tomás Albornoz <jojo@eljojo.net>
Joyce Jang <mail@joycejang.com>
JP <jpellerin@leapfrogonline.com>
JSchltggr <jschltggr@gmail.com>
Julian Taylor <jtaylor.debian@googlemail.com>
Julien Barbier <write0@gmail.com>
Julien Bisconti <veggiemonk@users.noreply.github.com>
@@ -1267,6 +1297,7 @@ Lakshan Perera <lakshan@laktek.com>
Lalatendu Mohanty <lmohanty@redhat.com>
Lance Chen <cyen0312@gmail.com>
Lance Kinley <lkinley@loyaltymethods.com>
Lars Andringa <l.s.andringa@rug.nl>
Lars Butler <Lars.Butler@gmail.com>
Lars Kellogg-Stedman <lars@redhat.com>
Lars R. Damerow <lars@pixar.com>
@@ -1276,6 +1307,7 @@ Laura Brehm <laurabrehm@hey.com>
Laura Frank <ljfrank@gmail.com>
Laurent Bernaille <laurent.bernaille@datadoghq.com>
Laurent Erignoux <lerignoux@gmail.com>
Laurent Goderre <laurent.goderre@docker.com>
Laurie Voss <github@seldo.com>
Leandro Motta Barros <lmb@stackedboxes.org>
Leandro Siqueira <leandro.siqueira@gmail.com>
@@ -1356,6 +1388,7 @@ Madhan Raj Mookkandy <MadhanRaj.Mookkandy@microsoft.com>
Madhav Puri <madhav.puri@gmail.com>
Madhu Venugopal <mavenugo@gmail.com>
Mageee <fangpuyi@foxmail.com>
maggie44 <64841595+maggie44@users.noreply.github.com>
Mahesh Tiyyagura <tmahesh@gmail.com>
malnick <malnick@gmail..com>
Malte Janduda <mail@janduda.net>
@@ -1566,6 +1599,7 @@ Muayyad Alsadi <alsadi@gmail.com>
Muhammad Zohaib Aslam <zohaibse011@gmail.com>
Mustafa Akın <mustafa91@gmail.com>
Muthukumar R <muthur@gmail.com>
Myeongjoon Kim <kimmj8409@gmail.com>
Máximo Cuadros <mcuadros@gmail.com>
Médi-Rémi Hashim <medimatrix@users.noreply.github.com>
Nace Oroz <orkica@gmail.com>
@@ -1580,6 +1614,7 @@ Natasha Jarus <linuxmercedes@gmail.com>
Nate Brennand <nate.brennand@clever.com>
Nate Eagleson <nate@nateeag.com>
Nate Jones <nate@endot.org>
Nathan Baulch <nathan.baulch@gmail.com>
Nathan Carlson <carl4403@umn.edu>
Nathan Herald <me@nathanherald.com>
Nathan Hsieh <hsieh.nathan@gmail.com>
@@ -1642,6 +1677,7 @@ Nuutti Kotivuori <naked@iki.fi>
nzwsch <hi@nzwsch.com>
O.S. Tezer <ostezer@gmail.com>
objectified <objectified@gmail.com>
Octol1ttle <l1ttleofficial@outlook.com>
Odin Ugedal <odin@ugedal.com>
Oguz Bilgic <fisyonet@gmail.com>
Oh Jinkyun <tintypemolly@gmail.com>
@@ -1673,6 +1709,7 @@ Patrick Böänziger <patrick.baenziger@bsi-software.com>
Patrick Devine <patrick.devine@docker.com>
Patrick Haas <patrickhaas@google.com>
Patrick Hemmer <patrick.hemmer@gmail.com>
Patrick St. laurent <patrick@saint-laurent.us>
Patrick Stapleton <github@gdi2290.com>
Patrik Cyvoct <patrik@ptrk.io>
pattichen <craftsbear@gmail.com>
@@ -1749,6 +1786,7 @@ Pierre Carrier <pierre@meteor.com>
Pierre Dal-Pra <dalpra.pierre@gmail.com>
Pierre Wacrenier <pierre.wacrenier@gmail.com>
Pierre-Alain RIVIERE <pariviere@ippon.fr>
pinglanlu <pinglanlu@outlook.com>
Piotr Bogdan <ppbogdan@gmail.com>
Piotr Karbowski <piotr.karbowski@protonmail.ch>
Porjo <porjo38@yahoo.com.au>
@@ -1776,6 +1814,7 @@ Quentin Tayssier <qtayssier@gmail.com>
r0n22 <cameron.regan@gmail.com>
Rachit Sharma <rachitsharma613@gmail.com>
Radostin Stoyanov <rstoyanov1@gmail.com>
Rafael Fernández López <ereslibre@ereslibre.es>
Rafal Jeczalik <rjeczalik@gmail.com>
Rafe Colton <rafael.colton@gmail.com>
Raghavendra K T <raghavendra.kt@linux.vnet.ibm.com>
@@ -1842,7 +1881,7 @@ Robin Speekenbrink <robin@kingsquare.nl>
Robin Thoni <robin@rthoni.com>
robpc <rpcann@gmail.com>
Rodolfo Carvalho <rhcarvalho@gmail.com>
Rodrigo Campos <rodrigo@kinvolk.io>
Rodrigo Campos <rodrigoca@microsoft.com>
Rodrigo Vaz <rodrigo.vaz@gmail.com>
Roel Van Nyen <roel.vannyen@gmail.com>
Roger Peppe <rogpeppe@gmail.com>
@@ -1878,6 +1917,7 @@ Royce Remer <royceremer@gmail.com>
Rozhnov Alexandr <nox73@ya.ru>
Rudolph Gottesheim <r.gottesheim@loot.at>
Rui Cao <ruicao@alauda.io>
Rui JingAn <quiterace@gmail.com>
Rui Lopes <rgl@ruilopes.com>
Ruilin Li <liruilin4@huawei.com>
Runshen Zhu <runshen.zhu@gmail.com>
@@ -1980,6 +2020,7 @@ Sevki Hasirci <s@sevki.org>
Shane Canon <scanon@lbl.gov>
Shane da Silva <shane@dasilva.io>
Shaun Kaasten <shaunk@gmail.com>
Shaun Thompson <shaun.thompson@docker.com>
shaunol <shaunol@gmail.com>
Shawn Landden <shawn@churchofgit.com>
Shawn Siefkas <shawn.siefkas@meredith.com>
@@ -1998,6 +2039,7 @@ Shijun Qin <qinshijun16@mails.ucas.ac.cn>
Shishir Mahajan <shishir.mahajan@redhat.com>
Shoubhik Bose <sbose78@gmail.com>
Shourya Sarcar <shourya.sarcar@gmail.com>
Shreenidhi Shedi <shreenidhi.shedi@broadcom.com>
Shu-Wai Chow <shu-wai.chow@seattlechildrens.org>
shuai-z <zs.broccoli@gmail.com>
Shukui Yang <yangshukui@huawei.com>
@@ -2085,6 +2127,7 @@ Sébastien Stormacq <sebsto@users.noreply.github.com>
Sören Tempel <soeren+git@soeren-tempel.net>
Tabakhase <mail@tabakhase.com>
Tadej Janež <tadej.j@nez.si>
Tadeusz Dudkiewicz <tadeusz.dudkiewicz@rtbhouse.com>
Takuto Sato <tockn.jp@gmail.com>
tang0th <tang0th@gmx.com>
Tangi Colin <tangicolin@gmail.com>
@@ -2092,6 +2135,7 @@ Tatsuki Sugiura <sugi@nemui.org>
Tatsushi Inagaki <e29253@jp.ibm.com>
Taylan Isikdemir <taylani@google.com>
Taylor Jones <monitorjbl@gmail.com>
tcpdumppy <847462026@qq.com>
Ted M. Young <tedyoung@gmail.com>
Tehmasp Chaudhri <tehmasp@gmail.com>
Tejaswini Duggaraju <naduggar@microsoft.com>
@@ -2184,6 +2228,7 @@ Tomek Mańko <tomek.manko@railgun-solutions.com>
Tommaso Visconti <tommaso.visconti@gmail.com>
Tomoya Tabuchi <t@tomoyat1.com>
Tomáš Hrčka <thrcka@redhat.com>
Tomáš Virtus <nechtom@gmail.com>
tonic <tonicbupt@gmail.com>
Tonny Xu <tonny.xu@gmail.com>
Tony Abboud <tdabboud@hotmail.com>
@@ -2228,6 +2273,7 @@ Victor I. Wood <viw@t2am.com>
Victor Lyuboslavsky <victor@victoreda.com>
Victor Marmol <vmarmol@google.com>
Victor Palma <palma.victor@gmail.com>
Victor Toni <victor.toni@gmail.com>
Victor Vieux <victor.vieux@docker.com>
Victoria Bialas <victoria.bialas@docker.com>
Vijaya Kumar K <vijayak@caviumnetworks.com>
@@ -2279,6 +2325,7 @@ Wassim Dhif <wassimdhif@gmail.com>
Wataru Ishida <ishida.wataru@lab.ntt.co.jp>
Wayne Chang <wayne@neverfear.org>
Wayne Song <wsong@docker.com>
weebney <weebney@gmail.com>
Weerasak Chongnguluam <singpor@gmail.com>
Wei Fu <fuweid89@gmail.com>
Wei Wu <wuwei4455@gmail.com>
@@ -2373,6 +2420,7 @@ You-Sheng Yang (楊有勝) <vicamo@gmail.com>
youcai <omegacoleman@gmail.com>
Youcef YEKHLEF <yyekhlef@gmail.com>
Youfu Zhang <zhangyoufu@gmail.com>
YR Chen <stevapple@icloud.com>
Yu Changchun <yuchangchun1@huawei.com>
Yu Chengxia <yuchengxia@huawei.com>
Yu Peng <yu.peng36@zte.com.cn>

View File

@@ -1,28 +1,32 @@
# syntax=docker/dockerfile:1.7
ARG GO_VERSION=1.21.9
ARG GO_VERSION=1.23.7
ARG BASE_DEBIAN_DISTRO="bookworm"
ARG GOLANG_IMAGE="golang:${GO_VERSION}-${BASE_DEBIAN_DISTRO}"
ARG XX_VERSION=1.4.0
ARG XX_VERSION=1.6.1
ARG VPNKIT_VERSION=0.5.0
# DOCKERCLI_VERSION is the version of the CLI to install in the dev-container.
ARG DOCKERCLI_VERSION=v28.0.1
ARG DOCKERCLI_REPOSITORY="https://github.com/docker/cli.git"
ARG DOCKERCLI_VERSION=v26.0.0
# cli version used for integration-cli tests
ARG DOCKERCLI_INTEGRATION_REPOSITORY="https://github.com/docker/cli.git"
ARG DOCKERCLI_INTEGRATION_VERSION=v17.06.2-ce
ARG BUILDX_VERSION=0.13.1
ARG COMPOSE_VERSION=v2.25.0
# BUILDX_VERSION is the version of buildx to install in the dev container.
ARG BUILDX_VERSION=0.20.1
ARG COMPOSE_VERSION=v2.33.1
ARG SYSTEMD="false"
ARG FIREWALLD="false"
ARG DOCKER_STATIC=1
# REGISTRY_VERSION specifies the version of the registry to download from
# https://hub.docker.com/r/distribution/distribution. This version of
# the registry is used to test schema 2 manifests. Generally, the version
# specified here should match a current release.
ARG REGISTRY_VERSION=2.8.3
ARG REGISTRY_VERSION=3.0.0-rc.1
# delve is currently only supported on linux/amd64 and linux/arm64;
# https://github.com/go-delve/delve/blob/v1.8.1/pkg/proc/native/support_sentinel.go#L1-L6
@@ -137,7 +141,9 @@ RUN /download-frozen-image-v2.sh /build \
busybox:glibc@sha256:1f81263701cddf6402afe9f33fca0266d9fff379e59b1748f33d3072da71ee85 \
debian:bookworm-slim@sha256:2bc5c236e9b262645a323e9088dfa3bb1ecb16cc75811daf40a23a824d665be9 \
hello-world:latest@sha256:d58e752213a51785838f9eed2b7a498ffa1cb3aa7f946dda11af39286c3db9a9 \
arm32v7/hello-world:latest@sha256:50b8560ad574c779908da71f7ce370c0a2471c098d44d1c8f6b513c5a55eeeb1
arm32v7/hello-world:latest@sha256:50b8560ad574c779908da71f7ce370c0a2471c098d44d1c8f6b513c5a55eeeb1 \
hello-world:amd64@sha256:90659bf80b44ce6be8234e6ff90a1ac34acbeb826903b02cfa0da11c82cbc042 \
hello-world:arm64@sha256:963612c5503f3f1674f315c67089dee577d8cc6afc18565e0b4183ae355fb343
# delve
FROM base AS delve-src
@@ -147,7 +153,7 @@ RUN git init . && git remote add origin "https://github.com/go-delve/delve.git"
# from the https://github.com/go-delve/delve repository.
# It can be used to run Docker with a possibility of
# attaching debugger to it.
ARG DELVE_VERSION=v1.21.1
ARG DELVE_VERSION=v1.23.0
RUN git fetch -q --depth 1 origin "${DELVE_VERSION}" +refs/tags/*:refs/tags/* && git checkout -q FETCH_HEAD
FROM base AS delve-supported
@@ -164,19 +170,6 @@ EOT
FROM binary-dummy AS delve-unsupported
FROM delve-${DELVE_SUPPORTED} AS delve
FROM base AS tomll
# GOTOML_VERSION specifies the version of the tomll binary to build and install
# from the https://github.com/pelletier/go-toml repository. This binary is used
# in CI in the hack/validate/toml script.
#
# When updating this version, consider updating the github.com/pelletier/go-toml
# dependency in vendor.mod accordingly.
ARG GOTOML_VERSION=v1.8.1
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOBIN=/build/ GO111MODULE=on go install "github.com/pelletier/go-toml/cmd/tomll@${GOTOML_VERSION}" \
&& /build/tomll --help
FROM base AS gowinres
# GOWINRES_VERSION defines go-winres tool version
ARG GOWINRES_VERSION=v0.3.1
@@ -196,7 +189,7 @@ RUN git init . && git remote add origin "https://github.com/containerd/container
# When updating the binary version you may also need to update the vendor
# version to pick up bug fixes or new APIs, however, usually the Go packages
# are built from a commit from the master branch.
ARG CONTAINERD_VERSION=v1.7.15
ARG CONTAINERD_VERSION=v1.7.27
RUN git fetch -q --depth 1 origin "${CONTAINERD_VERSION}" +refs/tags/*:refs/tags/* && git checkout -q FETCH_HEAD
FROM base AS containerd-build
@@ -206,8 +199,6 @@ RUN --mount=type=cache,sharing=locked,id=moby-containerd-aptlib,target=/var/lib/
--mount=type=cache,sharing=locked,id=moby-containerd-aptcache,target=/var/cache/apt \
apt-get update && xx-apt-get install -y --no-install-recommends \
gcc \
libbtrfs-dev \
libsecret-1-dev \
pkg-config
ARG DOCKER_STATIC
RUN --mount=from=containerd-src,src=/usr/src/containerd,rw \
@@ -229,14 +220,14 @@ FROM binary-dummy AS containerd-windows
FROM containerd-${TARGETOS} AS containerd
FROM base AS golangci_lint
ARG GOLANGCI_LINT_VERSION=v1.55.2
ARG GOLANGCI_LINT_VERSION=v1.64.5
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOBIN=/build/ GO111MODULE=on go install "github.com/golangci/golangci-lint/cmd/golangci-lint@${GOLANGCI_LINT_VERSION}" \
&& /build/golangci-lint --version
FROM base AS gotestsum
ARG GOTESTSUM_VERSION=v1.8.2
ARG GOTESTSUM_VERSION=v1.12.0
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg/mod \
GOBIN=/build/ GO111MODULE=on go install "gotest.tools/gotestsum@${GOTESTSUM_VERSION}" \
@@ -265,7 +256,8 @@ RUN --mount=source=hack/dockerfile/cli.sh,target=/download-or-build-cli.sh \
--mount=type=cache,target=/root/.cache/go-build,id=dockercli-build-$TARGETPLATFORM \
rm -f ./.git/*.lock \
&& /download-or-build-cli.sh ${DOCKERCLI_VERSION} ${DOCKERCLI_REPOSITORY} /build \
&& /build/docker --version
&& /build/docker --version \
&& /build/docker completion bash >/completion.bash
FROM base AS dockercli-integration
WORKDIR /go/src/github.com/docker/cli
@@ -287,7 +279,7 @@ RUN git init . && git remote add origin "https://github.com/opencontainers/runc.
# that is used. If you need to update runc, open a pull request in the containerd
# project first, and update both after that is merged. When updating RUNC_VERSION,
# consider updating runc in vendor.mod accordingly.
ARG RUNC_VERSION=v1.1.12
ARG RUNC_VERSION=v1.2.5
RUN git fetch -q --depth 1 origin "${RUNC_VERSION}" +refs/tags/*:refs/tags/* && git checkout -q FETCH_HEAD
FROM base AS runc-build
@@ -296,7 +288,6 @@ ARG TARGETPLATFORM
RUN --mount=type=cache,sharing=locked,id=moby-runc-aptlib,target=/var/lib/apt \
--mount=type=cache,sharing=locked,id=moby-runc-aptcache,target=/var/cache/apt \
apt-get update && xx-apt-get install -y --no-install-recommends \
dpkg-dev \
gcc \
libc6-dev \
libseccomp-dev \
@@ -356,7 +347,7 @@ FROM base AS rootlesskit-src
WORKDIR /usr/src/rootlesskit
RUN git init . && git remote add origin "https://github.com/rootless-containers/rootlesskit.git"
# When updating, also update vendor.mod and hack/dockerfile/install/rootlesskit.installer accordingly.
ARG ROOTLESSKIT_VERSION=v2.0.2
ARG ROOTLESSKIT_VERSION=v2.3.4
RUN git fetch -q --depth 1 origin "${ROOTLESSKIT_VERSION}" +refs/tags/*:refs/tags/* && git checkout -q FETCH_HEAD
FROM base AS rootlesskit-build
@@ -377,8 +368,6 @@ RUN --mount=from=rootlesskit-src,src=/usr/src/rootlesskit,rw \
export CGO_ENABLED=$([ "$DOCKER_STATIC" = "1" ] && echo "0" || echo "1")
xx-go build -o /build/rootlesskit -ldflags="$([ "$DOCKER_STATIC" != "1" ] && echo "-linkmode=external")" ./cmd/rootlesskit
xx-verify $([ "$DOCKER_STATIC" = "1" ] && echo "--static") /build/rootlesskit
xx-go build -o /build/rootlesskit-docker-proxy -ldflags="$([ "$DOCKER_STATIC" != "1" ] && echo "-linkmode=external")" ./cmd/rootlesskit-docker-proxy
xx-verify $([ "$DOCKER_STATIC" = "1" ] && echo "--static") /build/rootlesskit-docker-proxy
EOT
COPY --link ./contrib/dockerd-rootless.sh /build/
COPY --link ./contrib/dockerd-rootless-setuptool.sh /build/
@@ -400,7 +389,6 @@ RUN --mount=type=cache,sharing=locked,id=moby-crun-aptlib,target=/var/lib/apt \
libseccomp-dev \
libsystemd-dev \
libtool \
libudev-dev \
libyajl-dev \
python3 \
;
@@ -453,14 +441,13 @@ FROM binary-dummy AS containerutil-linux
FROM containerutil-build AS containerutil-windows-amd64
FROM containerutil-windows-${TARGETARCH} AS containerutil-windows
FROM containerutil-${TARGETOS} AS containerutil
FROM docker/buildx-bin:${BUILDX_VERSION} as buildx
FROM docker/compose-bin:${COMPOSE_VERSION} as compose
FROM docker/buildx-bin:${BUILDX_VERSION} AS buildx
FROM docker/compose-bin:${COMPOSE_VERSION} AS compose
FROM base AS dev-systemd-false
COPY --link --from=frozen-images /build/ /docker-frozen-images
COPY --link --from=swagger /build/ /usr/local/bin/
COPY --link --from=delve /build/ /usr/local/bin/
COPY --link --from=tomll /build/ /usr/local/bin/
COPY --link --from=gowinres /build/ /usr/local/bin/
COPY --link --from=tini /build/ /usr/local/bin/
COPY --link --from=registry /build/ /usr/local/bin/
@@ -504,16 +491,24 @@ RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \
systemd-sysv
ENTRYPOINT ["hack/dind-systemd"]
FROM dev-systemd-${SYSTEMD} AS dev-base
FROM dev-systemd-${SYSTEMD} AS dev-firewalld-false
FROM dev-systemd-true AS dev-firewalld-true
RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \
--mount=type=cache,sharing=locked,id=moby-dev-aptcache,target=/var/cache/apt \
apt-get update && apt-get install -y --no-install-recommends \
firewalld
RUN sed -i 's/FirewallBackend=nftables/FirewallBackend=iptables/' /etc/firewalld/firewalld.conf
FROM dev-firewalld-${FIREWALLD} AS dev-base
RUN groupadd -r docker
RUN useradd --create-home --gid docker unprivilegeduser \
&& mkdir -p /home/unprivilegeduser/.local/share/docker \
&& chown -R unprivilegeduser /home/unprivilegeduser
# Let us use a .bashrc file
RUN ln -sfv /go/src/github.com/docker/docker/.bashrc ~/.bashrc
# Activate bash completion and include Docker's completion if mounted with DOCKER_BASH_COMPLETION_PATH
# Activate bash completion
RUN echo "source /usr/share/bash-completion/bash_completion" >> /etc/bash.bashrc
RUN ln -s /usr/local/completion/bash/docker /etc/bash_completion.d/docker
RUN ldconfig
# Set dev environment as safe git directory to prevent "dubious ownership" errors
# when bind-mounting the source into the dev-container. See https://github.com/moby/moby/pull/44930
@@ -529,6 +524,7 @@ RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \
inetutils-ping \
iproute2 \
iptables \
nftables \
jq \
libcap2-bin \
libnet1 \
@@ -536,6 +532,7 @@ RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \
libprotobuf-c1 \
libyajl2 \
net-tools \
netcat-openbsd \
patch \
pigz \
sudo \
@@ -548,24 +545,16 @@ RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \
xz-utils \
zip \
zstd
# Switch to use iptables instead of nftables (to match the CI hosts)
# TODO use some kind of runtime auto-detection instead if/when nftables is supported (https://github.com/moby/moby/issues/26824)
RUN update-alternatives --set iptables /usr/sbin/iptables-legacy || true \
&& update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy || true \
&& update-alternatives --set arptables /usr/sbin/arptables-legacy || true
RUN --mount=type=cache,sharing=locked,id=moby-dev-aptlib,target=/var/lib/apt \
--mount=type=cache,sharing=locked,id=moby-dev-aptcache,target=/var/cache/apt \
apt-get update && apt-get install --no-install-recommends -y \
gcc \
pkg-config \
dpkg-dev \
libapparmor-dev \
libseccomp-dev \
libsecret-1-dev \
libsystemd-dev \
libudev-dev \
yamllint
COPY --link --from=dockercli /build/ /usr/local/cli
COPY --link --from=dockercli /completion.bash /etc/bash_completion.d/docker
COPY --link --from=dockercli-integration /build/ /usr/local/cli-integration
FROM base AS build
@@ -583,14 +572,10 @@ ARG TARGETPLATFORM
RUN --mount=type=cache,sharing=locked,id=moby-build-aptlib,target=/var/lib/apt \
--mount=type=cache,sharing=locked,id=moby-build-aptcache,target=/var/cache/apt \
xx-apt-get install --no-install-recommends -y \
dpkg-dev \
gcc \
libapparmor-dev \
libc6-dev \
libseccomp-dev \
libsecret-1-dev \
libsystemd-dev \
libudev-dev \
pkg-config
ARG DOCKER_BUILDTAGS
ARG DOCKER_DEBUG
@@ -613,14 +598,13 @@ RUN <<EOT
EOT
RUN --mount=type=bind,target=.,rw \
--mount=type=tmpfs,target=cli/winresources/dockerd \
--mount=type=tmpfs,target=cli/winresources/docker-proxy \
--mount=type=cache,target=/root/.cache/go-build,id=moby-build-$TARGETPLATFORM <<EOT
set -e
target=$([ "$DOCKER_STATIC" = "1" ] && echo "binary" || echo "dynbinary")
xx-go --wrap
PKG_CONFIG=$(xx-go env PKG_CONFIG) ./hack/make.sh $target
xx-verify $([ "$DOCKER_STATIC" = "1" ] && echo "--static") /tmp/bundles/${target}-daemon/dockerd$([ "$(xx-info os)" = "windows" ] && echo ".exe")
xx-verify $([ "$DOCKER_STATIC" = "1" ] && echo "--static") /tmp/bundles/${target}-daemon/docker-proxy$([ "$(xx-info os)" = "windows" ] && echo ".exe")
[ "$(xx-info os)" != "linux" ] || xx-verify $([ "$DOCKER_STATIC" = "1" ] && echo "--static") /tmp/bundles/${target}-daemon/docker-proxy
mkdir /build
mv /tmp/bundles/${target}-daemon/* /build/
EOT
@@ -648,7 +632,7 @@ COPY --link --from=build /build /
# smoke tests
# usage:
# > docker buildx bake binary-smoketest
FROM --platform=$TARGETPLATFORM base AS smoketest
FROM base AS smoketest
WORKDIR /usr/local/bin
COPY --from=build /build .
RUN <<EOT

View File

@@ -5,7 +5,7 @@
# This represents the bare minimum required to build and test Docker.
ARG GO_VERSION=1.21.9
ARG GO_VERSION=1.23.7
ARG BASE_DEBIAN_DISTRO="bookworm"
ARG GOLANG_IMAGE="golang:${GO_VERSION}-${BASE_DEBIAN_DISTRO}"
@@ -22,7 +22,6 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
curl \
cmake \
git \
libapparmor-dev \
libseccomp-dev \
ca-certificates \
e2fsprogs \

View File

@@ -161,10 +161,10 @@ FROM ${WINDOWS_BASE_IMAGE}:${WINDOWS_BASE_IMAGE_TAG}
# Use PowerShell as the default shell
SHELL ["powershell", "-Command", "$ErrorActionPreference = 'Stop'; $ProgressPreference = 'SilentlyContinue';"]
ARG GO_VERSION=1.21.9
ARG GOTESTSUM_VERSION=v1.8.2
ARG GO_VERSION=1.23.7
ARG GOTESTSUM_VERSION=v1.12.0
ARG GOWINRES_VERSION=v0.3.1
ARG CONTAINERD_VERSION=v1.7.15
ARG CONTAINERD_VERSION=v1.7.27
# Environment variable notes:
# - GO_VERSION must be consistent with 'Dockerfile' used by Linux.

165
Jenkinsfile vendored
View File

@@ -1,165 +0,0 @@
#!groovy
pipeline {
agent none
options {
buildDiscarder(logRotator(daysToKeepStr: '30'))
timeout(time: 2, unit: 'HOURS')
timestamps()
}
parameters {
booleanParam(name: 'arm64', defaultValue: true, description: 'ARM (arm64) Build/Test')
booleanParam(name: 'dco', defaultValue: true, description: 'Run the DCO check')
}
environment {
DOCKER_BUILDKIT = '1'
DOCKER_EXPERIMENTAL = '1'
DOCKER_GRAPHDRIVER = 'overlay2'
CHECK_CONFIG_COMMIT = '33a3680e08d1007e72c3b3f1454f823d8e9948ee'
TESTDEBUG = '0'
TIMEOUT = '120m'
}
stages {
stage('pr-hack') {
when { changeRequest() }
steps {
script {
echo "Workaround for PR auto-cancel feature. Borrowed from https://issues.jenkins-ci.org/browse/JENKINS-43353"
def buildNumber = env.BUILD_NUMBER as int
if (buildNumber > 1) milestone(buildNumber - 1)
milestone(buildNumber)
}
}
}
stage('DCO-check') {
when {
beforeAgent true
expression { params.dco }
}
agent { label 'arm64 && ubuntu-2004' }
steps {
sh '''
docker run --rm \
-v "$WORKSPACE:/workspace" \
-e VALIDATE_REPO=${GIT_URL} \
-e VALIDATE_BRANCH=${CHANGE_TARGET} \
alpine sh -c 'apk add --no-cache -q bash git openssh-client && git config --system --add safe.directory /workspace && cd /workspace && hack/validate/dco'
'''
}
}
stage('Build') {
parallel {
stage('arm64') {
when {
beforeAgent true
expression { params.arm64 }
}
agent { label 'arm64 && ubuntu-2004' }
environment {
TEST_SKIP_INTEGRATION_CLI = '1'
}
stages {
stage("Print info") {
steps {
sh 'docker version'
sh 'docker info'
sh '''
echo "check-config.sh version: ${CHECK_CONFIG_COMMIT}"
curl -fsSL -o ${WORKSPACE}/check-config.sh "https://raw.githubusercontent.com/moby/moby/${CHECK_CONFIG_COMMIT}/contrib/check-config.sh" \
&& bash ${WORKSPACE}/check-config.sh || true
'''
}
}
stage("Build dev image") {
steps {
sh 'docker build --force-rm -t docker:${GIT_COMMIT} .'
}
}
stage("Unit tests") {
steps {
sh '''
sudo modprobe ip6table_filter
'''
sh '''
docker run --rm -t --privileged \
-v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
--name docker-pr$BUILD_NUMBER \
-e DOCKER_EXPERIMENTAL \
-e DOCKER_GITCOMMIT=${GIT_COMMIT} \
-e DOCKER_GRAPHDRIVER \
-e VALIDATE_REPO=${GIT_URL} \
-e VALIDATE_BRANCH=${CHANGE_TARGET} \
docker:${GIT_COMMIT} \
hack/test/unit
'''
}
post {
always {
junit testResults: 'bundles/junit-report*.xml', allowEmptyResults: true
}
}
}
stage("Integration tests") {
environment { TEST_SKIP_INTEGRATION_CLI = '1' }
steps {
sh '''
docker run --rm -t --privileged \
-v "$WORKSPACE/bundles:/go/src/github.com/docker/docker/bundles" \
--name docker-pr$BUILD_NUMBER \
-e DOCKER_EXPERIMENTAL \
-e DOCKER_GITCOMMIT=${GIT_COMMIT} \
-e DOCKER_GRAPHDRIVER \
-e TESTDEBUG \
-e TEST_INTEGRATION_USE_SNAPSHOTTER \
-e TEST_SKIP_INTEGRATION_CLI \
-e TIMEOUT \
-e VALIDATE_REPO=${GIT_URL} \
-e VALIDATE_BRANCH=${CHANGE_TARGET} \
docker:${GIT_COMMIT} \
hack/make.sh \
dynbinary \
test-integration
'''
}
post {
always {
junit testResults: 'bundles/**/*-report.xml', allowEmptyResults: true
}
}
}
}
post {
always {
sh '''
echo "Ensuring container killed."
docker rm -vf docker-pr$BUILD_NUMBER || true
'''
sh '''
echo "Chowning /workspace to jenkins user"
docker run --rm -v "$WORKSPACE:/workspace" busybox chown -R "$(id -u):$(id -g)" /workspace
'''
catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE', message: 'Failed to create bundles.tar.gz') {
sh '''
bundleName=arm64-integration
echo "Creating ${bundleName}-bundles.tar.gz"
# exclude overlay2 directories
find bundles -path '*/root/*overlay2' -prune -o -type f \\( -name '*-report.json' -o -name '*.log' -o -name '*.prof' -o -name '*-report.xml' \\) -print | xargs tar -czf ${bundleName}-bundles.tar.gz
'''
archiveArtifacts artifacts: '*-bundles.tar.gz', allowEmptyArchive: true
}
}
cleanup {
sh 'make clean'
deleteDir()
}
}
}
}
}
}
}

View File

@@ -1,585 +1,33 @@
# Moby maintainers file
#
# This file describes the maintainer groups within the moby/moby project.
# More detail on Moby project governance is available in the
# project/GOVERNANCE.md file found in this repository.
# See project/GOVERNANCE.md for committer versus reviewer roles
#
# It is structured to be consumable by both humans and programs.
# To extract its contents programmatically, use any TOML-compliant
# parser.
# COMMITTERS
# GitHub ID, Name, Email address, GPG fingerprint
"akerouanton","Albin Kerouanton","albinker@gmail.com"
"AkihiroSuda","Akihiro Suda","akihiro.suda.cz@hco.ntt.co.jp"
"austinvazquez","Austin Vazquez","macedonv@amazon.com"
"cpuguy83","Brian Goff","cpuguy83@gmail.com"
"robmry","Rob Murray","rob.murray@docker.com"
"thaJeztah","Sebastiaan van Stijn","github@gone.nl"
"tianon","Tianon Gravi","admwiggin@gmail.com"
"tonistiigi","Tõnis Tiigi","tonis@docker.com"
"vvoland","Paweł Gronowski","pawel.gronowski@docker.com"
#
# TODO(estesp): This file should not necessarily depend on docker/opensource
# This file is compiled into the MAINTAINERS file in docker/opensource.
#
[Org]
[Org."Core maintainers"]
# The Core maintainers are the ghostbusters of the project: when there's a problem others
# can't solve, they show up and fix it with bizarre devices and weaponry.
# They have final say on technical implementation and coding style.
# They are ultimately responsible for quality in all its forms: usability polish,
# bugfixes, performance, stability, etc. When ownership can cleanly be passed to
# a subsystem, they are responsible for doing so and holding the
# subsystem maintainers accountable. If ownership is unclear, they are the de facto owners.
people = [
"akerouanton",
"akihirosuda",
"anusha",
"coolljt0725",
"corhere",
"cpuguy83",
"crazy-max",
"estesp",
"johnstep",
"justincormack",
"kolyshkin",
"laurazard",
"mhbauer",
"neersighted",
"rumpl",
"runcom",
"samuelkarp",
"stevvooe",
"thajeztah",
"tianon",
"tibor",
"tonistiigi",
"unclejack",
"vdemeester",
"vieux",
"vvoland",
"yongtang"
]
[Org.Curators]
# The curators help ensure that incoming issues and pull requests are properly triaged and
# that our various contribution and reviewing processes are respected. With their knowledge of
# the repository activity, they can also guide contributors to relevant material or
# discussions.
#
# They are neither code nor docs reviewers, so they are never expected to merge. They can
# however:
# - close an issue or pull request when it's an exact duplicate
# - close an issue or pull request when it's inappropriate or off-topic
people = [
"alexellis",
"andrewhsu",
"bsousaa",
"dmcgowan",
"fntlnz",
"gianarb",
"olljanat",
"programmerq",
"ripcurld",
"robmry",
"sam-thibault",
"samwhited",
"thajeztah"
]
[Org.Alumni]
# This list contains maintainers that are no longer active on the project.
# It is thanks to these people that the project has become what it is today.
# Thank you!
people = [
# Aaron Lehmann was a maintainer for swarmkit, the registry, and the engine,
# and contributed many improvements, features, and bugfixes in those areas,
# among which "automated service rollbacks", templated secrets and configs,
# and resumable image layer downloads.
"aaronlehmann",
# Harald Albers is the mastermind behind the bash completion scripts for the
# Docker CLI. The completion scripts moved to the Docker CLI repository, so
# you can now find him perform his magic in the https://github.com/docker/cli repository.
"albers",
# Andrea Luzzardi started contributing to the Docker codebase in the "dotCloud"
# era, even before it was called "Docker". He is one of the architects of both
# Swarm and SwarmKit, and its integration into the Docker engine.
"aluzzardi",
# David Calavera contributed many features to Docker, such as an improved
# event system, dynamic configuration reloading, volume plugins, fancy
# new templating options, and an external client credential store. As a
# maintainer, David was release captain for Docker 1.8, and competing
# with Jess Frazelle to be "top dream killer".
# David is now doing amazing stuff as CTO for https://www.netlify.com,
# and tweets as @calavera.
"calavera",
# Michael Crosby was "chief maintainer" of the Docker project.
# During his time as a maintainer, Michael contributed to many
# milestones of the project; he was release captain of Docker v1.0.0,
# started the development of "libcontainer" (what later became runc)
# and containerd, as well as demoing cool hacks such as live migrating
# a game server container with checkpoint/restore.
#
# Michael is currently a maintainer of containerd, but you may see
# him around in other projects on GitHub.
"crosbymichael",
# Before becoming a maintainer, Daniel Nephin was a core contributor
# to "Fig" (now known as Docker Compose). As a maintainer for both the
# Engine and Docker CLI, Daniel contributed many features, among which
# the `docker stack` commands, allowing users to deploy their Docker
# Compose projects as a Swarm service.
"dnephin",
# Doug Davis contributed many features and fixes for the classic builder,
# such as "wildcard" copy, the dockerignore file, custom paths/names
# for the Dockerfile, as well as enhancements to the API and documentation.
# Follow Doug on Twitter, where he tweets as @duginabox.
"duglin",
# As a maintainer, Erik was responsible for the "builder", and
# started the first designs for the new networking model in
# Docker. Erik is now working on all kinds of plugins for Docker
# (https://github.com/contiv) and various open source projects
# in his own repository https://github.com/erikh. You may
# still stumble into him in our issue tracker, or on IRC.
"erikh",
# Evan Hazlett is the creator of the Shipyard and Interlock open source projects,
# and the author of "Orca", which became the foundation of Docker Universal Control
# Plane (UCP). As a maintainer, Evan helped integrating SwarmKit (secrets, tasks)
# into the Docker engine.
"ehazlett",
# Arnaud Porterie (AKA "icecrime") was in charge of maintaining the maintainers.
# As a maintainer, he made life easier for contributors to the Docker open-source
# projects, bringing order in the chaos by designing a triage- and review workflow
# using labels (see https://icecrime.net/technology/a-structured-approach-to-labeling/),
# and automating the hell out of things with his buddies GordonTheTurtle and Poule
# (a chicken!).
#
# A lesser-known fact is that he created the first commit in the libnetwork repository
# even though he didn't know anything about it. Some say, he's now selling stuff on
# the internet ;-)
"icecrime",
# After a false start with his first PR being rejected, James Turnbull became a frequent
# contributor to the documentation, and became a docs maintainer on December 5, 2013. As
# a maintainer, James lifted the docs to a higher standard, and introduced the community
# guidelines ("three strikes"). James is currently changing the world as CTO of https://www.empatico.org,
# meanwhile authoring various books that are worth checking out. You can find him on Twitter,
# rambling as @kartar, and although no longer active as a maintainer, he's always "game" to
# help out reviewing docs PRs, so you may still see him around in the repository.
"jamtur01",
# Jessica Frazelle, also known as the "Keyser Söze of containers",
# runs *everything* in containers. She started contributing to
# Docker with a (fun fun) change involving both iptables and regular
# expressions (coz, YOLO!) on July 10, 2014
# https://github.com/docker/docker/pull/6950/commits/f3a68ffa390fb851115c77783fa4031f1d3b2995.
# Jess was Release Captain for Docker 1.4, 1.6 and 1.7, and contributed
# many features and improvement, among which "seccomp profiles" (making
# containers a lot more secure). Besides being a maintainer, she
# set up the CI infrastructure for the project, giving everyone
# something to shout at if a PR failed ("noooo Janky!").
# Be sure you don't miss her talks at a conference near you (a must-see),
# read her blog at https://blog.jessfraz.com (a must-read), and
# check out her open source projects on GitHub https://github.com/jessfraz (a must-try).
"jessfraz",
# As a maintainer, John Howard managed to make the impossible possible;
# to run Docker on Windows. After facing many challenges, teaching
# fellow-maintainers that 'Windows is not Linux', and many changes in
# Windows Server to facilitate containers, native Windows containers
# saw the light of day in 2015.
#
# John is now enjoying life without containers: playing piano, painting,
# and walking his dogs, but you may occasionally see him drop by on GitHub.
"lowenna",
# Alexander Morozov contributed many features to Docker, worked on the premise of
# what later became containerd (and worked on that too), and made a "stupid" Go
# vendor tool specifically for docker/docker needs: vndr (https://github.com/LK4D4/vndr).
# Not many know that Alexander is a master negotiator, being able to change course
# of action with a single "Nope, we're not gonna do that".
"lk4d4",
# Madhu Venugopal was part of the SocketPlane team that joined Docker.
# As a maintainer, he was working with Jana for the Container Network
# Model (CNM) implemented through libnetwork, and the "routing mesh" powering
# Swarm mode networking.
"mavenugo",
# As a maintainer, Kenfe-Mickaël Laventure worked on the container runtime,
# integrating containerd 1.0 with the daemon, and adding support for custom
# OCI runtimes, as well as implementing the `docker prune` subcommands,
# which was a welcome feature to be added. You can keep up with Mickaél on
# Twitter (@kmlaventure).
"mlaventure",
# As a docs maintainer, Mary Anthony contributed greatly to the Docker
# docs. She wrote the Docker Contributor Guide and Getting Started
# Guides. She helped create a doc build system independent of
# docker/docker project, and implemented a new docs.docker.com theme and
# nav for 2015 Dockercon. Fun fact: the most inherited layer in DockerHub
# public repositories was originally referenced in
# maryatdocker/docker-whale back in May 2015.
"moxiegirl",
# Jana Radhakrishnan was part of the SocketPlane team that joined Docker.
# As a maintainer, he was the lead architect for the Container Network
# Model (CNM) implemented through libnetwork, and the "routing mesh" powering
# Swarm mode networking.
#
# Jana started new adventures in networking, but you can find him tweeting as @mrjana,
# coding on GitHub https://github.com/mrjana, and he may be hiding on the Docker Community
# slack channel :-)
"mrjana",
# Sven Dowideit became a well known person in the Docker ecosphere, building
# boot2docker, and became a regular contributor to the project, starting as
# early as October 2013 (https://github.com/docker/docker/pull/2119), to become
# a maintainer less than two months later (https://github.com/docker/docker/pull/3061).
#
# As a maintainer, Sven took on the task to convert the documentation from
# ReStructuredText to Markdown, migrate to Hugo for generating the docs, and
# writing tooling for building, testing, and publishing them.
#
# If you're not in the occasion to visit "the Australian office", you
# can keep up with Sven on Twitter (@SvenDowideit), his blog http://fosiki.com,
# and of course on GitHub.
"sven",
# Vincent "vbatts!" Batts made his first contribution to the project
# in November 2013, to become a maintainer a few months later, on
# May 10, 2014 (https://github.com/docker/docker/commit/d6e666a87a01a5634c250358a94c814bf26cb778).
# As a maintainer, Vincent made important contributions to core elements
# of Docker, such as "distribution" (tarsum) and graphdrivers (btrfs, devicemapper).
# He also contributed the "tar-split" library, an important element
# for the content-addressable store.
# Vincent is currently a member of the Open Containers Initiative
# Technical Oversight Board (TOB), besides his work at Red Hat and
# Project Atomic. You can still find him regularly hanging out in
# our repository and the #docker-dev and #docker-maintainers IRC channels
# for a chat, as he's always a lot of fun.
"vbatts",
# Vishnu became a maintainer to help out on the daemon codebase and
# libcontainer integration. He's currently involved in the
# Open Containers Initiative, working on the specifications,
# besides his work on cAdvisor and Kubernetes for Google.
"vishh"
]
[people]
# A reference list of all people associated with the project.
# All other sections should refer to people by their canonical key
# in the people section.
# ADD YOURSELF HERE IN ALPHABETICAL ORDER
[people.aaronlehmann]
Name = "Aaron Lehmann"
Email = "aaron.lehmann@docker.com"
GitHub = "aaronlehmann"
[people.akerouanton]
Name = "Albin Kerouanton"
Email = "albinker@gmail.com"
GitHub = "akerouanton"
[people.alexellis]
Name = "Alex Ellis"
Email = "alexellis2@gmail.com"
GitHub = "alexellis"
[people.akihirosuda]
Name = "Akihiro Suda"
Email = "akihiro.suda.cz@hco.ntt.co.jp"
GitHub = "AkihiroSuda"
[people.aluzzardi]
Name = "Andrea Luzzardi"
Email = "al@docker.com"
GitHub = "aluzzardi"
[people.albers]
Name = "Harald Albers"
Email = "github@albersweb.de"
GitHub = "albers"
[people.andrewhsu]
Name = "Andrew Hsu"
Email = "andrewhsu@docker.com"
GitHub = "andrewhsu"
[people.anusha]
Name = "Anusha Ragunathan"
Email = "anusha@docker.com"
GitHub = "anusha-ragunathan"
[people.bsousaa]
Name = "Bruno de Sousa"
Email = "bruno.sousa@docker.com"
GitHub = "bsousaa"
[people.calavera]
Name = "David Calavera"
Email = "david.calavera@gmail.com"
GitHub = "calavera"
[people.coolljt0725]
Name = "Lei Jitang"
Email = "leijitang@huawei.com"
GitHub = "coolljt0725"
[people.corhere]
Name = "Cory Snider"
Email = "csnider@mirantis.com"
GitHub = "corhere"
[people.cpuguy83]
Name = "Brian Goff"
Email = "cpuguy83@gmail.com"
GitHub = "cpuguy83"
[people.crazy-max]
Name = "Kevin Alvarez"
Email = "contact@crazymax.dev"
GitHub = "crazy-max"
[people.crosbymichael]
Name = "Michael Crosby"
Email = "crosbymichael@gmail.com"
GitHub = "crosbymichael"
[people.dnephin]
Name = "Daniel Nephin"
Email = "dnephin@gmail.com"
GitHub = "dnephin"
[people.dmcgowan]
Name = "Derek McGowan"
Email = "derek@mcgstyle.net"
GitHub = "dmcgowan"
[people.duglin]
Name = "Doug Davis"
Email = "dug@us.ibm.com"
GitHub = "duglin"
[people.ehazlett]
Name = "Evan Hazlett"
Email = "ejhazlett@gmail.com"
GitHub = "ehazlett"
[people.erikh]
Name = "Erik Hollensbe"
Email = "erik@docker.com"
GitHub = "erikh"
[people.estesp]
Name = "Phil Estes"
Email = "estesp@linux.vnet.ibm.com"
GitHub = "estesp"
[people.fntlnz]
Name = "Lorenzo Fontana"
Email = "fontanalorenz@gmail.com"
GitHub = "fntlnz"
[people.gianarb]
Name = "Gianluca Arbezzano"
Email = "ga@thumpflow.com"
GitHub = "gianarb"
[people.icecrime]
Name = "Arnaud Porterie"
Email = "icecrime@gmail.com"
GitHub = "icecrime"
[people.jamtur01]
Name = "James Turnbull"
Email = "james@lovedthanlost.net"
GitHub = "jamtur01"
[people.jessfraz]
Name = "Jessie Frazelle"
Email = "jess@linux.com"
GitHub = "jessfraz"
[people.johnstep]
Name = "John Stephens"
Email = "johnstep@docker.com"
GitHub = "johnstep"
[people.justincormack]
Name = "Justin Cormack"
Email = "justin.cormack@docker.com"
GitHub = "justincormack"
[people.kolyshkin]
Name = "Kir Kolyshkin"
Email = "kolyshkin@gmail.com"
GitHub = "kolyshkin"
[people.laurazard]
Name = "Laura Brehm"
Email = "laura.brehm@docker.com"
GitHub = "laurazard"
[people.lk4d4]
Name = "Alexander Morozov"
Email = "lk4d4@docker.com"
GitHub = "lk4d4"
[people.lowenna]
Name = "John Howard"
Email = "github@lowenna.com"
GitHub = "lowenna"
[people.mavenugo]
Name = "Madhu Venugopal"
Email = "madhu@docker.com"
GitHub = "mavenugo"
[people.mhbauer]
Name = "Morgan Bauer"
Email = "mbauer@us.ibm.com"
GitHub = "mhbauer"
[people.mlaventure]
Name = "Kenfe-Mickaël Laventure"
Email = "mickael.laventure@gmail.com"
GitHub = "mlaventure"
[people.moxiegirl]
Name = "Mary Anthony"
Email = "mary.anthony@docker.com"
GitHub = "moxiegirl"
[people.mrjana]
Name = "Jana Radhakrishnan"
Email = "mrjana@docker.com"
GitHub = "mrjana"
[people.neersighted]
Name = "Bjorn Neergaard"
Email = "bjorn@neersighted.com"
GitHub = "neersighted"
[people.olljanat]
Name = "Olli Janatuinen"
Email = "olli.janatuinen@gmail.com"
GitHub = "olljanat"
[people.programmerq]
Name = "Jeff Anderson"
Email = "jeff@docker.com"
GitHub = "programmerq"
[people.robmry]
Name = "Rob Murray"
Email = "rob.murray@docker.com"
GitHub = "robmry"
[people.ripcurld]
Name = "Boaz Shuster"
Email = "ripcurld.github@gmail.com"
GitHub = "ripcurld"
[people.rumpl]
Name = "Djordje Lukic"
Email = "djordje.lukic@docker.com"
GitHub = "rumpl"
[people.runcom]
Name = "Antonio Murdaca"
Email = "runcom@redhat.com"
GitHub = "runcom"
[people.sam-thibault]
Name = "Sam Thibault"
Email = "sam.thibault@docker.com"
GitHub = "sam-thibault"
[people.samuelkarp]
Name = "Samuel Karp"
Email = "me@samuelkarp.com"
GitHub = "samuelkarp"
[people.samwhited]
Name = "Sam Whited"
Email = "sam@samwhited.com"
GitHub = "samwhited"
[people.shykes]
Name = "Solomon Hykes"
Email = "solomon@docker.com"
GitHub = "shykes"
[people.stevvooe]
Name = "Stephen Day"
Email = "stephen.day@docker.com"
GitHub = "stevvooe"
[people.sven]
Name = "Sven Dowideit"
Email = "SvenDowideit@home.org.au"
GitHub = "SvenDowideit"
[people.thajeztah]
Name = "Sebastiaan van Stijn"
Email = "github@gone.nl"
GitHub = "thaJeztah"
[people.tianon]
Name = "Tianon Gravi"
Email = "admwiggin@gmail.com"
GitHub = "tianon"
[people.tibor]
Name = "Tibor Vass"
Email = "tibor@docker.com"
GitHub = "tiborvass"
[people.tonistiigi]
Name = "Tõnis Tiigi"
Email = "tonis@docker.com"
GitHub = "tonistiigi"
[people.unclejack]
Name = "Cristian Staretu"
Email = "cristian.staretu@gmail.com"
GitHub = "unclejack"
[people.vbatts]
Name = "Vincent Batts"
Email = "vbatts@redhat.com"
GitHub = "vbatts"
[people.vdemeester]
Name = "Vincent Demeester"
Email = "vincent@sbr.pm"
GitHub = "vdemeester"
[people.vieux]
Name = "Victor Vieux"
Email = "vieux@docker.com"
GitHub = "vieux"
[people.vishh]
Name = "Vishnu Kannan"
Email = "vishnuk@google.com"
GitHub = "vishh"
[people.vvoland]
Name = "Paweł Gronowski"
Email = "pawel.gronowski@docker.com"
GitHub = "vvoland"
[people.yongtang]
Name = "Yong Tang"
Email = "yong.tang.github@outlook.com"
GitHub = "yongtang"
# REVIEWERS
# GitHub ID, Name, Email address, GPG fingerprint
"coolljt0725","Lei Jitang","leijitang@huawei.com"
"corhere","Cory Snider","csnider@mirantis.com"
"crazy-max","Kevin Alvarez","contact@crazymax.dev"
"dmcgowan","Derek McGowan","derek@mcgstyle.net"
"estesp","Phil Estes","estesp@linux.vnet.ibm.com"
"justincormack","Justin Cormack","justin.cormack@docker.com"
"kolyshkin","Kir Kolyshkin","kolyshkin@gmail.com"
"laurazard","Laura Brehm","laurabrehm@hey.com"
"neersighted","Bjorn Neergaard","bjorn@neersighted.com"
"rumpl","Djordje Lukic","djordje.lukic@docker.com"
"samuelkarp","Samuel Karp","me@samuelkarp.com"
"stevvooe","Stephen Day","stephen.day@docker.com"
"thompson-shaun","Shaun Thompson","shaun.thompson@docker.com"
"tiborvass","Tibor Vass","tibor@docker.com"
"unclejack","Cristian Staretu","cristian.staretu@gmail.com"

View File

@@ -1,12 +1,6 @@
.PHONY: all binary dynbinary build cross help install manpages run shell test test-docker-py test-integration test-unit validate validate-% win
DOCKER ?= docker
BUILDX ?= $(DOCKER) buildx
# set the graph driver as the current graphdriver if not set
DOCKER_GRAPHDRIVER := $(if $(DOCKER_GRAPHDRIVER),$(DOCKER_GRAPHDRIVER),$(shell docker info -f '{{ .Driver }}' 2>&1))
export DOCKER_GRAPHDRIVER
DOCKER_GITCOMMIT := $(shell git rev-parse HEAD)
export DOCKER_GITCOMMIT
@@ -37,7 +31,6 @@ DOCKER_ENVS := \
-e DOCKER_BUILD_OPTS \
-e DOCKER_BUILD_PKGS \
-e DOCKER_BUILDKIT \
-e DOCKER_BASH_COMPLETION_PATH \
-e DOCKER_CLI_PATH \
-e DOCKERCLI_VERSION \
-e DOCKERCLI_REPOSITORY \
@@ -45,6 +38,7 @@ DOCKER_ENVS := \
-e DOCKERCLI_INTEGRATION_REPOSITORY \
-e DOCKER_DEBUG \
-e DOCKER_EXPERIMENTAL \
-e DOCKER_FIREWALLD \
-e DOCKER_GITCOMMIT \
-e DOCKER_GRAPHDRIVER \
-e DOCKER_LDFLAGS \
@@ -92,7 +86,7 @@ DOCKER_ENVS := \
# note: BINDDIR is supported for backwards-compatibility here
BIND_DIR := $(if $(BINDDIR),$(BINDDIR),$(if $(DOCKER_HOST),,bundles))
# DOCKER_MOUNT can be overriden, but use at your own risk!
# DOCKER_MOUNT can be overridden, but use at your own risk!
ifndef DOCKER_MOUNT
DOCKER_MOUNT := $(if $(BIND_DIR),-v "$(CURDIR)/$(BIND_DIR):/go/src/github.com/docker/docker/$(BIND_DIR)")
DOCKER_MOUNT := $(if $(DOCKER_BINDDIR_MOUNT_OPTS),$(DOCKER_MOUNT):$(DOCKER_BINDDIR_MOUNT_OPTS),$(DOCKER_MOUNT))
@@ -104,8 +98,14 @@ DOCKER_MOUNT := $(if $(DOCKER_MOUNT),$(DOCKER_MOUNT),-v /go/src/github.com/docke
DOCKER_MOUNT_CACHE := -v docker-dev-cache:/root/.cache -v docker-mod-cache:/go/pkg/mod/
DOCKER_MOUNT_CLI := $(if $(DOCKER_CLI_PATH),-v $(shell dirname $(DOCKER_CLI_PATH)):/usr/local/cli,)
DOCKER_MOUNT_BASH_COMPLETION := $(if $(DOCKER_BASH_COMPLETION_PATH),-v $(shell dirname $(DOCKER_BASH_COMPLETION_PATH)):/usr/local/completion/bash,)
DOCKER_MOUNT := $(DOCKER_MOUNT) $(DOCKER_MOUNT_CACHE) $(DOCKER_MOUNT_CLI) $(DOCKER_MOUNT_BASH_COMPLETION)
ifdef BIND_GIT
# Gets the common .git directory (even from inside a git worktree)
GITDIR := $(shell realpath $(shell git rev-parse --git-common-dir))
MOUNT_GITDIR := $(if $(GITDIR),-v "$(GITDIR):$(GITDIR)")
endif
DOCKER_MOUNT := $(DOCKER_MOUNT) $(DOCKER_MOUNT_CACHE) $(DOCKER_MOUNT_CLI) $(DOCKER_MOUNT_BASH_COMPLETION) $(MOUNT_GITDIR)
endif # ifndef DOCKER_MOUNT
# This allows to set the docker-dev container name
@@ -150,6 +150,9 @@ DOCKER_BUILD_ARGS += --build-arg=DOCKERCLI_INTEGRATION_REPOSITORY
ifdef DOCKER_SYSTEMD
DOCKER_BUILD_ARGS += --build-arg=SYSTEMD=true
endif
ifdef DOCKER_FIREWALLD
DOCKER_BUILD_ARGS += --build-arg=FIREWALLD=true
endif
BUILD_OPTS := ${DOCKER_BUILD_ARGS} ${DOCKER_BUILD_OPTS}
BUILD_CMD := $(BUILDX) build
@@ -157,15 +160,19 @@ BAKE_CMD := $(BUILDX) bake
default: binary
.PHONY: all
all: build ## validate all checks, build linux binaries, run all tests,\ncross build non-linux binaries, and generate archives
$(DOCKER_RUN_DOCKER) bash -c 'hack/validate/default && hack/make.sh'
.PHONY: binary
binary: bundles ## build statically linked linux binaries
$(BAKE_CMD) binary
.PHONY: dynbinary
dynbinary: bundles ## build dynamically linked linux binaries
$(BAKE_CMD) dynbinary
.PHONY: cross
cross: bundles ## cross build the binaries
$(BAKE_CMD) binary-cross
@@ -179,12 +186,15 @@ clean: clean-cache
clean-cache: ## remove the docker volumes that are used for caching in the dev-container
docker volume rm -f docker-dev-cache docker-mod-cache
.PHONY: help
help: ## this help
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z0-9_-]+:.*?## / {gsub("\\\\n",sprintf("\n%22c",""), $$2);printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: install
install: ## install the linux binaries
KEEPBUNDLE=1 hack/make.sh install-binary
.PHONY: run
run: build ## run the docker daemon in a container
$(DOCKER_RUN_DOCKER) sh -c "KEEPBUNDLE=1 hack/make.sh install-binary run"
@@ -197,17 +207,22 @@ endif
build: bundles
$(BUILD_CMD) $(BUILD_OPTS) $(shell_target) --load -t "$(DOCKER_IMAGE)" .
.PHONY: shell
shell: build ## start a shell inside the build env
$(DOCKER_RUN_DOCKER) bash
.PHONY: test
test: build test-unit ## run the unit, integration and docker-py tests
$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-integration test-docker-py
.PHONY: test-docker-py
test-docker-py: build ## run the docker-py tests
$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-docker-py
.PHONY: test-integration-cli
test-integration-cli: test-integration ## (DEPRECATED) use test-integration
.PHONY: test-integration
ifneq ($(and $(TEST_SKIP_INTEGRATION),$(TEST_SKIP_INTEGRATION_CLI)),)
test-integration:
@echo Both integrations suites skipped per environment variables
@@ -216,23 +231,29 @@ test-integration: build ## run the integration tests
$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-integration
endif
.PHONY: test-integration-flaky
test-integration-flaky: build ## run the stress test for all new integration tests
$(DOCKER_RUN_DOCKER) hack/make.sh dynbinary test-integration-flaky
.PHONY: test-unit
test-unit: build ## run the unit tests
$(DOCKER_RUN_DOCKER) hack/test/unit
.PHONY: validate
validate: build ## validate DCO, Seccomp profile generation, gofmt,\n./pkg/ isolation, golint, tests, tomls, go vet and vendor
$(DOCKER_RUN_DOCKER) hack/validate/all
.PHONY: validate-generate-files
validate-generate-files:
$(BUILD_CMD) --target "validate" \
--output "type=cacheonly" \
--file "./hack/dockerfiles/generate-files.Dockerfile" .
.PHONY: validate-%
validate-%: build ## validate specific check
$(DOCKER_RUN_DOCKER) hack/validate/$*
.PHONY: win
win: bundles ## cross build the binary for windows
$(BAKE_CMD) --set *.platform=windows/amd64 binary

View File

@@ -1,6 +1,11 @@
The Moby Project
================
[![PkgGoDev](https://pkg.go.dev/badge/github.com/docker/docker)](https://pkg.go.dev/github.com/docker/docker)
[![Go Report Card](https://goreportcard.com/badge/github.com/docker/docker)](https://goreportcard.com/report/github.com/docker/docker)
[![OpenSSF Scorecard](https://api.scorecard.dev/projects/github.com/moby/moby/badge)](https://scorecard.dev/viewer/?uri=github.com/moby/moby)
![Moby Project logo](docs/static_files/moby-project-logo.png "The Moby Project")
Moby is an open-source project created by Docker to enable and accelerate software containerization.
@@ -32,7 +37,7 @@ New projects can be added if they fit with the community goals. Docker is commit
However, other projects are also encouraged to use Moby as an upstream, and to reuse the components in diverse ways, and all these uses will be treated in the same way. External maintainers and contributors are welcomed.
The Moby project is not intended as a location for support or feature requests for Docker products, but as a place for contributors to work on open source code, fix bugs, and make the code more useful.
The releases are supported by the maintainers, community and users, on a best efforts basis only, and are not intended for customers who want enterprise or commercial support; Docker EE is the appropriate product for these use cases.
The releases are supported by the maintainers, community and users, on a best efforts basis only. For customers who want enterprise or commercial support, [Docker Desktop](https://www.docker.com/products/docker-desktop/) and [Mirantis Container Runtime](https://www.mirantis.com/software/mirantis-container-runtime/) are the appropriate products for these use cases.
-----

View File

@@ -1,9 +1,42 @@
# Reporting security issues
# Security Policy
The Moby maintainers take security seriously. If you discover a security issue, please bring it to their attention right away!
The maintainers of the Moby project take security seriously. If you discover
a security issue, please bring it to their attention right away!
### Reporting a Vulnerability
## Reporting a Vulnerability
Please **DO NOT** file a public issue, instead send your report privately to security@docker.com.
Please **DO NOT** file a public issue, instead send your report privately
to [security@docker.com](mailto:security@docker.com).
Security reports are greatly appreciated and we will publicly thank you for it, although we keep your name confidential if you request it. We also like to send gifts—if you're into schwag, make sure to let us know. We currently do not offer a paid security bounty program, but are not ruling it out in the future.
Reporter(s) can expect a response within 72 hours, acknowledging the issue was
received.
## Review Process
After receiving the report, an initial triage and technical analysis is
performed to confirm the report and determine its scope. We may request
additional information in this stage of the process.
Once a reviewer has confirmed the relevance of the report, a draft security
advisory will be created on GitHub. The draft advisory will be used to discuss
the issue with maintainers, the reporter(s), and where applicable, other
affected parties under embargo.
If the vulnerability is accepted, a timeline for developing a patch, public
disclosure, and patch release will be determined. If there is an embargo period
on public disclosure before the patch release, the reporter(s) are expected to
participate in the discussion of the timeline and abide by agreed upon dates
for public disclosure.
## Accreditation
Security reports are greatly appreciated and we will publicly thank you,
although we will keep your name confidential if you request it. We also like to
send gifts - if you're into swag, make sure to let us know. We do not currently
offer a paid security bounty program at this time.
## Supported Versions
This project uses long-lived branches to maintain releases. Refer to
[BRANCHES-AND-TAGS.md](project/BRANCHES-AND-TAGS.md) in the default branch to
learn about the current maintenance status of each branch.

View File

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

View File

@@ -88,11 +88,9 @@ func (b *Backend) Build(ctx context.Context, config backend.BuildConfig) (string
}
}
if !useBuildKit {
stdout := config.ProgressWriter.StdoutFormatter
fmt.Fprintf(stdout, "Successfully built %s\n", stringid.TruncateID(imageID))
}
if imageID != "" && !useBuildKit {
stdout := config.ProgressWriter.StdoutFormatter
_, _ = fmt.Fprintf(stdout, "Successfully built %s\n", stringid.TruncateID(imageID))
err = tagImages(ctx, b.imageComponent, config.ProgressWriter.StdoutFormatter, image.ID(imageID), tags)
}
return imageID, err

View File

@@ -5,7 +5,7 @@ import (
"fmt"
"net/http"
cerrdefs "github.com/containerd/containerd/errdefs"
cerrdefs "github.com/containerd/errdefs"
"github.com/containerd/log"
"github.com/docker/distribution/registry/api/errcode"
"github.com/docker/docker/errdefs"
@@ -24,42 +24,37 @@ func FromError(err error) int {
return http.StatusInternalServerError
}
var statusCode int
// Stop right there
// Are you sure you should be adding a new error class here? Do one of the existing ones work?
// Note that the below functions are already checking the error causal chain for matches.
switch {
case errdefs.IsNotFound(err):
statusCode = http.StatusNotFound
return http.StatusNotFound
case errdefs.IsInvalidParameter(err):
statusCode = http.StatusBadRequest
return http.StatusBadRequest
case errdefs.IsConflict(err):
statusCode = http.StatusConflict
return http.StatusConflict
case errdefs.IsUnauthorized(err):
statusCode = http.StatusUnauthorized
return http.StatusUnauthorized
case errdefs.IsUnavailable(err):
statusCode = http.StatusServiceUnavailable
return http.StatusServiceUnavailable
case errdefs.IsForbidden(err):
statusCode = http.StatusForbidden
return http.StatusForbidden
case errdefs.IsNotModified(err):
statusCode = http.StatusNotModified
return http.StatusNotModified
case errdefs.IsNotImplemented(err):
statusCode = http.StatusNotImplemented
return http.StatusNotImplemented
case errdefs.IsSystem(err) || errdefs.IsUnknown(err) || errdefs.IsDataLoss(err) || errdefs.IsDeadline(err) || errdefs.IsCancelled(err):
statusCode = http.StatusInternalServerError
return http.StatusInternalServerError
default:
statusCode = statusCodeFromGRPCError(err)
if statusCode != http.StatusInternalServerError {
if statusCode := statusCodeFromGRPCError(err); statusCode != http.StatusInternalServerError {
return statusCode
}
statusCode = statusCodeFromContainerdError(err)
if statusCode != http.StatusInternalServerError {
if statusCode := statusCodeFromContainerdError(err); statusCode != http.StatusInternalServerError {
return statusCode
}
statusCode = statusCodeFromDistributionError(err)
if statusCode != http.StatusInternalServerError {
if statusCode := statusCodeFromDistributionError(err); statusCode != http.StatusInternalServerError {
return statusCode
}
if e, ok := err.(causer); ok {
@@ -71,13 +66,9 @@ func FromError(err error) int {
"error": err,
"error_type": fmt.Sprintf("%T", err),
}).Debug("FIXME: Got an API for which error does not match any expected type!!!")
}
if statusCode == 0 {
statusCode = http.StatusInternalServerError
return http.StatusInternalServerError
}
return statusCode
}
// statusCodeFromGRPCError returns status code according to gRPC error

View File

@@ -1,12 +1,17 @@
package httputils // import "github.com/docker/docker/api/server/httputils"
import (
"encoding/json"
"fmt"
"net/http"
"strconv"
"strings"
"github.com/distribution/reference"
"github.com/docker/docker/errdefs"
"github.com/pkg/errors"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
// BoolValue transforms a form value in different formats into a boolean type.
@@ -24,6 +29,29 @@ func BoolValueOrDefault(r *http.Request, k string, d bool) bool {
return BoolValue(r, k)
}
// Uint32Value parses a form value into an uint32 type. It returns an error
// if the field is not set, empty, incorrectly formatted, or out of range.
func Uint32Value(r *http.Request, field string) (uint32, error) {
// strconv.ParseUint returns an "strconv.ErrSyntax" for negative values,
// not an "out of range". Strip the prefix before parsing, and use it
// later to detect valid, but negative values.
v, isNeg := strings.CutPrefix(r.Form.Get(field), "-")
if v == "" || v[0] == '+' {
// Fast-path for invalid values.
return 0, strconv.ErrSyntax
}
i, err := strconv.ParseUint(v, 10, 32)
if err != nil {
// Unwrap to remove the 'strconv.ParseUint: parsing "some-invalid-value":' prefix.
return 0, errors.Unwrap(err)
}
if isNeg {
return 0, strconv.ErrRange
}
return uint32(i), nil
}
// Int64ValueOrZero parses a form value into an int64 type.
// It returns 0 if the parsing fails.
func Int64ValueOrZero(r *http.Request, k string) int64 {
@@ -109,3 +137,24 @@ func ArchiveFormValues(r *http.Request, vars map[string]string) (ArchiveOptions,
}
return ArchiveOptions{name, path}, nil
}
// DecodePlatform decodes the OCI platform JSON string into a Platform struct.
func DecodePlatform(platformJSON string) (*ocispec.Platform, error) {
var p ocispec.Platform
if err := json.Unmarshal([]byte(platformJSON), &p); err != nil {
return nil, errdefs.InvalidParameter(errors.Wrap(err, "failed to parse platform"))
}
hasAnyOptional := (p.Variant != "" || p.OSVersion != "" || len(p.OSFeatures) > 0)
if p.OS == "" && p.Architecture == "" && hasAnyOptional {
return nil, errdefs.InvalidParameter(errors.New("optional platform fields provided, but OS and Architecture are missing"))
}
if p.OS == "" || p.Architecture == "" {
return nil, errdefs.InvalidParameter(errors.New("both OS and Architecture must be provided"))
}
return &p, nil
}

View File

@@ -1,9 +1,16 @@
package httputils // import "github.com/docker/docker/api/server/httputils"
import (
"math"
"net/http"
"net/url"
"strconv"
"testing"
"github.com/docker/docker/errdefs"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
func TestBoolValue(t *testing.T) {
@@ -103,3 +110,126 @@ func TestInt64ValueOrDefaultWithError(t *testing.T) {
t.Fatal("Expected an error.")
}
}
func TestUint32Value(t *testing.T) {
const valueNotSet = "unset"
tests := []struct {
value string
expected uint32
expectedErr error
}{
{
value: "0",
expected: 0,
},
{
value: strconv.FormatUint(math.MaxUint32, 10),
expected: math.MaxUint32,
},
{
value: valueNotSet,
expectedErr: strconv.ErrSyntax,
},
{
value: "",
expectedErr: strconv.ErrSyntax,
},
{
value: "-1",
expectedErr: strconv.ErrRange,
},
{
value: "4294967296", // MaxUint32+1
expectedErr: strconv.ErrRange,
},
{
value: "not-a-number",
expectedErr: strconv.ErrSyntax,
},
}
for _, tc := range tests {
t.Run(tc.value, func(t *testing.T) {
r, _ := http.NewRequest(http.MethodPost, "", nil)
r.Form = url.Values{}
if tc.value != valueNotSet {
r.Form.Set("field", tc.value)
}
out, err := Uint32Value(r, "field")
assert.Check(t, is.Equal(tc.expected, out))
assert.Check(t, is.ErrorIs(err, tc.expectedErr))
})
}
}
func TestDecodePlatform(t *testing.T) {
tests := []struct {
doc string
platformJSON string
expected *ocispec.Platform
expectedErr string
}{
{
doc: "empty platform",
expectedErr: `failed to parse platform: unexpected end of JSON input`,
},
{
doc: "not JSON",
platformJSON: `linux/ams64`,
expectedErr: `failed to parse platform: invalid character 'l' looking for beginning of value`,
},
{
doc: "malformed JSON",
platformJSON: `{"architecture"`,
expectedErr: `failed to parse platform: unexpected end of JSON input`,
},
{
doc: "missing os",
platformJSON: `{"architecture":"amd64","os":""}`,
expectedErr: `both OS and Architecture must be provided`,
},
{
doc: "variant without architecture",
platformJSON: `{"architecture":"","os":"","variant":"v7"}`,
expectedErr: `optional platform fields provided, but OS and Architecture are missing`,
},
{
doc: "missing architecture",
platformJSON: `{"architecture":"","os":"linux"}`,
expectedErr: `both OS and Architecture must be provided`,
},
{
doc: "os.version without os and architecture",
platformJSON: `{"architecture":"","os":"","os.version":"12.0"}`,
expectedErr: `optional platform fields provided, but OS and Architecture are missing`,
},
{
doc: "os.features without os and architecture",
platformJSON: `{"architecture":"","os":"","os.features":["a","b"]}`,
expectedErr: `optional platform fields provided, but OS and Architecture are missing`,
},
{
doc: "valid platform",
platformJSON: `{"architecture":"arm64","os":"linux","os.version":"12.0", "os.features":["a","b"], "variant": "v7"}`,
expected: &ocispec.Platform{
Architecture: "arm64",
OS: "linux",
OSVersion: "12.0",
OSFeatures: []string{"a", "b"},
Variant: "v7",
},
},
}
for _, tc := range tests {
t.Run(tc.doc, func(t *testing.T) {
p, err := DecodePlatform(tc.platformJSON)
assert.Check(t, is.DeepEqual(p, tc.expected))
if tc.expectedErr != "" {
assert.Check(t, errdefs.IsInvalidParameter(err))
assert.Check(t, is.Error(err, tc.expectedErr))
} else {
assert.Check(t, err)
}
})
}
}

View File

@@ -4,6 +4,7 @@ import (
"context"
"fmt"
"io"
"net/http"
"net/url"
"sort"
@@ -16,7 +17,11 @@ import (
// WriteLogStream writes an encoded byte stream of log messages from the
// messages channel, multiplexing them with a stdcopy.Writer if mux is true
func WriteLogStream(_ context.Context, w io.Writer, msgs <-chan *backend.LogMessage, config *container.LogsOptions, mux bool) {
func WriteLogStream(_ context.Context, w http.ResponseWriter, msgs <-chan *backend.LogMessage, config *container.LogsOptions, mux bool) {
// See https://github.com/moby/moby/issues/47448
// Trigger headers to be written immediately.
w.WriteHeader(http.StatusOK)
wf := ioutils.NewWriteFlusher(w)
defer wf.Close()

View File

@@ -1,38 +0,0 @@
package middleware // import "github.com/docker/docker/api/server/middleware"
import (
"context"
"net/http"
"github.com/containerd/log"
"github.com/docker/docker/api/types/registry"
)
// CORSMiddleware injects CORS headers to each request
// when it's configured.
type CORSMiddleware struct {
defaultHeaders string
}
// NewCORSMiddleware creates a new CORSMiddleware with default headers.
func NewCORSMiddleware(d string) CORSMiddleware {
return CORSMiddleware{defaultHeaders: d}
}
// WrapHandler returns a new handler function wrapping the previous one in the request chain.
func (c CORSMiddleware) WrapHandler(handler func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error) func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
// If "api-cors-header" is not given, but "api-enable-cors" is true, we set cors to "*"
// otherwise, all head values will be passed to HTTP handler
corsHeaders := c.defaultHeaders
if corsHeaders == "" {
corsHeaders = "*"
}
log.G(ctx).Debugf("CORS header is enabled and set to: %s", corsHeaders)
w.Header().Add("Access-Control-Allow-Origin", corsHeaders)
w.Header().Add("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept, "+registry.AuthHeader)
w.Header().Add("Access-Control-Allow-Methods", "HEAD, GET, POST, DELETE, PUT, OPTIONS")
return handler(ctx, w, r, vars)
}
}

View File

@@ -9,14 +9,34 @@ import (
"strings"
"github.com/containerd/log"
"github.com/docker/docker/api/server/httpstatus"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/pkg/ioutils"
"github.com/sirupsen/logrus"
)
// DebugRequestMiddleware dumps the request to logger
func DebugRequestMiddleware(handler func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error) func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
log.G(ctx).Debugf("Calling %s %s", r.Method, r.RequestURI)
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) (retErr error) {
logger := log.G(ctx)
// Use a variable for fields to prevent overhead of repeatedly
// calling WithFields.
fields := log.Fields{
"module": "api",
"method": r.Method,
"request-url": r.RequestURI,
"vars": vars,
}
logger.WithFields(fields).Debugf("handling %s request", r.Method)
defer func() {
if retErr != nil {
// TODO(thaJeztah): unify this with Server.makeHTTPHandler, which also logs internal server errors as error-log. See https://github.com/moby/moby/pull/48740#discussion_r1816675574
fields["error-response"] = retErr
fields["status"] = httpstatus.FromError(retErr)
logger.WithFields(fields).Debugf("error response for %s request", r.Method)
}
}()
if r.Method != http.MethodPost {
return handler(ctx, w, r, vars)
@@ -42,11 +62,15 @@ func DebugRequestMiddleware(handler func(ctx context.Context, w http.ResponseWri
var postForm map[string]interface{}
if err := json.Unmarshal(b, &postForm); err == nil {
maskSecretKeys(postForm)
formStr, errMarshal := json.Marshal(postForm)
if errMarshal == nil {
log.G(ctx).Debugf("form data: %s", string(formStr))
// TODO(thaJeztah): is there a better way to detect if we're using JSON-formatted logs?
if _, ok := logger.Logger.Formatter.(*logrus.JSONFormatter); ok {
fields["form-data"] = postForm
} else {
log.G(ctx).Debugf("form data: %q", postForm)
if data, err := json.Marshal(postForm); err != nil {
fields["form-data"] = postForm
} else {
fields["form-data"] = string(data)
}
}
}

View File

@@ -67,8 +67,8 @@ func (e versionUnsupportedError) InvalidParameter() {}
func (v VersionMiddleware) WrapHandler(handler func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error) func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
return func(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
w.Header().Set("Server", fmt.Sprintf("Docker/%s (%s)", v.serverVersion, runtime.GOOS))
w.Header().Set("API-Version", v.defaultAPIVersion)
w.Header().Set("OSType", runtime.GOOS)
w.Header().Set("Api-Version", v.defaultAPIVersion)
w.Header().Set("Ostype", runtime.GOOS)
apiVersion := vars["version"]
if apiVersion == "" {

View File

@@ -56,7 +56,6 @@ func TestNewVersionMiddlewareValidation(t *testing.T) {
}
for _, tc := range tests {
tc := tc
t.Run(tc.doc, func(t *testing.T) {
_, err := NewVersionMiddleware("1.2.3", tc.defaultVersion, tc.minVersion)
if tc.expectedErr == "" {
@@ -141,6 +140,6 @@ func TestVersionMiddlewareWithErrorsReturnsHeaders(t *testing.T) {
hdr := resp.Result().Header
assert.Check(t, is.Contains(hdr.Get("Server"), "Docker/1.2.3"))
assert.Check(t, is.Contains(hdr.Get("Server"), runtime.GOOS))
assert.Check(t, is.Equal(hdr.Get("API-Version"), api.DefaultVersion))
assert.Check(t, is.Equal(hdr.Get("OSType"), runtime.GOOS))
assert.Check(t, is.Equal(hdr.Get("Api-Version"), api.DefaultVersion))
assert.Check(t, is.Equal(hdr.Get("Ostype"), runtime.GOOS))
}

View File

@@ -13,6 +13,7 @@ import (
"strconv"
"strings"
"sync"
"syscall"
"github.com/containerd/log"
"github.com/docker/docker/api/server/httputils"
@@ -25,7 +26,6 @@ import (
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/pkg/progress"
"github.com/docker/docker/pkg/streamformatter"
units "github.com/docker/go-units"
"github.com/pkg/errors"
)
@@ -105,7 +105,7 @@ func newImageBuildOptions(ctx context.Context, r *http.Request) (*types.ImageBui
}
if ulimitsJSON := r.FormValue("ulimits"); ulimitsJSON != "" {
buildUlimits := []*units.Ulimit{}
buildUlimits := []*container.Ulimit{}
if err := json.Unmarshal([]byte(ulimitsJSON), &buildUlimits); err != nil {
return nil, invalidParam{errors.Wrap(err, "error reading ulimit settings")}
}
@@ -178,19 +178,55 @@ func (br *buildRouter) postPrune(ctx context.Context, w http.ResponseWriter, r *
if err != nil {
return err
}
ksfv := r.FormValue("keep-storage")
if ksfv == "" {
ksfv = "0"
}
ks, err := strconv.Atoi(ksfv)
if err != nil {
return invalidParam{errors.Wrapf(err, "keep-storage is in bytes and expects an integer, got %v", ksfv)}
}
opts := types.BuildCachePruneOptions{
All: httputils.BoolValue(r, "all"),
Filters: fltrs,
KeepStorage: int64(ks),
All: httputils.BoolValue(r, "all"),
Filters: fltrs,
}
parseBytesFromFormValue := func(name string) (int64, error) {
if fv := r.FormValue(name); fv != "" {
bs, err := strconv.Atoi(fv)
if err != nil {
return 0, invalidParam{errors.Wrapf(err, "%s is in bytes and expects an integer, got %v", name, fv)}
}
return int64(bs), nil
}
return 0, nil
}
version := httputils.VersionFromContext(ctx)
if versions.GreaterThanOrEqualTo(version, "1.48") {
bs, err := parseBytesFromFormValue("reserved-space")
if err != nil {
return err
} else if bs == 0 {
// Deprecated parameter. Only checked if reserved-space is not used.
bs, err = parseBytesFromFormValue("keep-storage")
if err != nil {
return err
}
}
opts.ReservedSpace = bs
if bs, err := parseBytesFromFormValue("max-used-space"); err != nil {
return err
} else {
opts.MaxUsedSpace = bs
}
if bs, err := parseBytesFromFormValue("min-free-space"); err != nil {
return err
} else {
opts.MinFreeSpace = bs
}
} else {
// Only keep-storage was valid in pre-1.48 versions.
bs, err := parseBytesFromFormValue("keep-storage")
if err != nil {
return err
}
opts.ReservedSpace = bs
}
report, err := br.backend.PruneCache(ctx, opts)
@@ -245,8 +281,9 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r *
return err
}
_, err = output.Write(streamformatter.FormatError(err))
if err != nil {
log.G(ctx).Warnf("could not write error response: %v", err)
// don't log broken pipe errors as this is the normal case when a client aborts.
if err != nil && !errors.Is(err, syscall.EPIPE) {
log.G(ctx).WithError(err).Warn("could not write error response")
}
return nil
}
@@ -281,6 +318,9 @@ func (br *buildRouter) postBuild(ctx context.Context, w http.ResponseWriter, r *
ProgressWriter: buildProgressWriter(out, wantAux, createProgressReader),
})
if err != nil {
if errors.Is(err, context.Canceled) {
log.G(ctx).Debug("build canceled")
}
return errf(err)
}
@@ -312,14 +352,14 @@ type syncWriter struct {
mu sync.Mutex
}
func (s *syncWriter) Write(b []byte) (count int, err error) {
func (s *syncWriter) Write(b []byte) (int, error) {
s.mu.Lock()
count, err = s.w.Write(b)
s.mu.Unlock()
return
defer s.mu.Unlock()
return s.w.Write(b)
}
func buildProgressWriter(out io.Writer, wantAux bool, createProgressReader func(io.ReadCloser) io.ReadCloser) backend.ProgressWriter {
// see https://github.com/moby/moby/pull/21406
out = &syncWriter{w: out}
var aux *streamformatter.AuxFormatter
@@ -340,8 +380,12 @@ type flusher interface {
Flush()
}
type nopFlusher struct{}
func (f *nopFlusher) Flush() {}
func wrapOutputBufferedUntilRequestRead(rc io.ReadCloser, out io.Writer) (io.ReadCloser, io.Writer) {
var fl flusher = &ioutils.NopFlusher{}
var fl flusher = &nopFlusher{}
if f, ok := out.(flusher); ok {
fl = f
}

View File

@@ -4,7 +4,6 @@ import (
"context"
"io"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
@@ -14,19 +13,19 @@ import (
// execBackend includes functions to implement to provide exec functionality.
type execBackend interface {
ContainerExecCreate(name string, config *types.ExecConfig) (string, error)
ContainerExecCreate(name string, options *container.ExecOptions) (string, error)
ContainerExecInspect(id string) (*backend.ExecInspect, error)
ContainerExecResize(name string, height, width int) error
ContainerExecStart(ctx context.Context, name string, options container.ExecStartOptions) error
ContainerExecResize(ctx context.Context, name string, height, width uint32) error
ContainerExecStart(ctx context.Context, name string, options backend.ExecStartConfig) error
ExecExists(name string) (bool, error)
}
// copyBackend includes functions to implement to provide container copy functionality.
type copyBackend interface {
ContainerArchivePath(name string, path string) (content io.ReadCloser, stat *types.ContainerPathStat, err error)
ContainerArchivePath(name string, path string) (content io.ReadCloser, stat *container.PathStat, err error)
ContainerExport(ctx context.Context, name string, out io.Writer) error
ContainerExtractToDir(name, path string, copyUIDGID, noOverwriteDirNonDir bool, content io.Reader) error
ContainerStatPath(name string, path string) (stat *types.ContainerPathStat, err error)
ContainerStatPath(name string, path string) (stat *container.PathStat, err error)
}
// stateBackend includes functions to implement to provide container state lifecycle functionality.
@@ -35,24 +34,24 @@ type stateBackend interface {
ContainerKill(name string, signal string) error
ContainerPause(name string) error
ContainerRename(oldName, newName string) error
ContainerResize(name string, height, width int) error
ContainerResize(ctx context.Context, name string, height, width uint32) error
ContainerRestart(ctx context.Context, name string, options container.StopOptions) error
ContainerRm(name string, config *backend.ContainerRmConfig) error
ContainerStart(ctx context.Context, name string, checkpoint string, checkpointDir string) error
ContainerStop(ctx context.Context, name string, options container.StopOptions) error
ContainerUnpause(name string) error
ContainerUpdate(name string, hostConfig *container.HostConfig) (container.ContainerUpdateOKBody, error)
ContainerUpdate(name string, hostConfig *container.HostConfig) (container.UpdateResponse, error)
ContainerWait(ctx context.Context, name string, condition containerpkg.WaitCondition) (<-chan containerpkg.StateStatus, error)
}
// monitorBackend includes functions to implement to provide containers monitoring functionality.
type monitorBackend interface {
ContainerChanges(ctx context.Context, name string) ([]archive.Change, error)
ContainerInspect(ctx context.Context, name string, size bool, version string) (interface{}, error)
ContainerInspect(ctx context.Context, name string, options backend.ContainerInspectOptions) (*container.InspectResponse, error)
ContainerLogs(ctx context.Context, name string, config *container.LogsOptions) (msgs <-chan *backend.LogMessage, tty bool, err error)
ContainerStats(ctx context.Context, name string, config *backend.ContainerStatsConfig) error
ContainerTop(name string, psArgs string) (*container.ContainerTopOKBody, error)
Containers(ctx context.Context, config *container.ListOptions) ([]*types.Container, error)
ContainerTop(name string, psArgs string) (*container.TopResponse, error)
Containers(ctx context.Context, config *container.ListOptions) ([]*container.Summary, error)
}
// attachBackend includes function to implement to provide container attaching functionality.
@@ -62,7 +61,7 @@ type attachBackend interface {
// systemBackend includes functions to implement to provide system wide containers functionality
type systemBackend interface {
ContainersPrune(ctx context.Context, pruneFilters filters.Args) (*types.ContainersPruneReport, error)
ContainersPrune(ctx context.Context, pruneFilters filters.Args) (*container.PruneReport, error)
}
type commitBackend interface {

View File

@@ -25,47 +25,47 @@ func NewRouter(b Backend, decoder httputils.ContainerDecoder, cgroup2 bool) rout
}
// Routes returns the available routes to the container controller
func (r *containerRouter) Routes() []router.Route {
return r.routes
func (c *containerRouter) Routes() []router.Route {
return c.routes
}
// initRoutes initializes the routes in container router
func (r *containerRouter) initRoutes() {
r.routes = []router.Route{
func (c *containerRouter) initRoutes() {
c.routes = []router.Route{
// HEAD
router.NewHeadRoute("/containers/{name:.*}/archive", r.headContainersArchive),
router.NewHeadRoute("/containers/{name:.*}/archive", c.headContainersArchive),
// GET
router.NewGetRoute("/containers/json", r.getContainersJSON),
router.NewGetRoute("/containers/{name:.*}/export", r.getContainersExport),
router.NewGetRoute("/containers/{name:.*}/changes", r.getContainersChanges),
router.NewGetRoute("/containers/{name:.*}/json", r.getContainersByName),
router.NewGetRoute("/containers/{name:.*}/top", r.getContainersTop),
router.NewGetRoute("/containers/{name:.*}/logs", r.getContainersLogs),
router.NewGetRoute("/containers/{name:.*}/stats", r.getContainersStats),
router.NewGetRoute("/containers/{name:.*}/attach/ws", r.wsContainersAttach),
router.NewGetRoute("/exec/{id:.*}/json", r.getExecByID),
router.NewGetRoute("/containers/{name:.*}/archive", r.getContainersArchive),
router.NewGetRoute("/containers/json", c.getContainersJSON),
router.NewGetRoute("/containers/{name:.*}/export", c.getContainersExport),
router.NewGetRoute("/containers/{name:.*}/changes", c.getContainersChanges),
router.NewGetRoute("/containers/{name:.*}/json", c.getContainersByName),
router.NewGetRoute("/containers/{name:.*}/top", c.getContainersTop),
router.NewGetRoute("/containers/{name:.*}/logs", c.getContainersLogs),
router.NewGetRoute("/containers/{name:.*}/stats", c.getContainersStats),
router.NewGetRoute("/containers/{name:.*}/attach/ws", c.wsContainersAttach),
router.NewGetRoute("/exec/{id:.*}/json", c.getExecByID),
router.NewGetRoute("/containers/{name:.*}/archive", c.getContainersArchive),
// POST
router.NewPostRoute("/containers/create", r.postContainersCreate),
router.NewPostRoute("/containers/{name:.*}/kill", r.postContainersKill),
router.NewPostRoute("/containers/{name:.*}/pause", r.postContainersPause),
router.NewPostRoute("/containers/{name:.*}/unpause", r.postContainersUnpause),
router.NewPostRoute("/containers/{name:.*}/restart", r.postContainersRestart),
router.NewPostRoute("/containers/{name:.*}/start", r.postContainersStart),
router.NewPostRoute("/containers/{name:.*}/stop", r.postContainersStop),
router.NewPostRoute("/containers/{name:.*}/wait", r.postContainersWait),
router.NewPostRoute("/containers/{name:.*}/resize", r.postContainersResize),
router.NewPostRoute("/containers/{name:.*}/attach", r.postContainersAttach),
router.NewPostRoute("/containers/{name:.*}/exec", r.postContainerExecCreate),
router.NewPostRoute("/exec/{name:.*}/start", r.postContainerExecStart),
router.NewPostRoute("/exec/{name:.*}/resize", r.postContainerExecResize),
router.NewPostRoute("/containers/{name:.*}/rename", r.postContainerRename),
router.NewPostRoute("/containers/{name:.*}/update", r.postContainerUpdate),
router.NewPostRoute("/containers/prune", r.postContainersPrune),
router.NewPostRoute("/commit", r.postCommit),
router.NewPostRoute("/containers/create", c.postContainersCreate),
router.NewPostRoute("/containers/{name:.*}/kill", c.postContainersKill),
router.NewPostRoute("/containers/{name:.*}/pause", c.postContainersPause),
router.NewPostRoute("/containers/{name:.*}/unpause", c.postContainersUnpause),
router.NewPostRoute("/containers/{name:.*}/restart", c.postContainersRestart),
router.NewPostRoute("/containers/{name:.*}/start", c.postContainersStart),
router.NewPostRoute("/containers/{name:.*}/stop", c.postContainersStop),
router.NewPostRoute("/containers/{name:.*}/wait", c.postContainersWait),
router.NewPostRoute("/containers/{name:.*}/resize", c.postContainersResize),
router.NewPostRoute("/containers/{name:.*}/attach", c.postContainersAttach),
router.NewPostRoute("/containers/{name:.*}/exec", c.postContainerExecCreate),
router.NewPostRoute("/exec/{name:.*}/start", c.postContainerExecStart),
router.NewPostRoute("/exec/{name:.*}/resize", c.postContainerExecResize),
router.NewPostRoute("/containers/{name:.*}/rename", c.postContainerRename),
router.NewPostRoute("/containers/{name:.*}/update", c.postContainerUpdate),
router.NewPostRoute("/containers/prune", c.postContainersPrune),
router.NewPostRoute("/commit", c.postCommit),
// PUT
router.NewPutRoute("/containers/{name:.*}/archive", r.putContainersArchive),
router.NewPutRoute("/containers/{name:.*}/archive", c.putContainersArchive),
// DELETE
router.NewDeleteRoute("/containers/{name:.*}", r.deleteContainers),
router.NewDeleteRoute("/containers/{name:.*}", c.deleteContainers),
}
}

View File

@@ -10,8 +10,8 @@ import (
"strconv"
"strings"
"github.com/containerd/containerd/platforms"
"github.com/containerd/log"
"github.com/containerd/platforms"
"github.com/docker/docker/api/server/httpstatus"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types"
@@ -22,15 +22,18 @@ import (
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/versions"
containerpkg "github.com/docker/docker/container"
networkSettings "github.com/docker/docker/daemon/network"
"github.com/docker/docker/errdefs"
"github.com/docker/docker/libnetwork/netlabel"
"github.com/docker/docker/pkg/ioutils"
"github.com/docker/docker/runconfig"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/pkg/errors"
"go.opentelemetry.io/otel"
"golang.org/x/net/websocket"
)
func (s *containerRouter) postCommit(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postCommit(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -39,7 +42,14 @@ func (s *containerRouter) postCommit(ctx context.Context, w http.ResponseWriter,
return err
}
config, _, _, err := s.decoder.DecodeConfig(r.Body)
// FIXME(thaJeztah): change this to unmarshal just [container.Config]:
// The commit endpoint accepts a [container.Config], but the decoder uses a
// [container.CreateRequest], which is a superset, and also contains
// [container.HostConfig] and [network.NetworkConfig]. Those structs
// are discarded here, but decoder.DecodeConfig also performs validation,
// so a request containing those additional fields would result in a
// validation error.
config, _, _, err := c.decoder.DecodeConfig(r.Body)
if err != nil && !errors.Is(err, io.EOF) { // Do not fail if body is empty.
return err
}
@@ -49,7 +59,7 @@ func (s *containerRouter) postCommit(ctx context.Context, w http.ResponseWriter,
return errdefs.InvalidParameter(err)
}
imgID, err := s.backend.CreateImageFromContainer(ctx, r.Form.Get("container"), &backend.CreateImageConfig{
imgID, err := c.backend.CreateImageFromContainer(ctx, r.Form.Get("container"), &backend.CreateImageConfig{
Pause: httputils.BoolValueOrDefault(r, "pause", true), // TODO(dnephin): remove pause arg, and always pause in backend
Tag: ref,
Author: r.Form.Get("author"),
@@ -61,10 +71,10 @@ func (s *containerRouter) postCommit(ctx context.Context, w http.ResponseWriter,
return err
}
return httputils.WriteJSON(w, http.StatusCreated, &types.IDResponse{ID: imgID})
return httputils.WriteJSON(w, http.StatusCreated, &container.CommitResponse{ID: imgID})
}
func (s *containerRouter) getContainersJSON(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) getContainersJSON(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -89,15 +99,31 @@ func (s *containerRouter) getContainersJSON(ctx context.Context, w http.Response
config.Limit = limit
}
containers, err := s.backend.Containers(ctx, config)
containers, err := c.backend.Containers(ctx, config)
if err != nil {
return err
}
version := httputils.VersionFromContext(ctx)
if versions.LessThan(version, "1.46") {
for _, c := range containers {
// Ignore HostConfig.Annotations because it was added in API v1.46.
c.HostConfig.Annotations = nil
}
}
if versions.LessThan(version, "1.48") {
// ImageManifestDescriptor information was added in API 1.48
for _, c := range containers {
c.ImageManifestDescriptor = nil
}
}
return httputils.WriteJSON(w, http.StatusOK, containers)
}
func (s *containerRouter) getContainersStats(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) getContainersStats(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -111,14 +137,23 @@ func (s *containerRouter) getContainersStats(ctx context.Context, w http.Respons
oneShot = httputils.BoolValueOrDefault(r, "one-shot", false)
}
return s.backend.ContainerStats(ctx, vars["name"], &backend.ContainerStatsConfig{
Stream: stream,
OneShot: oneShot,
OutStream: w,
return c.backend.ContainerStats(ctx, vars["name"], &backend.ContainerStatsConfig{
Stream: stream,
OneShot: oneShot,
OutStream: func() io.Writer {
// Assume that when this is called the request is OK.
w.WriteHeader(http.StatusOK)
if !stream {
return w
}
wf := ioutils.NewWriteFlusher(w)
wf.Flush()
return wf
},
})
}
func (s *containerRouter) getContainersLogs(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) getContainersLogs(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -145,7 +180,7 @@ func (s *containerRouter) getContainersLogs(ctx context.Context, w http.Response
Details: httputils.BoolValue(r, "details"),
}
msgs, tty, err := s.backend.ContainerLogs(ctx, containerName, logsConfig)
msgs, tty, err := c.backend.ContainerLogs(ctx, containerName, logsConfig)
if err != nil {
return err
}
@@ -164,11 +199,14 @@ func (s *containerRouter) getContainersLogs(ctx context.Context, w http.Response
return nil
}
func (s *containerRouter) getContainersExport(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
return s.backend.ContainerExport(ctx, vars["name"], w)
func (c *containerRouter) getContainersExport(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
return c.backend.ContainerExport(ctx, vars["name"], w)
}
func (s *containerRouter) postContainersStart(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainersStart(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
ctx, span := otel.Tracer("").Start(ctx, "containerRouter.postContainersStart")
defer span.End()
// If contentLength is -1, we can assumed chunked encoding
// or more technically that the length is unknown
// https://golang.org/src/pkg/net/http/request.go#L139
@@ -185,7 +223,7 @@ func (s *containerRouter) postContainersStart(ctx context.Context, w http.Respon
return err
}
if err := s.backend.ContainerStart(ctx, vars["name"], r.Form.Get("checkpoint"), r.Form.Get("checkpoint-dir")); err != nil {
if err := c.backend.ContainerStart(ctx, vars["name"], r.Form.Get("checkpoint"), r.Form.Get("checkpoint-dir")); err != nil {
return err
}
@@ -193,7 +231,7 @@ func (s *containerRouter) postContainersStart(ctx context.Context, w http.Respon
return nil
}
func (s *containerRouter) postContainersStop(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainersStop(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -213,7 +251,7 @@ func (s *containerRouter) postContainersStop(ctx context.Context, w http.Respons
options.Timeout = &valSeconds
}
if err := s.backend.ContainerStop(ctx, vars["name"], options); err != nil {
if err := c.backend.ContainerStop(ctx, vars["name"], options); err != nil {
return err
}
@@ -221,13 +259,13 @@ func (s *containerRouter) postContainersStop(ctx context.Context, w http.Respons
return nil
}
func (s *containerRouter) postContainersKill(_ context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainersKill(_ context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
name := vars["name"]
if err := s.backend.ContainerKill(name, r.Form.Get("signal")); err != nil {
if err := c.backend.ContainerKill(name, r.Form.Get("signal")); err != nil {
return errors.Wrapf(err, "cannot kill container: %s", name)
}
@@ -235,7 +273,7 @@ func (s *containerRouter) postContainersKill(_ context.Context, w http.ResponseW
return nil
}
func (s *containerRouter) postContainersRestart(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainersRestart(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -255,7 +293,7 @@ func (s *containerRouter) postContainersRestart(ctx context.Context, w http.Resp
options.Timeout = &valSeconds
}
if err := s.backend.ContainerRestart(ctx, vars["name"], options); err != nil {
if err := c.backend.ContainerRestart(ctx, vars["name"], options); err != nil {
return err
}
@@ -263,12 +301,12 @@ func (s *containerRouter) postContainersRestart(ctx context.Context, w http.Resp
return nil
}
func (s *containerRouter) postContainersPause(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainersPause(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
if err := s.backend.ContainerPause(vars["name"]); err != nil {
if err := c.backend.ContainerPause(vars["name"]); err != nil {
return err
}
@@ -277,12 +315,12 @@ func (s *containerRouter) postContainersPause(ctx context.Context, w http.Respon
return nil
}
func (s *containerRouter) postContainersUnpause(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainersUnpause(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
if err := s.backend.ContainerUnpause(vars["name"]); err != nil {
if err := c.backend.ContainerUnpause(vars["name"]); err != nil {
return err
}
@@ -291,7 +329,7 @@ func (s *containerRouter) postContainersUnpause(ctx context.Context, w http.Resp
return nil
}
func (s *containerRouter) postContainersWait(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainersWait(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
// Behavior changed in version 1.30 to handle wait condition and to
// return headers immediately.
version := httputils.VersionFromContext(ctx)
@@ -319,7 +357,7 @@ func (s *containerRouter) postContainersWait(ctx context.Context, w http.Respons
}
}
waitC, err := s.backend.ContainerWait(ctx, vars["name"], waitCondition)
waitC, err := c.backend.ContainerWait(ctx, vars["name"], waitCondition)
if err != nil {
return err
}
@@ -356,8 +394,8 @@ func (s *containerRouter) postContainersWait(ctx context.Context, w http.Respons
})
}
func (s *containerRouter) getContainersChanges(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
changes, err := s.backend.ContainerChanges(ctx, vars["name"])
func (c *containerRouter) getContainersChanges(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
changes, err := c.backend.ContainerChanges(ctx, vars["name"])
if err != nil {
return err
}
@@ -365,12 +403,12 @@ func (s *containerRouter) getContainersChanges(ctx context.Context, w http.Respo
return httputils.WriteJSON(w, http.StatusOK, changes)
}
func (s *containerRouter) getContainersTop(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) getContainersTop(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
procList, err := s.backend.ContainerTop(vars["name"], r.Form.Get("ps_args"))
procList, err := c.backend.ContainerTop(vars["name"], r.Form.Get("ps_args"))
if err != nil {
return err
}
@@ -378,21 +416,21 @@ func (s *containerRouter) getContainersTop(ctx context.Context, w http.ResponseW
return httputils.WriteJSON(w, http.StatusOK, procList)
}
func (s *containerRouter) postContainerRename(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainerRename(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
name := vars["name"]
newName := r.Form.Get("name")
if err := s.backend.ContainerRename(name, newName); err != nil {
if err := c.backend.ContainerRename(name, newName); err != nil {
return err
}
w.WriteHeader(http.StatusNoContent)
return nil
}
func (s *containerRouter) postContainerUpdate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainerUpdate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -424,7 +462,7 @@ func (s *containerRouter) postContainerUpdate(ctx context.Context, w http.Respon
}
name := vars["name"]
resp, err := s.backend.ContainerUpdate(name, hostConfig)
resp, err := c.backend.ContainerUpdate(name, hostConfig)
if err != nil {
return err
}
@@ -432,7 +470,7 @@ func (s *containerRouter) postContainerUpdate(ctx context.Context, w http.Respon
return httputils.WriteJSON(w, http.StatusOK, resp)
}
func (s *containerRouter) postContainersCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainersCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -442,7 +480,7 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
name := r.Form.Get("name")
config, hostConfig, networkingConfig, err := s.decoder.DecodeConfig(r.Body)
config, hostConfig, networkingConfig, err := c.decoder.DecodeConfig(r.Body)
if err != nil {
if errors.Is(err, io.EOF) {
return errdefs.InvalidParameter(errors.New("invalid JSON: got EOF while reading request body"))
@@ -471,7 +509,7 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
// Note that this is not the only place where this conversion has to be
// done (as there are various other places where containers get created).
if hostConfig.NetworkMode == "" || hostConfig.NetworkMode.IsDefault() {
hostConfig.NetworkMode = runconfig.DefaultDaemonNetworkMode()
hostConfig.NetworkMode = networkSettings.DefaultNetwork
if nw, ok := networkingConfig.EndpointsConfig[network.NetworkDefault]; ok {
networkingConfig.EndpointsConfig[hostConfig.NetworkMode.NetworkName()] = nw
delete(networkingConfig.EndpointsConfig, network.NetworkDefault)
@@ -504,7 +542,7 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
if versions.LessThan(version, "1.41") {
// Older clients expect the default to be "host" on cgroup v1 hosts
if !s.cgroup2 && hostConfig.CgroupnsMode.IsEmpty() {
if !c.cgroup2 && hostConfig.CgroupnsMode.IsEmpty() {
hostConfig.CgroupnsMode = container.CgroupnsModeHost
}
}
@@ -612,13 +650,35 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
}
}
if versions.LessThan(version, "1.48") {
for _, epConfig := range networkingConfig.EndpointsConfig {
// Before 1.48, all endpoints had the same priority, so
// reinitialize this field.
epConfig.GwPriority = 0
}
for _, m := range hostConfig.Mounts {
if m.Type == mount.TypeImage {
return errdefs.InvalidParameter(errors.New(`Mount type "Image" needs API v1.48 or newer`))
}
}
}
var warnings []string
if warn := handleVolumeDriverBC(version, hostConfig); warn != "" {
warnings = append(warnings, warn)
}
if warn, err := handleMACAddressBC(config, hostConfig, networkingConfig, version); err != nil {
return err
} else if warn != "" {
warnings = append(warnings, warn)
}
if warn, err := handleSysctlBC(hostConfig, networkingConfig, version); err != nil {
return err
} else if warn != "" {
warnings = append(warnings, warn)
}
if hostConfig.PidsLimit != nil && *hostConfig.PidsLimit <= 0 {
// Don't set a limit if either no limit was specified, or "unlimited" was
// explicitly set.
@@ -627,7 +687,7 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
hostConfig.PidsLimit = nil
}
ccr, err := s.backend.ContainerCreate(ctx, backend.ContainerCreateConfig{
ccr, err := c.backend.ContainerCreate(ctx, backend.ContainerCreateConfig{
Name: name,
Config: config,
HostConfig: hostConfig,
@@ -635,6 +695,12 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
Platform: platform,
DefaultReadOnlyNonRecursive: defaultReadOnlyNonRecursive,
})
// Log warnings for debugging, regardless if the request was successful or not.
if len(ccr.Warnings) > 0 {
log.G(ctx).WithField("warnings", ccr.Warnings).Debug("warnings encountered during container create request")
}
if err != nil {
return err
}
@@ -642,6 +708,27 @@ func (s *containerRouter) postContainersCreate(ctx context.Context, w http.Respo
return httputils.WriteJSON(w, http.StatusCreated, ccr)
}
// handleVolumeDriverBC handles the use of the container-wide "VolumeDriver"
// option when the Mounts API is used for volumes. It produces a warning
// on API 1.48 and up. Older versions of the API did not produce a warning,
// but the CLI would do so.
func handleVolumeDriverBC(version string, hostConfig *container.HostConfig) (warning string) {
if hostConfig.VolumeDriver == "" || versions.LessThan(version, "1.48") {
return ""
}
for _, m := range hostConfig.Mounts {
if m.Type != mount.TypeVolume {
continue
}
if m.VolumeOptions != nil && m.VolumeOptions.DriverConfig != nil && m.VolumeOptions.DriverConfig.Name != "" {
// Driver was configured for this mount, so no ambiguity.
continue
}
return "WARNING: the container-wide volume-driver configuration is ignored for volumes specified via 'mount'. Use '--mount type=volume,volume-driver=...' instead"
}
return ""
}
// handleMACAddressBC takes care of backward-compatibility for the container-wide MAC address by mutating the
// networkingConfig to set the endpoint-specific MACAddress field introduced in API v1.44. It returns a warning message
// or an error if the container-wide field was specified for API >= v1.44.
@@ -662,23 +749,11 @@ func handleMACAddressBC(config *container.Config, hostConfig *container.HostConf
return "", runconfig.ErrConflictContainerNetworkAndMac
}
// There cannot be more than one entry in EndpointsConfig with API < 1.44.
// If there's no EndpointsConfig, create a place to store the configured address. It is
// safe to use NetworkMode as the network name, whether it's a name or id/short-id, as
// it will be normalised later and there is no other EndpointSettings object that might
// refer to this network/endpoint.
if len(networkingConfig.EndpointsConfig) == 0 {
nwName := hostConfig.NetworkMode.NetworkName()
networkingConfig.EndpointsConfig[nwName] = &network.EndpointSettings{}
}
// There's exactly one network in EndpointsConfig, either from the API or just-created.
// Migrate the container-wide setting to it.
// No need to check for a match between NetworkMode and the names/ids in EndpointsConfig,
// the old version of the API would have applied the address to this network anyway.
for _, ep := range networkingConfig.EndpointsConfig {
ep.MacAddress = deprecatedMacAddress
epConfig, err := epConfigForNetMode(version, hostConfig.NetworkMode, networkingConfig)
if err != nil {
return "", err
}
epConfig.MacAddress = deprecatedMacAddress
return "", nil
}
@@ -688,31 +763,16 @@ func handleMACAddressBC(config *container.Config, hostConfig *container.HostConf
}
var warning string
if hostConfig.NetworkMode.IsBridge() || hostConfig.NetworkMode.IsUserDefined() {
nwName := hostConfig.NetworkMode.NetworkName()
// If there's no endpoint config, create a place to store the configured address.
if len(networkingConfig.EndpointsConfig) == 0 {
networkingConfig.EndpointsConfig[nwName] = &network.EndpointSettings{
MacAddress: deprecatedMacAddress,
}
} else {
// There is existing endpoint config - if it's not indexed by NetworkMode.Name(), we
// can't tell which network the container-wide settings was intended for. NetworkMode,
// the keys in EndpointsConfig and the NetworkID in EndpointsConfig may mix network
// name/id/short-id. It's not safe to create EndpointsConfig under the NetworkMode
// name to store the container-wide MAC address, because that may result in two sets
// of EndpointsConfig for the same network and one set will be discarded later. So,
// reject the request ...
ep, ok := networkingConfig.EndpointsConfig[nwName]
if !ok {
return "", errdefs.InvalidParameter(errors.New("if a container-wide MAC address is supplied, HostConfig.NetworkMode must match the identity of a network in NetworkSettings.Networks"))
}
// ep is the endpoint that needs the container-wide MAC address; migrate the address
// to it, or bail out if there's a mismatch.
if ep.MacAddress == "" {
ep.MacAddress = deprecatedMacAddress
} else if ep.MacAddress != deprecatedMacAddress {
return "", errdefs.InvalidParameter(errors.New("the container-wide MAC address must match the endpoint-specific MAC address for the main network, or be left empty"))
}
ep, err := epConfigForNetMode(version, hostConfig.NetworkMode, networkingConfig)
if err != nil {
return "", errors.Wrap(err, "unable to migrate container-wide MAC address to a specific network")
}
// ep is the endpoint that needs the container-wide MAC address; migrate the address
// to it, or bail out if there's a mismatch.
if ep.MacAddress == "" {
ep.MacAddress = deprecatedMacAddress
} else if ep.MacAddress != deprecatedMacAddress {
return "", errdefs.InvalidParameter(errors.New("the container-wide MAC address must match the endpoint-specific MAC address for the main network, or be left empty"))
}
}
warning = "The container-wide MacAddress field is now deprecated. It should be specified in EndpointsConfig instead."
@@ -721,7 +781,147 @@ func handleMACAddressBC(config *container.Config, hostConfig *container.HostConf
return warning, nil
}
func (s *containerRouter) deleteContainers(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
// handleSysctlBC migrates top level network endpoint-specific '--sysctl'
// settings to an DriverOpts for an endpoint. This is necessary because sysctls
// are applied during container task creation, but sysctls that name an interface
// (for example 'net.ipv6.conf.eth0.forwarding') cannot be applied until the
// interface has been created. So, these settings are removed from hostConfig.Sysctls
// and added to DriverOpts[netlabel.EndpointSysctls].
//
// Because interface names ('ethN') are allocated sequentially, and the order of
// network connections is not deterministic on container restart, only 'eth0'
// would work reliably in a top-level '--sysctl' option, and then only when
// there's a single initial network connection. So, settings for 'eth0' are
// migrated to the primary interface, identified by 'hostConfig.NetworkMode'.
// Settings for other interfaces are treated as errors.
//
// In the DriverOpts, because the interface name cannot be determined in advance, the
// interface name is replaced by "IFNAME". For example, 'net.ipv6.conf.eth0.forwarding'
// becomes 'net.ipv6.conf.IFNAME.forwarding'. The value in DriverOpts is a
// comma-separated list.
//
// A warning is generated when settings are migrated.
func handleSysctlBC(
hostConfig *container.HostConfig,
netConfig *network.NetworkingConfig,
version string,
) (string, error) {
if !hostConfig.NetworkMode.IsPrivate() {
return "", nil
}
var ep *network.EndpointSettings
var toDelete []string
var netIfSysctls []string
for k, v := range hostConfig.Sysctls {
// If the sysctl name matches "net.*.*.eth0.*" ...
if spl := strings.SplitN(k, ".", 5); len(spl) == 5 && spl[0] == "net" && strings.HasPrefix(spl[3], "eth") {
netIfSysctl := fmt.Sprintf("net.%s.%s.IFNAME.%s=%s", spl[1], spl[2], spl[4], v)
// Find the EndpointConfig to migrate settings to, if not already found.
if ep == nil {
// Per-endpoint sysctls were introduced in API version 1.46. Migration is
// needed, but refuse to do it automatically for API 1.48 and newer.
if versions.GreaterThan(version, "1.47") {
return "", fmt.Errorf("interface specific sysctl setting %q must be supplied using driver option '%s'",
k, netlabel.EndpointSysctls)
}
var err error
ep, err = epConfigForNetMode(version, hostConfig.NetworkMode, netConfig)
if err != nil {
return "", fmt.Errorf("unable to find a network for sysctl %s: %w", k, err)
}
}
// Only try to migrate settings for "eth0", anything else would always
// have behaved unpredictably.
if spl[3] != "eth0" {
return "", fmt.Errorf(`unable to determine network endpoint for sysctl %s, use driver option '%s' to set per-interface sysctls`,
k, netlabel.EndpointSysctls)
}
// Prepare the migration.
toDelete = append(toDelete, k)
netIfSysctls = append(netIfSysctls, netIfSysctl)
}
}
if ep == nil {
return "", nil
}
newDriverOpt := strings.Join(netIfSysctls, ",")
warning := fmt.Sprintf(`Migrated sysctl %q to DriverOpts{%q:%q}.`,
strings.Join(toDelete, ","),
netlabel.EndpointSysctls, newDriverOpt)
// Append existing per-endpoint sysctls to the migrated sysctls (give priority
// to per-endpoint settings).
if ep.DriverOpts == nil {
ep.DriverOpts = map[string]string{}
}
if oldDriverOpt, ok := ep.DriverOpts[netlabel.EndpointSysctls]; ok {
newDriverOpt += "," + oldDriverOpt
}
ep.DriverOpts[netlabel.EndpointSysctls] = newDriverOpt
// Delete migrated settings from the top-level sysctls.
for _, k := range toDelete {
delete(hostConfig.Sysctls, k)
}
return warning, nil
}
// epConfigForNetMode finds, or creates, an entry in netConfig.EndpointsConfig
// corresponding to nwMode.
//
// nwMode.NetworkName() may be the network's name, its id, or its short-id.
//
// The corresponding endpoint in netConfig.EndpointsConfig may be keyed on a
// different one of name/id/short-id. If there's any ambiguity (there are
// endpoints but the names don't match), return an error and do not create a new
// endpoint, because it might be a duplicate.
func epConfigForNetMode(
version string,
nwMode container.NetworkMode,
netConfig *network.NetworkingConfig,
) (*network.EndpointSettings, error) {
nwName := nwMode.NetworkName()
// It's always safe to create an EndpointsConfig entry under nwName if there are
// no entries already (because there can't be an entry for this network nwName
// refers to under any other name/short-id/id).
if len(netConfig.EndpointsConfig) == 0 {
es := &network.EndpointSettings{}
netConfig.EndpointsConfig = map[string]*network.EndpointSettings{
nwName: es,
}
return es, nil
}
// There cannot be more than one entry in EndpointsConfig with API < 1.44.
if versions.LessThan(version, "1.44") {
// No need to check for a match between NetworkMode and the names/ids in EndpointsConfig,
// the old version of the API would pick this network anyway.
for _, ep := range netConfig.EndpointsConfig {
return ep, nil
}
}
// There is existing endpoint config - if it's not indexed by NetworkMode.Name(), we
// can't tell which network the container-wide settings are intended for. NetworkMode,
// the keys in EndpointsConfig and the NetworkID in EndpointsConfig may mix network
// name/id/short-id. It's not safe to create EndpointsConfig under the NetworkMode
// name to store the container-wide setting, because that may result in two sets
// of EndpointsConfig for the same network and one set will be discarded later. So,
// reject the request ...
ep, ok := netConfig.EndpointsConfig[nwName]
if !ok {
return nil, errdefs.InvalidParameter(
errors.New("HostConfig.NetworkMode must match the identity of a network in NetworkSettings.Networks"))
}
return ep, nil
}
func (c *containerRouter) deleteContainers(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -733,7 +933,7 @@ func (s *containerRouter) deleteContainers(ctx context.Context, w http.ResponseW
RemoveLink: httputils.BoolValue(r, "link"),
}
if err := s.backend.ContainerRm(name, config); err != nil {
if err := c.backend.ContainerRm(name, config); err != nil {
return err
}
@@ -742,24 +942,24 @@ func (s *containerRouter) deleteContainers(ctx context.Context, w http.ResponseW
return nil
}
func (s *containerRouter) postContainersResize(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainersResize(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
height, err := strconv.Atoi(r.Form.Get("h"))
height, err := httputils.Uint32Value(r, "h")
if err != nil {
return errdefs.InvalidParameter(err)
return errdefs.InvalidParameter(errors.Wrapf(err, "invalid resize height %q", r.Form.Get("h")))
}
width, err := strconv.Atoi(r.Form.Get("w"))
width, err := httputils.Uint32Value(r, "w")
if err != nil {
return errdefs.InvalidParameter(err)
return errdefs.InvalidParameter(errors.Wrapf(err, "invalid resize width %q", r.Form.Get("w")))
}
return s.backend.ContainerResize(vars["name"], height, width)
return c.backend.ContainerResize(ctx, vars["name"], height, width)
}
func (s *containerRouter) postContainersAttach(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainersAttach(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
err := httputils.ParseForm(r)
if err != nil {
return err
@@ -775,7 +975,7 @@ func (s *containerRouter) postContainersAttach(ctx context.Context, w http.Respo
}
contentType := types.MediaTypeRawStream
setupStreams := func(multiplexed bool) (io.ReadCloser, io.Writer, io.Writer, error) {
setupStreams := func(multiplexed bool, cancel func()) (io.ReadCloser, io.Writer, io.Writer, error) {
conn, _, err := hijacker.Hijack()
if err != nil {
return nil, nil, nil, err
@@ -788,11 +988,15 @@ func (s *containerRouter) postContainersAttach(ctx context.Context, w http.Respo
if multiplexed && versions.GreaterThanOrEqualTo(httputils.VersionFromContext(ctx), "1.42") {
contentType = types.MediaTypeMultiplexedStream
}
fmt.Fprintf(conn, "HTTP/1.1 101 UPGRADED\r\nContent-Type: "+contentType+"\r\nConnection: Upgrade\r\nUpgrade: tcp\r\n\r\n")
// FIXME(thaJeztah): we should not ignore errors here; see https://github.com/moby/moby/pull/48359#discussion_r1725562802
fmt.Fprintf(conn, "HTTP/1.1 101 UPGRADED\r\nContent-Type: %v\r\nConnection: Upgrade\r\nUpgrade: tcp\r\n\r\n", contentType)
} else {
fmt.Fprintf(conn, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n\r\n")
// FIXME(thaJeztah): we should not ignore errors here; see https://github.com/moby/moby/pull/48359#discussion_r1725562802
fmt.Fprint(conn, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n\r\n")
}
go notifyClosed(ctx, conn, cancel)
closer := func() error {
httputils.CloseStreams(conn)
return nil
@@ -811,7 +1015,7 @@ func (s *containerRouter) postContainersAttach(ctx context.Context, w http.Respo
MuxStreams: true,
}
if err = s.backend.ContainerAttach(containerName, attachConfig); err != nil {
if err = c.backend.ContainerAttach(containerName, attachConfig); err != nil {
log.G(ctx).WithError(err).Errorf("Handler for %s %s returned error", r.Method, r.URL.Path)
// Remember to close stream if error happens
conn, _, errHijack := hijacker.Hijack()
@@ -827,7 +1031,7 @@ func (s *containerRouter) postContainersAttach(ctx context.Context, w http.Respo
return nil
}
func (s *containerRouter) wsContainersAttach(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) wsContainersAttach(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -841,7 +1045,7 @@ func (s *containerRouter) wsContainersAttach(ctx context.Context, w http.Respons
version := httputils.VersionFromContext(ctx)
setupStreams := func(multiplexed bool) (io.ReadCloser, io.Writer, io.Writer, error) {
setupStreams := func(multiplexed bool, cancel func()) (io.ReadCloser, io.Writer, io.Writer, error) {
wsChan := make(chan *websocket.Conn)
h := func(conn *websocket.Conn) {
wsChan <- conn
@@ -860,6 +1064,8 @@ func (s *containerRouter) wsContainersAttach(ctx context.Context, w http.Respons
if versions.GreaterThanOrEqualTo(version, "1.28") {
conn.PayloadType = websocket.BinaryFrame
}
// TODO: Close notifications
return conn, conn, conn, nil
}
@@ -881,7 +1087,7 @@ func (s *containerRouter) wsContainersAttach(ctx context.Context, w http.Respons
MuxStreams: false, // never multiplex, as we rely on websocket to manage distinct streams
}
err = s.backend.ContainerAttach(containerName, attachConfig)
err = c.backend.ContainerAttach(containerName, attachConfig)
close(done)
select {
case <-started:
@@ -896,7 +1102,7 @@ func (s *containerRouter) wsContainersAttach(ctx context.Context, w http.Respons
return err
}
func (s *containerRouter) postContainersPrune(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainersPrune(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -906,7 +1112,7 @@ func (s *containerRouter) postContainersPrune(ctx context.Context, w http.Respon
return err
}
pruneReport, err := s.backend.ContainersPrune(ctx, pruneFilters)
pruneReport, err := c.backend.ContainersPrune(ctx, pruneFilters)
if err != nil {
return err
}

View File

@@ -1,10 +1,12 @@
package container
import (
"strings"
"testing"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/libnetwork/netlabel"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -102,7 +104,7 @@ func TestHandleMACAddressBC(t *testing.T) {
ctrWideMAC: "11:22:33:44:55:66",
networkMode: "aNetId",
epConfig: map[string]*network.EndpointSettings{"aNetName": {}},
expError: "if a container-wide MAC address is supplied, HostConfig.NetworkMode must match the identity of a network in NetworkSettings.Networks",
expError: "unable to migrate container-wide MAC address to a specific network: HostConfig.NetworkMode must match the identity of a network in NetworkSettings.Networks",
expCtrWideMAC: "11:22:33:44:55:66",
},
{
@@ -126,8 +128,8 @@ func TestHandleMACAddressBC(t *testing.T) {
}
epConfig := make(map[string]*network.EndpointSettings, len(tc.epConfig))
for k, v := range tc.epConfig {
v := v
epConfig[k] = v
v := *v
epConfig[k] = &v
}
netCfg := &network.NetworkingConfig{
EndpointsConfig: epConfig,
@@ -158,3 +160,191 @@ func TestHandleMACAddressBC(t *testing.T) {
})
}
}
func TestEpConfigForNetMode(t *testing.T) {
testcases := []struct {
name string
apiVersion string
networkMode string
epConfig map[string]*network.EndpointSettings
expEpId string
expNumEps int
expError bool
}{
{
name: "old api no eps",
apiVersion: "1.43",
networkMode: "mynet",
expNumEps: 1,
},
{
name: "new api no eps",
apiVersion: "1.44",
networkMode: "mynet",
expNumEps: 1,
},
{
name: "old api with ep",
apiVersion: "1.43",
networkMode: "mynet",
epConfig: map[string]*network.EndpointSettings{
"anything": {EndpointID: "epone"},
},
expEpId: "epone",
expNumEps: 1,
},
{
name: "new api with matching ep",
apiVersion: "1.44",
networkMode: "mynet",
epConfig: map[string]*network.EndpointSettings{
"mynet": {EndpointID: "epone"},
},
expEpId: "epone",
expNumEps: 1,
},
{
name: "new api with mismatched ep",
apiVersion: "1.44",
networkMode: "mynet",
epConfig: map[string]*network.EndpointSettings{
"shortid": {EndpointID: "epone"},
},
expError: true,
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
netConfig := &network.NetworkingConfig{
EndpointsConfig: tc.epConfig,
}
ep, err := epConfigForNetMode(tc.apiVersion, container.NetworkMode(tc.networkMode), netConfig)
if tc.expError {
assert.Check(t, is.ErrorContains(err, "HostConfig.NetworkMode must match the identity of a network in NetworkSettings.Networks"))
} else {
assert.Assert(t, err)
assert.Check(t, is.Equal(ep.EndpointID, tc.expEpId))
assert.Check(t, is.Len(netConfig.EndpointsConfig, tc.expNumEps))
}
})
}
}
func TestHandleSysctlBC(t *testing.T) {
testcases := []struct {
name string
apiVersion string
networkMode string
sysctls map[string]string
epConfig map[string]*network.EndpointSettings
expEpSysctls []string
expSysctls map[string]string
expWarningContains []string
expError string
}{
{
name: "migrate to new ep",
apiVersion: "1.46",
networkMode: "mynet",
sysctls: map[string]string{
"net.ipv6.conf.all.disable_ipv6": "0",
"net.ipv6.conf.eth0.accept_ra": "2",
"net.ipv6.conf.eth0.forwarding": "1",
},
expSysctls: map[string]string{
"net.ipv6.conf.all.disable_ipv6": "0",
},
expEpSysctls: []string{"net.ipv6.conf.IFNAME.forwarding=1", "net.ipv6.conf.IFNAME.accept_ra=2"},
expWarningContains: []string{
"Migrated",
"net.ipv6.conf.eth0.accept_ra", "net.ipv6.conf.IFNAME.accept_ra=2",
"net.ipv6.conf.eth0.forwarding", "net.ipv6.conf.IFNAME.forwarding=1",
},
},
{
name: "migrate nothing",
apiVersion: "1.46",
networkMode: "mynet",
sysctls: map[string]string{
"net.ipv6.conf.all.disable_ipv6": "0",
},
expSysctls: map[string]string{
"net.ipv6.conf.all.disable_ipv6": "0",
},
},
{
name: "migration disabled for newer api",
apiVersion: "1.48",
networkMode: "mynet",
sysctls: map[string]string{
"net.ipv6.conf.eth0.accept_ra": "2",
},
expError: "must be supplied using driver option 'com.docker.network.endpoint.sysctls'",
},
{
name: "only migrate eth0",
apiVersion: "1.46",
networkMode: "mynet",
sysctls: map[string]string{
"net.ipv6.conf.eth1.accept_ra": "2",
},
expError: "unable to determine network endpoint",
},
{
name: "net name mismatch",
apiVersion: "1.46",
networkMode: "mynet",
epConfig: map[string]*network.EndpointSettings{
"shortid": {EndpointID: "epone"},
},
sysctls: map[string]string{
"net.ipv6.conf.eth1.accept_ra": "2",
},
expError: "unable to find a network for sysctl",
},
}
for _, tc := range testcases {
t.Run(tc.name, func(t *testing.T) {
hostCfg := &container.HostConfig{
NetworkMode: container.NetworkMode(tc.networkMode),
Sysctls: map[string]string{},
}
for k, v := range tc.sysctls {
hostCfg.Sysctls[k] = v
}
netCfg := &network.NetworkingConfig{
EndpointsConfig: tc.epConfig,
}
warnings, err := handleSysctlBC(hostCfg, netCfg, tc.apiVersion)
for _, s := range tc.expWarningContains {
assert.Check(t, is.Contains(warnings, s))
}
if tc.expError != "" {
assert.Check(t, is.ErrorContains(err, tc.expError))
} else {
assert.Check(t, err)
assert.Check(t, is.DeepEqual(hostCfg.Sysctls, tc.expSysctls))
ep := netCfg.EndpointsConfig[tc.networkMode]
if ep == nil {
assert.Check(t, is.Nil(tc.expEpSysctls))
} else {
got, ok := ep.DriverOpts[netlabel.EndpointSysctls]
assert.Check(t, ok)
// Check for expected ep-sysctls.
for _, want := range tc.expEpSysctls {
assert.Check(t, is.Contains(got, want))
}
// Check for unexpected ep-sysctls.
assert.Check(t, is.Len(got, len(strings.Join(tc.expEpSysctls, ","))))
}
}
})
}
}

View File

@@ -10,12 +10,12 @@ import (
"net/http"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/container"
gddohttputil "github.com/golang/gddo/httputil"
)
// setContainerPathStatHeader encodes the stat to JSON, base64 encode, and place in a header.
func setContainerPathStatHeader(stat *types.ContainerPathStat, header http.Header) error {
func setContainerPathStatHeader(stat *container.PathStat, header http.Header) error {
statJSON, err := json.Marshal(stat)
if err != nil {
return err
@@ -29,13 +29,13 @@ func setContainerPathStatHeader(stat *types.ContainerPathStat, header http.Heade
return nil
}
func (s *containerRouter) headContainersArchive(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) headContainersArchive(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
v, err := httputils.ArchiveFormValues(r, vars)
if err != nil {
return err
}
stat, err := s.backend.ContainerStatPath(v.Name, v.Path)
stat, err := c.backend.ContainerStatPath(v.Name, v.Path)
if err != nil {
return err
}
@@ -66,13 +66,13 @@ func writeCompressedResponse(w http.ResponseWriter, r *http.Request, body io.Rea
return err
}
func (s *containerRouter) getContainersArchive(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) getContainersArchive(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
v, err := httputils.ArchiveFormValues(r, vars)
if err != nil {
return err
}
tarArchive, stat, err := s.backend.ContainerArchivePath(v.Name, v.Path)
tarArchive, stat, err := c.backend.ContainerArchivePath(v.Name, v.Path)
if err != nil {
return err
}
@@ -86,7 +86,7 @@ func (s *containerRouter) getContainersArchive(ctx context.Context, w http.Respo
return writeCompressedResponse(w, r, tarArchive)
}
func (s *containerRouter) putContainersArchive(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) putContainersArchive(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
v, err := httputils.ArchiveFormValues(r, vars)
if err != nil {
return err
@@ -95,5 +95,5 @@ func (s *containerRouter) putContainersArchive(ctx context.Context, w http.Respo
noOverwriteDirNonDir := httputils.BoolValue(r, "noOverwriteDirNonDir")
copyUIDGID := httputils.BoolValue(r, "copyUIDGID")
return s.backend.ContainerExtractToDir(v.Name, v.Path, copyUIDGID, noOverwriteDirNonDir, r.Body)
return c.backend.ContainerExtractToDir(v.Name, v.Path, copyUIDGID, noOverwriteDirNonDir, r.Body)
}

View File

@@ -5,19 +5,20 @@ import (
"fmt"
"io"
"net/http"
"strconv"
"github.com/containerd/log"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/errdefs"
"github.com/docker/docker/pkg/stdcopy"
"github.com/pkg/errors"
)
func (s *containerRouter) getExecByID(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
eConfig, err := s.backend.ContainerExecInspect(vars["id"])
func (c *containerRouter) getExecByID(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
eConfig, err := c.backend.ContainerExecInspect(vars["id"])
if err != nil {
return err
}
@@ -33,12 +34,12 @@ func (execCommandError) Error() string {
func (execCommandError) InvalidParameter() {}
func (s *containerRouter) postContainerExecCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainerExecCreate(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
execConfig := &types.ExecConfig{}
execConfig := &container.ExecOptions{}
if err := httputils.ReadJSON(r, execConfig); err != nil {
return err
}
@@ -54,19 +55,19 @@ func (s *containerRouter) postContainerExecCreate(ctx context.Context, w http.Re
}
// Register an instance of Exec in container.
id, err := s.backend.ContainerExecCreate(vars["name"], execConfig)
id, err := c.backend.ContainerExecCreate(vars["name"], execConfig)
if err != nil {
log.G(ctx).Errorf("Error setting up exec command in container %s: %v", vars["name"], err)
return err
}
return httputils.WriteJSON(w, http.StatusCreated, &types.IDResponse{
return httputils.WriteJSON(w, http.StatusCreated, &container.ExecCreateResponse{
ID: id,
})
}
// TODO(vishh): Refactor the code to avoid having to specify stream config as part of both create and start.
func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainerExecStart(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
@@ -77,30 +78,30 @@ func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.Res
stdout, stderr, outStream io.Writer
)
execStartCheck := &types.ExecStartCheck{}
if err := httputils.ReadJSON(r, execStartCheck); err != nil {
options := &container.ExecStartOptions{}
if err := httputils.ReadJSON(r, options); err != nil {
return err
}
if exists, err := s.backend.ExecExists(execName); !exists {
if exists, err := c.backend.ExecExists(execName); !exists {
return err
}
if execStartCheck.ConsoleSize != nil {
if options.ConsoleSize != nil {
version := httputils.VersionFromContext(ctx)
// Not supported before 1.42
if versions.LessThan(version, "1.42") {
execStartCheck.ConsoleSize = nil
options.ConsoleSize = nil
}
// No console without tty
if !execStartCheck.Tty {
execStartCheck.ConsoleSize = nil
if !options.Tty {
options.ConsoleSize = nil
}
}
if !execStartCheck.Detach {
if !options.Detach {
var err error
// Setting up the streaming http interface.
inStream, outStream, err = httputils.HijackConnection(w)
@@ -111,59 +112,60 @@ func (s *containerRouter) postContainerExecStart(ctx context.Context, w http.Res
if _, ok := r.Header["Upgrade"]; ok {
contentType := types.MediaTypeRawStream
if !execStartCheck.Tty && versions.GreaterThanOrEqualTo(httputils.VersionFromContext(ctx), "1.42") {
if !options.Tty && versions.GreaterThanOrEqualTo(httputils.VersionFromContext(ctx), "1.42") {
contentType = types.MediaTypeMultiplexedStream
}
fmt.Fprint(outStream, "HTTP/1.1 101 UPGRADED\r\nContent-Type: "+contentType+"\r\nConnection: Upgrade\r\nUpgrade: tcp\r\n")
_, _ = fmt.Fprint(outStream, "HTTP/1.1 101 UPGRADED\r\nContent-Type: "+contentType+"\r\nConnection: Upgrade\r\nUpgrade: tcp\r\n")
} else {
fmt.Fprint(outStream, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n")
_, _ = fmt.Fprint(outStream, "HTTP/1.1 200 OK\r\nContent-Type: application/vnd.docker.raw-stream\r\n")
}
// copy headers that were removed as part of hijack
if err := w.Header().WriteSubset(outStream, nil); err != nil {
return err
}
fmt.Fprint(outStream, "\r\n")
_, _ = fmt.Fprint(outStream, "\r\n")
stdin = inStream
stdout = outStream
if !execStartCheck.Tty {
if options.Tty {
stdout = outStream
} else {
stderr = stdcopy.NewStdWriter(outStream, stdcopy.Stderr)
stdout = stdcopy.NewStdWriter(outStream, stdcopy.Stdout)
}
}
options := container.ExecStartOptions{
// Now run the user process in container.
//
// TODO: Maybe we should we pass ctx here if we're not detaching?
err := c.backend.ContainerExecStart(context.Background(), execName, backend.ExecStartConfig{
Stdin: stdin,
Stdout: stdout,
Stderr: stderr,
ConsoleSize: execStartCheck.ConsoleSize,
}
// Now run the user process in container.
// Maybe we should we pass ctx here if we're not detaching?
if err := s.backend.ContainerExecStart(context.Background(), execName, options); err != nil {
if execStartCheck.Detach {
ConsoleSize: options.ConsoleSize,
})
if err != nil {
if options.Detach {
return err
}
stdout.Write([]byte(err.Error() + "\r\n"))
_, _ = fmt.Fprintf(stdout, "%v\r\n", err)
log.G(ctx).Errorf("Error running exec %s in container: %v", execName, err)
}
return nil
}
func (s *containerRouter) postContainerExecResize(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
func (c *containerRouter) postContainerExecResize(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
}
height, err := strconv.Atoi(r.Form.Get("h"))
height, err := httputils.Uint32Value(r, "h")
if err != nil {
return errdefs.InvalidParameter(err)
return errdefs.InvalidParameter(errors.Wrapf(err, "invalid resize height %q", r.Form.Get("h")))
}
width, err := strconv.Atoi(r.Form.Get("w"))
width, err := httputils.Uint32Value(r, "w")
if err != nil {
return errdefs.InvalidParameter(err)
return errdefs.InvalidParameter(errors.Wrapf(err, "invalid resize width %q", r.Form.Get("w")))
}
return s.backend.ContainerExecResize(vars["name"], height, width)
return c.backend.ContainerExecResize(ctx, vars["name"], height, width)
}

View File

@@ -1,3 +1,6 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.22
package container // import "github.com/docker/docker/api/server/router/container"
import (
@@ -5,17 +8,34 @@ import (
"net/http"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/versions"
"github.com/docker/docker/internal/sliceutil"
"github.com/docker/docker/pkg/stringid"
)
// getContainersByName inspects container's configuration and serializes it as json.
func (s *containerRouter) getContainersByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
displaySize := httputils.BoolValue(r, "size")
version := httputils.VersionFromContext(ctx)
json, err := s.backend.ContainerInspect(ctx, vars["name"], displaySize, version)
func (c *containerRouter) getContainersByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
ctr, err := c.backend.ContainerInspect(ctx, vars["name"], backend.ContainerInspectOptions{
Size: httputils.BoolValue(r, "size"),
})
if err != nil {
return err
}
return httputils.WriteJSON(w, http.StatusOK, json)
version := httputils.VersionFromContext(ctx)
if versions.LessThan(version, "1.45") {
shortCID := stringid.TruncateID(ctr.ID)
for nwName, ep := range ctr.NetworkSettings.Networks {
if container.NetworkMode(nwName).IsUserDefined() {
ep.Aliases = sliceutil.Dedup(append(ep.Aliases, shortCID, ctr.Config.Hostname))
}
}
}
if versions.LessThan(version, "1.48") {
ctr.ImageManifestDescriptor = nil
}
return httputils.WriteJSON(w, http.StatusOK, ctr)
}

View File

@@ -0,0 +1,54 @@
package container
import (
"context"
"net"
"syscall"
"github.com/containerd/log"
"github.com/docker/docker/internal/unix_noeintr"
"golang.org/x/sys/unix"
)
func notifyClosed(ctx context.Context, conn net.Conn, notify func()) {
sc, ok := conn.(syscall.Conn)
if !ok {
log.G(ctx).Debug("notifyClosed: conn does not support close notifications")
return
}
rc, err := sc.SyscallConn()
if err != nil {
log.G(ctx).WithError(err).Warn("notifyClosed: failed get raw conn for close notifications")
return
}
epFd, err := unix_noeintr.EpollCreate()
if err != nil {
log.G(ctx).WithError(err).Warn("notifyClosed: failed to create epoll fd")
return
}
defer unix.Close(epFd)
err = rc.Control(func(fd uintptr) {
err := unix_noeintr.EpollCtl(epFd, unix.EPOLL_CTL_ADD, int(fd), &unix.EpollEvent{
Events: unix.EPOLLHUP,
Fd: int32(fd),
})
if err != nil {
log.G(ctx).WithError(err).Warn("notifyClosed: failed to register fd for close notifications")
return
}
events := make([]unix.EpollEvent, 1)
if _, err := unix_noeintr.EpollWait(epFd, events, -1); err != nil {
log.G(ctx).WithError(err).Warn("notifyClosed: failed to wait for close notifications")
return
}
notify()
})
if err != nil {
log.G(ctx).WithError(err).Warn("notifyClosed: failed to register for close notifications")
return
}
}

View File

@@ -0,0 +1,10 @@
//go:build !linux
package container
import (
"context"
"net"
)
func notifyClosed(ctx context.Context, conn net.Conn, notify func()) {}

View File

@@ -24,13 +24,13 @@ type debugRouter struct {
func (r *debugRouter) initRoutes() {
r.routes = []router.Route{
router.NewGetRoute("/vars", frameworkAdaptHandler(expvar.Handler())),
router.NewGetRoute("/pprof/", frameworkAdaptHandlerFunc(pprof.Index)),
router.NewGetRoute("/pprof/cmdline", frameworkAdaptHandlerFunc(pprof.Cmdline)),
router.NewGetRoute("/pprof/profile", frameworkAdaptHandlerFunc(pprof.Profile)),
router.NewGetRoute("/pprof/symbol", frameworkAdaptHandlerFunc(pprof.Symbol)),
router.NewGetRoute("/pprof/trace", frameworkAdaptHandlerFunc(pprof.Trace)),
router.NewGetRoute("/pprof/{name}", handlePprof),
router.NewGetRoute("/debug/vars", frameworkAdaptHandler(expvar.Handler())),
router.NewGetRoute("/debug/pprof/", frameworkAdaptHandlerFunc(pprof.Index)),
router.NewGetRoute("/debug/pprof/cmdline", frameworkAdaptHandlerFunc(pprof.Cmdline)),
router.NewGetRoute("/debug/pprof/profile", frameworkAdaptHandlerFunc(pprof.Profile)),
router.NewGetRoute("/debug/pprof/symbol", frameworkAdaptHandlerFunc(pprof.Symbol)),
router.NewGetRoute("/debug/pprof/trace", frameworkAdaptHandlerFunc(pprof.Trace)),
router.NewGetRoute("/debug/pprof/{name}", handlePprof),
}
}

View File

@@ -1,12 +1,21 @@
// FIXME(thaJeztah): remove once we are a module; the go:build directive prevents go from downgrading language version to go1.16:
//go:build go1.22
package grpc // import "github.com/docker/docker/api/server/router/grpc"
import (
"context"
"fmt"
"os"
"strings"
"github.com/containerd/containerd/v2/defaults"
"github.com/containerd/log"
"github.com/docker/docker/api/server/router"
grpc_middleware "github.com/grpc-ecosystem/go-grpc-middleware"
"github.com/docker/docker/internal/otelutil"
"github.com/moby/buildkit/util/grpcerrors"
"github.com/moby/buildkit/util/stack"
"github.com/moby/buildkit/util/tracing"
"go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc"
"golang.org/x/net/http2"
"google.golang.org/grpc"
@@ -20,12 +29,18 @@ type grpcRouter struct {
// NewRouter initializes a new grpc http router
func NewRouter(backends ...Backend) router.Router {
unary := grpc.UnaryInterceptor(grpc_middleware.ChainUnaryServer(unaryInterceptor(), grpcerrors.UnaryServerInterceptor))
stream := grpc.StreamInterceptor(grpc_middleware.ChainStreamServer(otelgrpc.StreamServerInterceptor(), grpcerrors.StreamServerInterceptor)) //nolint:staticcheck // TODO(thaJeztah): ignore SA1019 for deprecated options: see https://github.com/moby/moby/issues/47437
tp, _ := otelutil.NewTracerProvider(context.Background(), false)
opts := []grpc.ServerOption{
grpc.StatsHandler(tracing.ServerStatsHandler(otelgrpc.WithTracerProvider(tp))),
grpc.ChainUnaryInterceptor(unaryInterceptor, grpcerrors.UnaryServerInterceptor),
grpc.StreamInterceptor(grpcerrors.StreamServerInterceptor),
grpc.MaxRecvMsgSize(defaults.DefaultMaxRecvMsgSize),
grpc.MaxSendMsgSize(defaults.DefaultMaxSendMsgSize),
}
r := &grpcRouter{
h2Server: &http2.Server{},
grpcServer: grpc.NewServer(unary, stream),
grpcServer: grpc.NewServer(opts...),
}
for _, b := range backends {
b.RegisterGRPC(r.grpcServer)
@@ -45,16 +60,20 @@ func (gr *grpcRouter) initRoutes() {
}
}
func unaryInterceptor() grpc.UnaryServerInterceptor {
withTrace := otelgrpc.UnaryServerInterceptor() //nolint:staticcheck // TODO(thaJeztah): ignore SA1019 for deprecated options: see https://github.com/moby/moby/issues/47437
return func(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp interface{}, err error) {
// This method is used by the clients to send their traces to buildkit so they can be included
// in the daemon trace and stored in the build history record. This method can not be traced because
// it would cause an infinite loop.
if strings.HasSuffix(info.FullMethod, "opentelemetry.proto.collector.trace.v1.TraceService/Export") {
return handler(ctx, req)
}
return withTrace(ctx, req, info, handler)
func unaryInterceptor(ctx context.Context, req any, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (resp any, err error) {
// This method is used by the clients to send their traces to buildkit so they can be included
// in the daemon trace and stored in the build history record. This method can not be traced because
// it would cause an infinite loop.
if strings.HasSuffix(info.FullMethod, "opentelemetry.proto.collector.trace.v1.TraceService/Export") {
return handler(ctx, req)
}
resp, err = handler(ctx, req)
if err != nil {
log.G(ctx).WithError(err).Error(info.FullMethod)
if log.GetLevel() >= log.DebugLevel {
fmt.Fprintf(os.Stderr, "%+v", stack.Formatter(grpcerrors.FromGRPC(err)))
}
}
return resp, err
}

View File

@@ -5,7 +5,6 @@ import (
"io"
"github.com/distribution/reference"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/image"
@@ -24,22 +23,23 @@ type Backend interface {
type imageBackend interface {
ImageDelete(ctx context.Context, imageRef string, force, prune bool) ([]image.DeleteResponse, error)
ImageHistory(ctx context.Context, imageName string) ([]*image.HistoryResponseItem, error)
ImageHistory(ctx context.Context, imageName string, platform *ocispec.Platform) ([]*image.HistoryResponseItem, error)
Images(ctx context.Context, opts image.ListOptions) ([]*image.Summary, error)
GetImage(ctx context.Context, refOrID string, options backend.GetImageOpts) (*dockerimage.Image, error)
ImageInspect(ctx context.Context, refOrID string, options backend.ImageInspectOpts) (*image.InspectResponse, error)
TagImage(ctx context.Context, id dockerimage.ID, newRef reference.Named) error
ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*types.ImagesPruneReport, error)
ImagesPrune(ctx context.Context, pruneFilters filters.Args) (*image.PruneReport, error)
}
type importExportBackend interface {
LoadImage(ctx context.Context, inTar io.ReadCloser, outStream io.Writer, quiet bool) error
LoadImage(ctx context.Context, inTar io.ReadCloser, platform *ocispec.Platform, outStream io.Writer, quiet bool) error
ImportImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, msg string, layerReader io.Reader, changes []string) (dockerimage.ID, error)
ExportImage(ctx context.Context, names []string, outStream io.Writer) error
ExportImage(ctx context.Context, names []string, platform *ocispec.Platform, outStream io.Writer) error
}
type registryBackend interface {
PullImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
PushImage(ctx context.Context, ref reference.Named, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
PushImage(ctx context.Context, ref reference.Named, platform *ocispec.Platform, metaHeaders map[string][]string, authConfig *registry.AuthConfig, outStream io.Writer) error
}
type Searcher interface {

View File

@@ -2,8 +2,6 @@ package image // import "github.com/docker/docker/api/server/router/image"
import (
"github.com/docker/docker/api/server/router"
"github.com/docker/docker/image"
"github.com/docker/docker/layer"
"github.com/docker/docker/reference"
)
@@ -12,19 +10,15 @@ type imageRouter struct {
backend Backend
searcher Searcher
referenceBackend reference.Store
imageStore image.Store
layerStore layer.Store
routes []router.Route
}
// NewRouter initializes a new image router
func NewRouter(backend Backend, searcher Searcher, referenceBackend reference.Store, imageStore image.Store, layerStore layer.Store) router.Router {
func NewRouter(backend Backend, searcher Searcher, referenceBackend reference.Store) router.Router {
ir := &imageRouter{
backend: backend,
searcher: searcher,
referenceBackend: referenceBackend,
imageStore: imageStore,
layerStore: layerStore,
}
ir.initRoutes()
return ir

View File

@@ -10,11 +10,10 @@ import (
"strings"
"time"
"github.com/containerd/containerd/platforms"
"github.com/containerd/platforms"
"github.com/distribution/reference"
"github.com/docker/docker/api"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/filters"
imagetypes "github.com/docker/docker/api/types/image"
@@ -56,7 +55,7 @@ func (ir *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrit
if p := r.FormValue("platform"); p != "" {
sp, err := platforms.Parse(p)
if err != nil {
return err
return errdefs.InvalidParameter(err)
}
platform = &sp
}
@@ -142,7 +141,7 @@ func (ir *imageRouter) postImagesCreate(ctx context.Context, w http.ResponseWrit
id, progressErr = ir.backend.ImportImage(ctx, tagRef, platform, comment, layerReader, r.Form["changes"])
if progressErr == nil {
output.Write(streamformatter.FormatStatus("", id.String()))
_, _ = output.Write(streamformatter.FormatStatus("", "%v", id.String()))
}
}
if progressErr != nil {
@@ -205,7 +204,24 @@ func (ir *imageRouter) postImagesPush(ctx context.Context, w http.ResponseWriter
ref = r
}
if err := ir.backend.PushImage(ctx, ref, metaHeaders, authConfig, output); err != nil {
var platform *ocispec.Platform
// Platform is optional, and only supported in API version 1.46 and later.
// However the PushOptions struct previously was an alias for the PullOptions struct
// which also contained a Platform field.
// This means that older clients may be sending a platform field, even
// though it wasn't really supported by the server.
// Don't break these clients and just ignore the platform field on older APIs.
if versions.GreaterThanOrEqualTo(httputils.VersionFromContext(ctx), "1.46") {
if formPlatform := r.Form.Get("platform"); formPlatform != "" {
p, err := httputils.DecodePlatform(formPlatform)
if err != nil {
return err
}
platform = p
}
}
if err := ir.backend.PushImage(ctx, ref, platform, metaHeaders, authConfig, output); err != nil {
if !output.Flushed() {
return err
}
@@ -230,7 +246,22 @@ func (ir *imageRouter) getImagesGet(ctx context.Context, w http.ResponseWriter,
names = r.Form["names"]
}
if err := ir.backend.ExportImage(ctx, names, output); err != nil {
var platform *ocispec.Platform
if versions.GreaterThanOrEqualTo(httputils.VersionFromContext(ctx), "1.48") {
if formPlatforms := r.Form["platform"]; len(formPlatforms) > 1 {
// TODO(thaJeztah): remove once we support multiple platforms: see https://github.com/moby/moby/issues/48759
return errdefs.InvalidParameter(errors.New("multiple platform parameters not supported"))
}
if formPlatform := r.Form.Get("platform"); formPlatform != "" {
p, err := httputils.DecodePlatform(formPlatform)
if err != nil {
return err
}
platform = p
}
}
if err := ir.backend.ExportImage(ctx, names, platform, output); err != nil {
if !output.Flushed() {
return err
}
@@ -243,13 +274,28 @@ func (ir *imageRouter) postImagesLoad(ctx context.Context, w http.ResponseWriter
if err := httputils.ParseForm(r); err != nil {
return err
}
var platform *ocispec.Platform
if versions.GreaterThanOrEqualTo(httputils.VersionFromContext(ctx), "1.48") {
if formPlatforms := r.Form["platform"]; len(formPlatforms) > 1 {
// TODO(thaJeztah): remove once we support multiple platforms: see https://github.com/moby/moby/issues/48759
return errdefs.InvalidParameter(errors.New("multiple platform parameters not supported"))
}
if formPlatform := r.Form.Get("platform"); formPlatform != "" {
p, err := httputils.DecodePlatform(formPlatform)
if err != nil {
return err
}
platform = p
}
}
quiet := httputils.BoolValueOrDefault(r, "quiet", true)
w.Header().Set("Content-Type", "application/json")
output := ioutils.NewWriteFlusher(w)
defer output.Close()
if err := ir.backend.LoadImage(ctx, r.Body, output, quiet); err != nil {
if err := ir.backend.LoadImage(ctx, r.Body, platform, output, quiet); err != nil {
_, _ = output.Write(streamformatter.FormatError(err))
}
return nil
@@ -286,14 +332,29 @@ func (ir *imageRouter) deleteImages(ctx context.Context, w http.ResponseWriter,
}
func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
img, err := ir.backend.GetImage(ctx, vars["name"], backend.GetImageOpts{Details: true})
if err := httputils.ParseForm(r); err != nil {
return err
}
var manifests bool
if r.Form.Get("manifests") != "" && versions.GreaterThanOrEqualTo(httputils.VersionFromContext(ctx), "1.48") {
manifests = httputils.BoolValue(r, "manifests")
}
imageInspect, err := ir.backend.ImageInspect(ctx, vars["name"], backend.ImageInspectOpts{
Manifests: manifests,
})
if err != nil {
return err
}
imageInspect, err := ir.toImageInspect(img)
if err != nil {
return err
// Make sure we output empty arrays instead of nil. While Go nil slice is functionally equivalent to an empty slice,
// it matters for the JSON representation.
if imageInspect.RepoTags == nil {
imageInspect.RepoTags = []string{}
}
if imageInspect.RepoDigests == nil {
imageInspect.RepoDigests = []string{}
}
version := httputils.VersionFromContext(ctx)
@@ -310,77 +371,12 @@ func (ir *imageRouter) getImagesByName(ctx context.Context, w http.ResponseWrite
imageInspect.Container = "" //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.45.
imageInspect.ContainerConfig = nil //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.45.
}
if versions.LessThan(version, "1.48") {
imageInspect.Descriptor = nil
}
return httputils.WriteJSON(w, http.StatusOK, imageInspect)
}
func (ir *imageRouter) toImageInspect(img *image.Image) (*types.ImageInspect, error) {
var repoTags, repoDigests []string
for _, ref := range img.Details.References {
switch ref.(type) {
case reference.NamedTagged:
repoTags = append(repoTags, reference.FamiliarString(ref))
case reference.Canonical:
repoDigests = append(repoDigests, reference.FamiliarString(ref))
}
}
comment := img.Comment
if len(comment) == 0 && len(img.History) > 0 {
comment = img.History[len(img.History)-1].Comment
}
// Make sure we output empty arrays instead of nil.
if repoTags == nil {
repoTags = []string{}
}
if repoDigests == nil {
repoDigests = []string{}
}
var created string
if img.Created != nil {
created = img.Created.Format(time.RFC3339Nano)
}
return &types.ImageInspect{
ID: img.ID().String(),
RepoTags: repoTags,
RepoDigests: repoDigests,
Parent: img.Parent.String(),
Comment: comment,
Created: created,
Container: img.Container, //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.45.
ContainerConfig: &img.ContainerConfig, //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.45.
DockerVersion: img.DockerVersion,
Author: img.Author,
Config: img.Config,
Architecture: img.Architecture,
Variant: img.Variant,
Os: img.OperatingSystem(),
OsVersion: img.OSVersion,
Size: img.Details.Size,
GraphDriver: types.GraphDriverData{
Name: img.Details.Driver,
Data: img.Details.Metadata,
},
RootFS: rootFSToAPIType(img.RootFS),
Metadata: imagetypes.Metadata{
LastTagTime: img.Details.LastUpdated,
},
}, nil
}
func rootFSToAPIType(rootfs *image.RootFS) types.RootFS {
var layers []string
for _, l := range rootfs.DiffIDs {
layers = append(layers, l.String())
}
return types.RootFS{
Type: rootfs.Type,
Layers: layers,
}
}
func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
return err
@@ -406,10 +402,16 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
sharedSize = httputils.BoolValue(r, "shared-size")
}
var manifests bool
if versions.GreaterThanOrEqualTo(version, "1.47") {
manifests = httputils.BoolValue(r, "manifests")
}
images, err := ir.backend.Images(ctx, imagetypes.ListOptions{
All: httputils.BoolValue(r, "all"),
Filters: imageFilters,
SharedSize: sharedSize,
Manifests: manifests,
})
if err != nil {
return err
@@ -417,6 +419,7 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
useNone := versions.LessThan(version, "1.43")
withVirtualSize := versions.LessThan(version, "1.44")
noDescriptor := versions.LessThan(version, "1.48")
for _, img := range images {
if useNone {
if len(img.RepoTags) == 0 && len(img.RepoDigests) == 0 {
@@ -434,13 +437,30 @@ func (ir *imageRouter) getImagesJSON(ctx context.Context, w http.ResponseWriter,
if withVirtualSize {
img.VirtualSize = img.Size //nolint:staticcheck // ignore SA1019: field is deprecated, but still set on API < v1.44.
}
if noDescriptor {
img.Descriptor = nil
}
}
return httputils.WriteJSON(w, http.StatusOK, images)
}
func (ir *imageRouter) getImagesHistory(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
history, err := ir.backend.ImageHistory(ctx, vars["name"])
if err := httputils.ParseForm(r); err != nil {
return err
}
var platform *ocispec.Platform
if versions.GreaterThanOrEqualTo(httputils.VersionFromContext(ctx), "1.48") {
if formPlatform := r.Form.Get("platform"); formPlatform != "" {
p, err := httputils.DecodePlatform(formPlatform)
if err != nil {
return err
}
platform = p
}
}
history, err := ir.backend.ImageHistory(ctx, vars["name"], platform)
if err != nil {
return err
}

View File

@@ -3,7 +3,6 @@ package network // import "github.com/docker/docker/api/server/router/network"
import (
"context"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
@@ -12,20 +11,20 @@ import (
// Backend is all the methods that need to be implemented
// to provide network specific functionality.
type Backend interface {
GetNetworks(filters.Args, backend.NetworkListConfig) ([]types.NetworkResource, error)
CreateNetwork(nc types.NetworkCreateRequest) (*types.NetworkCreateResponse, error)
ConnectContainerToNetwork(containerName, networkName string, endpointConfig *network.EndpointSettings) error
GetNetworks(filters.Args, backend.NetworkListConfig) ([]network.Inspect, error)
CreateNetwork(nc network.CreateRequest) (*network.CreateResponse, error)
ConnectContainerToNetwork(ctx context.Context, containerName, networkName string, endpointConfig *network.EndpointSettings) error
DisconnectContainerFromNetwork(containerName string, networkName string, force bool) error
DeleteNetwork(networkID string) error
NetworksPrune(ctx context.Context, pruneFilters filters.Args) (*types.NetworksPruneReport, error)
NetworksPrune(ctx context.Context, pruneFilters filters.Args) (*network.PruneReport, error)
}
// ClusterBackend is all the methods that need to be implemented
// to provide cluster network specific functionality.
type ClusterBackend interface {
GetNetworks(filters.Args) ([]types.NetworkResource, error)
GetNetwork(name string) (types.NetworkResource, error)
GetNetworksByName(name string) ([]types.NetworkResource, error)
CreateNetwork(nc types.NetworkCreateRequest) (string, error)
GetNetworks(filters.Args) ([]network.Inspect, error)
GetNetwork(name string) (network.Inspect, error)
GetNetworksByName(name string) ([]network.Inspect, error)
CreateNetwork(nc network.CreateRequest) (string, error)
RemoveNetwork(name string) error
}

View File

@@ -7,7 +7,6 @@ import (
"strings"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/backend"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/network"
@@ -32,7 +31,7 @@ func (n *networkRouter) getNetworksList(ctx context.Context, w http.ResponseWrit
return err
}
var list []types.NetworkResource
var list []network.Summary
nr, err := n.cluster.GetNetworks(filter)
if err == nil {
list = nr
@@ -60,7 +59,7 @@ func (n *networkRouter) getNetworksList(ctx context.Context, w http.ResponseWrit
}
if list == nil {
list = []types.NetworkResource{}
list = []network.Summary{}
}
return httputils.WriteJSON(w, http.StatusOK, list)
@@ -76,13 +75,13 @@ func (e invalidRequestError) Error() string {
func (e invalidRequestError) InvalidParameter() {}
type ambigousResultsError string
type ambiguousResultsError string
func (e ambigousResultsError) Error() string {
func (e ambiguousResultsError) Error() string {
return "network " + string(e) + " is ambiguous"
}
func (ambigousResultsError) InvalidParameter() {}
func (ambiguousResultsError) InvalidParameter() {}
func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
if err := httputils.ParseForm(r); err != nil {
@@ -109,8 +108,8 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r
// For full name and partial ID, save the result first, and process later
// in case multiple records was found based on the same term
listByFullName := map[string]types.NetworkResource{}
listByPartialID := map[string]types.NetworkResource{}
listByFullName := map[string]network.Inspect{}
listByPartialID := map[string]network.Inspect{}
// TODO(@cpuguy83): All this logic for figuring out which network to return does not belong here
// Instead there should be a backend function to just get one network.
@@ -183,7 +182,7 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r
}
}
if len(listByFullName) > 1 {
return errors.Wrapf(ambigousResultsError(term), "%d matches found based on name", len(listByFullName))
return errors.Wrapf(ambiguousResultsError(term), "%d matches found based on name", len(listByFullName))
}
// Find based on partial ID, returns true only if no duplicates
@@ -193,7 +192,7 @@ func (n *networkRouter) getNetwork(ctx context.Context, w http.ResponseWriter, r
}
}
if len(listByPartialID) > 1 {
return errors.Wrapf(ambigousResultsError(term), "%d matches found based on ID prefix", len(listByPartialID))
return errors.Wrapf(ambiguousResultsError(term), "%d matches found based on ID prefix", len(listByPartialID))
}
return libnetwork.ErrNoSuchNetwork(term)
@@ -204,7 +203,7 @@ func (n *networkRouter) postNetworkCreate(ctx context.Context, w http.ResponseWr
return err
}
var create types.NetworkCreateRequest
var create network.CreateRequest
if err := httputils.ReadJSON(r, &create); err != nil {
return err
}
@@ -213,6 +212,13 @@ func (n *networkRouter) postNetworkCreate(ctx context.Context, w http.ResponseWr
return libnetwork.NetworkNameError(create.Name)
}
version := httputils.VersionFromContext(ctx)
// EnableIPv4 was introduced in API 1.48.
if versions.LessThan(version, "1.48") {
create.EnableIPv4 = nil
}
// For a Swarm-scoped network, this call to backend.CreateNetwork is used to
// validate the configuration. The network will not be created but, if the
// configuration is valid, ManagerRedirectError will be returned and handled
@@ -226,7 +232,7 @@ func (n *networkRouter) postNetworkCreate(ctx context.Context, w http.ResponseWr
if err != nil {
return err
}
nw = &types.NetworkCreateResponse{
nw = &network.CreateResponse{
ID: id,
}
}
@@ -239,7 +245,7 @@ func (n *networkRouter) postNetworkConnect(ctx context.Context, w http.ResponseW
return err
}
var connect types.NetworkConnect
var connect network.ConnectOptions
if err := httputils.ReadJSON(r, &connect); err != nil {
return err
}
@@ -248,7 +254,7 @@ func (n *networkRouter) postNetworkConnect(ctx context.Context, w http.ResponseW
// The reason is that, In case of attachable network in swarm scope, the actual local network
// may not be available at the time. At the same time, inside daemon `ConnectContainerToNetwork`
// does the ambiguity check anyway. Therefore, passing the name to daemon would be enough.
return n.backend.ConnectContainerToNetwork(connect.Container, vars["id"], connect.EndpointConfig)
return n.backend.ConnectContainerToNetwork(ctx, connect.Container, vars["id"], connect.EndpointConfig)
}
func (n *networkRouter) postNetworkDisconnect(ctx context.Context, w http.ResponseWriter, r *http.Request, vars map[string]string) error {
@@ -256,7 +262,7 @@ func (n *networkRouter) postNetworkDisconnect(ctx context.Context, w http.Respon
return err
}
var disconnect types.NetworkDisconnect
var disconnect network.DisconnectOptions
if err := httputils.ReadJSON(r, &disconnect); err != nil {
return err
}
@@ -311,9 +317,9 @@ func (n *networkRouter) postNetworksPrune(ctx context.Context, w http.ResponseWr
// For full name and partial ID, save the result first, and process later
// in case multiple records was found based on the same term
// TODO (yongtang): should we wrap with version here for backward compatibility?
func (n *networkRouter) findUniqueNetwork(term string) (types.NetworkResource, error) {
listByFullName := map[string]types.NetworkResource{}
listByPartialID := map[string]types.NetworkResource{}
func (n *networkRouter) findUniqueNetwork(term string) (network.Inspect, error) {
listByFullName := map[string]network.Inspect{}
listByPartialID := map[string]network.Inspect{}
filter := filters.NewArgs(filters.Arg("idOrName", term))
networks, _ := n.backend.GetNetworks(filter, backend.NetworkListConfig{Detailed: true})
@@ -363,7 +369,7 @@ func (n *networkRouter) findUniqueNetwork(term string) (types.NetworkResource, e
}
}
if len(listByFullName) > 1 {
return types.NetworkResource{}, errdefs.InvalidParameter(errors.Errorf("network %s is ambiguous (%d matches found based on name)", term, len(listByFullName)))
return network.Inspect{}, errdefs.InvalidParameter(errors.Errorf("network %s is ambiguous (%d matches found based on name)", term, len(listByFullName)))
}
// Find based on partial ID, returns true only if no duplicates
@@ -373,8 +379,8 @@ func (n *networkRouter) findUniqueNetwork(term string) (types.NetworkResource, e
}
}
if len(listByPartialID) > 1 {
return types.NetworkResource{}, errdefs.InvalidParameter(errors.Errorf("network %s is ambiguous (%d matches found based on ID prefix)", term, len(listByPartialID)))
return network.Inspect{}, errdefs.InvalidParameter(errors.Errorf("network %s is ambiguous (%d matches found based on ID prefix)", term, len(listByPartialID)))
}
return types.NetworkResource{}, errdefs.NotFound(libnetwork.ErrNoSuchNetwork(term))
return network.Inspect{}, errdefs.NotFound(libnetwork.ErrNoSuchNetwork(term))
}

View File

@@ -209,10 +209,6 @@ func (sr *swarmRouter) createService(ctx context.Context, w http.ResponseWriter,
if err := httputils.ReadJSON(r, &service); err != nil {
return err
}
// TODO(thaJeztah): remove logentries check and migration code in release v26.0.0.
if service.TaskTemplate.LogDriver != nil && service.TaskTemplate.LogDriver.Name == "logentries" {
return errdefs.InvalidParameter(errors.New("the logentries logging driver has been deprecated and removed"))
}
// Get returns "" if the header does not exist
encodedAuth := r.Header.Get(registry.AuthHeader)
@@ -224,14 +220,6 @@ func (sr *swarmRouter) createService(ctx context.Context, w http.ResponseWriter,
adjustForAPIVersion(v, &service)
}
version := httputils.VersionFromContext(ctx)
if versions.LessThan(version, "1.44") {
if service.TaskTemplate.ContainerSpec != nil && service.TaskTemplate.ContainerSpec.Healthcheck != nil {
// StartInterval was added in API 1.44
service.TaskTemplate.ContainerSpec.Healthcheck.StartInterval = 0
}
}
resp, err := sr.backend.CreateService(service, encodedAuth, queryRegistry)
if err != nil {
log.G(ctx).WithFields(log.Fields{
@@ -249,10 +237,6 @@ func (sr *swarmRouter) updateService(ctx context.Context, w http.ResponseWriter,
if err := httputils.ReadJSON(r, &service); err != nil {
return err
}
// TODO(thaJeztah): remove logentries check and migration code in release v26.0.0.
if service.TaskTemplate.LogDriver != nil && service.TaskTemplate.LogDriver.Name == "logentries" {
return errdefs.InvalidParameter(errors.New("the logentries logging driver has been deprecated and removed"))
}
rawVersion := r.URL.Query().Get("version")
version, err := strconv.ParseUint(rawVersion, 10, 64)

View File

@@ -78,6 +78,16 @@ func adjustForAPIVersion(cliVersion string, service *swarm.ServiceSpec) {
if cliVersion == "" {
return
}
if versions.LessThan(cliVersion, "1.46") {
if service.TaskTemplate.ContainerSpec != nil {
for i, mount := range service.TaskTemplate.ContainerSpec.Mounts {
if mount.TmpfsOptions != nil {
mount.TmpfsOptions.Options = nil
service.TaskTemplate.ContainerSpec.Mounts[i] = mount
}
}
}
}
if versions.LessThan(cliVersion, "1.40") {
if service.TaskTemplate.ContainerSpec != nil {
// Sysctls for docker swarm services weren't supported before
@@ -121,11 +131,24 @@ func adjustForAPIVersion(cliVersion string, service *swarm.ServiceSpec) {
}
if versions.LessThan(cliVersion, "1.44") {
// seccomp, apparmor, and no_new_privs were added in 1.44.
if service.TaskTemplate.ContainerSpec != nil && service.TaskTemplate.ContainerSpec.Privileges != nil {
service.TaskTemplate.ContainerSpec.Privileges.Seccomp = nil
service.TaskTemplate.ContainerSpec.Privileges.AppArmor = nil
service.TaskTemplate.ContainerSpec.Privileges.NoNewPrivileges = false
if service.TaskTemplate.ContainerSpec != nil {
// seccomp, apparmor, and no_new_privs were added in 1.44.
if service.TaskTemplate.ContainerSpec.Privileges != nil {
service.TaskTemplate.ContainerSpec.Privileges.Seccomp = nil
service.TaskTemplate.ContainerSpec.Privileges.AppArmor = nil
service.TaskTemplate.ContainerSpec.Privileges.NoNewPrivileges = false
}
if service.TaskTemplate.ContainerSpec.Healthcheck != nil {
// StartInterval was added in API 1.44
service.TaskTemplate.ContainerSpec.Healthcheck.StartInterval = 0
}
}
}
if versions.LessThan(cliVersion, "1.46") {
if service.TaskTemplate.ContainerSpec != nil && service.TaskTemplate.ContainerSpec.OomScoreAdj != 0 {
// OomScoreAdj was added in API 1.46
service.TaskTemplate.ContainerSpec.OomScoreAdj = 0
}
}
}

View File

@@ -4,8 +4,9 @@ import (
"reflect"
"testing"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/swarm"
"github.com/docker/go-units"
)
func TestAdjustForAPIVersion(t *testing.T) {
@@ -38,13 +39,25 @@ func TestAdjustForAPIVersion(t *testing.T) {
ConfigName: "configRuntime",
},
},
Ulimits: []*units.Ulimit{
Ulimits: []*container.Ulimit{
{
Name: "nofile",
Soft: 100,
Hard: 200,
},
},
Mounts: []mount.Mount{
{
Type: mount.TypeTmpfs,
Source: "/foo",
Target: "/bar",
TmpfsOptions: &mount.TmpfsOptions{
Options: [][]string{
{"exec"},
},
},
},
},
},
Placement: &swarm.Placement{
MaxReplicas: 222,
@@ -57,6 +70,19 @@ func TestAdjustForAPIVersion(t *testing.T) {
},
}
adjustForAPIVersion("1.46", spec)
if !reflect.DeepEqual(
spec.TaskTemplate.ContainerSpec.Mounts[0].TmpfsOptions.Options,
[][]string{{"exec"}},
) {
t.Error("TmpfsOptions.Options was stripped from spec")
}
adjustForAPIVersion("1.45", spec)
if len(spec.TaskTemplate.ContainerSpec.Mounts[0].TmpfsOptions.Options) != 0 {
t.Error("TmpfsOptions.Options not stripped from spec")
}
// first, does calling this with a later version correctly NOT strip
// fields? do the later version first, so we can reuse this spec in the
// next test.

View File

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

View File

@@ -81,7 +81,6 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
nameOnly = append(nameOnly, so.Name)
}
info.SecurityOptions = nameOnly
info.ExecutionDriver = "<not supported>" //nolint:staticcheck // ignore SA1019 (ExecutionDriver is deprecated)
}
if versions.LessThan(version, "1.39") {
if info.KernelVersion == "" {
@@ -97,6 +96,22 @@ func (s *systemRouter) getInfo(ctx context.Context, w http.ResponseWriter, r *ht
info.Runtimes[k] = system.RuntimeWithStatus{Runtime: rt.Runtime}
}
}
if versions.LessThan(version, "1.46") {
// Containerd field introduced in API v1.46.
info.Containerd = nil
}
if versions.LessThan(version, "1.47") {
// Field is omitted in API 1.48 and up, but should still be included
// in older versions, even if no values are set.
info.RegistryConfig.AllowNondistributableArtifactsCIDRs = []*registry.NetIPNet{}
info.RegistryConfig.AllowNondistributableArtifactsHostnames = []string{}
}
// TODO(thaJeztah): Expected commits are deprecated, and should no longer be set in API 1.49.
info.ContainerdCommit.Expected = info.ContainerdCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
info.RuncCommit.Expected = info.RuncCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
info.InitCommit.Expected = info.InitCommit.ID //nolint:staticcheck // ignore SA1019: field is deprecated, but still used on API < v1.49.
if versions.GreaterThanOrEqualTo(version, "1.42") {
info.KernelMemory = false
}
@@ -263,6 +278,7 @@ func (s *systemRouter) getEvents(ctx context.Context, w http.ResponseWriter, r *
}
w.Header().Set("Content-Type", "application/json")
w.WriteHeader(http.StatusOK)
output := ioutils.NewWriteFlusher(w)
defer output.Close()
output.Flush()
@@ -272,7 +288,18 @@ func (s *systemRouter) getEvents(ctx context.Context, w http.ResponseWriter, r *
buffered, l := s.backend.SubscribeToEvents(since, until, ef)
defer s.backend.UnsubscribeFromEvents(l)
shouldSkip := func(ev events.Message) bool { return false }
if versions.LessThan(httputils.VersionFromContext(ctx), "1.46") {
// Image create events were added in API 1.46
shouldSkip = func(ev events.Message) bool {
return ev.Type == "image" && ev.Action == "create"
}
}
for _, ev := range buffered {
if shouldSkip(ev) {
continue
}
if err := enc.Encode(ev); err != nil {
return err
}
@@ -290,6 +317,9 @@ func (s *systemRouter) getEvents(ctx context.Context, w http.ResponseWriter, r *
log.G(ctx).Warnf("unexpected event message: %q", ev)
continue
}
if shouldSkip(jev) {
continue
}
if err := enc.Encode(jev); err != nil {
return err
}

View File

@@ -3,11 +3,9 @@ package volume // import "github.com/docker/docker/api/server/router/volume"
import (
"context"
"github.com/docker/docker/volume/service/opts"
// TODO return types need to be refactored into pkg
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume"
"github.com/docker/docker/volume/service/opts"
)
// Backend is the methods that need to be implemented to provide
@@ -17,7 +15,7 @@ type Backend interface {
Get(ctx context.Context, name string, opts ...opts.GetOption) (*volume.Volume, error)
Create(ctx context.Context, name, driverName string, opts ...opts.CreateOption) (*volume.Volume, error)
Remove(ctx context.Context, name string, opts ...opts.RemoveOption) error
Prune(ctx context.Context, pruneFilters filters.Args) (*types.VolumesPruneReport, error)
Prune(ctx context.Context, pruneFilters filters.Args) (*volume.PruneReport, error)
}
// ClusterBackend is the backend used for Swarm Cluster Volumes. Regular

View File

@@ -11,7 +11,6 @@ import (
"gotest.tools/v3/assert"
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/types"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/volume"
"github.com/docker/docker/errdefs"
@@ -189,17 +188,16 @@ func TestCreateRegularVolume(t *testing.T) {
Driver: "foodriver",
}
buf := bytes.Buffer{}
e := json.NewEncoder(&buf)
e.Encode(volumeCreate)
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(volumeCreate)
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/create", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
err := v.postVolumesCreate(ctx, resp, req, nil)
err = v.postVolumesCreate(ctx, resp, req, nil)
assert.NilError(t, err)
respVolume := volume.Volume{}
@@ -228,16 +226,16 @@ func TestCreateSwarmVolumeNoSwarm(t *testing.T) {
Driver: "someCSI",
}
buf := bytes.Buffer{}
json.NewEncoder(&buf).Encode(volumeCreate)
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(volumeCreate)
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/create", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
err := v.postVolumesCreate(ctx, resp, req, nil)
err = v.postVolumesCreate(ctx, resp, req, nil)
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsUnavailable(err))
}
@@ -257,16 +255,16 @@ func TestCreateSwarmVolumeNotManager(t *testing.T) {
Driver: "someCSI",
}
buf := bytes.Buffer{}
json.NewEncoder(&buf).Encode(volumeCreate)
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(volumeCreate)
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/create", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
err := v.postVolumesCreate(ctx, resp, req, nil)
err = v.postVolumesCreate(ctx, resp, req, nil)
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsUnavailable(err))
}
@@ -289,16 +287,16 @@ func TestCreateVolumeCluster(t *testing.T) {
Driver: "someCSI",
}
buf := bytes.Buffer{}
json.NewEncoder(&buf).Encode(volumeCreate)
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(volumeCreate)
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/create", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
err := v.postVolumesCreate(ctx, resp, req, nil)
err = v.postVolumesCreate(ctx, resp, req, nil)
assert.NilError(t, err)
respVolume := volume.Volume{}
@@ -336,15 +334,17 @@ func TestUpdateVolume(t *testing.T) {
Spec: &volume.ClusterVolumeSpec{},
}
buf := bytes.Buffer{}
json.NewEncoder(&buf).Encode(volumeUpdate)
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(volumeUpdate)
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/vol1/update?version=0", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
err := v.putVolumesUpdate(ctx, resp, req, map[string]string{"name": "vol1"})
err = v.putVolumesUpdate(ctx, resp, req, map[string]string{"name": "vol1"})
assert.NilError(t, err)
assert.Equal(t, c.volumes["vol1"].ClusterVolume.Meta.Version.Index, uint64(1))
@@ -363,15 +363,17 @@ func TestUpdateVolumeNoSwarm(t *testing.T) {
Spec: &volume.ClusterVolumeSpec{},
}
buf := bytes.Buffer{}
json.NewEncoder(&buf).Encode(volumeUpdate)
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(volumeUpdate)
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/vol1/update?version=0", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
err := v.putVolumesUpdate(ctx, resp, req, map[string]string{"name": "vol1"})
err = v.putVolumesUpdate(ctx, resp, req, map[string]string{"name": "vol1"})
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsUnavailable(err))
}
@@ -393,15 +395,17 @@ func TestUpdateVolumeNotFound(t *testing.T) {
Spec: &volume.ClusterVolumeSpec{},
}
buf := bytes.Buffer{}
json.NewEncoder(&buf).Encode(volumeUpdate)
var buf bytes.Buffer
err := json.NewEncoder(&buf).Encode(volumeUpdate)
assert.NilError(t, err)
ctx := context.WithValue(context.Background(), httputils.APIVersionKey{}, clusterVolumesVersion)
req := httptest.NewRequest("POST", "/volumes/vol1/update?version=0", &buf)
req.Header.Add("Content-Type", "application/json")
resp := httptest.NewRecorder()
err := v.putVolumesUpdate(ctx, resp, req, map[string]string{"name": "vol1"})
err = v.putVolumesUpdate(ctx, resp, req, map[string]string{"name": "vol1"})
assert.Assert(t, err != nil)
assert.Assert(t, errdefs.IsNotFound(err))
}
@@ -582,7 +586,7 @@ type fakeVolumeBackend struct {
}
func (b *fakeVolumeBackend) List(_ context.Context, _ filters.Args) ([]*volume.Volume, []string, error) {
volumes := []*volume.Volume{}
var volumes []*volume.Volume
for _, v := range b.volumes {
volumes = append(volumes, v)
}
@@ -636,7 +640,7 @@ func (b *fakeVolumeBackend) Remove(_ context.Context, name string, o ...opts.Rem
return nil
}
func (b *fakeVolumeBackend) Prune(_ context.Context, _ filters.Args) (*types.VolumesPruneReport, error) {
func (b *fakeVolumeBackend) Prune(_ context.Context, _ filters.Args) (*volume.PruneReport, error) {
return nil, nil
}
@@ -672,13 +676,12 @@ func (c *fakeClusterBackend) GetVolume(nameOrID string) (volume.Volume, error) {
return volume.Volume{}, errdefs.NotFound(fmt.Errorf("volume %s not found", nameOrID))
}
func (c *fakeClusterBackend) GetVolumes(options volume.ListOptions) ([]*volume.Volume, error) {
func (c *fakeClusterBackend) GetVolumes(_ volume.ListOptions) ([]*volume.Volume, error) {
if err := c.checkSwarm(); err != nil {
return nil, err
}
volumes := []*volume.Volume{}
var volumes []*volume.Volume
for _, v := range c.volumes {
volumes = append(volumes, v)
}

View File

@@ -9,7 +9,6 @@ import (
"github.com/docker/docker/api/server/httputils"
"github.com/docker/docker/api/server/middleware"
"github.com/docker/docker/api/server/router"
"github.com/docker/docker/api/server/router/debug"
"github.com/docker/docker/api/types"
"github.com/docker/docker/dockerversion"
"github.com/gorilla/mux"
@@ -66,26 +65,22 @@ func (s *Server) makeHTTPHandler(handler httputils.APIFunc, operation string) ht
}
// CreateMux returns a new mux with all the routers registered.
func (s *Server) CreateMux(routers ...router.Router) *mux.Router {
func (s *Server) CreateMux(ctx context.Context, routers ...router.Router) *mux.Router {
log.G(ctx).Debug("Registering routers")
m := mux.NewRouter()
log.G(context.TODO()).Debug("Registering routers")
for _, apiRouter := range routers {
for _, r := range apiRouter.Routes() {
if ctx.Err() != nil {
return m
}
log.G(ctx).WithFields(log.Fields{"method": r.Method(), "path": r.Path()}).Debug("Registering route")
f := s.makeHTTPHandler(r.Handler(), r.Method()+" "+r.Path())
log.G(context.TODO()).Debugf("Registering %s, %s", r.Method(), r.Path())
m.Path(versionMatcher + r.Path()).Methods(r.Method()).Handler(f)
m.Path(r.Path()).Methods(r.Method()).Handler(f)
}
}
debugRouter := debug.NewRouter()
for _, r := range debugRouter.Routes() {
f := s.makeHTTPHandler(r.Handler(), r.Method()+" "+r.Path())
m.Path("/debug" + r.Path()).Handler(f)
}
// Setup handlers for undefined paths and methods
notFoundHandler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
_ = httputils.WriteJSON(w, http.StatusNotFound, &types.ErrorResponse{
Message: "page not found",

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,26 @@
package auxprogress
import (
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
// ManifestPushedInsteadOfIndex is a note that is sent when a manifest is pushed
// instead of an index. It is sent when the pushed image is an multi-platform
// index, but the whole index couldn't be pushed.
type ManifestPushedInsteadOfIndex struct {
ManifestPushedInsteadOfIndex bool `json:"manifestPushedInsteadOfIndex"` // Always true
// OriginalIndex is the descriptor of the original image index.
OriginalIndex ocispec.Descriptor `json:"originalIndex"`
// SelectedManifest is the descriptor of the manifest that was pushed instead.
SelectedManifest ocispec.Descriptor `json:"selectedManifest"`
}
// ContentMissing is a note that is sent when push fails because the content is missing.
type ContentMissing struct {
ContentMissing bool `json:"contentMissing"` // Always true
// Desc is the descriptor of the root object that was attempted to be pushed.
Desc ocispec.Descriptor `json:"desc"`
}

View File

@@ -30,7 +30,7 @@ type ContainerRmConfig struct {
// ContainerAttachConfig holds the streams to use when connecting to a container to view logs.
type ContainerAttachConfig struct {
GetStreams func(multiplexed bool) (io.ReadCloser, io.Writer, io.Writer, error)
GetStreams func(multiplexed bool, cancel func()) (io.ReadCloser, io.Writer, io.Writer, error)
UseStdin bool
UseStdout bool
UseStderr bool
@@ -89,7 +89,22 @@ type LogSelector struct {
type ContainerStatsConfig struct {
Stream bool
OneShot bool
OutStream io.Writer
OutStream func() io.Writer
}
// ContainerInspectOptions defines options for the backend.ContainerInspect
// call.
type ContainerInspectOptions struct {
// Size controls whether to propagate the container's size fields.
Size bool
}
// ExecStartConfig holds the options to start container's exec.
type ExecStartConfig struct {
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
ConsoleSize *[2]uint `json:",omitempty"`
}
// ExecInspect holds information about a running process started
@@ -133,7 +148,11 @@ type CreateImageConfig struct {
// from the backend.
type GetImageOpts struct {
Platform *ocispec.Platform
Details bool
}
// ImageInspectOpts holds parameters to inspect an image.
type ImageInspectOpts struct {
Manifests bool
}
// CommitConfig is the configuration for creating an image as part of a build.

View File

@@ -2,44 +2,16 @@ package types // import "github.com/docker/docker/api/types"
import (
"bufio"
"context"
"io"
"net"
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/filters"
"github.com/docker/docker/api/types/registry"
units "github.com/docker/go-units"
)
// ContainerExecInspect holds information returned by exec inspect.
type ContainerExecInspect struct {
ExecID string `json:"ID"`
ContainerID string
Running bool
ExitCode int
Pid int
}
// CopyToContainerOptions holds information
// about files to copy into a container
type CopyToContainerOptions struct {
AllowOverwriteDirWithFile bool
CopyUIDGID bool
}
// EventsOptions holds parameters to filter events with.
type EventsOptions struct {
Since string
Until string
Filters filters.Args
}
// NetworkListOptions holds parameters to filter the list of networks with.
type NetworkListOptions struct {
Filters filters.Args
}
// NewHijackedResponse intializes a HijackedResponse type
// NewHijackedResponse initializes a [HijackedResponse] type.
func NewHijackedResponse(conn net.Conn, mediaType string) HijackedResponse {
return HijackedResponse{Conn: conn, Reader: bufio.NewReader(conn), mediaType: mediaType}
}
@@ -101,7 +73,7 @@ type ImageBuildOptions struct {
NetworkMode string
ShmSize int64
Dockerfile string
Ulimits []*units.Ulimit
Ulimits []*container.Ulimit
// BuildArgs needs to be a *string instead of just a string so that
// we can tell the difference between "" (empty string) and no value
// at all (nil). See the parsing of buildArgs in
@@ -122,7 +94,7 @@ type ImageBuildOptions struct {
Target string
SessionID string
Platform string
// Version specifies the version of the unerlying builder to use
// Version specifies the version of the underlying builder to use
Version BuilderVersion
// BuildID is an optional identifier that can be passed together with the
// build request. The same identifier can be used to gracefully cancel the
@@ -157,35 +129,6 @@ type ImageBuildResponse struct {
OSType string
}
// ImageImportSource holds source information for ImageImport
type ImageImportSource struct {
Source io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
}
// ImageLoadResponse returns information to the client about a load process.
type ImageLoadResponse struct {
// Body must be closed to avoid a resource leak
Body io.ReadCloser
JSON bool
}
// RequestPrivilegeFunc is a function interface that
// clients can supply to retry operations after
// getting an authorization error.
// This function returns the registry authentication
// header value in base 64 format, or an error
// if the privilege request fails.
type RequestPrivilegeFunc func() (string, error)
// ImageSearchOptions holds parameters to search images with.
type ImageSearchOptions struct {
RegistryAuth string
PrivilegeFunc RequestPrivilegeFunc
Filters filters.Args
Limit int
}
// NodeListOptions holds parameters to list nodes with.
type NodeListOptions struct {
Filters filters.Args
@@ -284,12 +227,19 @@ type PluginDisableOptions struct {
// PluginInstallOptions holds parameters to install a plugin.
type PluginInstallOptions struct {
Disabled bool
AcceptAllPermissions bool
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
RemoteRef string // RemoteRef is the plugin name on the registry
PrivilegeFunc RequestPrivilegeFunc
AcceptPermissionsFunc func(PluginPrivileges) (bool, error)
Disabled bool
AcceptAllPermissions bool
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
RemoteRef string // RemoteRef is the plugin name on the registry
// PrivilegeFunc is a function that clients can supply to retry operations
// after getting an authorization error. This function returns the registry
// authentication header value in base64 encoded format, or an error if the
// privilege request fails.
//
// For details, refer to [github.com/docker/docker/api/types/registry.RequestAuthConfig].
PrivilegeFunc func(context.Context) (string, error)
AcceptPermissionsFunc func(context.Context, PluginPrivileges) (bool, error)
Args []string
}

View File

@@ -1,10 +1,10 @@
package types
package common
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// IDResponse Response to an API call that returns just an Id
// swagger:model IdResponse
// swagger:model IDResponse
type IDResponse struct {
// The id of the newly created object.

View File

@@ -1,18 +0,0 @@
package types // import "github.com/docker/docker/api/types"
// ExecConfig is a small subset of the Config struct that holds the configuration
// for the exec feature of docker.
type ExecConfig struct {
User string // User that will run the command
Privileged bool // Is the container in privileged mode
Tty bool // Attach standard streams to a tty.
ConsoleSize *[2]uint `json:",omitempty"` // Initial console size [height, width]
AttachStdin bool // Attach the standard input, makes possible user interaction
AttachStderr bool // Attach the standard error
AttachStdout bool // Attach the standard output
Detach bool // Execute in detach mode
DetachKeys string // Escape keys for detach
Env []string // Environment variables
WorkingDir string // Working directory
Cmd []string // Execution commands and args
}

View File

@@ -0,0 +1,7 @@
package container
import "github.com/docker/docker/api/types/common"
// CommitResponse response for the commit API call, containing the ID of the
// image that was produced.
type CommitResponse = common.IDResponse

View File

@@ -1,7 +1,6 @@
package container // import "github.com/docker/docker/api/types/container"
import (
"io"
"time"
"github.com/docker/docker/api/types/strslice"
@@ -36,14 +35,6 @@ type StopOptions struct {
// HealthConfig holds configuration settings for the HEALTHCHECK feature.
type HealthConfig = dockerspec.HealthcheckConfig
// ExecStartOptions holds the options to start container's exec.
type ExecStartOptions struct {
Stdin io.Reader
Stdout io.Writer
Stderr io.Writer
ConsoleSize *[2]uint `json:",omitempty"`
}
// Config contains the configuration data about a container.
// It should hold only portable information about the container.
// Here, "portable" means "independent from the host we are running on".

View File

@@ -0,0 +1,188 @@
package container
import (
"io"
"os"
"time"
"github.com/docker/docker/api/types/mount"
"github.com/docker/docker/api/types/storage"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
// ContainerUpdateOKBody OK response to ContainerUpdate operation
//
// Deprecated: use [UpdateResponse]. This alias will be removed in the next release.
type ContainerUpdateOKBody = UpdateResponse
// ContainerTopOKBody OK response to ContainerTop operation
//
// Deprecated: use [TopResponse]. This alias will be removed in the next release.
type ContainerTopOKBody = TopResponse
// PruneReport contains the response for Engine API:
// POST "/containers/prune"
type PruneReport struct {
ContainersDeleted []string
SpaceReclaimed uint64
}
// PathStat is used to encode the header from
// GET "/containers/{name:.*}/archive"
// "Name" is the file or directory name.
type PathStat struct {
Name string `json:"name"`
Size int64 `json:"size"`
Mode os.FileMode `json:"mode"`
Mtime time.Time `json:"mtime"`
LinkTarget string `json:"linkTarget"`
}
// CopyToContainerOptions holds information
// about files to copy into a container
type CopyToContainerOptions struct {
AllowOverwriteDirWithFile bool
CopyUIDGID bool
}
// StatsResponseReader wraps an io.ReadCloser to read (a stream of) stats
// for a container, as produced by the GET "/stats" endpoint.
//
// The OSType field is set to the server's platform to allow
// platform-specific handling of the response.
//
// TODO(thaJeztah): remove this wrapper, and make OSType part of [StatsResponse].
type StatsResponseReader struct {
Body io.ReadCloser `json:"body"`
OSType string `json:"ostype"`
}
// MountPoint represents a mount point configuration inside the container.
// This is used for reporting the mountpoints in use by a container.
type MountPoint struct {
// Type is the type of mount, see `Type<foo>` definitions in
// github.com/docker/docker/api/types/mount.Type
Type mount.Type `json:",omitempty"`
// Name is the name reference to the underlying data defined by `Source`
// e.g., the volume name.
Name string `json:",omitempty"`
// Source is the source location of the mount.
//
// For volumes, this contains the storage location of the volume (within
// `/var/lib/docker/volumes/`). For bind-mounts, and `npipe`, this contains
// the source (host) part of the bind-mount. For `tmpfs` mount points, this
// field is empty.
Source string
// Destination is the path relative to the container root (`/`) where the
// Source is mounted inside the container.
Destination string
// Driver is the volume driver used to create the volume (if it is a volume).
Driver string `json:",omitempty"`
// Mode is a comma separated list of options supplied by the user when
// creating the bind/volume mount.
//
// The default is platform-specific (`"z"` on Linux, empty on Windows).
Mode string
// RW indicates whether the mount is mounted writable (read-write).
RW bool
// Propagation describes how mounts are propagated from the host into the
// mount point, and vice-versa. Refer to the Linux kernel documentation
// for details:
// https://www.kernel.org/doc/Documentation/filesystems/sharedsubtree.txt
//
// This field is not used on Windows.
Propagation mount.Propagation
}
// State stores container's running state
// it's part of ContainerJSONBase and returned by "inspect" command
type State struct {
Status string // String representation of the container state. Can be one of "created", "running", "paused", "restarting", "removing", "exited", or "dead"
Running bool
Paused bool
Restarting bool
OOMKilled bool
Dead bool
Pid int
ExitCode int
Error string
StartedAt string
FinishedAt string
Health *Health `json:",omitempty"`
}
// Summary contains response of Engine API:
// GET "/containers/json"
type Summary struct {
ID string `json:"Id"`
Names []string
Image string
ImageID string
ImageManifestDescriptor *ocispec.Descriptor `json:"ImageManifestDescriptor,omitempty"`
Command string
Created int64
Ports []Port
SizeRw int64 `json:",omitempty"`
SizeRootFs int64 `json:",omitempty"`
Labels map[string]string
State string
Status string
HostConfig struct {
NetworkMode string `json:",omitempty"`
Annotations map[string]string `json:",omitempty"`
}
NetworkSettings *NetworkSettingsSummary
Mounts []MountPoint
}
// ContainerJSONBase contains response of Engine API GET "/containers/{name:.*}/json"
// for API version 1.18 and older.
//
// TODO(thaJeztah): combine ContainerJSONBase and InspectResponse into a single struct.
// The split between ContainerJSONBase (ContainerJSONBase) and InspectResponse (InspectResponse)
// was done in commit 6deaa58ba5f051039643cedceee97c8695e2af74 (https://github.com/moby/moby/pull/13675).
// ContainerJSONBase contained all fields for API < 1.19, and InspectResponse
// held fields that were added in API 1.19 and up. Given that the minimum
// supported API version is now 1.24, we no longer use the separate type.
type ContainerJSONBase struct {
ID string `json:"Id"`
Created string
Path string
Args []string
State *State
Image string
ResolvConfPath string
HostnamePath string
HostsPath string
LogPath string
Name string
RestartCount int
Driver string
Platform string
MountLabel string
ProcessLabel string
AppArmorProfile string
ExecIDs []string
HostConfig *HostConfig
GraphDriver storage.DriverData
SizeRw *int64 `json:",omitempty"`
SizeRootFs *int64 `json:",omitempty"`
}
// InspectResponse is the response for the GET "/containers/{name:.*}/json"
// endpoint.
type InspectResponse struct {
*ContainerJSONBase
Mounts []MountPoint
Config *Config
NetworkSettings *NetworkSettings
// ImageManifestDescriptor is the descriptor of a platform-specific manifest of the image used to create the container.
ImageManifestDescriptor *ocispec.Descriptor `json:"ImageManifestDescriptor,omitempty"`
}

View File

@@ -1,22 +0,0 @@
package container // import "github.com/docker/docker/api/types/container"
// ----------------------------------------------------------------------------
// Code generated by `swagger generate operation`. DO NOT EDIT.
//
// See hack/generate-swagger-api.sh
// ----------------------------------------------------------------------------
// ContainerTopOKBody OK response to ContainerTop operation
// swagger:model ContainerTopOKBody
type ContainerTopOKBody struct {
// Each process running in the container, where each is process
// is an array of values corresponding to the titles.
//
// Required: true
Processes [][]string `json:"Processes"`
// The ps column titles
// Required: true
Titles []string `json:"Titles"`
}

View File

@@ -1,16 +0,0 @@
package container // import "github.com/docker/docker/api/types/container"
// ----------------------------------------------------------------------------
// Code generated by `swagger generate operation`. DO NOT EDIT.
//
// See hack/generate-swagger-api.sh
// ----------------------------------------------------------------------------
// ContainerUpdateOKBody OK response to ContainerUpdate operation
// swagger:model ContainerUpdateOKBody
type ContainerUpdateOKBody struct {
// warnings
// Required: true
Warnings []string `json:"Warnings"`
}

View File

@@ -0,0 +1,13 @@
package container
import "github.com/docker/docker/api/types/network"
// CreateRequest is the request message sent to the server for container
// create calls. It is a config wrapper that holds the container [Config]
// (portable) and the corresponding [HostConfig] (non-portable) and
// [network.NetworkingConfig].
type CreateRequest struct {
*Config
HostConfig *HostConfig `json:"HostConfig,omitempty"`
NetworkingConfig *network.NetworkingConfig `json:"NetworkingConfig,omitempty"`
}

View File

@@ -0,0 +1,51 @@
package container
import "github.com/docker/docker/api/types/common"
// ExecCreateResponse is the response for a successful exec-create request.
// It holds the ID of the exec that was created.
//
// TODO(thaJeztah): make this a distinct type.
type ExecCreateResponse = common.IDResponse
// ExecOptions is a small subset of the Config struct that holds the configuration
// for the exec feature of docker.
type ExecOptions struct {
User string // User that will run the command
Privileged bool // Is the container in privileged mode
Tty bool // Attach standard streams to a tty.
ConsoleSize *[2]uint `json:",omitempty"` // Initial console size [height, width]
AttachStdin bool // Attach the standard input, makes possible user interaction
AttachStderr bool // Attach the standard error
AttachStdout bool // Attach the standard output
Detach bool // Execute in detach mode
DetachKeys string // Escape keys for detach
Env []string // Environment variables
WorkingDir string // Working directory
Cmd []string // Execution commands and args
}
// ExecStartOptions is a temp struct used by execStart
// Config fields is part of ExecConfig in runconfig package
type ExecStartOptions struct {
// ExecStart will first check if it's detached
Detach bool
// Check if there's a tty
Tty bool
// Terminal size [height, width], unused if Tty == false
ConsoleSize *[2]uint `json:",omitempty"`
}
// ExecAttachOptions is a temp struct used by execAttach.
//
// TODO(thaJeztah): make this a separate type; ContainerExecAttach does not use the Detach option, and cannot run detached.
type ExecAttachOptions = ExecStartOptions
// ExecInspect holds information returned by exec inspect.
type ExecInspect struct {
ExecID string `json:"ID"`
ContainerID string
Running bool
ExitCode int
Pid int
}

View File

@@ -0,0 +1,26 @@
package container
import "time"
// Health states
const (
NoHealthcheck = "none" // Indicates there is no healthcheck
Starting = "starting" // Starting indicates that the container is not yet ready
Healthy = "healthy" // Healthy indicates that the container is running correctly
Unhealthy = "unhealthy" // Unhealthy indicates that the container has a problem
)
// Health stores information about the container's healthcheck results
type Health struct {
Status string // Status is one of [Starting], [Healthy] or [Unhealthy].
FailingStreak int // FailingStreak is the number of consecutive failures
Log []*HealthcheckResult // Log contains the last few results (oldest first)
}
// HealthcheckResult stores information about a single run of a healthcheck probe
type HealthcheckResult struct {
Start time.Time // Start is the time this check started
End time.Time // End is the time this check ended
ExitCode int // ExitCode meanings: 0=healthy, 1=unhealthy, 2=reserved (considered unhealthy), else=error running probe
Output string // Output from last check
}

View File

@@ -1,6 +1,7 @@
package container // import "github.com/docker/docker/api/types/container"
import (
"errors"
"fmt"
"strings"
@@ -9,7 +10,7 @@ import (
"github.com/docker/docker/api/types/network"
"github.com/docker/docker/api/types/strslice"
"github.com/docker/go-connections/nat"
units "github.com/docker/go-units"
"github.com/docker/go-units"
)
// CgroupnsMode represents the cgroup namespace mode of the container
@@ -325,12 +326,12 @@ func ValidateRestartPolicy(policy RestartPolicy) error {
if policy.MaximumRetryCount < 0 {
msg += " and cannot be negative"
}
return &errInvalidParameter{fmt.Errorf(msg)}
return &errInvalidParameter{errors.New(msg)}
}
return nil
case RestartPolicyOnFailure:
if policy.MaximumRetryCount < 0 {
return &errInvalidParameter{fmt.Errorf("invalid restart policy: maximum retry count cannot be negative")}
return &errInvalidParameter{errors.New("invalid restart policy: maximum retry count cannot be negative")}
}
return nil
case "":
@@ -360,6 +361,12 @@ type LogConfig struct {
Config map[string]string
}
// Ulimit is an alias for [units.Ulimit], which may be moving to a different
// location or become a local type. This alias is to help transitioning.
//
// Users are recommended to use this alias instead of using [units.Ulimit] directly.
type Ulimit = units.Ulimit
// Resources contains container's resources (cgroups config, ulimits...)
type Resources struct {
// Applicable to all platforms
@@ -387,14 +394,14 @@ type Resources struct {
// KernelMemory specifies the kernel memory limit (in bytes) for the container.
// Deprecated: kernel 5.4 deprecated kmem.limit_in_bytes.
KernelMemory int64 `json:",omitempty"`
KernelMemoryTCP int64 `json:",omitempty"` // Hard limit for kernel TCP buffer memory (in bytes)
MemoryReservation int64 // Memory soft limit (in bytes)
MemorySwap int64 // Total memory usage (memory + swap); set `-1` to enable unlimited swap
MemorySwappiness *int64 // Tuning container memory swappiness behaviour
OomKillDisable *bool // Whether to disable OOM Killer or not
PidsLimit *int64 // Setting PIDs limit for a container; Set `0` or `-1` for unlimited, or `null` to not change.
Ulimits []*units.Ulimit // List of ulimits to be set in the container
KernelMemory int64 `json:",omitempty"`
KernelMemoryTCP int64 `json:",omitempty"` // Hard limit for kernel TCP buffer memory (in bytes)
MemoryReservation int64 // Memory soft limit (in bytes)
MemorySwap int64 // Total memory usage (memory + swap); set `-1` to enable unlimited swap
MemorySwappiness *int64 // Tuning container memory swappiness behaviour
OomKillDisable *bool // Whether to disable OOM Killer or not
PidsLimit *int64 // Setting PIDs limit for a container; Set `0` or `-1` for unlimited, or `null` to not change.
Ulimits []*Ulimit // List of ulimits to be set in the container
// Applicable to Windows
CPUCount int64 `json:"CpuCount"` // CPU count

View File

@@ -3,7 +3,6 @@ package container
import (
"testing"
"github.com/docker/docker/errdefs"
"gotest.tools/v3/assert"
is "gotest.tools/v3/assert/cmp"
)
@@ -91,15 +90,24 @@ func TestValidateRestartPolicy(t *testing.T) {
}
for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) {
err := ValidateRestartPolicy(tc.input)
if tc.expectedErr == "" {
assert.Check(t, err)
} else {
assert.Check(t, is.ErrorType(err, errdefs.IsInvalidParameter))
assert.Check(t, is.ErrorType(err, isInvalidParameter))
assert.Check(t, is.Error(err, tc.expectedErr))
}
})
}
}
// isInvalidParameter is a minimal implementation of [github.com/docker/docker/errdefs.IsInvalidParameter],
// because this was the only import of that package in api/types, which is the
// package imported by external users.
func isInvalidParameter(err error) bool {
_, ok := err.(interface {
InvalidParameter()
})
return ok
}

View File

@@ -9,24 +9,6 @@ func (i Isolation) IsValid() bool {
return i.IsDefault()
}
// NetworkName returns the name of the network stack.
func (n NetworkMode) NetworkName() string {
if n.IsBridge() {
return network.NetworkBridge
} else if n.IsHost() {
return network.NetworkHost
} else if n.IsContainer() {
return "container"
} else if n.IsNone() {
return network.NetworkNone
} else if n.IsDefault() {
return network.NetworkDefault
} else if n.IsUserDefined() {
return n.UserDefined()
}
return ""
}
// IsBridge indicates whether container uses the bridge network stack
func (n NetworkMode) IsBridge() bool {
return n == network.NetworkBridge
@@ -41,3 +23,23 @@ func (n NetworkMode) IsHost() bool {
func (n NetworkMode) IsUserDefined() bool {
return !n.IsDefault() && !n.IsBridge() && !n.IsHost() && !n.IsNone() && !n.IsContainer()
}
// NetworkName returns the name of the network stack.
func (n NetworkMode) NetworkName() string {
switch {
case n.IsDefault():
return network.NetworkDefault
case n.IsBridge():
return network.NetworkBridge
case n.IsHost():
return network.NetworkHost
case n.IsNone():
return network.NetworkNone
case n.IsContainer():
return "container"
case n.IsUserDefined():
return n.UserDefined()
default:
return ""
}
}

View File

@@ -2,6 +2,11 @@ package container // import "github.com/docker/docker/api/types/container"
import "github.com/docker/docker/api/types/network"
// IsValid indicates if an isolation technology is valid
func (i Isolation) IsValid() bool {
return i.IsDefault() || i.IsHyperV() || i.IsProcess()
}
// IsBridge indicates whether container uses the bridge network stack
// in windows it is given the name NAT
func (n NetworkMode) IsBridge() bool {
@@ -19,24 +24,24 @@ func (n NetworkMode) IsUserDefined() bool {
return !n.IsDefault() && !n.IsNone() && !n.IsBridge() && !n.IsContainer()
}
// IsValid indicates if an isolation technology is valid
func (i Isolation) IsValid() bool {
return i.IsDefault() || i.IsHyperV() || i.IsProcess()
}
// NetworkName returns the name of the network stack.
func (n NetworkMode) NetworkName() string {
if n.IsDefault() {
switch {
case n.IsDefault():
return network.NetworkDefault
} else if n.IsBridge() {
case n.IsBridge():
return network.NetworkNat
} else if n.IsNone() {
case n.IsHost():
// Windows currently doesn't support host network-mode, so
// this would currently never happen..
return network.NetworkHost
case n.IsNone():
return network.NetworkNone
} else if n.IsContainer() {
case n.IsContainer():
return "container"
} else if n.IsUserDefined() {
case n.IsUserDefined():
return n.UserDefined()
default:
return ""
}
return ""
}

View File

@@ -0,0 +1,56 @@
package container
import (
"github.com/docker/docker/api/types/network"
"github.com/docker/go-connections/nat"
)
// NetworkSettings exposes the network settings in the api
type NetworkSettings struct {
NetworkSettingsBase
DefaultNetworkSettings
Networks map[string]*network.EndpointSettings
}
// NetworkSettingsBase holds networking state for a container when inspecting it.
type NetworkSettingsBase struct {
Bridge string // Bridge contains the name of the default bridge interface iff it was set through the daemon --bridge flag.
SandboxID string // SandboxID uniquely represents a container's network stack
SandboxKey string // SandboxKey identifies the sandbox
Ports nat.PortMap // Ports is a collection of PortBinding indexed by Port
// HairpinMode specifies if hairpin NAT should be enabled on the virtual interface
//
// Deprecated: This field is never set and will be removed in a future release.
HairpinMode bool
// LinkLocalIPv6Address is an IPv6 unicast address using the link-local prefix
//
// Deprecated: This field is never set and will be removed in a future release.
LinkLocalIPv6Address string
// LinkLocalIPv6PrefixLen is the prefix length of an IPv6 unicast address
//
// Deprecated: This field is never set and will be removed in a future release.
LinkLocalIPv6PrefixLen int
SecondaryIPAddresses []network.Address // Deprecated: This field is never set and will be removed in a future release.
SecondaryIPv6Addresses []network.Address // Deprecated: This field is never set and will be removed in a future release.
}
// DefaultNetworkSettings holds network information
// during the 2 release deprecation period.
// It will be removed in Docker 1.11.
type DefaultNetworkSettings struct {
EndpointID string // EndpointID uniquely represents a service endpoint in a Sandbox
Gateway string // Gateway holds the gateway address for the network
GlobalIPv6Address string // GlobalIPv6Address holds network's global IPv6 address
GlobalIPv6PrefixLen int // GlobalIPv6PrefixLen represents mask length of network's global IPv6 address
IPAddress string // IPAddress holds the IPv4 address for the network
IPPrefixLen int // IPPrefixLen represents mask length of network's IPv4 address
IPv6Gateway string // IPv6Gateway holds gateway address specific for IPv6
MacAddress string // MacAddress holds the MAC address for the network
}
// NetworkSettingsSummary provides a summary of container's networks
// in /containers/json
type NetworkSettingsSummary struct {
Networks map[string]*network.EndpointSettings
}

View File

@@ -1,4 +1,4 @@
package types
package container
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command

View File

@@ -1,6 +1,4 @@
// Package types is used for API stability in the types and response to the
// consumers of the API stats endpoint.
package types // import "github.com/docker/docker/api/types"
package container
import "time"
@@ -150,7 +148,15 @@ type PidsStats struct {
}
// Stats is Ultimate struct aggregating all types of stats of one container
type Stats struct {
//
// Deprecated: use [StatsResponse] instead. This type will be removed in the next release.
type Stats = StatsResponse
// StatsResponse aggregates all types of stats of one container.
type StatsResponse struct {
Name string `json:"name,omitempty"`
ID string `json:"id,omitempty"`
// Common stats
Read time.Time `json:"read"`
PreRead time.Time `json:"preread"`
@@ -164,18 +170,8 @@ type Stats struct {
StorageStats StorageStats `json:"storage_stats,omitempty"`
// Shared stats
CPUStats CPUStats `json:"cpu_stats,omitempty"`
PreCPUStats CPUStats `json:"precpu_stats,omitempty"` // "Pre"="Previous"
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
}
// StatsJSON is newly used Networks
type StatsJSON struct {
Stats
Name string `json:"name,omitempty"`
ID string `json:"id,omitempty"`
// Networks request version >=1.21
Networks map[string]NetworkStats `json:"networks,omitempty"`
CPUStats CPUStats `json:"cpu_stats,omitempty"`
PreCPUStats CPUStats `json:"precpu_stats,omitempty"` // "Pre"="Previous"
MemoryStats MemoryStats `json:"memory_stats,omitempty"`
Networks map[string]NetworkStats `json:"networks,omitempty"`
}

View File

@@ -0,0 +1,18 @@
package container
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// TopResponse ContainerTopResponse
//
// Container "top" response.
// swagger:model TopResponse
type TopResponse struct {
// Each process running in the container, where each process
// is an array of values corresponding to the titles.
Processes [][]string `json:"Processes"`
// The ps column titles
Titles []string `json:"Titles"`
}

View File

@@ -0,0 +1,14 @@
package container
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// UpdateResponse ContainerUpdateResponse
//
// Response for a successful container-update.
// swagger:model UpdateResponse
type UpdateResponse struct {
// Warnings encountered when updating the container.
Warnings []string `json:"Warnings"`
}

View File

@@ -1,4 +1,5 @@
package events // import "github.com/docker/docker/api/types/events"
import "github.com/docker/docker/api/types/filters"
// Type is used for event-types.
type Type string
@@ -125,3 +126,10 @@ type Message struct {
Time int64 `json:"time,omitempty"`
TimeNano int64 `json:"timeNano,omitempty"`
}
// ListOptions holds parameters to filter events with.
type ListOptions struct {
Since string
Until string
Filters filters.Args
}

View File

@@ -22,16 +22,3 @@ func (e invalidFilter) Error() string {
// InvalidParameter marks this error as ErrInvalidParameter
func (e invalidFilter) InvalidParameter() {}
// unreachableCode is an error indicating that the code path was not expected to be reached.
type unreachableCode struct {
Filter string
Value []string
}
// System marks this error as ErrSystem
func (e unreachableCode) System() {}
func (e unreachableCode) Error() string {
return fmt.Sprintf("unreachable code reached for filter: %q with values: %s", e.Filter, e.Value)
}

View File

@@ -196,11 +196,10 @@ func (args Args) Match(field, source string) bool {
}
// GetBoolOrDefault returns a boolean value of the key if the key is present
// and is intepretable as a boolean value. Otherwise the default value is returned.
// and is interpretable as a boolean value. Otherwise the default value is returned.
// Error is not nil only if the filter values are not valid boolean or are conflicting.
func (args Args) GetBoolOrDefault(key string, defaultValue bool) (bool, error) {
fieldValues, ok := args.fields[key]
if !ok {
return defaultValue, nil
}
@@ -211,20 +210,11 @@ func (args Args) GetBoolOrDefault(key string, defaultValue bool) (bool, error) {
isFalse := fieldValues["0"] || fieldValues["false"]
isTrue := fieldValues["1"] || fieldValues["true"]
conflicting := isFalse && isTrue
invalid := !isFalse && !isTrue
if conflicting || invalid {
if isFalse == isTrue {
// Either no or conflicting truthy/falsy value were provided
return defaultValue, &invalidFilter{key, args.Get(key)}
} else if isFalse {
return false, nil
} else if isTrue {
return true, nil
}
// This code shouldn't be reached.
return defaultValue, &unreachableCode{Filter: key, Value: args.Get(key)}
return isTrue, nil
}
// ExactMatch returns true if the source matches exactly one of the values.

View File

@@ -2,7 +2,6 @@ package filters // import "github.com/docker/docker/api/types/filters"
import (
"encoding/json"
"errors"
"fmt"
"sort"
"testing"
@@ -12,53 +11,49 @@ import (
)
func TestMarshalJSON(t *testing.T) {
fields := map[string]map[string]bool{
"created": {"today": true},
"image.name": {"ubuntu*": true, "*untu": true},
}
a := Args{fields: fields}
a := NewArgs(
Arg("created", "today"),
Arg("image.name", "ubuntu*"),
Arg("image.name", "*untu"),
)
_, err := a.MarshalJSON()
if err != nil {
t.Errorf("failed to marshal the filters: %s", err)
}
s, err := a.MarshalJSON()
assert.Check(t, err)
const expected = `{"created":{"today":true},"image.name":{"*untu":true,"ubuntu*":true}}`
assert.Check(t, is.Equal(string(s), expected))
}
func TestMarshalJSONWithEmpty(t *testing.T) {
_, err := json.Marshal(NewArgs())
if err != nil {
t.Errorf("failed to marshal the filters: %s", err)
}
s, err := json.Marshal(NewArgs())
assert.Check(t, err)
const expected = `{}`
assert.Check(t, is.Equal(string(s), expected))
}
func TestToJSON(t *testing.T) {
fields := map[string]map[string]bool{
"created": {"today": true},
"image.name": {"ubuntu*": true, "*untu": true},
}
a := Args{fields: fields}
a := NewArgs(
Arg("created", "today"),
Arg("image.name", "ubuntu*"),
Arg("image.name", "*untu"),
)
_, err := ToJSON(a)
if err != nil {
t.Errorf("failed to marshal the filters: %s", err)
}
s, err := ToJSON(a)
assert.Check(t, err)
const expected = `{"created":{"today":true},"image.name":{"*untu":true,"ubuntu*":true}}`
assert.Check(t, is.Equal(s, expected))
}
func TestToParamWithVersion(t *testing.T) {
fields := map[string]map[string]bool{
"created": {"today": true},
"image.name": {"ubuntu*": true, "*untu": true},
}
a := Args{fields: fields}
a := NewArgs(
Arg("created", "today"),
Arg("image.name", "ubuntu*"),
Arg("image.name", "*untu"),
)
str1, err := ToParamWithVersion("1.21", a)
if err != nil {
t.Errorf("failed to marshal the filters with version < 1.22: %s", err)
}
assert.Check(t, err)
str2, err := ToParamWithVersion("1.22", a)
if err != nil {
t.Errorf("failed to marshal the filters with version >= 1.22: %s", err)
}
assert.Check(t, err)
if str1 != `{"created":["today"],"image.name":["*untu","ubuntu*"]}` &&
str1 != `{"created":["today"],"image.name":["ubuntu*","*untu"]}` {
t.Errorf("incorrectly marshaled the filters: %s", str1)
@@ -92,39 +87,30 @@ func TestFromJSON(t *testing.T) {
}
for _, invalid := range invalids {
_, err := FromJSON(invalid)
if err == nil {
t.Fatalf("Expected an error with %v, got nothing", invalid)
}
var invalidFilterError *invalidFilter
if !errors.As(err, &invalidFilterError) {
t.Fatalf("Expected an invalidFilter error, got %T", err)
}
wrappedErr := fmt.Errorf("something went wrong: %w", err)
if !errors.Is(wrappedErr, err) {
t.Errorf("Expected a wrapped error to be detected as invalidFilter")
}
t.Run(invalid, func(t *testing.T) {
_, err := FromJSON(invalid)
if err == nil {
t.Fatalf("Expected an error with %v, got nothing", invalid)
}
var invalidFilterError *invalidFilter
assert.Check(t, is.ErrorType(err, invalidFilterError))
wrappedErr := fmt.Errorf("something went wrong: %w", err)
assert.Check(t, is.ErrorIs(wrappedErr, err))
})
}
for expectedArgs, matchers := range valid {
for _, jsonString := range matchers {
args, err := FromJSON(jsonString)
if err != nil {
t.Fatal(err)
}
if args.Len() != expectedArgs.Len() {
t.Fatalf("Expected %v, go %v", expectedArgs, args)
}
assert.Check(t, err)
assert.Check(t, is.Equal(args.Len(), expectedArgs.Len()))
for key, expectedValues := range expectedArgs.fields {
values := args.Get(key)
if len(values) != len(expectedValues) {
t.Fatalf("Expected %v, go %v", expectedArgs, args)
}
assert.Check(t, is.Len(values, len(expectedValues)), expectedArgs)
for _, v := range values {
if !expectedValues[v] {
t.Fatalf("Expected %v, go %v", expectedArgs, args)
t.Errorf("Expected %v, go %v", expectedArgs, args)
}
}
}
@@ -134,17 +120,12 @@ func TestFromJSON(t *testing.T) {
func TestEmpty(t *testing.T) {
a := Args{}
assert.Check(t, is.Equal(a.Len(), 0))
v, err := ToJSON(a)
if err != nil {
t.Errorf("failed to marshal the filters: %s", err)
}
assert.Check(t, err)
v1, err := FromJSON(v)
if err != nil {
t.Errorf("%s", err)
}
if a.Len() != v1.Len() {
t.Error("these should both be empty sets")
}
assert.Check(t, err)
assert.Check(t, is.Equal(v1.Len(), 0))
}
func TestArgsMatchKVListEmptySources(t *testing.T) {
@@ -185,7 +166,7 @@ func TestArgsMatchKVList(t *testing.T) {
for args, field := range matches {
if !args.MatchKVList(field, sources) {
t.Fatalf("Expected true for %v on %v, got false", sources, args)
t.Errorf("Expected true for %v on %v, got false", sources, args)
}
}
@@ -211,7 +192,7 @@ func TestArgsMatchKVList(t *testing.T) {
for args, field := range differs {
if args.MatchKVList(field, sources) {
t.Fatalf("Expected false for %v on %v, got true", sources, args)
t.Errorf("Expected false for %v on %v, got true", sources, args)
}
}
}
@@ -249,8 +230,7 @@ func TestArgsMatch(t *testing.T) {
}
for args, field := range matches {
assert.Check(t, args.Match(field, source),
"Expected field %s to match %s", field, source)
assert.Check(t, args.Match(field, source), "Expected field %s to match %s", field, source)
}
differs := map[*Args]string{
@@ -290,89 +270,62 @@ func TestArgsMatch(t *testing.T) {
func TestAdd(t *testing.T) {
f := NewArgs()
f.Add("status", "running")
v := f.fields["status"]
if len(v) != 1 || !v["running"] {
t.Fatalf("Expected to include a running status, got %v", v)
}
v := f.Get("status")
assert.Check(t, is.DeepEqual(v, []string{"running"}))
f.Add("status", "paused")
if len(v) != 2 || !v["paused"] {
t.Fatalf("Expected to include a paused status, got %v", v)
}
v = f.Get("status")
assert.Check(t, is.Len(v, 2))
assert.Check(t, is.Contains(v, "running"))
assert.Check(t, is.Contains(v, "paused"))
}
func TestDel(t *testing.T) {
f := NewArgs()
f.Add("status", "running")
f.Del("status", "running")
v := f.fields["status"]
if v["running"] {
t.Fatal("Expected to not include a running status filter, got true")
}
assert.Check(t, is.Equal(f.Len(), 0))
assert.Check(t, is.DeepEqual(f.Get("status"), []string{}))
}
func TestLen(t *testing.T) {
f := NewArgs()
if f.Len() != 0 {
t.Fatal("Expected to not include any field")
}
assert.Check(t, is.Equal(f.Len(), 0))
f.Add("status", "running")
if f.Len() != 1 {
t.Fatal("Expected to include one field")
}
assert.Check(t, is.Equal(f.Len(), 1))
}
func TestExactMatch(t *testing.T) {
f := NewArgs()
if !f.ExactMatch("status", "running") {
t.Fatal("Expected to match `running` when there are no filters, got false")
}
assert.Check(t, f.ExactMatch("status", "running"), "Expected to match `running` when there are no filters")
f.Add("status", "running")
f.Add("status", "pause*")
if !f.ExactMatch("status", "running") {
t.Fatal("Expected to match `running` with one of the filters, got false")
}
if f.ExactMatch("status", "paused") {
t.Fatal("Expected to not match `paused` with one of the filters, got true")
}
assert.Check(t, f.ExactMatch("status", "running"), "Expected to match `running` with one of the filters")
assert.Check(t, !f.ExactMatch("status", "paused"), "Expected to not match `paused` with one of the filters")
}
func TestOnlyOneExactMatch(t *testing.T) {
f := NewArgs()
if !f.UniqueExactMatch("status", "running") {
t.Fatal("Expected to match `running` when there are no filters, got false")
}
assert.Check(t, f.ExactMatch("status", "running"), "Expected to match `running` when there are no filters")
f.Add("status", "running")
if !f.UniqueExactMatch("status", "running") {
t.Fatal("Expected to match `running` with one of the filters, got false")
}
if f.UniqueExactMatch("status", "paused") {
t.Fatal("Expected to not match `paused` with one of the filters, got true")
}
assert.Check(t, f.ExactMatch("status", "running"), "Expected to match `running` with one of the filters")
assert.Check(t, !f.UniqueExactMatch("status", "paused"), "Expected to not match `paused` with one of the filters")
f.Add("status", "pause")
if f.UniqueExactMatch("status", "running") {
t.Fatal("Expected to not match only `running` with two filters, got true")
}
assert.Check(t, !f.UniqueExactMatch("status", "running"), "Expected to not match only `running` with two filters")
}
func TestContains(t *testing.T) {
f := NewArgs()
if f.Contains("status") {
t.Fatal("Expected to not contain a status key, got true")
}
assert.Check(t, !f.Contains("status"))
f.Add("status", "running")
if !f.Contains("status") {
t.Fatal("Expected to contain a status key, got false")
}
assert.Check(t, f.Contains("status"))
}
func TestValidate(t *testing.T) {
@@ -384,23 +337,14 @@ func TestValidate(t *testing.T) {
"dangling": true,
}
if err := f.Validate(valid); err != nil {
t.Fatal(err)
}
assert.Check(t, f.Validate(valid))
f.Add("bogus", "running")
err := f.Validate(valid)
if err == nil {
t.Fatal("Expected to return an error, got nil")
}
var invalidFilterError *invalidFilter
if !errors.As(err, &invalidFilterError) {
t.Errorf("Expected an invalidFilter error, got %T", err)
}
assert.Check(t, is.ErrorType(err, invalidFilterError))
wrappedErr := fmt.Errorf("something went wrong: %w", err)
if !errors.Is(wrappedErr, err) {
t.Errorf("Expected a wrapped error to be detected as invalidFilter")
}
assert.Check(t, is.ErrorIs(wrappedErr, err))
}
func TestWalkValues(t *testing.T) {
@@ -414,23 +358,23 @@ func TestWalkValues(t *testing.T) {
}
return nil
})
if err != nil {
t.Fatalf("Expected no error, got %v", err)
}
assert.Check(t, err)
loops1 := 0
err = f.WalkValues("status", func(value string) error {
return errors.New("return")
loops1++
return nil
})
if err == nil {
t.Fatal("Expected to get an error, got nil")
}
assert.Check(t, err)
assert.Check(t, is.Equal(loops1, 2), "Expected to not iterate when the field doesn't exist")
err = f.WalkValues("foo", func(value string) error {
return errors.New("return")
loops2 := 0
err = f.WalkValues("unknown-key", func(value string) error {
loops2++
return nil
})
if err != nil {
t.Fatalf("Expected to not iterate when the field doesn't exist, got %v", err)
}
assert.Check(t, err)
assert.Check(t, is.Equal(loops2, 0), "Expected to not iterate when the field doesn't exist")
}
func TestFuzzyMatch(t *testing.T) {
@@ -446,7 +390,7 @@ func TestFuzzyMatch(t *testing.T) {
for source, match := range cases {
got := f.FuzzyMatch("container", source)
if got != match {
t.Fatalf("Expected %v, got %v: %s", match, got, source)
t.Errorf("Expected %v, got %v: %s", match, got, source)
}
}
}
@@ -540,7 +484,6 @@ func TestGetBoolOrDefault(t *testing.T) {
expectedValue: false,
},
} {
tc := tc
t.Run(tc.name, func(t *testing.T) {
a := NewArgs()
@@ -568,7 +511,7 @@ func TestGetBoolOrDefault(t *testing.T) {
assert.Check(t, is.DeepEqual(expected.Value, actual.Value))
wrappedErr := fmt.Errorf("something went wrong: %w", err)
assert.Check(t, errors.Is(wrappedErr, err), "Expected a wrapped error to be detected as invalidFilter")
assert.Check(t, is.ErrorIs(wrappedErr, err), "Expected a wrapped error to be detected as invalidFilter")
}
assert.Check(t, is.Equal(tc.expectedValue, value))

View File

@@ -1,9 +1,47 @@
package image
import "time"
import (
"io"
"time"
)
// Metadata contains engine-local data about the image.
type Metadata struct {
// LastTagTime is the date and time at which the image was last tagged.
LastTagTime time.Time `json:",omitempty"`
}
// PruneReport contains the response for Engine API:
// POST "/images/prune"
type PruneReport struct {
ImagesDeleted []DeleteResponse
SpaceReclaimed uint64
}
// LoadResponse returns information to the client about a load process.
//
// TODO(thaJeztah): remove this type, and just use an io.ReadCloser
//
// This type was added in https://github.com/moby/moby/pull/18878, related
// to https://github.com/moby/moby/issues/19177;
//
// Make docker load to output json when the response content type is json
// Swarm hijacks the response from docker load and returns JSON rather
// than plain text like the Engine does. This makes the API library to return
// information to figure that out.
//
// However the "load" endpoint unconditionally returns JSON;
// https://github.com/moby/moby/blob/7b9d2ef6e5518a3d3f3cc418459f8df786cfbbd1/api/server/router/image/image_routes.go#L248-L255
//
// PR https://github.com/moby/moby/pull/21959 made the response-type depend
// on whether "quiet" was set, but this logic got changed in a follow-up
// https://github.com/moby/moby/pull/25557, which made the JSON response-type
// unconditionally, but the output produced depend on whether"quiet" was set.
//
// We should deprecated the "quiet" option, as it's really a client
// responsibility.
type LoadResponse struct {
// Body must be closed to avoid a resource leak
Body io.ReadCloser
JSON bool
}

View File

@@ -0,0 +1,140 @@
package image
import (
"github.com/docker/docker/api/types/container"
"github.com/docker/docker/api/types/storage"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
// RootFS returns Image's RootFS description including the layer IDs.
type RootFS struct {
Type string `json:",omitempty"`
Layers []string `json:",omitempty"`
}
// InspectResponse contains response of Engine API:
// GET "/images/{name:.*}/json"
type InspectResponse struct {
// ID is the content-addressable ID of an image.
//
// This identifier is a content-addressable digest calculated from the
// image's configuration (which includes the digests of layers used by
// the image).
//
// Note that this digest differs from the `RepoDigests` below, which
// holds digests of image manifests that reference the image.
ID string `json:"Id"`
// RepoTags is a list of image names/tags in the local image cache that
// reference this image.
//
// Multiple image tags can refer to the same image, and this list may be
// empty if no tags reference the image, in which case the image is
// "untagged", in which case it can still be referenced by its ID.
RepoTags []string
// RepoDigests is a list of content-addressable digests of locally available
// image manifests that the image is referenced from. Multiple manifests can
// refer to the same image.
//
// These digests are usually only available if the image was either pulled
// from a registry, or if the image was pushed to a registry, which is when
// the manifest is generated and its digest calculated.
RepoDigests []string
// Parent is the ID of the parent image.
//
// Depending on how the image was created, this field may be empty and
// is only set for images that were built/created locally. This field
// is empty if the image was pulled from an image registry.
Parent string
// Comment is an optional message that can be set when committing or
// importing the image.
Comment string
// Created is the date and time at which the image was created, formatted in
// RFC 3339 nano-seconds (time.RFC3339Nano).
//
// This information is only available if present in the image,
// and omitted otherwise.
Created string `json:",omitempty"`
// Container is the ID of the container that was used to create the image.
//
// Depending on how the image was created, this field may be empty.
//
// Deprecated: this field is omitted in API v1.45, but kept for backward compatibility.
Container string `json:",omitempty"`
// ContainerConfig is an optional field containing the configuration of the
// container that was last committed when creating the image.
//
// Previous versions of Docker builder used this field to store build cache,
// and it is not in active use anymore.
//
// Deprecated: this field is omitted in API v1.45, but kept for backward compatibility.
ContainerConfig *container.Config `json:",omitempty"`
// DockerVersion is the version of Docker that was used to build the image.
//
// Depending on how the image was created, this field may be empty.
DockerVersion string
// Author is the name of the author that was specified when committing the
// image, or as specified through MAINTAINER (deprecated) in the Dockerfile.
Author string
Config *container.Config
// Architecture is the hardware CPU architecture that the image runs on.
Architecture string
// Variant is the CPU architecture variant (presently ARM-only).
Variant string `json:",omitempty"`
// OS is the Operating System the image is built to run on.
Os string
// OsVersion is the version of the Operating System the image is built to
// run on (especially for Windows).
OsVersion string `json:",omitempty"`
// Size is the total size of the image including all layers it is composed of.
Size int64
// VirtualSize is the total size of the image including all layers it is
// composed of.
//
// Deprecated: this field is omitted in API v1.44, but kept for backward compatibility. Use Size instead.
VirtualSize int64 `json:"VirtualSize,omitempty"`
// GraphDriver holds information about the storage driver used to store the
// container's and image's filesystem.
GraphDriver storage.DriverData
// RootFS contains information about the image's RootFS, including the
// layer IDs.
RootFS RootFS
// Metadata of the image in the local cache.
//
// This information is local to the daemon, and not part of the image itself.
Metadata Metadata
// Descriptor is the OCI descriptor of the image target.
// It's only set if the daemon provides a multi-platform image store.
//
// WARNING: This is experimental and may change at any time without any backward
// compatibility.
Descriptor *ocispec.Descriptor `json:"Descriptor,omitempty"`
// Manifests is a list of image manifests available in this image. It
// provides a more detailed view of the platform-specific image manifests or
// other image-attached data like build attestations.
//
// Only available if the daemon provides a multi-platform image store.
//
// WARNING: This is experimental and may change at any time without any backward
// compatibility.
Manifests []ManifestSummary `json:"Manifests,omitempty"`
}

View File

@@ -0,0 +1,99 @@
package image
import (
"github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
type ManifestKind string
const (
ManifestKindImage ManifestKind = "image"
ManifestKindAttestation ManifestKind = "attestation"
ManifestKindUnknown ManifestKind = "unknown"
)
type ManifestSummary struct {
// ID is the content-addressable ID of an image and is the same as the
// digest of the image manifest.
//
// Required: true
ID string `json:"ID"`
// Descriptor is the OCI descriptor of the image.
//
// Required: true
Descriptor ocispec.Descriptor `json:"Descriptor"`
// Indicates whether all the child content (image config, layers) is
// fully available locally
//
// Required: true
Available bool `json:"Available"`
// Size is the size information of the content related to this manifest.
// Note: These sizes only take the locally available content into account.
//
// Required: true
Size struct {
// Content is the size (in bytes) of all the locally present
// content in the content store (e.g. image config, layers)
// referenced by this manifest and its children.
// This only includes blobs in the content store.
Content int64 `json:"Content"`
// Total is the total size (in bytes) of all the locally present
// data (both distributable and non-distributable) that's related to
// this manifest and its children.
// This equal to the sum of [Content] size AND all the sizes in the
// [Size] struct present in the Kind-specific data struct.
// For example, for an image kind (Kind == ManifestKindImage),
// this would include the size of the image content and unpacked
// image snapshots ([Size.Content] + [ImageData.Size.Unpacked]).
Total int64 `json:"Total"`
} `json:"Size"`
// Kind is the kind of the image manifest.
//
// Required: true
Kind ManifestKind `json:"Kind"`
// Fields below are specific to the kind of the image manifest.
// Present only if Kind == ManifestKindImage.
ImageData *ImageProperties `json:"ImageData,omitempty"`
// Present only if Kind == ManifestKindAttestation.
AttestationData *AttestationProperties `json:"AttestationData,omitempty"`
}
type ImageProperties struct {
// Platform is the OCI platform object describing the platform of the image.
//
// Required: true
Platform ocispec.Platform `json:"Platform"`
Size struct {
// Unpacked is the size (in bytes) of the locally unpacked
// (uncompressed) image content that's directly usable by the containers
// running this image.
// It's independent of the distributable content - e.g.
// the image might still have an unpacked data that's still used by
// some container even when the distributable/compressed content is
// already gone.
//
// Required: true
Unpacked int64 `json:"Unpacked"`
}
// Containers is an array containing the IDs of the containers that are
// using this image.
//
// Required: true
Containers []string `json:"Containers"`
}
type AttestationProperties struct {
// For is the digest of the image manifest that this attestation is for.
For digest.Digest `json:"For"`
}

View File

@@ -1,6 +1,18 @@
package image
import "github.com/docker/docker/api/types/filters"
import (
"context"
"io"
"github.com/docker/docker/api/types/filters"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
)
// ImportSource holds source information for ImageImport
type ImportSource struct {
Source io.Reader // Source is the data to send to the server to create this image from. You must set SourceName to "-" to leverage this.
SourceName string // SourceName is the name of the image to pull. Set to "-" to leverage the Source attribute.
}
// ImportOptions holds information to import images from the client host.
type ImportOptions struct {
@@ -26,13 +38,29 @@ type PullOptions struct {
// authentication header value in base64 encoded format, or an error if the
// privilege request fails.
//
// Also see [github.com/docker/docker/api/types.RequestPrivilegeFunc].
PrivilegeFunc func() (string, error)
// For details, refer to [github.com/docker/docker/api/types/registry.RequestAuthConfig].
PrivilegeFunc func(context.Context) (string, error)
Platform string
}
// PushOptions holds information to push images.
type PushOptions PullOptions
type PushOptions struct {
All bool
RegistryAuth string // RegistryAuth is the base64 encoded credentials for the registry
// PrivilegeFunc is a function that clients can supply to retry operations
// after getting an authorization error. This function returns the registry
// authentication header value in base64 encoded format, or an error if the
// privilege request fails.
//
// For details, refer to [github.com/docker/docker/api/types/registry.RequestAuthConfig].
PrivilegeFunc func(context.Context) (string, error)
// Platform is an optional field that selects a specific platform to push
// when the image is a multi-platform image.
// Using this will only push a single platform-specific manifest.
Platform *ocispec.Platform `json:",omitempty"`
}
// ListOptions holds parameters to list images with.
type ListOptions struct {
@@ -48,6 +76,9 @@ type ListOptions struct {
// ContainerCount indicates whether container count should be computed.
ContainerCount bool
// Manifests indicates whether the image manifests should be returned.
Manifests bool
}
// RemoveOptions holds parameters to remove images.
@@ -55,3 +86,31 @@ type RemoveOptions struct {
Force bool
PruneChildren bool
}
// HistoryOptions holds parameters to get image history.
type HistoryOptions struct {
// Platform from the manifest list to use for history.
Platform *ocispec.Platform
}
// LoadOptions holds parameters to load images.
type LoadOptions struct {
// Quiet suppresses progress output
Quiet bool
// Platforms selects the platforms to load if the image is a
// multi-platform image and has multiple variants.
Platforms []ocispec.Platform
}
type InspectOptions struct {
// Manifests returns the image manifests.
Manifests bool
}
// SaveOptions holds parameters to save images.
type SaveOptions struct {
// Platforms selects the platforms to save if the image is a
// multi-platform image and has multiple variants.
Platforms []ocispec.Platform
}

View File

@@ -1,10 +1,7 @@
package image
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
import ocispec "github.com/opencontainers/image-spec/specs-go/v1"
// Summary summary
// swagger:model Summary
type Summary struct {
// Number of containers using this image. Includes both stopped and running
@@ -17,7 +14,7 @@ type Summary struct {
Containers int64 `json:"Containers"`
// Date and time at which the image was created as a Unix timestamp
// (number of seconds sinds EPOCH).
// (number of seconds since EPOCH).
//
// Required: true
Created int64 `json:"Created"`
@@ -47,6 +44,21 @@ type Summary struct {
// Required: true
ParentID string `json:"ParentId"`
// Descriptor is the OCI descriptor of the image target.
// It's only set if the daemon provides a multi-platform image store.
//
// WARNING: This is experimental and may change at any time without any backward
// compatibility.
Descriptor *ocispec.Descriptor `json:"Descriptor,omitempty"`
// Manifests is a list of image manifests available in this image. It
// provides a more detailed view of the platform-specific image manifests or
// other image-attached data like build attestations.
//
// WARNING: This is experimental and may change at any time without any backward
// compatibility.
Manifests []ManifestSummary `json:"Manifests,omitempty"`
// List of content-addressable digests of locally available image manifests
// that the image is referenced from. Multiple manifests can refer to the
// same image.

View File

@@ -19,6 +19,8 @@ const (
TypeNamedPipe Type = "npipe"
// TypeCluster is the type for Swarm Cluster Volumes.
TypeCluster Type = "cluster"
// TypeImage is the type for mounting another image's filesystem
TypeImage Type = "image"
)
// Mount represents a mount (volume).
@@ -34,6 +36,7 @@ type Mount struct {
BindOptions *BindOptions `json:",omitempty"`
VolumeOptions *VolumeOptions `json:",omitempty"`
ImageOptions *ImageOptions `json:",omitempty"`
TmpfsOptions *TmpfsOptions `json:",omitempty"`
ClusterOptions *ClusterOptions `json:",omitempty"`
}
@@ -100,6 +103,10 @@ type VolumeOptions struct {
DriverConfig *Driver `json:",omitempty"`
}
type ImageOptions struct {
Subpath string `json:",omitempty"`
}
// Driver represents a volume driver.
type Driver struct {
Name string `json:",omitempty"`
@@ -119,7 +126,11 @@ type TmpfsOptions struct {
SizeBytes int64 `json:",omitempty"`
// Mode of the tmpfs upon creation
Mode os.FileMode `json:",omitempty"`
// Options to be passed to the tmpfs mount. An array of arrays. Flag
// options should be provided as 1-length arrays. Other types should be
// provided as 2-length arrays, where the first item is the key and the
// second the value.
Options [][]string `json:",omitempty"`
// TODO(stevvooe): There are several more tmpfs flags, specified in the
// daemon, that are accepted. Only the most basic are added for now.
//

View File

@@ -0,0 +1,19 @@
package network
// This file was generated by the swagger tool.
// Editing this file might prove futile when you re-run the swagger generate command
// CreateResponse NetworkCreateResponse
//
// OK response to NetworkCreate operation
// swagger:model CreateResponse
type CreateResponse struct {
// The ID of the created network.
// Required: true
ID string `json:"Id"`
// Warnings encountered when creating the container
// Required: true
Warning string `json:"Warning"`
}

View File

@@ -18,6 +18,13 @@ type EndpointSettings struct {
// Once the container is running, it becomes operational data (it may contain a
// generated address).
MacAddress string
DriverOpts map[string]string
// GwPriority determines which endpoint will provide the default gateway
// for the container. The endpoint with the highest priority will be used.
// If multiple endpoints have the same priority, they are lexicographically
// sorted based on their network name, and the one that sorts first is picked.
GwPriority int
// Operational data
NetworkID string
EndpointID string
@@ -27,7 +34,6 @@ type EndpointSettings struct {
IPv6Gateway string
GlobalIPv6Address string
GlobalIPv6PrefixLen int
DriverOpts map[string]string
// DNSNames holds all the (non fully qualified) DNS names associated to this endpoint. First entry is used to
// generate PTR records.
DNSNames []string

View File

@@ -23,7 +23,7 @@ func (stub subnetStub) Contains(addr net.IP) bool {
}
func TestEndpointIPAMConfigWithOutOfRangeAddrs(t *testing.T) {
testcases := []struct {
tests := []struct {
name string
ipamConfig *EndpointIPAMConfig
v4Subnets []NetworkSubnet
@@ -80,8 +80,7 @@ func TestEndpointIPAMConfigWithOutOfRangeAddrs(t *testing.T) {
},
}
for _, tc := range testcases {
tc := tc
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()
@@ -102,11 +101,10 @@ func TestEndpointIPAMConfigWithOutOfRangeAddrs(t *testing.T) {
}
})
}
}
func TestEndpointIPAMConfigWithInvalidConfig(t *testing.T) {
testcases := []struct {
tests := []struct {
name string
ipamConfig *EndpointIPAMConfig
expectedErrors []string
@@ -163,8 +161,7 @@ func TestEndpointIPAMConfigWithInvalidConfig(t *testing.T) {
},
}
for _, tc := range testcases {
tc := tc
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

View File

@@ -8,7 +8,7 @@ import (
)
func TestNetworkWithInvalidIPAM(t *testing.T) {
testcases := []struct {
tests := []struct {
name string
ipam IPAM
ipv6 bool
@@ -123,8 +123,7 @@ func TestNetworkWithInvalidIPAM(t *testing.T) {
},
}
for _, tc := range testcases {
tc := tc
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
t.Parallel()

View File

@@ -1,6 +1,8 @@
package network // import "github.com/docker/docker/api/types/network"
import (
"time"
"github.com/docker/docker/api/types/filters"
)
@@ -17,6 +19,84 @@ const (
NetworkNat = "nat"
)
// CreateRequest is the request message sent to the server for network create call.
type CreateRequest struct {
CreateOptions
Name string // Name is the requested name of the network.
// Deprecated: CheckDuplicate is deprecated since API v1.44, but it defaults to true when sent by the client
// package to older daemons.
CheckDuplicate *bool `json:",omitempty"`
}
// CreateOptions holds options to create a network.
type CreateOptions struct {
Driver string // Driver is the driver-name used to create the network (e.g. `bridge`, `overlay`)
Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level).
EnableIPv4 *bool `json:",omitempty"` // EnableIPv4 represents whether to enable IPv4.
EnableIPv6 *bool `json:",omitempty"` // EnableIPv6 represents whether to enable IPv6.
IPAM *IPAM // IPAM is the network's IP Address Management.
Internal bool // Internal represents if the network is used internal only.
Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster.
ConfigOnly bool // ConfigOnly creates a config-only network. Config-only networks are place-holder networks for network configurations to be used by other networks. ConfigOnly networks cannot be used directly to run containers or services.
ConfigFrom *ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network. The specified network must be a config-only network; see [CreateOptions.ConfigOnly].
Options map[string]string // Options specifies the network-specific options to use for when creating the network.
Labels map[string]string // Labels holds metadata specific to the network being created.
}
// ListOptions holds parameters to filter the list of networks with.
type ListOptions struct {
Filters filters.Args
}
// InspectOptions holds parameters to inspect network.
type InspectOptions struct {
Scope string
Verbose bool
}
// ConnectOptions represents the data to be used to connect a container to the
// network.
type ConnectOptions struct {
Container string
EndpointConfig *EndpointSettings `json:",omitempty"`
}
// DisconnectOptions represents the data to be used to disconnect a container
// from the network.
type DisconnectOptions struct {
Container string
Force bool
}
// Inspect is the body of the "get network" http response message.
type Inspect struct {
Name string // Name is the name of the network
ID string `json:"Id"` // ID uniquely identifies a network on a single machine
Created time.Time // Created is the time the network created
Scope string // Scope describes the level at which the network exists (e.g. `swarm` for cluster-wide or `local` for machine level)
Driver string // Driver is the Driver name used to create the network (e.g. `bridge`, `overlay`)
EnableIPv4 bool // EnableIPv4 represents whether IPv4 is enabled
EnableIPv6 bool // EnableIPv6 represents whether IPv6 is enabled
IPAM IPAM // IPAM is the network's IP Address Management
Internal bool // Internal represents if the network is used internal only
Attachable bool // Attachable represents if the global scope is manually attachable by regular containers from workers in swarm mode.
Ingress bool // Ingress indicates the network is providing the routing-mesh for the swarm cluster.
ConfigFrom ConfigReference // ConfigFrom specifies the source which will provide the configuration for this network.
ConfigOnly bool // ConfigOnly networks are place-holder networks for network configurations to be used by other networks. ConfigOnly networks cannot be used directly to run containers or services.
Containers map[string]EndpointResource // Containers contains endpoints belonging to the network
Options map[string]string // Options holds the network specific options to use for when creating the network
Labels map[string]string // Labels holds metadata specific to the network being created
Peers []PeerInfo `json:",omitempty"` // List of peer nodes for an overlay network
Services map[string]ServiceInfo `json:",omitempty"`
}
// Summary is used as response when listing networks. It currently is an alias
// for [Inspect], but may diverge in the future, as not all information may
// be included when listing networks.
type Summary = Inspect
// Address represents an IP address
type Address struct {
Addr string
@@ -45,6 +125,16 @@ type ServiceInfo struct {
Tasks []Task
}
// EndpointResource contains network resources allocated and used for a
// container in a network.
type EndpointResource struct {
Name string
EndpointID string
MacAddress string
IPv4Address string
IPv6Address string
}
// NetworkingConfig represents the container's networking configuration for each of its interfaces
// Carries the networking configs specified in the `docker run` and `docker network connect` commands
type NetworkingConfig struct {
@@ -70,3 +160,9 @@ var acceptedFilters = map[string]bool{
func ValidateFilters(filter filters.Args) error {
return filter.Validate(acceptedFilters)
}
// PruneReport contains the response for Engine API:
// POST "/networks/prune"
type PruneReport struct {
NetworksDeleted []string
}

View File

@@ -1,17 +1,29 @@
package registry // import "github.com/docker/docker/api/types/registry"
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"io"
"strings"
"github.com/pkg/errors"
)
// AuthHeader is the name of the header used to send encoded registry
// authorization credentials for registry operations (push/pull).
const AuthHeader = "X-Registry-Auth"
// RequestAuthConfig is a function interface that clients can supply
// to retry operations after getting an authorization error.
//
// The function must return the [AuthHeader] value ([AuthConfig]), encoded
// in base64url format ([RFC4648, section 5]), which can be decoded by
// [DecodeAuthConfig].
//
// It must return an error if the privilege request fails.
//
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
type RequestAuthConfig func(context.Context) (string, error)
// AuthConfig contains authorization information for connecting to a Registry.
type AuthConfig struct {
Username string `json:"username,omitempty"`
@@ -34,10 +46,9 @@ type AuthConfig struct {
}
// EncodeAuthConfig serializes the auth configuration as a base64url encoded
// RFC4648, section 5) JSON string for sending through the X-Registry-Auth header.
// ([RFC4648, section 5]) JSON string for sending through the X-Registry-Auth header.
//
// For details on base64url encoding, see:
// - RFC4648, section 5: https://tools.ietf.org/html/rfc4648#section-5
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
func EncodeAuthConfig(authConfig AuthConfig) (string, error) {
buf, err := json.Marshal(authConfig)
if err != nil {
@@ -46,15 +57,14 @@ func EncodeAuthConfig(authConfig AuthConfig) (string, error) {
return base64.URLEncoding.EncodeToString(buf), nil
}
// DecodeAuthConfig decodes base64url encoded (RFC4648, section 5) JSON
// DecodeAuthConfig decodes base64url encoded ([RFC4648, section 5]) JSON
// authentication information as sent through the X-Registry-Auth header.
//
// This function always returns an AuthConfig, even if an error occurs. It is up
// This function always returns an [AuthConfig], even if an error occurs. It is up
// to the caller to decide if authentication is required, and if the error can
// be ignored.
//
// For details on base64url encoding, see:
// - RFC4648, section 5: https://tools.ietf.org/html/rfc4648#section-5
// [RFC4648, section 5]: https://tools.ietf.org/html/rfc4648#section-5
func DecodeAuthConfig(authEncoded string) (*AuthConfig, error) {
if authEncoded == "" {
return &AuthConfig{}, nil
@@ -69,7 +79,7 @@ func DecodeAuthConfig(authEncoded string) (*AuthConfig, error) {
// clients and API versions. Current clients and API versions expect authentication
// to be provided through the X-Registry-Auth header.
//
// Like DecodeAuthConfig, this function always returns an AuthConfig, even if an
// Like [DecodeAuthConfig], this function always returns an [AuthConfig], even if an
// error occurs. It is up to the caller to decide if authentication is required,
// and if the error can be ignored.
func DecodeAuthConfigBody(rdr io.ReadCloser) (*AuthConfig, error) {
@@ -87,7 +97,7 @@ func decodeAuthConfigFromReader(rdr io.Reader) (*AuthConfig, error) {
}
func invalid(err error) error {
return errInvalidParameter{errors.Wrap(err, "invalid X-Registry-Auth header")}
return errInvalidParameter{fmt.Errorf("invalid X-Registry-Auth header: %w", err)}
}
type errInvalidParameter struct{ error }

View File

@@ -9,11 +9,29 @@ import (
// ServiceConfig stores daemon registry services configuration.
type ServiceConfig struct {
AllowNondistributableArtifactsCIDRs []*NetIPNet
AllowNondistributableArtifactsHostnames []string
InsecureRegistryCIDRs []*NetIPNet `json:"InsecureRegistryCIDRs"`
IndexConfigs map[string]*IndexInfo `json:"IndexConfigs"`
Mirrors []string
AllowNondistributableArtifactsCIDRs []*NetIPNet `json:"AllowNondistributableArtifactsCIDRs,omitempty"` // Deprecated: non-distributable artifacts are deprecated and enabled by default. This field will be removed in the next release.
AllowNondistributableArtifactsHostnames []string `json:"AllowNondistributableArtifactsHostnames,omitempty"` // Deprecated: non-distributable artifacts are deprecated and enabled by default. This field will be removed in the next release.
InsecureRegistryCIDRs []*NetIPNet `json:"InsecureRegistryCIDRs"`
IndexConfigs map[string]*IndexInfo `json:"IndexConfigs"`
Mirrors []string
}
// MarshalJSON implements a custom marshaler to include legacy fields
// in API responses.
func (sc ServiceConfig) MarshalJSON() ([]byte, error) {
tmp := map[string]interface{}{
"InsecureRegistryCIDRs": sc.InsecureRegistryCIDRs,
"IndexConfigs": sc.IndexConfigs,
"Mirrors": sc.Mirrors,
}
if sc.AllowNondistributableArtifactsCIDRs != nil {
tmp["AllowNondistributableArtifactsCIDRs"] = nil
}
if sc.AllowNondistributableArtifactsHostnames != nil {
tmp["AllowNondistributableArtifactsHostnames"] = nil
}
return json.Marshal(tmp)
}
// NetIPNet is the net.IPNet type, which can be marshalled and
@@ -31,15 +49,17 @@ func (ipnet *NetIPNet) MarshalJSON() ([]byte, error) {
}
// UnmarshalJSON sets the IPNet from a byte array of JSON
func (ipnet *NetIPNet) UnmarshalJSON(b []byte) (err error) {
func (ipnet *NetIPNet) UnmarshalJSON(b []byte) error {
var ipnetStr string
if err = json.Unmarshal(b, &ipnetStr); err == nil {
var cidr *net.IPNet
if _, cidr, err = net.ParseCIDR(ipnetStr); err == nil {
*ipnet = NetIPNet(*cidr)
}
if err := json.Unmarshal(b, &ipnetStr); err != nil {
return err
}
return
_, cidr, err := net.ParseCIDR(ipnetStr)
if err != nil {
return err
}
*ipnet = NetIPNet(*cidr)
return nil
}
// IndexInfo contains information about a registry
@@ -84,32 +104,6 @@ type IndexInfo struct {
Official bool
}
// SearchResult describes a search result returned from a registry
type SearchResult struct {
// StarCount indicates the number of stars this repository has
StarCount int `json:"star_count"`
// IsOfficial is true if the result is from an official repository.
IsOfficial bool `json:"is_official"`
// Name is the name of the repository
Name string `json:"name"`
// IsAutomated indicates whether the result is automated.
//
// Deprecated: the "is_automated" field is deprecated and will always be "false".
IsAutomated bool `json:"is_automated"`
// Description is a textual description of the repository
Description string `json:"description"`
}
// SearchResults lists a collection search results returned from a registry
type SearchResults struct {
// Query contains the query string that generated the search results
Query string `json:"query"`
// NumResults indicates the number of results the query returned
NumResults int `json:"num_results"`
// Results is a slice containing the actual results for the search
Results []SearchResult `json:"results"`
}
// DistributionInspect describes the result obtained from contacting the
// registry to retrieve image metadata
type DistributionInspect struct {

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