Commit Graph

50036 Commits

Author SHA1 Message Date
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
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
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