File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -32,6 +32,8 @@ import (
3232 dockercli "github.com/docker/cli/cli"
3333 "github.com/docker/cli/cli-plugins/manager"
3434 "github.com/docker/cli/cli/command"
35+ "github.com/docker/cli/cli/flags"
36+ "github.com/docker/docker/client"
3537 "github.com/morikuni/aec"
3638 "github.com/pkg/errors"
3739 "github.com/sirupsen/logrus"
@@ -291,6 +293,18 @@ func RootCommand(dockerCli command.Cli, backend api.Service) *cobra.Command {
291293 if err != nil {
292294 return err
293295 }
296+
297+ // Reset DockerCli and APIClient to get possible `DOCKER_HOST` and/or `DOCKER_CONTEXT` loaded from environment file
298+ err = dockerCli .Apply (func (cli * command.DockerCli ) error {
299+ return cli .Initialize (flags .NewClientOptions (),
300+ command .WithInitializeClient (func (_ * command.DockerCli ) (client.APIClient , error ) {
301+ return nil , nil
302+ }))
303+ })
304+ if err != nil {
305+ return err
306+ }
307+
294308 parent := cmd .Root ()
295309 if parent != nil {
296310 parentPrerun := parent .PersistentPreRunE
You can’t perform that action at this time.
0 commit comments