Commit Graph

1918 Commits

Author SHA1 Message Date
Sebastiaan van Stijn
de52d67ec0 Merge pull request #50279 from dmcgowan/move-libcontainerd
Move libcontainerd and container under daemon
2025-06-30 13:35:37 +02:00
Sebastiaan van Stijn
c5b25bf7de Merge pull request #50225 from robmry/TestRoutedNonGateway
Add TestRoutedNonGateway
2025-06-30 11:56:40 +02:00
Derek McGowan
5419eb1efc Move container to daemon/container
Signed-off-by: Derek McGowan <derek@mcg.dev>
2025-06-27 14:27:21 -07:00
Matthieu MOREL
90ab64cbda fix increment-decrement from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-26 12:07:38 +00:00
Matthieu MOREL
381d9d0723 fix use-errors-new from revive
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-26 12:07:38 +00:00
Sebastiaan van Stijn
53475e1adf integration/container: TestCreateByImageID: minor improvements
- Assert that we're not using empty IDs
- stringid.TruncateID already truncates algorithm, so we can just feed
  it the full id
- Fail early on error, and skip asserting the `resp.ID` to reduce some
  noise;

    === FAIL: github.com/docker/docker/integration/container TestCreateByImageID/image_short-ID (60.33s)
        create_test.go:134: assertion failed: resp.ID is ""
        create_test.go:135: assertion failed: error is not nil: error during connect: Post "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.48/containers/create": EOF

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-23 12:19:44 +02:00
Rob Murray
4ccbca1efe Add TestRoutedNonGateway
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-18 17:21:57 +01:00
Sebastiaan van Stijn
0c56619d79 Merge pull request #50218 from thaJeztah/deprecate_execconfig_detach
api/types/container: deprecate ExecOptions.Detach
2025-06-18 17:52:39 +02:00
Sebastiaan van Stijn
0c182d4d57 api/types/container: deprecate ExecOptions.Detach
This field was added in 5130fe5d38, which
added it for use as intermediate struct when parsing CLI flags (through
`runconfig.ParseExec`) in c786a8ee5e.

Commit 9d9dff3d0d rewrote the CLI to use
Cobra, and as part of this introduced a separate `execOptions` type in
`api/client/container`.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-17 12:38:33 +02:00
Rob Murray
1ad9599da7 Drop DOCKER-ISOLATION rules
The Inter-Network Communication rules in the iptables chains
DOCKER-ISOLATION-STAGE-1 / DOCKER-ISOLATION-STAGE-2 (which are
called from filter-FORWARD) currently:
- Block access from containers in one bridge network, to ports
  published to host addresses by containers in other bridge
  networks, when the userland-proxy is disabled.
  - But, that access is allowed when the proxy is enabled.
- Block access to all ports on container addresses in gateway
  mode "nat-unprotected" networks.
  - But, those ports can be accessed from anywhere else, including
    other hosts. Just not other bridge networks.
- Allow access from containers in "nat" bridge networks to published
  ports on container addresses in "routed" networks. But, to do that,
  extra INC rules are added for the routed network.

The INC rules are no longer needed to block access from containers
in one network to unpublished ports on container addresses in
other networks. Direct routing to containers in NAT networks is
blocked by the "raw-PREROUTING" rules that block access from
untrusted interfaces (all interfaces apart from the network's
own bridge).

Drop these INC rules to resolve the inconsistencies listed above,
with this change:
- Published ports on host addresses can be accessed from containers
  in other networks (even without the userland-proxy).
- The rules for direct routing between bridge networks are the same
  as the rules for direct routing from outside the Docker host
  (allowed for gw modes "routed" and "nat-unprotected", disallowed
  for "nat").

Fewer rules, so it's simpler, and perhaps slightly faster.

Internal networks (with no access to networks outside the host)
are also implemented using rules in the DOCKER-ISOLATION chains.
This change moves those rules to a new chain, DOCKER-INTERNAL,
and drops the DOCKER-ISOLATION chains.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-06-16 14:54:31 +01:00
Matthieu MOREL
6d737371b8 fix comparison rule from errorlint
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>

Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-13 08:26:56 +00:00
Sebastiaan van Stijn
d3d20b9195 integration-cli: TestCopyFromContainerPathIsNotDir: adjust for win 2025
It looks like the error returned by Windows changed in Windows 2025; before
Windows 2025, this produced a `ERROR_INVALID_NAME`;

    The filename, directory name, or volume label syntax is incorrect.

