Commit graph

5666 commits

Author SHA1 Message Date
Sebastiaan van Stijn
4f9db655ed
portmapper: move userland-proxy lookup to daemon config
When mapping a port with the userland-proxy enabled, the daemon would
perform an "exec.LookPath" for every mapped port (which, in case of
a range of ports, would be for every port in the range).

This was both inefficient (looking up the binary for each port), inconsistent
(when running in rootless-mode, the binary was looked-up once), as well as
inconvenient, because a missing binary, or a mis-configureed userland-proxy-path
would not be detected daeemon startup, and not produce an error until starting
the container;

    docker run -d -P nginx:alpine
    4f7b6589a1680f883d98d03db12203973387f9061e7a963331776170e4414194
    docker: Error response from daemon: driver failed programming external connectivity on endpoint romantic_wiles (7cfdc361821f75cbc665564cf49856cf216a5b09046d3c22d5b9988836ee088d): fork/exec docker-proxy: no such file or directory.

However, the container would still be created (but invalid);

    docker ps -a
    CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS    PORTS     NAMES
    869f41d7e94f   nginx:alpine   "/docker-entrypoint.…"   10 seconds ago   Created             romantic_wiles

This patch changes how the userland-proxy is configured;

- The path of the userland-proxy is now looked up / configured at daemon
  startup; this is similar to how the proxy is configured in rootless-mode.
- A warning is logged when failing to lookup the binary.
- If the daemon is configured with "userland-proxy" enabled, an error is
  produced, and the daemon will refuse to start.
- The "proxyPath" argument for newProxyCommand() (in libnetwork/portmapper)
  is now required to be set. It no longer looks up the executable, and
  produces an error if no path was provided. While this change was not
  required, it makes the daemon config the canonical source of truth, instead
  of logic spread accross multiplee locations.

Some of this logic is a change of behavior, but these changes were made with
the assumption that we don't want to support;

- installing the userland proxy _after_ the daemon was started
- moving the userland proxy (or installing a proxy with a higher
  preference in PATH)

With this patch:

Validating the config produces an error if the binary is not found:

    dockerd --validate
    WARN[2023-12-29T11:36:39.748699591Z] failed to lookup default userland-proxy binary       error="exec: \"docker-proxy\": executable file not found in $PATH"
    userland-proxy is enabled, but userland-proxy-path is not set

Disabling userland-proxy prints a warning, but validates as "OK":

    dockerd --userland-proxy=false --validate
    WARN[2023-12-29T11:38:30.752523879Z] ffailed to lookup default userland-proxy binary       error="exec: \"docker-proxy\": executable file not found in $PATH"
    configuration OK

Speficying a non-absolute path produces an error:

    dockerd --userland-proxy-path=docker-proxy --validate
    invalid userland-proxy-path: must be an absolute path: docker-proxy

Befor this patch, we would not validate this path, which would allow the daemon
to start, but fail to map a port;

    docker run -d -P nginx:alpine
    4f7b6589a1680f883d98d03db12203973387f9061e7a963331776170e4414194
    docker: Error response from daemon: driver failed programming external connectivity on endpoint romantic_wiles (7cfdc361821f75cbc665564cf49856cf216a5b09046d3c22d5b9988836ee088d): fork/exec docker-proxy: no such file or directory.

Specifying an invalid userland-proxy-path produces an error as well:

    dockerd --userland-proxy-path=/usr/local/bin/no-such-binary --validate
    userland-proxy-path is invalid: stat /usr/local/bin/no-such-binary: no such file or directory

    mkdir -p /usr/local/bin/not-a-file
    dockerd --userland-proxy-path=/usr/local/bin/not-a-file --validate
    userland-proxy-path is invalid: exec: "/usr/local/bin/not-a-file": is a directory

    touch /usr/local/bin/not-an-executable
    dockerd --userland-proxy-path=/usr/local/bin/not-an-executable --validate
    userland-proxy-path is invalid: exec: "/usr/local/bin/not-an-executable": permission denied

