mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Add daemon options required by buildkit tests
Signed-off-by: Sam Whited <sam@samwhited.com>
This commit is contained in:
parent
76dbd884d3
commit
b96a0c7754
2 changed files with 30 additions and 13 deletions
|
@ -39,8 +39,10 @@ type nopLog struct{}
|
|||
|
||||
func (nopLog) Logf(string, ...interface{}) {}
|
||||
|
||||
const defaultDockerdBinary = "dockerd"
|
||||
const containerdSocket = "/var/run/docker/containerd/containerd.sock"
|
||||
const (
|
||||
defaultDockerdBinary = "dockerd"
|
||||
defaultContainerdSocket = "/var/run/docker/containerd/containerd.sock"
|
||||
)
|
||||
|
||||
var errDaemonNotStarted = errors.New("daemon not started")
|
||||
|
||||
|
@ -75,6 +77,7 @@ type Daemon struct {
|
|||
log LogT
|
||||
pidFile string
|
||||
args []string
|
||||
containerdSocket string
|
||||
|
||||
// swarm related field
|
||||
swarmListenAddr string
|
||||
|
@ -120,11 +123,12 @@ func NewDaemon(workingDir string, ops ...Option) (*Daemon, error) {
|
|||
storageDriver: storageDriver,
|
||||
userlandProxy: userlandProxy,
|
||||
// dxr stands for docker-execroot (shortened for avoiding unix(7) path length limitation)
|
||||
execRoot: filepath.Join(os.TempDir(), "dxr", id),
|
||||
dockerdBinary: defaultDockerdBinary,
|
||||
swarmListenAddr: defaultSwarmListenAddr,
|
||||
SwarmPort: DefaultSwarmPort,
|
||||
log: nopLog{},
|
||||
execRoot: filepath.Join(os.TempDir(), "dxr", id),
|
||||
dockerdBinary: defaultDockerdBinary,
|
||||
swarmListenAddr: defaultSwarmListenAddr,
|
||||
SwarmPort: DefaultSwarmPort,
|
||||
log: nopLog{},
|
||||
containerdSocket: defaultContainerdSocket,
|
||||
}
|
||||
|
||||
for _, op := range ops {
|
||||
|
@ -252,17 +256,20 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
|
|||
d.pidFile = filepath.Join(d.Folder, "docker.pid")
|
||||
}
|
||||
|
||||
d.args = append(d.GlobalFlags,
|
||||
"--containerd", containerdSocket,
|
||||
"--data-root", d.Root,
|
||||
d.args = append(d.GlobalFlags, "--data-root", d.Root)
|
||||
if d.containerdSocket != "" {
|
||||
d.args = append(d.args, "--containerd", d.containerdSocket)
|
||||
}
|
||||
d.args = append(d.args,
|
||||
"--exec-root", d.execRoot,
|
||||
"--pidfile", d.pidFile,
|
||||
fmt.Sprintf("--userland-proxy=%t", d.userlandProxy),
|
||||
"--containerd-namespace", d.id,
|
||||
"--containerd-plugins-namespace", d.id+"p",
|
||||
)
|
||||
|
||||
if d.defaultCgroupNamespaceMode != "" {
|
||||
d.args = append(d.args, []string{"--default-cgroupns-mode", d.defaultCgroupNamespaceMode}...)
|
||||
d.args = append(d.args, "--default-cgroupns-mode", d.defaultCgroupNamespaceMode)
|
||||
}
|
||||
if d.experimental {
|
||||
d.args = append(d.args, "--experimental")
|
||||
|
@ -271,10 +278,10 @@ func (d *Daemon) StartWithLogFile(out *os.File, providedArgs ...string) error {
|
|||
d.args = append(d.args, "--init")
|
||||
}
|
||||
if !(d.UseDefaultHost || d.UseDefaultTLSHost) {
|
||||
d.args = append(d.args, []string{"--host", d.Sock()}...)
|
||||
d.args = append(d.args, "--host", d.Sock())
|
||||
}
|
||||
if root := os.Getenv("DOCKER_REMAP_ROOT"); root != "" {
|
||||
d.args = append(d.args, []string{"--userns-remap", root}...)
|
||||
d.args = append(d.args, "--userns-remap", root)
|
||||
}
|
||||
|
||||
// If we don't explicitly set the log-level or debug flag(-D) then
|
||||
|
|
|
@ -7,6 +7,16 @@ import (
|
|||
// Option is used to configure a daemon.
|
||||
type Option func(*Daemon)
|
||||
|
||||
// WithContainerdSocket sets the --containerd option on the daemon.
|
||||
// Use an empty string to remove the option.
|
||||
//
|
||||
// If unset the --containerd option will be used with a default value.
|
||||
func WithContainerdSocket(socket string) Option {
|
||||
return func(d *Daemon) {
|
||||
d.containerdSocket = socket
|
||||
}
|
||||
}
|
||||
|
||||
// WithDefaultCgroupNamespaceMode sets the default cgroup namespace mode for the daemon
|
||||
func WithDefaultCgroupNamespaceMode(mode string) Option {
|
||||
return func(d *Daemon) {
|
||||
|
|
Loading…
Reference in a new issue