コード例 #1
0
ファイル: container.go プロジェクト: jpgbus/docker
func populateCommand(c *Container) {
	var (
		en           *execdriver.Network
		driverConfig = c.hostConfig.DriverOptions
	)

	if driverConfig == nil {
		driverConfig = make(map[string][]string)
	}

	en = &execdriver.Network{
		Mtu:       c.runtime.config.Mtu,
		Interface: nil,
	}

	if !c.Config.NetworkDisabled {
		network := c.NetworkSettings
		en.Interface = &execdriver.NetworkInterface{
			Gateway:     network.Gateway,
			Bridge:      network.Bridge,
			IPAddress:   network.IPAddress,
			IPPrefixLen: network.IPPrefixLen,
		}
	}

	// TODO: this can be removed after lxc-conf is fully deprecated
	mergeLxcConfIntoOptions(c.hostConfig, driverConfig)

	resources := &execdriver.Resources{
		Memory:     c.Config.Memory,
		MemorySwap: c.Config.MemorySwap,
		CpuShares:  c.Config.CpuShares,
	}
	c.command = &execdriver.Command{
		ID:         c.ID,
		Privileged: c.hostConfig.Privileged,
		Rootfs:     c.RootfsPath(),
		InitPath:   "/.dockerinit",
		Entrypoint: c.Path,
		Arguments:  c.Args,
		WorkingDir: c.Config.WorkingDir,
		Network:    en,
		Tty:        c.Config.Tty,
		User:       c.Config.User,
		Config:     driverConfig,
		Resources:  resources,
		Context:    c.Config.Context,
	}
	c.command.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
}
コード例 #2
0
ファイル: container.go プロジェクト: rws-github/docker
func populateCommand(c *Container) {
	var (
		en           *execdriver.Network
		driverConfig []string
	)

	en = &execdriver.Network{
		Mtu:       c.runtime.config.Mtu,
		Interface: nil,
	}

	if !c.Config.NetworkDisabled {
		network := c.NetworkSettings
		en.Interface = &execdriver.NetworkInterface{
			Gateway:     network.Gateway,
			Bridge:      network.Bridge,
			IPAddress:   network.IPAddress,
			IPPrefixLen: network.IPPrefixLen,
		}
	}

	if lxcConf := c.hostConfig.LxcConf; lxcConf != nil {
		for _, pair := range lxcConf {
			driverConfig = append(driverConfig, fmt.Sprintf("%s = %s", pair.Key, pair.Value))
		}
	}
	resources := &execdriver.Resources{
		Memory:     c.Config.Memory,
		MemorySwap: c.Config.MemorySwap,
		CpuShares:  c.Config.CpuShares,
	}
	c.command = &execdriver.Command{
		ID:         c.ID,
		Privileged: c.hostConfig.Privileged,
		Rootfs:     c.RootfsPath(),
		InitPath:   "/.dockerinit",
		Entrypoint: c.Path,
		Arguments:  c.Args,
		WorkingDir: c.Config.WorkingDir,
		Network:    en,
		Tty:        c.Config.Tty,
		User:       c.Config.User,
		Config:     driverConfig,
		Resources:  resources,
		Context:    c.Config.Context,
	}
	c.command.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
}