Pārlūkot izejas kodu

Add insecure registries to docker info

Signed-off-by: Tomasz Kopczynski <tomek@kopczynski.net.pl>
Tomasz Kopczynski 9 gadi atpakaļ
vecāks
revīzija
44a50abe7b

+ 14 - 0
api/client/info.go

@@ -151,5 +151,19 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
 	if info.ClusterAdvertise != "" {
 	if info.ClusterAdvertise != "" {
 		fmt.Fprintf(cli.out, "Cluster Advertise: %s\n", info.ClusterAdvertise)
 		fmt.Fprintf(cli.out, "Cluster Advertise: %s\n", info.ClusterAdvertise)
 	}
 	}
+
+	if info.RegistryConfig != nil && (len(info.RegistryConfig.InsecureRegistryCIDRs) > 0 || len(info.RegistryConfig.IndexConfigs) > 0) {
+		fmt.Fprintln(cli.out, "Insecure registries:")
+		for _, registry := range info.RegistryConfig.IndexConfigs {
+			if registry.Secure == false {
+				fmt.Fprintf(cli.out, " %s\n", registry.Name)
+			}
+		}
+
+		for _, registry := range info.RegistryConfig.InsecureRegistryCIDRs {
+			mask, _ := registry.Mask.Size()
+			fmt.Fprintf(cli.out, " %s/%d\n", registry.IP.String(), mask)
+		}
+	}
 	return nil
 	return nil
 }
 }

+ 3 - 0
docs/reference/commandline/info.md

@@ -62,6 +62,9 @@ For example:
     Registry: [https://index.docker.io/v1/]
     Registry: [https://index.docker.io/v1/]
     Labels:
     Labels:
      storage=ssd
      storage=ssd
+    Insecure registries:
+     myinsecurehost:5000
+     127.0.0.0/8
 
 
 The global `-D` option tells all `docker` commands to output debug information.
 The global `-D` option tells all `docker` commands to output debug information.
 
 

+ 18 - 0
integration-cli/docker_cli_info_test.go

@@ -164,3 +164,21 @@ func (s *DockerSuite) TestInfoDebug(c *check.C) {
 	c.Assert(out, checker.Contains, "EventsListeners")
 	c.Assert(out, checker.Contains, "EventsListeners")
 	c.Assert(out, checker.Contains, "Docker Root Dir")
 	c.Assert(out, checker.Contains, "Docker Root Dir")
 }
 }
+
+func (s *DockerSuite) TestInsecureRegistries(c *check.C) {
+	testRequires(c, SameHostDaemon, DaemonIsLinux)
+
+	registryCIDR := "192.168.1.0/24"
+	registryHost := "insecurehost.com:5000"
+
+	d := NewDaemon(c)
+	err := d.Start("--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost)
+	c.Assert(err, checker.IsNil)
+	defer d.Stop()
+
+	out, err := d.Cmd("info")
+	c.Assert(err, checker.IsNil)
+	c.Assert(out, checker.Contains, "Insecure registries:\n")
+	c.Assert(out, checker.Contains, fmt.Sprintf(" %s\n", registryHost))
+	c.Assert(out, checker.Contains, fmt.Sprintf(" %s\n", registryCIDR))
+}

+ 3 - 0
man/docker-info.1.md

@@ -59,6 +59,9 @@ Here is a sample output:
     Debug mode (server): false
     Debug mode (server): false
     Username: xyz
     Username: xyz
     Registry: https://index.docker.io/v1/
     Registry: https://index.docker.io/v1/
+    Insecure registries:
+     myinsecurehost:5000
+     127.0.0.0/8
 	
 	
 # HISTORY
 # HISTORY
 April 2014, Originally compiled by William Henry (whenry at redhat dot com)
 April 2014, Originally compiled by William Henry (whenry at redhat dot com)