Skip to content

Commit

Permalink
Merge pull request #3834 from tstromberg/proxy-plumbing
Browse files Browse the repository at this point in the history
Automatically propagate proxy environment variables to docker env
  • Loading branch information
tstromberg authored Mar 21, 2019
2 parents 2579c73 + ecb6f3b commit 2d4e560
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion cmd/minikube/cmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ var (
apiServerNames []string
apiServerIPs []net.IP
extraOptions pkgutil.ExtraOptionSlice

// proxyVars are variables we plumb through to the underlying container runtime
proxyVars = []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}
)

func init() {
Expand Down Expand Up @@ -265,6 +268,17 @@ func generateConfig(cmd *cobra.Command, kVersion string) (cfg.Config, error) {
}
}

// Feed Docker our host proxy environment by default, so that it can pull images
if _, ok := r.(*cruntime.Docker); ok {
if !cmd.Flags().Changed("docker-env") {
for _, k := range proxyVars {
if v := os.Getenv(k); v != "" {
dockerEnv = append(dockerEnv, fmt.Sprintf("%s=%s", k, v))
}
}
}
}

cfg := cfg.Config{
MachineConfig: cfg.MachineConfig{
MinikubeISO: viper.GetString(isoURL),
Expand Down Expand Up @@ -371,7 +385,7 @@ func validateNetwork(h *host.Host) string {
console.OutStyle("connectivity", "%q IP address is %s", cfg.GetMachineName(), ip)

optSeen := false
for _, k := range []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"} {
for _, k := range proxyVars {
if v := os.Getenv(k); v != "" {
if !optSeen {
console.OutStyle("internet", "Found network options:")
Expand Down

0 comments on commit 2d4e560

Please sign in to comment.