flags.go 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. flHelp = flag.Bool([]string{"h", "-help"}, false, "Print usage")
  25. // these are initialized in init() below since their default values depend on dockerCertPath which isn't fully initialized until init() runs
  26. flCa *string
  27. flCert *string
  28. flKey *string
  29. flHosts []string
  30. )
  31. func init() {
  32. flCa = flag.String([]string{"-tlscacert"}, filepath.Join(dockerCertPath, defaultCaFile), "Trust only remotes providing a certificate signed by the CA given here")
  33. flCert = flag.String([]string{"-tlscert"}, filepath.Join(dockerCertPath, defaultCertFile), "Path to TLS certificate file")
  34. flKey = flag.String([]string{"-tlskey"}, filepath.Join(dockerCertPath, defaultKeyFile), "Path to TLS key file")
  35. 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.")
  36. }