mirror of https://github.com/docker/docs.git
Move lxc template into lxc driver
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
9e9f4b925b
commit
70a5cb95b3
|
@ -12,8 +12,13 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
// https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt
|
type Values struct {
|
||||||
|
Memory int64 `json:"memory"`
|
||||||
|
MemorySwap int64 `json:"memory_swap"`
|
||||||
|
CpuShares int64 `json:"cpu_shares"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://www.kernel.org/doc/Documentation/cgroups/cgroups.txt
|
||||||
func FindCgroupMountpoint(subsystem string) (string, error) {
|
func FindCgroupMountpoint(subsystem string) (string, error) {
|
||||||
mounts, err := mount.GetMounts()
|
mounts, err := mount.GetMounts()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
39
container.go
39
container.go
|
@ -5,6 +5,7 @@ import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/dotcloud/docker/archive"
|
"github.com/dotcloud/docker/archive"
|
||||||
|
"github.com/dotcloud/docker/cgroups"
|
||||||
"github.com/dotcloud/docker/execdriver"
|
"github.com/dotcloud/docker/execdriver"
|
||||||
"github.com/dotcloud/docker/graphdriver"
|
"github.com/dotcloud/docker/graphdriver"
|
||||||
"github.com/dotcloud/docker/mount"
|
"github.com/dotcloud/docker/mount"
|
||||||
|
@ -299,15 +300,6 @@ func (container *Container) generateEnvConfig(env []string) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) generateLXCConfig() error {
|
|
||||||
fo, err := os.Create(container.lxcConfigPath())
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer fo.Close()
|
|
||||||
return LxcTemplateCompiled.Execute(fo, container)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (container *Container) setupPty() error {
|
func (container *Container) setupPty() error {
|
||||||
ptyMaster, ptySlave, err := pty.Open()
|
ptyMaster, ptySlave, err := pty.Open()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -554,10 +546,6 @@ func (container *Container) Start() (err error) {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := container.generateLXCConfig(); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
// Setup environment
|
// Setup environment
|
||||||
env := []string{
|
env := []string{
|
||||||
"HOME=/",
|
"HOME=/",
|
||||||
|
@ -662,17 +650,33 @@ func (container *Container) Start() (err error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var en *execdriver.Network
|
var (
|
||||||
|
en *execdriver.Network
|
||||||
|
driverConfig []string
|
||||||
|
)
|
||||||
|
|
||||||
if !container.Config.NetworkDisabled {
|
if !container.Config.NetworkDisabled {
|
||||||
network := container.NetworkSettings
|
network := container.NetworkSettings
|
||||||
en = &execdriver.Network{
|
en = &execdriver.Network{
|
||||||
Gateway: network.Gateway,
|
Gateway: network.Gateway,
|
||||||
|
Bridge: network.Bridge,
|
||||||
IPAddress: network.IPAddress,
|
IPAddress: network.IPAddress,
|
||||||
IPPrefixLen: network.IPPrefixLen,
|
IPPrefixLen: network.IPPrefixLen,
|
||||||
Mtu: container.runtime.config.Mtu,
|
Mtu: container.runtime.config.Mtu,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if lxcConf := container.hostConfig.LxcConf; lxcConf != nil {
|
||||||
|
for _, pair := range lxcConf {
|
||||||
|
driverConfig = append(driverConfig, fmt.Sprintf("%s = %s", pair.Key, pair.Value))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
cgroupValues := &cgroups.Values{
|
||||||
|
Memory: container.Config.Memory,
|
||||||
|
MemorySwap: container.Config.MemorySwap,
|
||||||
|
CpuShares: container.Config.CpuShares,
|
||||||
|
}
|
||||||
|
|
||||||
container.process = &execdriver.Process{
|
container.process = &execdriver.Process{
|
||||||
ID: container.ID,
|
ID: container.ID,
|
||||||
Privileged: container.hostConfig.Privileged,
|
Privileged: container.hostConfig.Privileged,
|
||||||
|
@ -681,10 +685,11 @@ func (container *Container) Start() (err error) {
|
||||||
Entrypoint: container.Path,
|
Entrypoint: container.Path,
|
||||||
Arguments: container.Args,
|
Arguments: container.Args,
|
||||||
WorkingDir: workingDir,
|
WorkingDir: workingDir,
|
||||||
ConfigPath: container.lxcConfigPath(),
|
|
||||||
Network: en,
|
Network: en,
|
||||||
Tty: container.Config.Tty,
|
Tty: container.Config.Tty,
|
||||||
User: container.Config.User,
|
User: container.Config.User,
|
||||||
|
Config: driverConfig,
|
||||||
|
Cgroups: cgroupValues,
|
||||||
}
|
}
|
||||||
container.process.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
container.process.SysProcAttr = &syscall.SysProcAttr{Setsid: true}
|
||||||
|
|
||||||
|
@ -1381,10 +1386,6 @@ func (container *Container) EnvConfigPath() (string, error) {
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (container *Container) lxcConfigPath() string {
|
|
||||||
return path.Join(container.root, "config.lxc")
|
|
||||||
}
|
|
||||||
|
|
||||||
// This method must be exported to be used from the lxc template
|
// This method must be exported to be used from the lxc template
|
||||||
func (container *Container) RootfsPath() string {
|
func (container *Container) RootfsPath() string {
|
||||||
return container.rootfs
|
return container.rootfs
|
||||||
|
|
|
@ -2,6 +2,7 @@ package execdriver
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/dotcloud/docker/cgroups"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
@ -71,6 +72,7 @@ type Driver interface {
|
||||||
type Network struct {
|
type Network struct {
|
||||||
Gateway string `json:"gateway"`
|
Gateway string `json:"gateway"`
|
||||||
IPAddress string `json:"ip"`
|
IPAddress string `json:"ip"`
|
||||||
|
Bridge string `json:"bridge"`
|
||||||
IPPrefixLen int `json:"ip_prefix_len"`
|
IPPrefixLen int `json:"ip_prefix_len"`
|
||||||
Mtu int `json:"mtu"`
|
Mtu int `json:"mtu"`
|
||||||
}
|
}
|
||||||
|
@ -79,17 +81,19 @@ type Network struct {
|
||||||
type Process struct {
|
type Process struct {
|
||||||
exec.Cmd
|
exec.Cmd
|
||||||
|
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Privileged bool `json:"privileged"`
|
Privileged bool `json:"privileged"`
|
||||||
User string `json:"user"`
|
User string `json:"user"`
|
||||||
Rootfs string `json:"rootfs"` // root fs of the container
|
Rootfs string `json:"rootfs"` // root fs of the container
|
||||||
InitPath string `json:"initpath"` // dockerinit
|
InitPath string `json:"initpath"` // dockerinit
|
||||||
Entrypoint string `json:"entrypoint"`
|
Entrypoint string `json:"entrypoint"`
|
||||||
Arguments []string `json:"arguments"`
|
Arguments []string `json:"arguments"`
|
||||||
WorkingDir string `json:"working_dir"`
|
WorkingDir string `json:"working_dir"`
|
||||||
ConfigPath string `json:"config_path"` // This should be able to be removed when the lxc template is moved into the driver
|
ConfigPath string `json:"config_path"` // This should be able to be removed when the lxc template is moved into the driver
|
||||||
Tty bool `json:"tty"`
|
Tty bool `json:"tty"`
|
||||||
Network *Network `json:"network"` // if network is nil then networking is disabled
|
Network *Network `json:"network"` // if network is nil then networking is disabled
|
||||||
|
Config []string `json:"config"`
|
||||||
|
Cgroups *cgroups.Values `json:"cgroups"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the pid of the process
|
// Return the pid of the process
|
||||||
|
|
|
@ -72,10 +72,14 @@ func (d *driver) Name() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) Run(c *execdriver.Process, startCallback execdriver.StartCallback) (int, error) {
|
func (d *driver) Run(c *execdriver.Process, startCallback execdriver.StartCallback) (int, error) {
|
||||||
|
configPath, err := d.generateLXCConfig(c)
|
||||||
|
if err != nil {
|
||||||
|
return -1, err
|
||||||
|
}
|
||||||
params := []string{
|
params := []string{
|
||||||
"lxc-start",
|
"lxc-start",
|
||||||
"-n", c.ID,
|
"-n", c.ID,
|
||||||
"-f", c.ConfigPath,
|
"-f", configPath,
|
||||||
"--",
|
"--",
|
||||||
c.InitPath,
|
c.InitPath,
|
||||||
"-driver",
|
"-driver",
|
||||||
|
@ -259,7 +263,6 @@ func (i *info) IsRunning() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *driver) Info(id string) execdriver.Info {
|
func (d *driver) Info(id string) execdriver.Info {
|
||||||
|
|
||||||
return &info{
|
return &info{
|
||||||
ID: id,
|
ID: id,
|
||||||
driver: d,
|
driver: d,
|
||||||
|
@ -297,3 +300,23 @@ func rootIsShared() bool {
|
||||||
// No idea, probably safe to assume so
|
// No idea, probably safe to assume so
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (d *driver) generateLXCConfig(p *execdriver.Process) (string, error) {
|
||||||
|
root := path.Join(d.root, "containers", p.ID, "config.lxc")
|
||||||
|
fo, err := os.Create(root)
|
||||||
|
if err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
defer fo.Close()
|
||||||
|
|
||||||
|
if err := LxcTemplateCompiled.Execute(fo, struct {
|
||||||
|
*execdriver.Process
|
||||||
|
AppArmor bool
|
||||||
|
}{
|
||||||
|
Process: p,
|
||||||
|
AppArmor: d.apparmor,
|
||||||
|
}); err != nil {
|
||||||
|
return "", err
|
||||||
|
}
|
||||||
|
return root, nil
|
||||||
|
}
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
package docker
|
package lxc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/dotcloud/docker/pkg/sysinfo"
|
"github.com/dotcloud/docker/cgroups"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
)
|
)
|
||||||
|
|
||||||
const LxcTemplate = `
|
const LxcTemplate = `
|
||||||
{{if .Config.NetworkDisabled}}
|
{{if .Network}}
|
||||||
# network is disabled (-n=false)
|
|
||||||
lxc.network.type = empty
|
|
||||||
{{else}}
|
|
||||||
# network configuration
|
# network configuration
|
||||||
lxc.network.type = veth
|
lxc.network.type = veth
|
||||||
lxc.network.link = {{.NetworkSettings.Bridge}}
|
lxc.network.link = {{.Network.Bridge}}
|
||||||
lxc.network.name = eth0
|
lxc.network.name = eth0
|
||||||
|
{{else}}
|
||||||
|
# network is disabled (-n=false)
|
||||||
|
lxc.network.type = empty
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
# root filesystem
|
# root filesystem
|
||||||
{{$ROOTFS := .RootfsPath}}
|
{{$ROOTFS := .Rootfs}}
|
||||||
lxc.rootfs = {{$ROOTFS}}
|
lxc.rootfs = {{$ROOTFS}}
|
||||||
|
|
||||||
# use a dedicated pts for the container (and limit the number of pseudo terminal
|
# use a dedicated pts for the container (and limit the number of pseudo terminal
|
||||||
|
@ -31,7 +31,7 @@ lxc.console = none
|
||||||
# no controlling tty at all
|
# no controlling tty at all
|
||||||
lxc.tty = 1
|
lxc.tty = 1
|
||||||
|
|
||||||
{{if (getHostConfig .).Privileged}}
|
{{if .Privileged}}
|
||||||
lxc.cgroup.devices.allow = a
|
lxc.cgroup.devices.allow = a
|
||||||
{{else}}
|
{{else}}
|
||||||
# no implicit access to devices
|
# no implicit access to devices
|
||||||
|
@ -82,8 +82,8 @@ lxc.mount.entry = sysfs {{escapeFstabSpaces $ROOTFS}}/sys sysfs nosuid,nodev,noe
|
||||||
lxc.mount.entry = devpts {{escapeFstabSpaces $ROOTFS}}/dev/pts devpts newinstance,ptmxmode=0666,nosuid,noexec 0 0
|
lxc.mount.entry = devpts {{escapeFstabSpaces $ROOTFS}}/dev/pts devpts newinstance,ptmxmode=0666,nosuid,noexec 0 0
|
||||||
lxc.mount.entry = shm {{escapeFstabSpaces $ROOTFS}}/dev/shm tmpfs size=65536k,nosuid,nodev,noexec 0 0
|
lxc.mount.entry = shm {{escapeFstabSpaces $ROOTFS}}/dev/shm tmpfs size=65536k,nosuid,nodev,noexec 0 0
|
||||||
|
|
||||||
{{if (getHostConfig .).Privileged}}
|
{{if .Privileged}}
|
||||||
{{if (getSysInfo .).AppArmor}}
|
{{if .AppArmor}}
|
||||||
lxc.aa_profile = unconfined
|
lxc.aa_profile = unconfined
|
||||||
{{else}}
|
{{else}}
|
||||||
#lxc.aa_profile = unconfined
|
#lxc.aa_profile = unconfined
|
||||||
|
@ -91,20 +91,22 @@ lxc.aa_profile = unconfined
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
# limits
|
# limits
|
||||||
{{if .Config.Memory}}
|
{{if .Cgroups}}
|
||||||
lxc.cgroup.memory.limit_in_bytes = {{.Config.Memory}}
|
{{if .Cgroups.Memory}}
|
||||||
lxc.cgroup.memory.soft_limit_in_bytes = {{.Config.Memory}}
|
lxc.cgroup.memory.limit_in_bytes = {{.Cgroups.Memory}}
|
||||||
{{with $memSwap := getMemorySwap .Config}}
|
lxc.cgroup.memory.soft_limit_in_bytes = {{.Cgroups.Memory}}
|
||||||
|
{{with $memSwap := getMemorySwap .Cgroups}}
|
||||||
lxc.cgroup.memory.memsw.limit_in_bytes = {{$memSwap}}
|
lxc.cgroup.memory.memsw.limit_in_bytes = {{$memSwap}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{if .Config.CpuShares}}
|
{{if .Cgroups.CpuShares}}
|
||||||
lxc.cgroup.cpu.shares = {{.Config.CpuShares}}
|
lxc.cgroup.cpu.shares = {{.Cgroups.CpuShares}}
|
||||||
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|
||||||
{{if (getHostConfig .).LxcConf}}
|
{{if .Config}}
|
||||||
{{range $pair := (getHostConfig .).LxcConf}}
|
{{range $value := .Config}}
|
||||||
{{$pair.Key}} = {{$pair.Value}}
|
{{$value}}
|
||||||
{{end}}
|
{{end}}
|
||||||
{{end}}
|
{{end}}
|
||||||
`
|
`
|
||||||
|
@ -117,29 +119,19 @@ func escapeFstabSpaces(field string) string {
|
||||||
return strings.Replace(field, " ", "\\040", -1)
|
return strings.Replace(field, " ", "\\040", -1)
|
||||||
}
|
}
|
||||||
|
|
||||||
func getMemorySwap(config *Config) int64 {
|
func getMemorySwap(v *cgroups.Values) int64 {
|
||||||
// By default, MemorySwap is set to twice the size of RAM.
|
// By default, MemorySwap is set to twice the size of RAM.
|
||||||
// If you want to omit MemorySwap, set it to `-1'.
|
// If you want to omit MemorySwap, set it to `-1'.
|
||||||
if config.MemorySwap < 0 {
|
if v.MemorySwap < 0 {
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
return config.Memory * 2
|
return v.Memory * 2
|
||||||
}
|
|
||||||
|
|
||||||
func getHostConfig(container *Container) *HostConfig {
|
|
||||||
return container.hostConfig
|
|
||||||
}
|
|
||||||
|
|
||||||
func getSysInfo(container *Container) *sysinfo.SysInfo {
|
|
||||||
return container.runtime.sysInfo
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
var err error
|
var err error
|
||||||
funcMap := template.FuncMap{
|
funcMap := template.FuncMap{
|
||||||
"getMemorySwap": getMemorySwap,
|
"getMemorySwap": getMemorySwap,
|
||||||
"getHostConfig": getHostConfig,
|
|
||||||
"getSysInfo": getSysInfo,
|
|
||||||
"escapeFstabSpaces": escapeFstabSpaces,
|
"escapeFstabSpaces": escapeFstabSpaces,
|
||||||
}
|
}
|
||||||
LxcTemplateCompiled, err = template.New("lxc").Funcs(funcMap).Parse(LxcTemplate)
|
LxcTemplateCompiled, err = template.New("lxc").Funcs(funcMap).Parse(LxcTemplate)
|
|
@ -1,11 +1,14 @@
|
||||||
package docker
|
package lxc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"github.com/dotcloud/docker/cgroups"
|
||||||
|
"github.com/dotcloud/docker/execdriver"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"math/rand"
|
"math/rand"
|
||||||
"os"
|
"os"
|
||||||
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
"time"
|
"time"
|
||||||
|
@ -17,32 +20,39 @@ func TestLXCConfig(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
|
|
||||||
|
os.MkdirAll(path.Join(root, "containers", "1"), 0777)
|
||||||
|
|
||||||
// Memory is allocated randomly for testing
|
// Memory is allocated randomly for testing
|
||||||
rand.Seed(time.Now().UTC().UnixNano())
|
rand.Seed(time.Now().UTC().UnixNano())
|
||||||
memMin := 33554432
|
var (
|
||||||
memMax := 536870912
|
memMin = 33554432
|
||||||
mem := memMin + rand.Intn(memMax-memMin)
|
memMax = 536870912
|
||||||
// CPU shares as well
|
mem = memMin + rand.Intn(memMax-memMin)
|
||||||
cpuMin := 100
|
cpuMin = 100
|
||||||
cpuMax := 10000
|
cpuMax = 10000
|
||||||
cpu := cpuMin + rand.Intn(cpuMax-cpuMin)
|
cpu = cpuMin + rand.Intn(cpuMax-cpuMin)
|
||||||
container := &Container{
|
)
|
||||||
root: root,
|
|
||||||
Config: &Config{
|
driver, err := NewDriver(root, false)
|
||||||
Memory: int64(mem),
|
if err != nil {
|
||||||
CpuShares: int64(cpu),
|
|
||||||
NetworkDisabled: true,
|
|
||||||
},
|
|
||||||
hostConfig: &HostConfig{
|
|
||||||
Privileged: false,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if err := container.generateLXCConfig(); err != nil {
|
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
grepFile(t, container.lxcConfigPath(),
|
process := &execdriver.Process{
|
||||||
|
ID: "1",
|
||||||
|
Cgroups: &cgroups.Values{
|
||||||
|
Memory: int64(mem),
|
||||||
|
CpuShares: int64(cpu),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
p, err := driver.generateLXCConfig(process)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
grepFile(t, p,
|
||||||
fmt.Sprintf("lxc.cgroup.memory.limit_in_bytes = %d", mem))
|
fmt.Sprintf("lxc.cgroup.memory.limit_in_bytes = %d", mem))
|
||||||
grepFile(t, container.lxcConfigPath(),
|
|
||||||
|
grepFile(t, p,
|
||||||
fmt.Sprintf("lxc.cgroup.memory.memsw.limit_in_bytes = %d", mem*2))
|
fmt.Sprintf("lxc.cgroup.memory.memsw.limit_in_bytes = %d", mem*2))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,31 +62,29 @@ func TestCustomLxcConfig(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
defer os.RemoveAll(root)
|
defer os.RemoveAll(root)
|
||||||
container := &Container{
|
|
||||||
root: root,
|
os.MkdirAll(path.Join(root, "containers", "1"), 0777)
|
||||||
Config: &Config{
|
|
||||||
Hostname: "foobar",
|
driver, err := NewDriver(root, false)
|
||||||
NetworkDisabled: true,
|
if err != nil {
|
||||||
},
|
|
||||||
hostConfig: &HostConfig{
|
|
||||||
Privileged: false,
|
|
||||||
LxcConf: []KeyValuePair{
|
|
||||||
{
|
|
||||||
Key: "lxc.utsname",
|
|
||||||
Value: "docker",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
Key: "lxc.cgroup.cpuset.cpus",
|
|
||||||
Value: "0,1",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
if err := container.generateLXCConfig(); err != nil {
|
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
grepFile(t, container.lxcConfigPath(), "lxc.utsname = docker")
|
process := &execdriver.Process{
|
||||||
grepFile(t, container.lxcConfigPath(), "lxc.cgroup.cpuset.cpus = 0,1")
|
ID: "1",
|
||||||
|
Privileged: false,
|
||||||
|
Config: []string{
|
||||||
|
"lxc.utsname = docker",
|
||||||
|
"lxc.cgroup.cpuset.cpus = 0,1",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
p, err := driver.generateLXCConfig(process)
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
grepFile(t, p, "lxc.utsname = docker")
|
||||||
|
grepFile(t, p, "lxc.cgroup.cpuset.cpus = 0,1")
|
||||||
}
|
}
|
||||||
|
|
||||||
func grepFile(t *testing.T, path string, pattern string) {
|
func grepFile(t *testing.T, path string, pattern string) {
|
Loading…
Reference in New Issue