Same when using the daemon.json config-file;

    echo '{"userland-proxy-path":"no-such-binary"}' > /etc/docker/daemon.json
    dockerd --validate
    unable to configure the Docker daemon with file /etc/docker/daemon.json: merged configuration validation from file and command line flags failed: invalid userland-proxy-path: must be an absolute path: no-such-binary

    dockerd --userland-proxy-path=hello --validate
    unable to configure the Docker daemon with file /etc/docker/daemon.json: the following directives are specified both as a flag and in the configuration file: userland-proxy-path: (from flag: hello, from file: /usr/local/bin/docker-proxy)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-29 16:23:18 +01:00
Derek McGowan
cf1ea9237c
Add dangling image reference on delete when last image has children
Signed-off-by: Derek McGowan <derek@mcg.dev>
2023-12-19 05:56:43 -08:00
Sebastiaan van Stijn
294274e10e
Merge pull request #46847 from thaJeztah/uncontainerise_TestDaemonNoSpaceLeftOnDeviceError
un-containerize TestDaemonNoSpaceLeftOnDeviceError
2023-12-07 20:02:29 +01:00
Paweł Gronowski
90dfb1c8ad
c8d/integration-cli: Adjust TestBuildClearCmd
Config serialization performed by the graphdriver implementation
maintained the distinction between an empty array and having no Cmd set.

With containerd integration we serialize the OCI types directly that use
the `omitempty` option which doesn't persist that distinction.

Considering that both values should have exactly the same semantics (no
cmd being passed) it should be fine if in this case the Cmd would be
null instead of an empty array.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-12-07 14:17:35 +01:00
Paweł Gronowski
bc94dfc7d2
hack: Load special images on demand
Rewrite `.build-empty-images` shell script that produced special images
(emptyfs with no layers, and empty danglign image) to a Go functions
that construct the same archives in a temporary directory.

Use them to load these images on demand only in the tests that need
them.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-12-06 17:16:37 +01:00
Sebastiaan van Stijn
713c7d49a1
integration(-cli): remove skips for old daemon versions (<20.10)
This removes various skips that accounted for running the integration tests
against older versions of the daemon before 20.10 (API version v1.41). Those
versions are EOL, and we don't run tests against them.

This reverts most of e440831802, and similar
PRs.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-05 01:03:50 +01:00
Sebastiaan van Stijn
7f68e3107e
integration-cli: TestAPIClientVersionOldNotSupported: use daemon API version
Use the minimum API version as advertised by the test-daemon, instead of the
hard-coded API version from code.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-04 22:58:47 +01:00
Sebastiaan van Stijn
aa2fa2caa3
un-containerize TestDaemonNoSpaceLeftOnDeviceError
Commit 59b83d8aae containerized these steps,
as they didn't work well on Debian Jessie:

> Because the `mount` here will sometimes fail when run in `debian:jessie`,
> which is what the environrment hosting the test suite is running if run
> from the `Makefile`.
> Also, why the heck not containerize it, all the things.

Follow-up commits, such as 228d74842f, and
1c5806cf57 updated the Debian distro, but
also updated this comment, losing the original context (the issue was
(originally) related to Debian Jessie).

