Skip to content

Commit

Permalink
Merge pull request moby#20410 from tkopczynski/20236-info-insecure-re…
Browse files Browse the repository at this point in the history
…gistry

Add insecure registries to docker info
  • Loading branch information
thaJeztah committed Mar 31, 2016
2 parents 3acb466 + 44a50ab commit 4a7bd7e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 0 deletions.
14 changes: 14 additions & 0 deletions api/client/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
3 changes: 3 additions & 0 deletions docs/reference/commandline/info.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
18 changes: 18 additions & 0 deletions integration-cli/docker_cli_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
3 changes: 3 additions & 0 deletions man/docker-info.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 4a7bd7e

Please sign in to comment.