diff --git a/.github/workflows/.windows.yml b/.github/workflows/.windows.yml index 7d9c1410a2..48f73d9518 100644 --- a/.github/workflows/.windows.yml +++ b/.github/workflows/.windows.yml @@ -344,8 +344,11 @@ jobs: "--register-service" If ("${{ inputs.storage }}" -eq "graphdriver") { # Make the env-var visible to the service-managed dockerd, as there's no CLI flag for this option. - & reg add "HKLM\SYSTEM\CurrentControlSet\Services\docker" /v Environment /t REG_MULTI_SZ /s '@' /d TEST_INTEGRATION_USE_GRAPHDRIVER=1 + & reg add "HKLM\SYSTEM\CurrentControlSet\Services\docker" /v Environment /t REG_MULTI_SZ /s '@' /d "DOCKER_MIN_API_VERSION=1.24@TEST_INTEGRATION_USE_GRAPHDRIVER=1" echo "TEST_INTEGRATION_USE_GRAPHDRIVER=1" | Out-File -FilePath $Env:GITHUB_ENV -Encoding utf-8 -Append + } Else { + # Make the env-var visible to the service-managed dockerd, as there's no CLI flag for this option. + & reg add "HKLM\SYSTEM\CurrentControlSet\Services\docker" /v Environment /t REG_MULTI_SZ /s '@' /d DOCKER_MIN_API_VERSION=1.24 } Write-Host "Starting service" Start-Service -Name docker diff --git a/daemon/config/config.go b/daemon/config/config.go index 460077c676..42ed66df1c 100644 --- a/daemon/config/config.go +++ b/daemon/config/config.go @@ -59,10 +59,12 @@ const ( // // This version may be lower than the version of the api library module used. MaxAPIVersion = "1.52" - // MinAPIVersion is the minimum API version supported by the API. + // defaultMinAPIVersion is the minimum API version supported by the API. // This version can be overridden through the "DOCKER_MIN_API_VERSION" - // environment variable. It currently defaults to the minimum API version - // implemented in the API module. + // environment variable. The minimum allowed version is determined + // by [MinAPIVersion]. + defaultMinAPIVersion = "1.44" + // MinAPIVersion is the minimum API version supported by the daemon. MinAPIVersion = "1.24" // SeccompProfileDefault is the built-in default seccomp profile. SeccompProfileDefault = "builtin" @@ -339,7 +341,7 @@ func New() (*Config, error) { ContainerdPluginNamespace: DefaultPluginNamespace, Features: make(map[string]bool), DefaultRuntime: StockRuntimeName, - MinAPIVersion: MinAPIVersion, + MinAPIVersion: defaultMinAPIVersion, }, } diff --git a/hack/make/.integration-daemon-start b/hack/make/.integration-daemon-start index 5ebce9998f..1cda397a91 100644 --- a/hack/make/.integration-daemon-start +++ b/hack/make/.integration-daemon-start @@ -43,6 +43,9 @@ exec 41>&1 42>&2 export DOCKER_GRAPHDRIVER=${DOCKER_GRAPHDRIVER:-native} export DOCKER_USERLANDPROXY=${DOCKER_USERLANDPROXY:-true} +# Allow testing old API versions +export DOCKER_MIN_API_VERSION=1.24 + # example usage: DOCKER_STORAGE_OPTS="dm.basesize=20G,dm.loopdatasize=200G" storage_params="" if [ -n "$DOCKER_STORAGE_OPTS" ]; then diff --git a/integration-cli/daemon/daemon.go b/integration-cli/daemon/daemon.go index 5a44de2a5f..e045e4a18f 100644 --- a/integration-cli/daemon/daemon.go +++ b/integration-cli/daemon/daemon.go @@ -26,7 +26,7 @@ type Daemon struct { // The daemon will not automatically start. func New(t testing.TB, dockerBinary string, dockerdBinary string, ops ...daemon.Option) *Daemon { t.Helper() - ops = append(ops, daemon.WithDockerdBinary(dockerdBinary)) + ops = append(ops, daemon.WithDockerdBinary(dockerdBinary), daemon.WithEnvVars("DOCKER_MIN_API_VERSION=1.24")) d := daemon.New(t, ops...) return &Daemon{ Daemon: d, diff --git a/integration/container/run_cgroupns_linux_test.go b/integration/container/run_cgroupns_linux_test.go index 3dd4a7022d..b644958480 100644 --- a/integration/container/run_cgroupns_linux_test.go +++ b/integration/container/run_cgroupns_linux_test.go @@ -138,7 +138,7 @@ func TestCgroupNamespacesRunOlderClient(t *testing.T) { ctx := testutil.StartSpan(baseContext, t) - d := daemon.New(t, daemon.WithDefaultCgroupNamespaceMode("private")) + d := daemon.New(t, daemon.WithEnvVars("DOCKER_MIN_API_VERSION=1.39"), daemon.WithDefaultCgroupNamespaceMode("private")) apiClient := d.NewClientT(t, client.WithVersion("1.39")) d.StartWithBusybox(ctx, t) diff --git a/integration/image/list_test.go b/integration/image/list_test.go index 81c9d65ee6..9d0f69eb85 100644 --- a/integration/image/list_test.go +++ b/integration/image/list_test.go @@ -9,9 +9,7 @@ import ( "github.com/google/go-cmp/cmp/cmpopts" "github.com/moby/moby/api/types/image" - "github.com/moby/moby/api/types/versions" "github.com/moby/moby/client" - "github.com/moby/moby/v2/daemon/config" "github.com/moby/moby/v2/integration/internal/container" iimage "github.com/moby/moby/v2/integration/internal/image" "github.com/moby/moby/v2/internal/testutil" @@ -255,7 +253,7 @@ func TestAPIImagesListManifests(t *testing.T) { t.Run("unsupported before 1.47", func(t *testing.T) { // TODO: Remove when MinAPIVersion >= 1.47 - c := d.NewClientT(t, client.WithVersion(config.MinAPIVersion)) + c := d.NewClientT(t, client.WithVersion("1.46")) images, err := c.ImageList(ctx, client.ImageListOptions{Manifests: true}) assert.NilError(t, err) @@ -264,8 +262,6 @@ func TestAPIImagesListManifests(t *testing.T) { assert.Check(t, is.Nil(images[0].Manifests)) }) - skip.If(t, versions.LessThan(testEnv.DaemonAPIVersion(), "1.47")) - api147 := d.NewClientT(t, client.WithVersion("1.47")) t.Run("no manifests if not requested", func(t *testing.T) { diff --git a/integration/networking/mac_addr_test.go b/integration/networking/mac_addr_test.go index 8fdd882782..3846ed36fa 100644 --- a/integration/networking/mac_addr_test.go +++ b/integration/networking/mac_addr_test.go @@ -146,7 +146,7 @@ func TestInspectCfgdMAC(t *testing.T) { ctx := setupTest(t) - d := daemon.New(t) + d := daemon.New(t, daemon.WithEnvVars("DOCKER_MIN_API_VERSION=1.43")) d.StartWithBusybox(ctx, t) defer d.Stop(t) @@ -241,7 +241,7 @@ func TestWatchtowerCreate(t *testing.T) { ctx := setupTest(t) - d := daemon.New(t) + d := daemon.New(t, daemon.WithEnvVars("DOCKER_MIN_API_VERSION=1.25")) d.StartWithBusybox(ctx, t) defer d.Stop(t) diff --git a/integration/service/network_linux_test.go b/integration/service/network_linux_test.go index 2650643a7b..77555ddeee 100644 --- a/integration/service/network_linux_test.go +++ b/integration/service/network_linux_test.go @@ -28,7 +28,7 @@ import ( func TestDockerNetworkConnectAliasPreV144(t *testing.T) { ctx := setupTest(t) - d := swarm.NewSwarm(ctx, t, testEnv) + d := swarm.NewSwarm(ctx, t, testEnv, daemon.WithEnvVars("DOCKER_MIN_API_VERSION=1.43")) defer d.Stop(t) apiClient := d.NewClientT(t, client.WithVersion("1.43")) defer apiClient.Close()