func (options *ServiceOptions) InstallCliFlags(cmd *flag.FlagSet, usageFn func(string) string) {
	mirrors := opts.NewNamedListOptsRef("registry-mirrors", &options.Mirrors, ValidateMirror)
	cmd.Var(mirrors, []string{"-registry-mirror"}, usageFn("Preferred Docker registry mirror"))
	insecureRegistries := opts.NewNamedListOptsRef("insecure-registries", &options.InsecureRegistries, ValidateIndexName)
	cmd.Var(insecureRegistries, []string{"-insecure-registry"}, usageFn("Enable insecure registry communication"))
	cmd.BoolVar(&options.V2Only, []string{"-disable-legacy-registry"}, false, usageFn("Do not contact legacy registries"))
}
InstallCliFlags adds command-line options to the top-level flag parser for
the current process.
package registry
import (
	"errors"
	"fmt"
	"net"
	"net/url"
	"strings"
	"github.com/docker/docker/opts"
	flag "github.com/docker/docker/pkg/mflag"
	"github.com/docker/docker/reference"
	registrytypes "github.com/docker/engine-api/types/registry"
)
type ServiceOptions struct {
	Mirrors            []string `json:"registry-mirrors,omitempty"`
	InsecureRegistries []string `json:"insecure-registries,omitempty"`
	V2Only bool `json:"disable-legacy-registry,omitempty"`
}
type serviceConfig struct {
	registrytypes.ServiceConfig
	V2Only bool
}
var (
	DefaultNamespace = "docker.io"
	DefaultRegistryVersionHeader = "Docker-Distribution-Api-Version"
	IndexServer = DefaultV1Registry.String() + "/v1/"
	IndexName = "docker.io"
	NotaryServer = "https://notary.docker.io"
	DefaultV1Registry = &url.URL{
		Scheme: "https",
		Host:   "index.docker.io",
	}
	DefaultV2Registry = &url.URL{
		Scheme: "https",
		Host:   "registry-1.docker.io",
	}
)
var (
	ErrInvalidRepositoryName = errors.New("Invalid repository name (ex: \"registry.domain.tld/myrepos\")")
	emptyServiceConfig = newServiceConfig(ServiceOptions{})
)
var lookupIP = net.LookupIP