08e4e88482
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>
83 lines
2.7 KiB
Go
83 lines
2.7 KiB
Go
package config // import "github.com/docker/docker/daemon/config"
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/containerd/log"
|
|
)
|
|
|
|
const (
|
|
// StockRuntimeName is used by the 'default-runtime' flag in dockerd as the
|
|
// default value. On Windows keep this empty so the value is auto-detected
|
|
// based on other options.
|
|
StockRuntimeName = ""
|
|
|
|
// minAPIVersion represents Minimum REST API version supported
|
|
// Technically the first daemon API version released on Windows is v1.25 in
|
|
// engine version 1.13. However, some clients are explicitly using downlevel
|
|
// APIs (e.g. docker-compose v2.1 file format) and that is just too restrictive.
|
|
// Hence also allowing 1.24 on Windows.
|
|
minAPIVersion string = "1.24"
|
|
)
|
|
|
|
// BridgeConfig is meant to store all the parameters for both the bridge driver and the default bridge network. On
|
|
// Windows: 1. "bridge" in this context reference the nat driver and the default nat network; 2. the nat driver has no
|
|
// specific parameters, so this struct effectively just stores parameters for the default nat network.
|
|
type BridgeConfig struct {
|
|
DefaultBridgeConfig
|
|
}
|
|
|
|
type DefaultBridgeConfig struct {
|
|
commonBridgeConfig
|
|
|
|
// MTU is not actually used on Windows, but the --mtu option has always
|
|
// been there on Windows (but ignored).
|
|
MTU int `json:"mtu,omitempty"`
|
|
}
|
|
|
|
// Config defines the configuration of a docker daemon.
|
|
// It includes json tags to deserialize configuration from a file
|
|
// using the same names that the flags in the command line uses.
|
|
type Config struct {
|
|
CommonConfig
|
|
|
|
// Fields below here are platform specific. (There are none presently
|
|
// for the Windows daemon.)
|
|
}
|
|
|
|
// GetExecRoot returns the user configured Exec-root
|
|
func (conf *Config) GetExecRoot() string {
|
|
return ""
|
|
}
|
|
|
|
// GetInitPath returns the configured docker-init path
|
|
func (conf *Config) GetInitPath() string {
|
|
return ""
|
|
}
|
|
|
|
// IsSwarmCompatible defines if swarm mode can be enabled in this config
|
|
func (conf *Config) IsSwarmCompatible() error {
|
|
return nil
|
|
}
|
|
|
|
// ValidatePlatformConfig checks if any platform-specific configuration settings are invalid.
|
|
func (conf *Config) ValidatePlatformConfig() error {
|
|
if conf.MTU != 0 && conf.MTU != DefaultNetworkMtu {
|
|
log.G(context.TODO()).Warn(`WARNING: MTU for the default network is not configurable on Windows, and this option will be ignored.`)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// IsRootless returns conf.Rootless on Linux but false on Windows
|
|
func (conf *Config) IsRootless() bool {
|
|
return false
|
|
}
|
|
|
|
func setPlatformDefaults(cfg *Config) error {
|
|
cfg.Root = filepath.Join(os.Getenv("programdata"), "docker")
|
|
cfg.ExecRoot = filepath.Join(os.Getenv("programdata"), "docker", "exec-root")
|
|
cfg.Pidfile = filepath.Join(cfg.Root, "docker.pid")
|
|
return nil
|
|
}
|