Skip to content

e2e: forward Docker TLS environment variables to the tests - #14524

Merged
ndeloof merged 2 commits into
docker:mainfrom
ricardobranco777:e2e-forward-docker-tls-env
Nov 18, 2026
Merged

ndeloof merged 2 commits into
docker:mainfrom
ricardobranco777:e2e-forward-docker-tls-env

Conversation

@ricardobranco777

@ricardobranco777 ricardobranco777 commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Fix the tests when running on TLS-enabled daemons. Broken since v5.7.1. Tested with v5.8.0.

What this PR does

BaseEnvironment() forwards DOCKER_HOST to the docker and compose commands run by the e2e tests, but not the variables that go with a TLS endpoint. With DOCKER_HOST=tcp://host:2376 and DOCKER_TLS_VERIFY=1 set, the tests talk plain HTTP to the daemon and fail with "Client sent an HTTP request to an HTTPS server".

Otherwise tests fail in openQA since docker-compose v5.7.1:
https://openqa.opensuse.org/tests/6345435/logfile?filename=docker_compose-e2e-compose.txt

Related issue

Fixes #

Changes made

  • Forward DOCKER_TLS_VERIFY, DOCKER_CERT_PATH and DOCKER_API_VERSION too.

Testing done

  • Unit tests pass: make test
  • E2E tests pass: make e2e-compose or make e2e-compose-standalone
  • Linting passes: make lint
  • Code formatted: make fmt
  • Manually tested (describe):

Additional context

(not mandatory) A picture of a cute animal, if possible in relation to what you did

@ricardobranco777

Copy link
Copy Markdown
Contributor Author

This makes other tests fail. Sigh.

TestBuildEntitlements		# Test messages # TestBuildEntitlements
# failure: 

Failed
=== RUN   TestBuildEntitlements
=== PAUSE TestBuildEntitlements
=== CONT  TestBuildEntitlements
    framework.go:172: WARNING: docker-model cli-plugin not found
    build_test.go:505: Running command: docker compose version
    build_test.go:510: 	[TestBuildEntitlements] docker buildx create --name build-insecure-TestBuildEntitlements --use --bootstrap --buildkitd-flags '--allow-insecure-entitlement=security.insecure'
Docker Compose version 5.7.1
    build_test.go:510: assertion failed: 
        Command:  docker buildx create --name build-insecure-TestBuildEntitlements --use --bootstrap --buildkitd-flags '--allow-insecure-entitlement=security.insecure'
        ExitCode: 1
        Error:    exit status 1
        Stdout:   
        Stderr:   ERROR: could not create a builder instance with TLS data loaded from environment. Please use `docker context create <context-name>` to create a context for current environment and then create a builder instance with context set to <context-name>
        
        
        Failures:
        ExitCode was 1 expected 0
        Expected no error
    framework.go:145: Contents of config dir:
    framework.go:147:   - /tmp/TestBuildEntitlements4239685740/001
    framework.go:147:   - /tmp/TestBuildEntitlements4239685740/001/buildx
    framework.go:147:   - /tmp/TestBuildEntitlements4239685740/001/buildx/.lock
    framework.go:147:   - /tmp/TestBuildEntitlements4239685740/001/buildx/activity
    framework.go:147:   - /tmp/TestBuildEntitlements4239685740/001/buildx/defaults
    framework.go:147:   - /tmp/TestBuildEntitlements4239685740/001/buildx/instances
    framework.go:147:   - /tmp/TestBuildEntitlements4239685740/001/cli-plugins
    framework.go:147:   - /tmp/TestBuildEntitlements4239685740/001/cli-plugins/docker-buildx
    framework.go:147:   - /tmp/TestBuildEntitlements4239685740/001/cli-plugins/docker-compose
    framework.go:147:   - /tmp/TestBuildEntitlements4239685740/001/cli-plugins/docker-scan
--- FAIL: TestBuildEntitlements (0.39s)

e2e-compose__github	TestBuildBuilder		# Test messages # TestBuildBuilder
# failure: 

Failed
=== RUN   TestBuildBuilder
=== PAUSE TestBuildBuilder
=== CONT  TestBuildBuilder
    framework.go:172: WARNING: docker-model cli-plugin not found
    build_test.go:478: Running command: docker compose version
