Commit Graph

50448 Commits

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