This patch changes the test back to not use containers, which seems to
work fine (at least "it worked on my machine").

    make TEST_IGNORE_CGROUP_CHECK=1 TEST_FILTER=TestDaemonNoSpaceLeftOnDeviceError DOCKER_GRAPHDRIVER=overlay2 test-integration

    === RUN   TestDockerDaemonSuite/TestDaemonNoSpaceLeftOnDeviceError
        check_test.go:589: [df36ad96a412b] daemon is not started
    --- PASS: TestDockerDaemonSuite (5.12s)
        --- PASS: TestDockerDaemonSuite/TestDaemonNoSpaceLeftOnDeviceError (5.12s)

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-04 18:51:15 +01:00
Tianon Gravi
488fe76eb8
Merge pull request #45789 from thaJeztah/update_debian
Dockerfile: update to Debian "bookworm", and update frozen images to debian:bookworm-slim
2023-11-30 12:33:48 -08:00
Sebastiaan van Stijn
75546e1e46
Merge pull request #46865 from vvoland/c8d-fix-DockerRegistryAuthTokenSuite
c8d/integration-cli: Adjust DockerRegistryAuthTokenSuite
2023-11-30 17:36:45 +01:00
Sebastiaan van Stijn
08035dc805
Merge pull request #46868 from vvoland/c8d-skip-TestListDanglingImagesWithDigests
c8d/integration-cli: Skip part of TestListDanglingImagesWithDigests
2023-11-30 16:16:02 +01:00
Paweł Gronowski
fcb89da9c2
c8d/integration-cli: Skip TestListDanglingImagesWithDigests
Skip TestListDanglingImagesWithDigests which tests graphdriver
implementation specific behavior of `docker images --filter
dangling=true`.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-11-30 14:01:22 +01:00
Sebastiaan van Stijn
3bfb6a9420
frozen images: update to debian:bookworm-slim
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-30 12:01:06 +01:00
Sebastiaan van Stijn
e72c4818c4
Dockerfile: update to Debian "bookworm" (current stable)
Also switch yamllint to be installed from debian's packages, which are
currently at v1.29.0.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-30 11:50:34 +01:00
Paweł Gronowski
e262cd38ad
c8d/integration-cli: Adjust DockerRegistryAuthTokenSuite
The auth service error response is not a part of the spec and containerd
doesn't parse it like the Docker's distribution does.

Check for containerd specific errors instead.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-11-29 14:28:18 +01:00
Sebastiaan van Stijn
c3eed9fa3e
integration-cli: fix TestDaemonICC tests for newer iptables versions
Debian Woodworm ships with a newer version of iptables, which caused two
tests to fail:

    === FAIL: amd64.integration-cli TestDockerDaemonSuite/TestDaemonICCLinkExpose (1.18s)
    docker_cli_daemon_test.go:841: assertion failed: false (matched bool) != true (true bool): iptables output should have contained "DROP.*all.*ext-bridge6.*ext-bridge6", but was "Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target prot opt in out source destination \n 0 0 DOCKER-USER 0 -- * * 0.0.0.0/0 0.0.0.0/0 \n 0 0 DOCKER-ISOLATION-STAGE-1 0 -- * * 0.0.0.0/0 0.0.0.0/0 \n 0 0 ACCEPT 0 -- * ext-bridge6 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED\n 0 0 DOCKER 0 -- * ext-bridge6 0.0.0.0/0 0.0.0.0/0 \n 0 0 ACCEPT 0 -- ext-bridge6 !ext-bridge6 0.0.0.0/0 0.0.0.0/0 \n 0 0 DROP 0 -- ext-bridge6 ext-bridge6 0.0.0.0/0 0.0.0.0/0 \n"
    --- FAIL: TestDockerDaemonSuite/TestDaemonICCLinkExpose (1.18s)

    === FAIL: amd64.integration-cli TestDockerDaemonSuite/TestDaemonICCPing (1.19s)
    docker_cli_daemon_test.go:803: assertion failed: false (matched bool) != true (true bool): iptables output should have contained "DROP.*all.*ext-bridge5.*ext-bridge5", but was "Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target prot opt in out source destination \n 0 0 DOCKER-USER 0 -- * * 0.0.0.0/0 0.0.0.0/0 \n 0 0 DOCKER-ISOLATION-STAGE-1 0 -- * * 0.0.0.0/0 0.0.0.0/0 \n 0 0 ACCEPT 0 -- * ext-bridge5 0.0.0.0/0 0.0.0.0/0 ctstate RELATED,ESTABLISHED\n 0 0 DOCKER 0 -- * ext-bridge5 0.0.0.0/0 0.0.0.0/0 \n 0 0 ACCEPT 0 -- ext-bridge5 !ext-bridge5 0.0.0.0/0 0.0.0.0/0 \n 0 0 DROP 0 -- ext-bridge5 ext-bridge5 0.0.0.0/0 0.0.0.0/0 \n"
    --- FAIL: TestDockerDaemonSuite/TestDaemonICCPing (1.19s)

Both the `TestDaemonICCPing`, and `TestDaemonICCLinkExpose` test were introduced
in dd0666e64f. These tests called `iptables` with
the `-n` (`--numeric`) option, which prevents it from doing a reverse-DNS lookup
as an optimization.