Docker Compose version 5.7.1
    build_test.go:482: 	[TestBuildBuilder] docker buildx create --name build-with-builder-TestBuildBuilder --use --bootstrap
    build_test.go:482: assertion failed: 
        Command:  docker buildx create --name build-with-builder-TestBuildBuilder --use --bootstrap
        ExitCode: 1
        Error:    exit status 1
        Stdout:   
        Stderr:   ERROR: could not create a builder instance with TLS data loaded from environment. Please use `docker context create <context-name>` to create a context for current environment and then create a builder instance with context set to <context-name>
        
        
        Failures:
        ExitCode was 1 expected 0
        Expected no error
    framework.go:145: Contents of config dir:
    framework.go:147:   - /tmp/TestBuildBuilder656564895/001
    framework.go:147:   - /tmp/TestBuildBuilder656564895/001/buildx
    framework.go:147:   - /tmp/TestBuildBuilder656564895/001/buildx/.lock
    framework.go:147:   - /tmp/TestBuildBuilder656564895/001/buildx/activity
    framework.go:147:   - /tmp/TestBuildBuilder656564895/001/buildx/defaults
    framework.go:147:   - /tmp/TestBuildBuilder656564895/001/buildx/instances
    framework.go:147:   - /tmp/TestBuildBuilder656564895/001/cli-plugins
    framework.go:147:   - /tmp/TestBuildBuilder656564895/001/cli-plugins/docker-buildx
    framework.go:147:   - /tmp/TestBuildBuilder656564895/001/cli-plugins/docker-compose
    framework.go:147:   - /tmp/TestBuildBuilder656564895/001/cli-plugins/docker-scan
--- FAIL: TestBuildBuilder (0.36s)

e2e-compose__github	TestBuildPrivileged		# Test messages # TestBuildPrivileged
# failure: 

Failed
=== RUN   TestBuildPrivileged
=== PAUSE TestBuildPrivileged
=== CONT  TestBuildPrivileged
    framework.go:172: WARNING: docker-model cli-plugin not found
    build_test.go:360: Running command: docker compose version
Docker Compose version 5.7.1
    build_test.go:365: 	[TestBuildPrivileged] docker buildx create --name build-privileged-TestBuildPrivileged --use --bootstrap --buildkitd-flags '--allow-insecure-entitlement=security.insecure'
    build_test.go:365: assertion failed: 
        Command:  docker buildx create --name build-privileged-TestBuildPrivileged --use --bootstrap --buildkitd-flags '--allow-insecure-entitlement=security.insecure'
        ExitCode: 1
        Error:    exit status 1
        Stdout:   
        Stderr:   ERROR: could not create a builder instance with TLS data loaded from environment. Please use `docker context create <context-name>` to create a context for current environment and then create a builder instance with context set to <context-name>
        
        
        Failures:
        ExitCode was 1 expected 0
        Expected no error
    framework.go:145: Contents of config dir:
    framework.go:147:   - /tmp/TestBuildPrivileged3111790229/001
    framework.go:147:   - /tmp/TestBuildPrivileged3111790229/001/buildx
    framework.go:147:   - /tmp/TestBuildPrivileged3111790229/001/buildx/.lock
    framework.go:147:   - /tmp/TestBuildPrivileged3111790229/001/buildx/activity
    framework.go:147:   - /tmp/TestBuildPrivileged3111790229/001/buildx/defaults
    framework.go:147:   - /tmp/TestBuildPrivileged3111790229/001/buildx/instances
    framework.go:147:   - /tmp/TestBuildPrivileged3111790229/001/cli-plugins
    framework.go:147:   - /tmp/TestBuildPrivileged3111790229/001/cli-plugins/docker-buildx
    framework.go:147:   - /tmp/TestBuildPrivileged3111790229/001/cli-plugins/docker-compose
    framework.go:147:   - /tmp/TestBuildPrivileged3111790229/001/cli-plugins/docker-scan
--- FAIL: TestBuildPrivileged (0.44s)

e2e-compose__github	TestBuildPlatformsWithCorrectBuildxConfig		# Test messages # TestBuildPlatformsWithCorrectBuildxConfig
# failure: 

