mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
712e8da885
This removes the key generation for trust from main while it is not being consumed. The problem is that because this is being set in main if a user runs as root initially the files will be owned by root. Later if the user sets up the docker group they are unable to read the keys. This is half a user error and documentation problem and the other half is management. We decided to remove this code for now while it is not being used and will revisit it later when the consuming features are added. A few options are to generate lazily and provide a clear error message on an EPERM so that the user knows what is wrong and can correct the permissions. Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
85 lines
2 KiB
Go
85 lines
2 KiB
Go
// +build daemon
|
|
|
|
package main
|
|
|
|
import (
|
|
"github.com/docker/docker/builder"
|
|
"github.com/docker/docker/builtins"
|
|
"github.com/docker/docker/daemon"
|
|
_ "github.com/docker/docker/daemon/execdriver/lxc"
|
|
_ "github.com/docker/docker/daemon/execdriver/native"
|
|
"github.com/docker/docker/dockerversion"
|
|
"github.com/docker/docker/engine"
|
|
"github.com/docker/docker/pkg/log"
|
|
flag "github.com/docker/docker/pkg/mflag"
|
|
"github.com/docker/docker/pkg/signal"
|
|
)
|
|
|
|
const CanDaemon = true
|
|
|
|
var (
|
|
daemonCfg = &daemon.Config{}
|
|
)
|
|
|
|
func init() {
|
|
daemonCfg.InstallFlags()
|
|
}
|
|
|
|
func mainDaemon() {
|
|
if flag.NArg() != 0 {
|
|
flag.Usage()
|
|
return
|
|
}
|
|
eng := engine.New()
|
|
signal.Trap(eng.Shutdown)
|
|
// Load builtins
|
|
if err := builtins.Register(eng); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
// load the daemon in the background so we can immediately start
|
|
// the http api so that connections don't fail while the daemon
|
|
// is booting
|
|
go func() {
|
|
d, err := daemon.NewDaemon(daemonCfg, eng)
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
if err := d.Install(eng); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
b := &builder.BuilderJob{eng, d}
|
|
b.Install()
|
|
|
|
// after the daemon is done setting up we can tell the api to start
|
|
// accepting connections
|
|
if err := eng.Job("acceptconnections").Run(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}()
|
|
// TODO actually have a resolved graphdriver to show?
|
|
log.Infof("docker daemon: %s %s; execdriver: %s; graphdriver: %s",
|
|
dockerversion.VERSION,
|
|
dockerversion.GITCOMMIT,
|
|
daemonCfg.ExecDriver,
|
|
daemonCfg.GraphDriver,
|
|
)
|
|
|
|
// Serve api
|
|
job := eng.Job("serveapi", flHosts...)
|
|
job.SetenvBool("Logging", true)
|
|
job.SetenvBool("EnableCors", *flEnableCors)
|
|
job.Setenv("Version", dockerversion.VERSION)
|
|
job.Setenv("SocketGroup", *flSocketGroup)
|
|
|
|
job.SetenvBool("Tls", *flTls)
|
|
job.SetenvBool("TlsVerify", *flTlsVerify)
|
|
job.Setenv("TlsCa", *flCa)
|
|
job.Setenv("TlsCert", *flCert)
|
|
job.Setenv("TlsKey", *flKey)
|
|
job.SetenvBool("BufferRequests", true)
|
|
if err := job.Run(); err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
}
|