Jelajahi Sumber

docker info display http/https_proxy setting

Signed-off-by: Zhang Wentao <zhangwentao234@huawei.com>
Zhang Wentao 10 tahun lalu
induk
melakukan
06a40f0f28

+ 9 - 1
api/client/commands.go

@@ -590,7 +590,15 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
 			fmt.Fprintf(cli.out, "Docker Root Dir: %s\n", root)
 		}
 	}
-
+	if remoteInfo.Exists("HttpProxy") {
+		fmt.Fprintf(cli.out, "Http Proxy: %s\n", remoteInfo.Get("HttpProxy"))
+	}
+	if remoteInfo.Exists("HttpsProxy") {
+		fmt.Fprintf(cli.out, "Https Proxy: %s\n", remoteInfo.Get("HttpsProxy"))
+	}
+	if remoteInfo.Exists("NoProxy") {
+		fmt.Fprintf(cli.out, "No Proxy: %s\n", remoteInfo.Get("NoProxy"))
+	}
 	if len(remoteInfo.GetList("IndexServerAddress")) != 0 {
 		cli.LoadConfigFile()
 		u := cli.configFile.Configs[remoteInfo.Get("IndexServerAddress")].Username

+ 10 - 0
daemon/info.go

@@ -87,6 +87,16 @@ func (daemon *Daemon) CmdInfo(job *engine.Job) engine.Status {
 	v.SetInt("NCPU", runtime.NumCPU())
 	v.SetInt64("MemTotal", meminfo.MemTotal)
 	v.Set("DockerRootDir", daemon.Config().Root)
+	if http_proxy := os.Getenv("http_proxy"); http_proxy != "" {
+		v.Set("HttpProxy", http_proxy)
+	}
+	if https_proxy := os.Getenv("https_proxy"); https_proxy != "" {
+		v.Set("HttpsProxy", https_proxy)
+	}
+	if no_proxy := os.Getenv("no_proxy"); no_proxy != "" {
+		v.Set("NoProxy", no_proxy)
+	}
+
 	if hostname, err := os.Hostname(); err == nil {
 		v.SetJson("Name", hostname)
 	}

+ 6 - 0
docs/sources/reference/api/docker_remote_api.md

@@ -57,6 +57,12 @@ This endpoint now returns `Os`, `Arch` and `KernelVersion`.
 **New!**
 You can set ulimit settings to be used within the container.
 
+`Get /info`
+
+**New!**
+Add return value `HttpProxy`,`HttpsProxy` and `NoProxy` to this entrypoint.
+
+
 ## v1.17
 
 ### Full Documentation

+ 3 - 0
docs/sources/reference/api/docker_remote_api_v1.18.md

@@ -1455,6 +1455,9 @@ Display system-wide information
              "IPv4Forwarding":true,
              "Labels":["storage=ssd"],
              "DockerRootDir": "/var/lib/docker",
+             "HttpProxy": "http://test:test@localhost:8080"
+             "HttpsProxy": "https://test:test@localhost:8080"
+             "NoProxy": "9.81.1.160"
              "OperatingSystem": "Boot2Docker",
         }
 

+ 3 - 0
docs/sources/reference/commandline/cli.md

@@ -1241,6 +1241,9 @@ For example:
     EventsListeners: 0
     Init Path: /usr/bin/docker
     Docker Root Dir: /var/lib/docker
+    Http Proxy: http://test:test@localhost:8080
+    Https Proxy: https://test:test@localhost:8080
+    No Proxy: 9.81.1.160
     Username: svendowideit
     Registry: [https://index.docker.io/v1/]
     Labels: