diff options
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/spec/createconfig.go | 1 | ||||
-rw-r--r-- | pkg/spec/spec.go | 18 |
2 files changed, 19 insertions, 0 deletions
diff --git a/pkg/spec/createconfig.go b/pkg/spec/createconfig.go index 064dedd45..9c674d9f1 100644 --- a/pkg/spec/createconfig.go +++ b/pkg/spec/createconfig.go @@ -87,6 +87,7 @@ type CreateConfig struct { NoHosts bool HostAdd []string //add-host Hostname string //hostname + HTTPProxy bool Image string ImageID string BuiltinImgVolumes map[string]struct{} // volumes defined in the image config diff --git a/pkg/spec/spec.go b/pkg/spec/spec.go index 4cbed0ea4..383eeadf3 100644 --- a/pkg/spec/spec.go +++ b/pkg/spec/spec.go @@ -192,6 +192,24 @@ func CreateConfigToOCISpec(config *CreateConfig) (*spec.Spec, error) { //nolint } g.SetRootReadonly(config.ReadOnlyRootfs) + if config.HTTPProxy { + for _, envSpec := range []string{ + "http_proxy", + "HTTP_PROXY", + "https_proxy", + "HTTPS_PROXY", + "ftp_proxy", + "FTP_PROXY", + "no_proxy", + "NO_PROXY", + } { + envVal := os.Getenv(envSpec) + if envVal != "" { + g.AddProcessEnv(envSpec, envVal) + } + } + } + hostname := config.Hostname if hostname == "" && (config.NetMode.IsHost() || config.UtsMode.IsHost()) { hostname, err = os.Hostname() |