2013-01-19 19:07:19 -05:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2013-04-10 06:24:15 -04:00
|
|
|
"fmt"
|
2016-08-03 12:20:46 -04:00
|
|
|
"os"
|
2016-10-17 14:48:51 -04:00
|
|
|
"runtime"
|
2014-02-01 06:38:39 -05:00
|
|
|
|
2016-06-21 16:42:47 -04:00
|
|
|
"github.com/docker/docker/cli"
|
2017-01-23 06:23:07 -05:00
|
|
|
"github.com/docker/docker/daemon/config"
|
2015-11-09 13:32:46 -05:00
|
|
|
"github.com/docker/docker/dockerversion"
|
2014-10-30 08:48:30 -04:00
|
|
|
"github.com/docker/docker/pkg/reexec"
|
2015-01-23 20:33:49 -05:00
|
|
|
"github.com/docker/docker/pkg/term"
|
2018-07-11 18:25:38 -04:00
|
|
|
"github.com/moby/buildkit/util/apicaps"
|
2017-07-26 17:42:13 -04:00
|
|
|
"github.com/sirupsen/logrus"
|
2016-06-21 16:42:47 -04:00
|
|
|
"github.com/spf13/cobra"
|
2013-01-24 02:14:46 -05:00
|
|
|
)
|
|
|
|
|
2016-06-21 16:42:47 -04:00
|
|
|
func newDaemonCommand() *cobra.Command {
|
2017-06-01 16:34:31 -04:00
|
|
|
opts := newDaemonOptions(config.New())
|
2015-03-19 21:07:56 -04:00
|
|
|
|
2016-06-21 16:42:47 -04:00
|
|
|
cmd := &cobra.Command{
|
|
|
|
Use: "dockerd [OPTIONS]",
|
|
|
|
Short: "A self-sufficient runtime for containers.",
|
|
|
|
SilenceUsage: true,
|
|
|
|
SilenceErrors: true,
|
|
|
|
Args: cli.NoArgs,
|
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
opts.flags = cmd.Flags()
|
|
|
|
return runDaemon(opts)
|
|
|
|
},
|
2018-05-18 19:19:16 -04:00
|
|
|
DisableFlagsInUseLine: true,
|
2018-05-18 21:15:08 -04:00
|
|
|
Version: fmt.Sprintf("%s, build %s", dockerversion.Version, dockerversion.GitCommit),
|
2015-05-07 12:49:07 -04:00
|
|
|
}
|
2016-06-23 11:25:51 -04:00
|
|
|
cli.SetupRootCommand(cmd)
|
2015-05-07 12:49:07 -04:00
|
|
|
|
2016-06-21 16:42:47 -04:00
|
|
|
flags := cmd.Flags()
|
2018-05-18 21:15:08 -04:00
|
|
|
flags.BoolP("version", "v", false, "Print version information and quit")
|
2017-03-30 06:01:00 -04:00
|
|
|
flags.StringVar(&opts.configFile, "config-file", defaultDaemonConfigFile, "Daemon configuration file")
|
2017-06-01 16:34:31 -04:00
|
|
|
opts.InstallFlags(flags)
|
2017-01-23 06:23:07 -05:00
|
|
|
installConfigFlags(opts.daemonConfig, flags)
|
2016-06-22 18:36:51 -04:00
|
|
|
installServiceFlags(flags)
|
2015-05-05 00:18:28 -04:00
|
|
|
|
2016-06-21 16:42:47 -04:00
|
|
|
return cmd
|
|
|
|
}
|
2014-06-27 09:55:20 -04:00
|
|
|
|
2018-07-11 18:25:38 -04:00
|
|
|
func init() {
|
|
|
|
if dockerversion.ProductName != "" {
|
|
|
|
apicaps.ExportedProduct = dockerversion.ProductName
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-21 16:42:47 -04:00
|
|
|
func main() {
|
|
|
|
if reexec.Init() {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set terminal emulation based on platform as required.
|
|
|
|
_, stdout, stderr := term.StdStreams()
|
2017-03-30 18:36:42 -04:00
|
|
|
|
|
|
|
// @jhowardmsft - maybe there is a historic reason why on non-Windows, stderr is used
|
|
|
|
// here. However, on Windows it makes no sense and there is no need.
|
|
|
|
if runtime.GOOS == "windows" {
|
|
|
|
logrus.SetOutput(stdout)
|
|
|
|
} else {
|
|
|
|
logrus.SetOutput(stderr)
|
|
|
|
}
|
2016-06-21 16:42:47 -04:00
|
|
|
|
|
|
|
cmd := newDaemonCommand()
|
|
|
|
cmd.SetOutput(stdout)
|
|
|
|
if err := cmd.Execute(); err != nil {
|
2016-08-03 12:20:46 -04:00
|
|
|
fmt.Fprintf(stderr, "%s\n", err)
|
|
|
|
os.Exit(1)
|
2016-06-21 16:42:47 -04:00
|
|
|
}
|
|
|
|
}
|