However, the `-n` option did not have an effect to the `prot` column before
commit [da8ecc62dd765b15df84c3aa6b83dcb7a81d4ffa] (iptables < v1.8.9 or v1.8.8).
Newer versions, such as the iptables version shipping with Debian Woodworm do,
so we need to update the expected output for this version.

This patch removes the `-n` option, to keep the test more portable, also when
run non-containerized, and removes the use of regular expressions to check the
result, as these regular expressions were quite permissive (using `.*` wild-
card matching). Instead, we're getting the

With this change;

make DOCKER_GRAPHDRIVER=vfs TEST_FILTER=TestDaemonICC TEST_IGNORE_CGROUP_CHECK=1 test-integration
...
--- PASS: TestDockerDaemonSuite (139.11s)
--- PASS: TestDockerDaemonSuite/TestDaemonICCLinkExpose (54.62s)
--- PASS: TestDockerDaemonSuite/TestDaemonICCPing (84.48s)

[da8ecc62dd765b15df84c3aa6b83dcb7a81d4ffa]: https://git.netfilter.org/iptables/commit/?id=da8ecc62dd765b15df84c3aa6b83dcb7a81d4ffa

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-28 18:58:03 +01:00
Paweł Gronowski
9b399814e7
integration-cli/TestCrossRepositoryLayerPush: Change repo name
Change the repo name used as for an intermediate image so it doesn't
try to mount from the image pushed by `TestBuildMultiStageImplicitPull`.

Before this patch, this test failed because the distribution.source
labels are not cleared between tests and the busybox content still has
the distribution.source label pointing to the `dockercli/testf`
repository which is no longer present in the test registry.
So both `dockercli/busybox` and `dockercli/testf` are equally valid
mount candidates for `dockercli/crossrepopush` and containerd algorithm
just happens to select the last one.

This changes the repo name to not have the common repository component
(`dockercli`) with the `dockercli/testf` repository.

Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
2023-11-27 18:12:50 +01:00
Sebastiaan van Stijn
981a878cf5
vendor: github.com/docker/go-connections fa09c952e3ea (v0.5.0-dev)
0b8c1f4e07...fa09c952e3

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-11-10 23:23:37 +01:00
Sebastiaan van Stijn
49cea49cfa
Merge pull request #45905 from akerouanton/endpoint-specific-mac-address
api: Add a field MacAddress to EndpointSettings
2023-11-07 16:37:27 +01:00
Sebastiaan van Stijn
050e6066af
Merge pull request #46517 from rumpl/c8d-windows-pull-linux
c8d: test a backend dependent error on pull
2023-11-03 09:28:16 +01:00
Sebastiaan van Stijn
8068038a60
Merge pull request #46758 from rumpl/c8d-image-list-digest
Skip the busybox digest check when containerd is enabled
2023-11-03 09:16:48 +01:00
Djordje Lukic
3c2b06099d
Skip TestPullManifestList when using containerd
This test is very weird, the Size in the manifests that it creates is
wrong, graph drivers only print a warning in that case but containerd
fails because it verifies more things. The media types are also wrong in
the containerd case, the manifest list forces the media type to be
"schema2.MediaTypeManifest" but in the containerd case the media type is
an OCI one.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-11-02 16:09:35 +01:00
Djordje Lukic
6ca1b9e4ce
Skip the busybox digest check when containerd is enabled
We always have a digest with containerd.

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
2023-11-02 14:07:49 +01:00
Frank Villaro-Dixon
123ade3763 builder/dockerfile: errmsg: quote build target
The build target is not quoted and it makes it difficult for some
persons to see what the problem is.

By quoting it we emphasize that the target name is variable.

Signed-off-by: Frank Villaro-Dixon <frank.villarodixon@merkle.com>
2023-11-02 09:38:14 +01:00
Albin Kerouanton
59c5f6e35b
integration-cli: mark dockerCmdWithFail as an helper function
Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-10-25 22:55:59 +02:00
Albin Kerouanton
ee9f0ed895
api: Deprecate ContainerConfig.MacAddress
Having a sandbox/container-wide MacAddress field makes little sense
since a container can be connected to multiple networks at the same
time. This field is an artefact of old times where a container could be
connected to a single network only.

