Skip to content

Commit 2d4e560

Browse files
authored
Merge pull request #3834 from tstromberg/proxy-plumbing
Automatically propagate proxy environment variables to docker env
2 parents 2579c73 + ecb6f3b commit 2d4e560

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

cmd/minikube/cmd/start.go

+15-1
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,9 @@ var (
9696
apiServerNames []string
9797
apiServerIPs []net.IP
9898
extraOptions pkgutil.ExtraOptionSlice
99+
100+
// proxyVars are variables we plumb through to the underlying container runtime
101+
proxyVars = []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"}
99102
)
100103

101104
func init() {
@@ -265,6 +268,17 @@ func generateConfig(cmd *cobra.Command, kVersion string) (cfg.Config, error) {
265268
}
266269
}
267270

271+
// Feed Docker our host proxy environment by default, so that it can pull images
272+
if _, ok := r.(*cruntime.Docker); ok {
273+
if !cmd.Flags().Changed("docker-env") {
274+
for _, k := range proxyVars {
275+
if v := os.Getenv(k); v != "" {
276+
dockerEnv = append(dockerEnv, fmt.Sprintf("%s=%s", k, v))
277+
}
278+
}
279+
}
280+
}
281+
268282
cfg := cfg.Config{
269283
MachineConfig: cfg.MachineConfig{
270284
MinikubeISO: viper.GetString(isoURL),
@@ -371,7 +385,7 @@ func validateNetwork(h *host.Host) string {
371385
console.OutStyle("connectivity", "%q IP address is %s", cfg.GetMachineName(), ip)
372386

373387
optSeen := false
374-
for _, k := range []string{"HTTP_PROXY", "HTTPS_PROXY", "NO_PROXY"} {
388+
for _, k := range proxyVars {
375389
if v := os.Getenv(k); v != "" {
376390
if !optSeen {
377391
console.OutStyle("internet", "Found network options:")

0 commit comments

Comments
 (0)