1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/cmd/docker/daemon_unix.go

38 lines
760 B
Go
Raw Normal View History

// +build !windows
package main
import (
"os"
"os/exec"
"syscall"
)
// CmdDaemon execs dockerd with the same flags
// TODO: add a deprecation warning?
func (p DaemonProxy) CmdDaemon(args ...string) error {
// Use os.Args[1:] so that "global" args are passed to dockerd
args = stripDaemonArg(os.Args[1:])
// TODO: check dirname args[0] first
binaryAbsPath, err := exec.LookPath(daemonBinary)
if err != nil {
return err
}
return syscall.Exec(
binaryAbsPath,
append([]string{daemonBinary}, args...),
os.Environ())
}
// stripDaemonArg removes the `daemon` argument from the list
func stripDaemonArg(args []string) []string {
for i, arg := range args {
if arg == "daemon" {
return append(args[:i], args[i+1:]...)
}
}
return args
}