But Windows 2025 produces a `ERROR_DIRECTORY` ("The directory name is invalid."):

    CreateFile \\\\?\\Volume{d9f06b05-0405-418b-b3e5-4fede64f3cdc}\\windows\\system32\\drivers\\etc\\hosts\\: The directory name is invalid.

Docs; https://learn.microsoft.com/en-us/windows/win32/debug/system-error-codes--0-499-

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-06-12 15:18:17 +02:00
Matthieu MOREL
19f5ac3c81 fix initClause from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:59 +02:00
Matthieu MOREL
469afa5f8f fix httpNoBody from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:58 +02:00
Matthieu MOREL
e5be7b54b1 fix yodaStyleExpr from go-critic
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-06-07 09:57:58 +02:00
Rob Murray
9663b36b6d Merge pull request #50054 from robmry/fix_port_mapping
Avoid selecting duplicate host ports for mappings to 0.0.0.0 and specific addresses
2025-06-04 16:46:29 +01:00
Sebastiaan van Stijn
4970333621 integration: remove // import comments
These comments were added to enforce using the correct import path for
our packages ("github.com/docker/docker", not "github.com/moby/moby").
However, when working in go module mode (not GOPATH / vendor), they have
no effect, so their impact is limited.

Remove these imports in preparation of migrating our code to become an
actual go module.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-30 15:59:14 +02:00
Rob Murray
b43afbf898 Merge pull request #50098 from robmry/remove_docker-user_return_rule
iptables: Drop explicit RETURN rule from DOCKER-USER
2025-05-29 11:27:54 +01:00
Rob Murray
d6620915db portallocator: always check for ports allocated for 0.0.0.0/::
We set SO_REUSEADDR on sockets used for host port mappings by
docker-proxy - which means it's possible to bind the same port
on a specific address as well as 0.0.0.0/::.

For TCP sockets, an error is raised when listen() is called on
both sockets - and the port allocator will be called again to
avoid the clash (if the port was allocated from a range, otherwise
the container will just fail to start).

But, for UDP sockets, there's no listen() - so take more care
to avoid the clash in the portallocator.

The port allocator keeps a set of allocated ports for each of
the host IP addresses it's seen, including 0.0.0.0/::. So, if a
mapping to 0.0.0.0/:: is requested, find a port that's free in
the range for each of the known IP addresses (but still only
mark it as allocated against 0.0.0.0/::). And, if a port is
requested for specific host addresses, make sure it's also
free in the corresponding 0.0.0.0/:: set (but only mark it as
allocated against the specific addresses - because the same
port can be allocated against a different specific address).

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-28 14:00:33 +01:00
Paweł Gronowski
e37efd4c2d Merge pull request #50068 from mmorel-35/github.com/containerd/errdefs
refactor: replace uses of errdefs package
2025-05-28 12:57:15 +00:00
Rob Murray
19dc38f79b Listen on mapped host ports before mapping more ports
Because we set SO_REUSEADDR on sockets for host ports, if there
are port mappings for INADDR_ANY (the default) as well as for
specific host ports - bind() cannot be used to detect clashes.

That means, for example, on daemon startup, if the port allocator
returns the first port in its ephemeral range for a specific host
adddress, and the next port mapping is for 0.0.0.0 - the same port
is returned and both bind() calls succeed. Then, the container
fails to start later when listen() spots the problem and it's too
late to find another port.