As we now have a way to specify per-endpoint mac address, this field is
now deprecated.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-25 22:55:59 +02:00
Albin Kerouanton
91eee33f62
api: ContainerCreate: return an error when config is nil
The same error is already returned by `(*Daemon).containerCreate()` but
since this function is also called by the cluster executor, the error
has to be duplicated.

Doing that allows to remove a nil check on container config in
`postContainersCreate`.

Signed-off-by: Albin Kerouanton <albinker@gmail.com>
2023-10-25 21:25:17 +02:00
Sebastiaan van Stijn
5a72ed3406
integration-cli: remove deprecated dockerCmd and waitRun utilities
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 18:02:30 +02:00
Sebastiaan van Stijn
06115bf82c
integration-cli: DockerCLIPruneSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 18:02:16 +02:00
Sebastiaan van Stijn
285ab8c861
integration-cli: DockerCLIPluginsSuite: replace dockerCmd
Also fixed some variables that shadowed package-level vars, and
used consts for fixed values.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 18:02:04 +02:00
Sebastiaan van Stijn
e28da7686e
integration-cli: DockerCLIPluginLogDriverSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 18:01:46 +02:00
Sebastiaan van Stijn
a837cb444c
integration-cli: DockerExternalVolumeSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 18:01:37 +02:00
Sebastiaan van Stijn
5f884478e5
integration-cli: DockerCLIImportSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 18:01:24 +02:00
Sebastiaan van Stijn
885eceba1d
integration-cli: DockerCLITopSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 18:01:09 +02:00
Sebastiaan van Stijn
6ce6b63482
integration-cli: DockerCLIHistorySuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 18:00:56 +02:00
Sebastiaan van Stijn
268e72f10f
integration-cli: DockerCLIRestartSuite: replace dockerCmd and waitRun
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 18:00:39 +02:00
Sebastiaan van Stijn
c388416aac
integration-cli: DockerCLICreateSuite: replace dockerCmd and waitRun
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 18:00:27 +02:00
Sebastiaan van Stijn
5c297fcc09
integration-cli: DockerCLIStatsSuite: replace dockerCmd and waitRun
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 18:00:00 +02:00
Sebastiaan van Stijn
7d2a6f2030
integration-cli: DockerCLICommitSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 17:59:48 +02:00
Sebastiaan van Stijn
a4522b6a8f
integration-cli: DockerCLIStartSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 17:59:34 +02:00
Sebastiaan van Stijn
f7ddfdbae6
integration-cli: DockerCLIUpdateSuite: replace dockerCmd and waitRun
Also adding some consts for fixed values.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 17:59:24 +02:00
Sebastiaan van Stijn
d1108b8a06
integration-cli: DockerDaemonSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 17:59:10 +02:00
Sebastiaan van Stijn
9c161cc65a
integration-cli: DockerCLIVolumeSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 17:58:57 +02:00
Sebastiaan van Stijn
f482857959
integration-cli: DockerCLIImagesSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 17:58:12 +02:00
Sebastiaan van Stijn
f1102e98bb
integration-cli: DockerCLIPortSuite: replace dockerCmd and waitRun
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 17:57:41 +02:00
Sebastiaan van Stijn
ba4d491562
integration-cli: DockerCLIRmiSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 17:57:31 +02:00
Sebastiaan van Stijn
16e4bc9827
integration-cli: DockerCLISearchSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 17:54:11 +02:00
Sebastiaan van Stijn
89d7b77022
integration-cli: DockerRegistrySuite: replace dockerCmd
Also renaming vars that collided with package-level vars
and using consts for fixed values.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 17:53:43 +02:00
Sebastiaan van Stijn
c867ac4527
integration-cli: DockerCLICpSuite: replace dockerCmd
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 17:52:44 +02:00
Sebastiaan van Stijn
980a5bc72a
integration-cli: DockerCLIBuildSuite: replace dockerCmd
Also adding some consts for fixed values.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-10-19 17:52:39 +02:00