Skip to content

Commit

Permalink
Add multiple insecure registries support
Browse files Browse the repository at this point in the history
Add flag daemon.insecure-registry to indecate multiple insecure registry.
Append insecure registry parameters when starting daemon.
  • Loading branch information
orangedeng committed Mar 30, 2020
1 parent f2aeb0f commit 569e15c
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 26 deletions.
32 changes: 19 additions & 13 deletions cmd/drone-docker/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,11 @@ func main() {
Usage: "docker daemon allows insecure registries",
EnvVar: "PLUGIN_INSECURE",
},
cli.StringSliceFlag{
Name: "daemon.insecure-registry",
Usage: "docker daemon insecure registries",
EnvVar: "PLUGIN_INSECURE_REGISTRY",
},
cli.BoolFlag{
Name: "daemon.ipv6",
Usage: "docker daemon IPv6 networking",
Expand Down Expand Up @@ -271,19 +276,20 @@ func run(c *cli.Context) error {
AddHost: c.StringSlice("add-host"),
},
Daemon: docker.Daemon{
Registry: c.String("docker.registry"),
Mirror: c.String("daemon.mirror"),
StorageDriver: c.String("daemon.storage-driver"),
StoragePath: c.String("daemon.storage-path"),
Insecure: c.Bool("daemon.insecure"),
Disabled: c.Bool("daemon.off"),
IPv6: c.Bool("daemon.ipv6"),
Debug: c.Bool("daemon.debug"),
Bip: c.String("daemon.bip"),
DNS: c.StringSlice("daemon.dns"),
DNSSearch: c.StringSlice("daemon.dns-search"),
MTU: c.String("daemon.mtu"),
Experimental: c.Bool("daemon.experimental"),
InsecureRegistry: c.StringSlice("daemon.insecure-registry")
Registry: c.String("docker.registry"),
Mirror: c.String("daemon.mirror"),
StorageDriver: c.String("daemon.storage-driver"),
StoragePath: c.String("daemon.storage-path"),
Insecure: c.Bool("daemon.insecure"),
Disabled: c.Bool("daemon.off"),
IPv6: c.Bool("daemon.ipv6"),
Debug: c.Bool("daemon.debug"),
Bip: c.String("daemon.bip"),
DNS: c.StringSlice("daemon.dns"),
DNSSearch: c.StringSlice("daemon.dns-search"),
MTU: c.String("daemon.mtu"),
Experimental: c.Bool("daemon.experimental"),
},
}

Expand Down
32 changes: 19 additions & 13 deletions docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,20 @@ import (
type (
// Daemon defines Docker daemon parameters.
Daemon struct {
Registry string // Docker registry
Mirror string // Docker registry mirror
Insecure bool // Docker daemon enable insecure registries
StorageDriver string // Docker daemon storage driver
StoragePath string // Docker daemon storage path
Disabled bool // DOcker daemon is disabled (already running)
Debug bool // Docker daemon started in debug mode
Bip string // Docker daemon network bridge IP address
DNS []string // Docker daemon dns server
DNSSearch []string // Docker daemon dns search domain
MTU string // Docker daemon mtu setting
IPv6 bool // Docker daemon IPv6 networking
Experimental bool // Docker daemon enable experimental mode
InsecureRegistry []string // Docker insecure registries
Registry string // Docker registry
Mirror string // Docker registry mirror
Insecure bool // Docker daemon enable insecure registries
StorageDriver string // Docker daemon storage driver
StoragePath string // Docker daemon storage path
Disabled bool // DOcker daemon is disabled (already running)
Debug bool // Docker daemon started in debug mode
Bip string // Docker daemon network bridge IP address
DNS []string // Docker daemon dns server
DNSSearch []string // Docker daemon dns search domain
MTU string // Docker daemon mtu setting
IPv6 bool // Docker daemon IPv6 networking
Experimental bool // Docker daemon enable experimental mode
}

// Login defines Docker login parameters.
Expand Down Expand Up @@ -338,6 +339,11 @@ func commandDaemon(daemon Daemon) *exec.Cmd {
if daemon.Insecure && daemon.Registry != "" {
args = append(args, "--insecure-registry", daemon.Registry)
}
if len(daemon.InsecureRegistry) > 0{
for _, registry := range daemon.InsecureRegistry {
args = append(args, "--insecure-registry", registry)
}
}
if daemon.IPv6 {
args = append(args, "--ipv6")
}
Expand Down

0 comments on commit 569e15c

Please sign in to comment.