So, bind and listen to each set of ports as they're allocated
instead of just binding.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-28 11:38:59 +01:00
Rob Murray
dc519a0f18 iptables: Drop explicit RETURN rule from DOCKER-USER
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-28 11:11:56 +01:00
Matthieu MOREL
14852fcd82 integration: replace uses of errdefs package
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
2025-05-28 05:39:50 +00:00
Rob Murray
e48ea1c6e0 Make integration tests ready for nftables
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-27 17:50:03 +01:00
Rob Murray
f9f0db0789 Add nftables support to testutil SetFilterForwardPolicies
Because nftables tables/chain aren't fixed, like they are
in iptables - this change makes an assumption about the
bridge driver's naming.

Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-27 17:50:03 +01:00
Rob Murray
7ea0e60dde Skip test TestBridgeINCRouted in rootless mode
Signed-off-by: Rob Murray <rob.murray@docker.com>
2025-05-27 17:50:03 +01:00
Paweł Gronowski
072483f9d7 c8d/delete: Require --force when deleting platforms
When deleting specific platforms from a multi-platform image, there's
potential risk as platform-specific content might be shared across
images/containers.

For now, require `force` parameter to make the user aware.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-26 17:43:10 +02:00
Paweł Gronowski
30da69d694 c8d/delete: Support deleting specific platforms
This change adds the ability to delete a specific platform from a
multi-platform image.

Previously, image deletion was an all-or-nothing operation - when
deleting a multi-platform image, all platforms would be removed
together. This change allows users to selectively remove individual
platforms from a multi-architecture image while keeping other platforms
intact.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-26 17:43:10 +02:00
Sebastiaan van Stijn
7148c6a5f5 Merge pull request #42300 from thaJeztah/carry_39384_remove_v2_schema1_push
Remove support for pulling v2 schema1
2025-05-21 23:43:41 +02:00
Sebastiaan van Stijn
0b1c7a8306 api/types: move ServiceUpdateOptions to api/types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 16:30:33 +02:00
Sebastiaan van Stijn
31d62930f7 api/types: move ServiceCreateOptions to api/types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 16:30:31 +02:00
Sebastiaan van Stijn
5ad0867236 api/types: move TaskListOptions to api/types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 16:30:03 +02:00
Sebastiaan van Stijn
b13528522a api/types: move ServiceListOptions, ServiceInspectOptions to types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 13:41:59 +02:00
Sebastiaan van Stijn
7937f0846c Merge pull request #50025 from thaJeztah/move_builder_options
api/types: move build-related types to api/types/build
2025-05-19 13:40:40 +02:00
Sebastiaan van Stijn
a411a39be0 api/types: move ConfigCreateResponse, ConfigListOptions to types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 09:39:23 +02:00
Sebastiaan van Stijn
23117afca8 api/types: move SecretCreateResponse, SecretListOptions to types/swarm
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 09:36:48 +02:00
Sebastiaan van Stijn
3d1e4d9002 api/types: move build-related types to api/types/build
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-19 09:30:27 +02:00
Sebastiaan van Stijn
bb7dbaafcd api/types: move BuildResult to api/types/build.Result
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-17 00:39:09 +02:00
Sebastiaan van Stijn
6505d3877c API: /info: remove BridgeNfIptables, BridgeNfIp6tables fields
The `BridgeNfIptables` and `BridgeNfIp6tables` fields in the
`GET /info` response were deprecated in API v1.48, and are now omitted
in API v1.50.

With this patch, old API version continue to return the field:

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.48/info | jq .BridgeNfIp6tables
    false

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.48/info | jq .BridgeNfIptables
    false

Omitting the field in API v1.50 and above

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.50/info | jq .BridgeNfIp6tables
    null

    curl -s --unix-socket /var/run/docker.sock http://localhost/v1.50/info | jq .BridgeNfIptables
    null

This reverts commit eacbbdeec6, and re-applies
a variant of 5d2006256f

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 19:49:52 +02:00
Sebastiaan van Stijn
7130cd4f16 Remove DockerSchema1RegistrySuite schema 2 version 1 tests
Also remove the DOCKER_ALLOW_SCHEMA1_PUSH_DONOTUSE from Jenkins

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-16 18:00:06 +02:00
Paweł Gronowski
9095698a5c daemon: Discover devices and include in system info
Add ability for the device driver to implement a device discovery
mechanism and expose discovered devices in the `docker info` output.

