1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

Merge pull request #20410 from tkopczynski/20236-info-insecure-registry

Add insecure registries to docker info
This commit is contained in:
Sebastiaan van Stijn 2016-03-31 16:39:25 -07:00
commit 4a7bd7eaef
4 changed files with 38 additions and 0 deletions

View file

@ -151,5 +151,19 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
if 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
}

View file

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

View file

@ -164,3 +164,21 @@ func (s *DockerSuite) TestInfoDebug(c *check.C) {
c.Assert(out, checker.Contains, "EventsListeners")
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))
}

View file

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