Failed
=== RUN   TestBuildPlatformsWithCorrectBuildxConfig
=== PAUSE TestBuildPlatformsWithCorrectBuildxConfig
=== CONT  TestBuildPlatformsWithCorrectBuildxConfig
    framework.go:172: WARNING: docker-model cli-plugin not found
    build_test.go:294: Running command: docker compose version
    build_test.go:299: 	[TestBuildPlatformsWithCorrectBuildxConfig] docker buildx create --name build-platform-TestBuildPlatformsWithCorrectBuildxConfig --use --bootstrap
    build_test.go:299: assertion failed: 
        Command:  docker buildx create --name build-platform-TestBuildPlatformsWithCorrectBuildxConfig --use --bootstrap
        ExitCode: 1
        Error:    exit status 1
        Stdout:   
        Stderr:   ERROR: could not create a builder instance with TLS data loaded from environment. Please use `docker context create <context-name>` to create a context for current environment and then create a builder instance with context set to <context-name>
        
        
        Failures:
        ExitCode was 1 expected 0
        Expected no error
    framework.go:145: Contents of config dir:
    framework.go:147:   - /tmp/TestBuildPlatformsWithCorrectBuildxConfig341480672/001
    framework.go:147:   - /tmp/TestBuildPlatformsWithCorrectBuildxConfig341480672/001/buildx
    framework.go:147:   - /tmp/TestBuildPlatformsWithCorrectBuildxConfig341480672/001/buildx/.lock
    framework.go:147:   - /tmp/TestBuildPlatformsWithCorrectBuildxConfig341480672/001/buildx/activity
    framework.go:147:   - /tmp/TestBuildPlatformsWithCorrectBuildxConfig341480672/001/buildx/defaults
    framework.go:147:   - /tmp/TestBuildPlatformsWithCorrectBuildxConfig341480672/001/buildx/instances
    framework.go:147:   - /tmp/TestBuildPlatformsWithCorrectBuildxConfig341480672/001/cli-plugins
    framework.go:147:   - /tmp/TestBuildPlatformsWithCorrectBuildxConfig341480672/001/cli-plugins/docker-buildx
    framework.go:147:   - /tmp/TestBuildPlatformsWithCorrectBuildxConfig341480672/001/cli-plugins/docker-compose
    framework.go:147:   - /tmp/TestBuildPlatformsWithCorrectBuildxConfig341480672/001/cli-plugins/docker-scan
--- FAIL: TestBuildPlatformsWithCorrectBuildxConfig (0.35s)

BaseEnvironment() forwards DOCKER_HOST to the docker and compose
commands run by the e2e tests, but not the variables that go with a TLS
endpoint. With DOCKER_HOST=tcp://host:2376 and DOCKER_TLS_VERIFY=1 set,
the tests talk plain HTTP to the daemon and fail with "Client sent an
HTTP request to an HTTPS server".

Forward DOCKER_TLS_VERIFY, DOCKER_CERT_PATH and DOCKER_API_VERSION too.

Signed-off-by: Ricardo Branco <rbranco@suse.de>
@ricardobranco777
ricardobranco777 force-pushed the e2e-forward-docker-tls-env branch from 748d452 to 7068f65 Compare November 18, 2026 11:05
…ronment

"docker buildx create" refuses to use the default context when its TLS
data is loaded from DOCKER_TLS_VERIFY/DOCKER_CERT_PATH:

  could not create a builder instance with TLS data loaded from
  environment. Please use `docker context create <context-name>` ...

Now that these variables are forwarded to the tests, add a CreateBuilder
helper that copies the default context to a "<builder>-ctx" context
and creates the builder on it when TLS is configured through the
environment. The context cannot share the builder's name because buildx
treats every context as an implicit builder.

Use it in the four tests that create a builder:
TestBuildPlatformsWithCorrectBuildxConfig, TestBuildPrivileged,
TestBuildBuilder and TestBuildEntitlements.

Signed-off-by: Ricardo Branco <rbranco@suse.de>
@ricardobranco777
ricardobranco777 force-pushed the e2e-forward-docker-tls-env branch from 7068f65 to dc79760 Compare November 18, 2026 11:26
@ricardobranco777

Copy link
Copy Markdown
Contributor Author

@ndeloof ndeloof left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Comment thread internal/e2e/framework.go
t.Helper()
create := []string{"buildx", "create", "--name", name, "--use", "--bootstrap"}
create = append(create, args...)
if os.Getenv("DOCKER_TLS_VERIFY") != "" || os.Getenv("DOCKER_CERT_PATH") != "" {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: DOCKER_TLS_VERIFY=0 (an explicit opt-out) also takes this branch since only emptiness is tested. Harmless (the copied context just carries no TLS), but os.Getenv("DOCKER_CERT_PATH") != "" || os.Getenv("DOCKER_TLS_VERIFY") == "1" would match the daemon's own semantics more closely.

@ndeloof
ndeloof enabled auto-merge (rebase) November 18, 2026 14:18
@ndeloof
ndeloof merged commit 469ab94 into docker:main Nov 18, 2026
61 checks passed
@codecov

codecov Bot commented Nov 18, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants