moby/cmd/dockerd
Sebastiaan van Stijn 08e4e88482
daemon: raise default minimum API version to v1.24
The daemon currently provides support for API versions all the way back
to v1.12, which is the version of the API that shipped with docker 1.0. On
Windows, the minimum supported version is v1.24.

Such old versions of the client are rare, and supporting older API versions
has accumulated significant amounts of code to remain backward-compatible
(which is largely untested, and a "best-effort" at most).

This patch updates the minimum API version to v1.24, which is the fallback
API version used when API-version negotiation fails. The intent is to start
deprecating older API versions, but no code is removed yet as part of this
patch, and a DOCKER_MIN_API_VERSION environment variable is added, which
allows overriding the minimum version (to allow restoring the behavior from
before this patch).

With this patch the daemon defaults to API v1.24 as minimum:

    docker version
    Client:
     Version:           24.0.2
     API version:       1.43
     Go version:        go1.20.4
     Git commit:        cb74dfc
     Built:             Thu May 25 21:50:49 2023
     OS/Arch:           linux/arm64
     Context:           default

    Server:
     Engine:
      Version:          dev
      API version:      1.44 (minimum version 1.24)
      Go version:       go1.21.3
      Git commit:       0322a29b9ef8806aaa4b45dc9d9a2ebcf0244bf4
      Built:            Mon Dec  4 15:22:17 2023
      OS/Arch:          linux/arm64
      Experimental:     false
     containerd:
      Version:          v1.7.9
      GitCommit:        4f03e100cb967922bec7459a78d16ccbac9bb81d
     runc:
      Version:          1.1.10
      GitCommit:        v1.1.10-0-g18a0cb0
     docker-init:
      Version:          0.19.0
      GitCommit:        de40ad0

Trying to use an older version of the API produces an error:

    DOCKER_API_VERSION=1.23 docker version
    Client:
     Version:           24.0.2
     API version:       1.23 (downgraded from 1.43)
     Go version:        go1.20.4
     Git commit:        cb74dfc
     Built:             Thu May 25 21:50:49 2023
     OS/Arch:           linux/arm64
     Context:           default
    Error response from daemon: client version 1.23 is too old. Minimum supported API version is 1.24, please upgrade your client to a newer version

To restore the previous minimum, users can start the daemon with the
DOCKER_MIN_API_VERSION environment variable set:

    DOCKER_MIN_API_VERSION=1.12 dockerd

API 1.12 is the oldest supported API version on Linux;

    docker version
    Client:
     Version:           24.0.2
     API version:       1.43
     Go version:        go1.20.4
     Git commit:        cb74dfc
     Built:             Thu May 25 21:50:49 2023
     OS/Arch:           linux/arm64
     Context:           default

    Server:
     Engine:
      Version:          dev
      API version:      1.44 (minimum version 1.12)
      Go version:       go1.21.3
      Git commit:       0322a29b9ef8806aaa4b45dc9d9a2ebcf0244bf4
      Built:            Mon Dec  4 15:22:17 2023
      OS/Arch:          linux/arm64
      Experimental:     false
     containerd:
      Version:          v1.7.9
      GitCommit:        4f03e100cb967922bec7459a78d16ccbac9bb81d
     runc:
      Version:          1.1.10
      GitCommit:        v1.1.10-0-g18a0cb0
     docker-init:
      Version:          0.19.0
      GitCommit:        de40ad0

When using the `DOCKER_MIN_API_VERSION` with a version of the API that
is not supported, an error is produced when starting the daemon;

    DOCKER_MIN_API_VERSION=1.11 dockerd --validate
    invalid DOCKER_MIN_API_VERSION: minimum supported API version is 1.12: 1.11

    DOCKER_MIN_API_VERSION=1.45 dockerd --validate
    invalid DOCKER_MIN_API_VERSION: maximum supported API version is 1.44: 1.45

Specifying a malformed API version also produces the same error;

    DOCKER_MIN_API_VERSION=hello dockerd --validate
    invalid DOCKER_MIN_API_VERSION: minimum supported API version is 1.12: hello

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
2023-12-05 23:11:02 +01:00
..
trap migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
cobra.go cmd/dockerd: make cobra templates a const 2023-11-30 13:40:15 +01:00
config.go daemon/config: change DNSConfig.DNS to a []net.IP 2023-11-13 12:22:51 +01:00
config_unix.go remove pre-go1.17 build-tags 2023-05-19 20:38:51 +02:00
config_unix_test.go remove pre-go1.17 build-tags 2023-05-19 20:38:51 +02:00
config_windows.go daemon/config: New(): initialize config with platform-specific defaults 2022-08-17 08:54:32 +02:00
daemon.go daemon: raise default minimum API version to v1.24 2023-12-05 23:11:02 +01:00
daemon_freebsd.go daemon: move check for CPU-realtime daemon options 2022-03-03 19:50:27 +01:00
daemon_linux.go vendor: github.com/containerd/cgroups/v3 v3.0.1 2023-03-08 20:15:17 +09:00
daemon_linux_test.go cmd/dockerd: gracefully shut down the API server 2023-04-26 10:57:28 -04:00
daemon_test.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
daemon_unix.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
daemon_unix_test.go remove pre-go1.17 build-tags 2023-05-19 20:38:51 +02:00
daemon_windows.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
docker.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
docker_unix.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
docker_windows.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
error.go cli: move cobra customizations into cmd/dockerd 2022-12-14 11:37:51 +01:00
genwinres_windows.go use go-winres for cross to create Windows resources 2022-04-14 19:52:35 +02:00
grpclog.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
main_linux_test.go Fix listener parsering regression when no addr set 2023-03-09 23:53:05 +00:00
metrics.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
options.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00
options_test.go cli: remove cli/config package, integrate into cmd/dockerd 2022-12-14 12:52:40 +01:00
README.md Fix readme doc for dockerd 2016-09-01 14:47:51 +08:00
required.go cli: move cobra customizations into cmd/dockerd 2022-12-14 11:37:51 +01:00
service_unsupported.go remove pre-go1.17 build-tags 2023-05-19 20:38:51 +02:00
service_windows.go migrate to github.com/containerd/log v0.1.0 2023-10-11 17:52:23 +02:00

docker.go contains Docker daemon's main function.

This file provides first line CLI argument parsing and environment variable setting.