Skip to content

Commit 4a7bd7e

Browse files
committed
Merge pull request moby#20410 from tkopczynski/20236-info-insecure-registry
Add insecure registries to docker info
2 parents 3acb466 + 44a50ab commit 4a7bd7e

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

api/client/info.go

+14
Original file line numberDiff line numberDiff line change
@@ -151,5 +151,19 @@ func (cli *DockerCli) CmdInfo(args ...string) error {
151151
if info.ClusterAdvertise != "" {
152152
fmt.Fprintf(cli.out, "Cluster Advertise: %s\n", info.ClusterAdvertise)
153153
}
154+
155+
if info.RegistryConfig != nil && (len(info.RegistryConfig.InsecureRegistryCIDRs) > 0 || len(info.RegistryConfig.IndexConfigs) > 0) {
156+
fmt.Fprintln(cli.out, "Insecure registries:")
157+
for _, registry := range info.RegistryConfig.IndexConfigs {
158+
if registry.Secure == false {
159+
fmt.Fprintf(cli.out, " %s\n", registry.Name)
160+
}
161+
}
162+
163+
for _, registry := range info.RegistryConfig.InsecureRegistryCIDRs {
164+
mask, _ := registry.Mask.Size()
165+
fmt.Fprintf(cli.out, " %s/%d\n", registry.IP.String(), mask)
166+
}
167+
}
154168
return nil
155169
}

docs/reference/commandline/info.md

+3
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ For example:
6262
Registry: [https://index.docker.io/v1/]
6363
Labels:
6464
storage=ssd
65+
Insecure registries:
66+
myinsecurehost:5000
67+
127.0.0.0/8
6568

6669
The global `-D` option tells all `docker` commands to output debug information.
6770

integration-cli/docker_cli_info_test.go

+18
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,21 @@ func (s *DockerSuite) TestInfoDebug(c *check.C) {
164164
c.Assert(out, checker.Contains, "EventsListeners")
165165
c.Assert(out, checker.Contains, "Docker Root Dir")
166166
}
167+
168+
func (s *DockerSuite) TestInsecureRegistries(c *check.C) {
169+
testRequires(c, SameHostDaemon, DaemonIsLinux)
170+
171+
registryCIDR := "192.168.1.0/24"
172+
registryHost := "insecurehost.com:5000"
173+
174+
d := NewDaemon(c)
175+
err := d.Start("--insecure-registry="+registryCIDR, "--insecure-registry="+registryHost)
176+
c.Assert(err, checker.IsNil)
177+
defer d.Stop()
178+
179+
out, err := d.Cmd("info")
180+
c.Assert(err, checker.IsNil)
181+
c.Assert(out, checker.Contains, "Insecure registries:\n")
182+
c.Assert(out, checker.Contains, fmt.Sprintf(" %s\n", registryHost))
183+
c.Assert(out, checker.Contains, fmt.Sprintf(" %s\n", registryCIDR))
184+
}

man/docker-info.1.md

+3
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ Here is a sample output:
5959
Debug mode (server): false
6060
Username: xyz
6161
Registry: https://index.docker.io/v1/
62+
Insecure registries:
63+
myinsecurehost:5000
64+
127.0.0.0/8
6265

6366
# HISTORY
6467
April 2014, Originally compiled by William Henry (whenry at redhat dot com)

0 commit comments

Comments
 (0)