flags.go 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. package main
  2. import (
  3. "os"
  4. "path/filepath"
  5. "github.com/docker/docker/opts"
  6. flag "github.com/docker/docker/pkg/mflag"
  7. )
  8. var (
  9. dockerCertPath = os.Getenv("DOCKER_CERT_PATH")
  10. )
  11. func init() {
  12. if dockerCertPath == "" {
  13. dockerCertPath = filepath.Join(os.Getenv("HOME"), ".docker")
  14. }
  15. }
  16. var (
  17. flVersion = flag.Bool([]string{"v", "-version"}, false, "Print version information and quit")
  18. flDaemon = flag.Bool([]string{"d", "-daemon"}, false, "Enable daemon mode")
  19. flDebug = flag.Bool([]string{"D", "-debug"}, false, "Enable debug mode")
  20. flSocketGroup = flag.String([]string{"G", "-group"}, "docker", "Group to assign the unix socket specified by -H when running in daemon mode\nuse '' (the empty string) to disable setting of a group")
  21. flEnableCors = flag.Bool([]string{"#api-enable-cors", "-api-enable-cors"}, false, "Enable CORS headers in the remote API")
  22. flTls = flag.Bool([]string{"-tls"}, false, "Use TLS; implied by tls-verify flags")
  23. flTlsVerify = flag.Bool([]string{"-tlsverify"}, false, "Use TLS and verify the remote (daemon: verify client, client: verify daemon)")
  24. // these are initialized in init() below since their default values depend on dockerCertPath which isn't fully initialized until init() runs
  25. flCa *string
  26. flCert *string
  27. flKey *string
  28. flHosts []string
  29. )
  30. func init() {
  31. flCa = flag.String([]string{"-tlscacert"}, filepath.Join(dockerCertPath, defaultCaFile), "Trust only remotes providing a certificate signed by the CA given here")
  32. flCert = flag.String([]string{"-tlscert"}, filepath.Join(dockerCertPath, defaultCertFile), "Path to TLS certificate file")
  33. flKey = flag.String([]string{"-tlskey"}, filepath.Join(dockerCertPath, defaultKeyFile), "Path to TLS key file")
  34. opts.HostListVar(&flHosts, []string{"H", "-host"}, "The socket(s) to bind to in daemon mode\nspecified using one or more tcp://host:port, unix:///path/to/socket, fd://* or fd://socketfd.")
  35. }