@@ -10,6 +10,7 @@ import (
1010 "github.com/docker/cli/cli"
1111 "github.com/docker/cli/cli/command"
1212 "github.com/docker/cli/cli/command/image"
13+ "github.com/docker/cli/opts"
1314 "github.com/docker/distribution/reference"
1415 "github.com/docker/docker/api/types"
1516 "github.com/docker/docker/api/types/container"
@@ -60,7 +61,17 @@ func NewCreateCommand(dockerCli command.Cli) *cobra.Command {
6061 return cmd
6162}
6263
63- func runCreate (dockerCli command.Cli , flags * pflag.FlagSet , opts * createOptions , copts * containerOptions ) error {
64+ func runCreate (dockerCli command.Cli , flags * pflag.FlagSet , options * createOptions , copts * containerOptions ) error {
65+ proxyConfig := dockerCli .ConfigFile ().ParseProxyConfig (dockerCli .Client ().DaemonHost (), copts .env .GetAll ())
66+ newEnv := []string {}
67+ for k , v := range proxyConfig {
68+ if v == nil {
69+ newEnv = append (newEnv , k )
70+ } else {
71+ newEnv = append (newEnv , fmt .Sprintf ("%s=%s" , k , * v ))
72+ }
73+ }
74+ copts .env = * opts .NewListOptsRef (& newEnv , nil )
6475 containerConfig , err := parse (flags , copts )
6576 if err != nil {
6677 reportError (dockerCli .Err (), "create" , err .Error (), true )
@@ -70,7 +81,7 @@ func runCreate(dockerCli command.Cli, flags *pflag.FlagSet, opts *createOptions,
7081 reportError (dockerCli .Err (), "create" , err .Error (), true )
7182 return cli.StatusError {StatusCode : 125 }
7283 }
73- response , err := createContainer (context .Background (), dockerCli , containerConfig , opts )
84+ response , err := createContainer (context .Background (), dockerCli , containerConfig , options )
7485 if err != nil {
7586 return err
7687 }
0 commit comments