diff --git a/cli/command/cli.go b/cli/command/cli.go index d11961e61b..85fac56502 100644 --- a/cli/command/cli.go +++ b/cli/command/cli.go @@ -282,6 +282,12 @@ func (cli *DockerCli) Initialize(opts *cliflags.ClientOptions, ops ...CLIOption) } filterResourceAttributesEnvvar() + // early return if GODEBUG is already set or the docker context is + // the default context, i.e. is a virtual context where we won't override + // any GODEBUG values. + if v := os.Getenv("GODEBUG"); cli.currentContext == DefaultContextName || v != "" { + return nil + } meta, err := cli.contextStore.GetMetadata(cli.currentContext) if err == nil { setGoDebug(meta)