Currently it's only implemented for CDI devices.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-16 17:03:29 +02:00
Paweł Gronowski
bcc7954343 Merge pull request #49707 from jsternberg/containerd-system-df
containerd: include present content size in layer disk usage calculation
2025-05-16 10:45:14 +00:00
Paweł Gronowski
4cecce03f6 daemon: Enable CDI by default
CDI will now be enabled by default unless opted-out by setting `cdi`
feature to `false`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2025-05-15 22:13:19 +02:00
Jonathan A. Sternberg
f07242f6d7 containerd: include present content size in disk usage calculations
The present content size is included in the image size usage and should
be included in the total size that the layer takes up on disk.

This prevents an issue where the reclaimable amount reported by the CLI
was a negative number.

This also updates the `/system/df` endpoint to use a new type that
computes information that was previously computed by the CLI. Computing
these in the server should require less work from the CLI and ensure
the calculations are more accurate because the CLI doesn't have to
reconstruct the numbers.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-05-15 09:46:51 -05:00
Sebastiaan van Stijn
a6ad2f2157 Merge pull request #49988 from thaJeztah/flaky_TestPortMappedHairpinWindows
integration/networking: mark TestPortMappedHairpinWindows as flaky
2025-05-15 13:12:00 +02:00
Sebastiaan van Stijn
b3ed54db81 integration/networking: mark TestPortMappedHairpinWindows as flaky
This test is failing frequently on Windows;

    === FAIL: github.com/docker/docker/integration/networking TestPortMappedHairpinWindows (12.37s)
        nat_windows_test.go:108: assertion failed: error is not nil: Post "http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.49/containers/1181d6510a2f55c742b7b183aa7324eddbc213cd15797428c4062dcb031fb825/start": context deadline exceeded
        panic.go:636: assertion failed: error is not nil: Error response from daemon: error while removing network: network clientnet has active endpoints (name:"laughing_lederberg" id:"8605ebbc2c7c")

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-15 10:57:00 +02:00
Jonathan A. Sternberg
61646c8bfc containerd: remove unleaseSnapshotsFromDeletedConfigs
Removes workaround for https://github.com/moby/buildkit/issues/3797 now
that the underlying issue is fixed.

Signed-off-by: Jonathan A. Sternberg <jonathan.sternberg@docker.com>
2025-05-14 09:20:22 -05:00
Rob Murray
2154b9c646 Merge pull request #49976 from thaJeztah/fix_godoc
integration, libnetwork: fix some godoc comments (ST1020)
2025-05-14 10:50:53 +01:00
Sebastiaan van Stijn
1028b123e8 integration, libnetwork: fix some godoc comments (ST1020)
integration/internal/network/ops.go:137:1: ST1020: comment on exported function WithIPAMRange should be of the form "WithIPAMRange ..." (staticcheck)
    // WithIPAM adds an IPAM with the specified Subnet, IPRange and Gateway to the network
    ^
    libnetwork/bitmap/sequence.go:50:1: ST1020: comment on exported function New should be of the form "New ..." (staticcheck)
    // NewHandle returns a new Bitmap of ordinals in the interval [0, n).
    ^
    libnetwork/diagnostic/server.go:61:1: ST1020: comment on exported method HandleFunc should be of the form "HandleFunc ..." (staticcheck)
    // Handle registers the handler function for the given pattern,
    ^
    libnetwork/endpoint.go:388:1: ST1020: comment on exported method Key should be of the form "Key ..." (staticcheck)
    // endpoint Key structure : endpoint/network-id/endpoint-id
    ^
    libnetwork/network.go:574:1: ST1020: comment on exported method MarshalJSON should be of the form "MarshalJSON ..." (staticcheck)
    // TODO : Can be made much more generic with the help of reflection (but has some golang limitations)
    ^
    libnetwork/network.go:633:1: ST1020: comment on exported method UnmarshalJSON should be of the form "UnmarshalJSON ..." (staticcheck)
    // TODO : Can be made much more generic with the help of reflection (but has some golang limitations)
    ^

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-14 10:11:59 +02:00
Sebastiaan van Stijn
3bbdda696d use container.ContainerState consts in tests
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2025-05-13 15:03:34 +02:00