| ... | ... |
@@ -11,7 +11,7 @@ import ( |
| 11 | 11 |
"github.com/dotcloud/docker/pkg/units" |
| 12 | 12 |
) |
| 13 | 13 |
|
| 14 |
-type Action func(*libcontainer.Container, interface{}, string) error
|
|
| 14 |
+type Action func(*libcontainer.Config, interface{}, string) error
|
|
| 15 | 15 |
|
| 16 | 16 |
var actions = map[string]Action{
|
| 17 | 17 |
"cap.add": addCap, // add a cap |
| ... | ... |
@@ -35,7 +35,7 @@ var actions = map[string]Action{
|
| 35 | 35 |
"fs.readonly": readonlyFs, // make the rootfs of the container read only |
| 36 | 36 |
} |
| 37 | 37 |
|
| 38 |
-func cpusetCpus(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 38 |
+func cpusetCpus(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 39 | 39 |
if container.Cgroups == nil {
|
| 40 | 40 |
return fmt.Errorf("cannot set cgroups when they are disabled")
|
| 41 | 41 |
} |
| ... | ... |
@@ -44,7 +44,7 @@ func cpusetCpus(container *libcontainer.Container, context interface{}, value st
|
| 44 | 44 |
return nil |
| 45 | 45 |
} |
| 46 | 46 |
|
| 47 |
-func systemdSlice(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 47 |
+func systemdSlice(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 48 | 48 |
if container.Cgroups == nil {
|
| 49 | 49 |
return fmt.Errorf("cannot set slice when cgroups are disabled")
|
| 50 | 50 |
} |
| ... | ... |
@@ -53,12 +53,12 @@ func systemdSlice(container *libcontainer.Container, context interface{}, value
|
| 53 | 53 |
return nil |
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 |
-func apparmorProfile(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 56 |
+func apparmorProfile(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 57 | 57 |
container.Context["apparmor_profile"] = value |
| 58 | 58 |
return nil |
| 59 | 59 |
} |
| 60 | 60 |
|
| 61 |
-func cpuShares(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 61 |
+func cpuShares(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 62 | 62 |
if container.Cgroups == nil {
|
| 63 | 63 |
return fmt.Errorf("cannot set cgroups when they are disabled")
|
| 64 | 64 |
} |
| ... | ... |
@@ -70,7 +70,7 @@ func cpuShares(container *libcontainer.Container, context interface{}, value str
|
| 70 | 70 |
return nil |
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 |
-func memory(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 73 |
+func memory(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 74 | 74 |
if container.Cgroups == nil {
|
| 75 | 75 |
return fmt.Errorf("cannot set cgroups when they are disabled")
|
| 76 | 76 |
} |
| ... | ... |
@@ -83,7 +83,7 @@ func memory(container *libcontainer.Container, context interface{}, value string
|
| 83 | 83 |
return nil |
| 84 | 84 |
} |
| 85 | 85 |
|
| 86 |
-func memoryReservation(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 86 |
+func memoryReservation(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 87 | 87 |
if container.Cgroups == nil {
|
| 88 | 88 |
return fmt.Errorf("cannot set cgroups when they are disabled")
|
| 89 | 89 |
} |
| ... | ... |
@@ -96,7 +96,7 @@ func memoryReservation(container *libcontainer.Container, context interface{}, v
|
| 96 | 96 |
return nil |
| 97 | 97 |
} |
| 98 | 98 |
|
| 99 |
-func memorySwap(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 99 |
+func memorySwap(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 100 | 100 |
if container.Cgroups == nil {
|
| 101 | 101 |
return fmt.Errorf("cannot set cgroups when they are disabled")
|
| 102 | 102 |
} |
| ... | ... |
@@ -108,12 +108,12 @@ func memorySwap(container *libcontainer.Container, context interface{}, value st
|
| 108 | 108 |
return nil |
| 109 | 109 |
} |
| 110 | 110 |
|
| 111 |
-func addCap(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 111 |
+func addCap(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 112 | 112 |
container.Capabilities = append(container.Capabilities, value) |
| 113 | 113 |
return nil |
| 114 | 114 |
} |
| 115 | 115 |
|
| 116 |
-func dropCap(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 116 |
+func dropCap(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 117 | 117 |
// If the capability is specified multiple times, remove all instances. |
| 118 | 118 |
for i, capability := range container.Capabilities {
|
| 119 | 119 |
if capability == value {
|
| ... | ... |
@@ -125,17 +125,17 @@ func dropCap(container *libcontainer.Container, context interface{}, value strin
|
| 125 | 125 |
return nil |
| 126 | 126 |
} |
| 127 | 127 |
|
| 128 |
-func addNamespace(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 128 |
+func addNamespace(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 129 | 129 |
container.Namespaces[value] = true |
| 130 | 130 |
return nil |
| 131 | 131 |
} |
| 132 | 132 |
|
| 133 |
-func dropNamespace(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 133 |
+func dropNamespace(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 134 | 134 |
container.Namespaces[value] = false |
| 135 | 135 |
return nil |
| 136 | 136 |
} |
| 137 | 137 |
|
| 138 |
-func readonlyFs(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 138 |
+func readonlyFs(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 139 | 139 |
switch value {
|
| 140 | 140 |
case "1", "true": |
| 141 | 141 |
container.MountConfig.ReadonlyFs = true |
| ... | ... |
@@ -145,7 +145,7 @@ func readonlyFs(container *libcontainer.Container, context interface{}, value st
|
| 145 | 145 |
return nil |
| 146 | 146 |
} |
| 147 | 147 |
|
| 148 |
-func joinNetNamespace(container *libcontainer.Container, context interface{}, value string) error {
|
|
| 148 |
+func joinNetNamespace(container *libcontainer.Config, context interface{}, value string) error {
|
|
| 149 | 149 |
var ( |
| 150 | 150 |
running = context.(map[string]*exec.Cmd) |
| 151 | 151 |
cmd = running[value] |
| ... | ... |
@@ -168,7 +168,7 @@ func joinNetNamespace(container *libcontainer.Container, context interface{}, va
|
| 168 | 168 |
// container's default configuration. |
| 169 | 169 |
// |
| 170 | 170 |
// TODO: this can be moved to a general utils or parser in pkg |
| 171 |
-func ParseConfiguration(container *libcontainer.Container, running map[string]*exec.Cmd, opts []string) error {
|
|
| 171 |
+func ParseConfiguration(container *libcontainer.Config, running map[string]*exec.Cmd, opts []string) error {
|
|
| 172 | 172 |
for _, opt := range opts {
|
| 173 | 173 |
kv := strings.SplitN(opt, "=", 2) |
| 174 | 174 |
if len(kv) < 2 {
|
| ... | ... |
@@ -18,7 +18,7 @@ import ( |
| 18 | 18 |
|
| 19 | 19 |
// createContainer populates and configures the container type with the |
| 20 | 20 |
// data provided by the execdriver.Command |
| 21 |
-func (d *driver) createContainer(c *execdriver.Command) (*libcontainer.Container, error) {
|
|
| 21 |
+func (d *driver) createContainer(c *execdriver.Command) (*libcontainer.Config, error) {
|
|
| 22 | 22 |
container := template.New() |
| 23 | 23 |
|
| 24 | 24 |
container.Hostname = getEnv("HOSTNAME", c.Env)
|
| ... | ... |
@@ -70,7 +70,7 @@ func (d *driver) createContainer(c *execdriver.Command) (*libcontainer.Container |
| 70 | 70 |
return container, nil |
| 71 | 71 |
} |
| 72 | 72 |
|
| 73 |
-func (d *driver) createNetwork(container *libcontainer.Container, c *execdriver.Command) error {
|
|
| 73 |
+func (d *driver) createNetwork(container *libcontainer.Config, c *execdriver.Command) error {
|
|
| 74 | 74 |
if c.Network.HostNetworking {
|
| 75 | 75 |
container.Namespaces["NEWNET"] = false |
| 76 | 76 |
return nil |
| ... | ... |
@@ -117,7 +117,7 @@ func (d *driver) createNetwork(container *libcontainer.Container, c *execdriver. |
| 117 | 117 |
return nil |
| 118 | 118 |
} |
| 119 | 119 |
|
| 120 |
-func (d *driver) setPrivileged(container *libcontainer.Container) (err error) {
|
|
| 120 |
+func (d *driver) setPrivileged(container *libcontainer.Config) (err error) {
|
|
| 121 | 121 |
container.Capabilities = capabilities.GetAllCapabilities() |
| 122 | 122 |
container.Cgroups.AllowAllDevices = true |
| 123 | 123 |
|
| ... | ... |
@@ -136,7 +136,7 @@ func (d *driver) setPrivileged(container *libcontainer.Container) (err error) {
|
| 136 | 136 |
return nil |
| 137 | 137 |
} |
| 138 | 138 |
|
| 139 |
-func (d *driver) setupCgroups(container *libcontainer.Container, c *execdriver.Command) error {
|
|
| 139 |
+func (d *driver) setupCgroups(container *libcontainer.Config, c *execdriver.Command) error {
|
|
| 140 | 140 |
if c.Resources != nil {
|
| 141 | 141 |
container.Cgroups.CpuShares = c.Resources.CpuShares |
| 142 | 142 |
container.Cgroups.Memory = c.Resources.Memory |
| ... | ... |
@@ -148,7 +148,7 @@ func (d *driver) setupCgroups(container *libcontainer.Container, c *execdriver.C |
| 148 | 148 |
return nil |
| 149 | 149 |
} |
| 150 | 150 |
|
| 151 |
-func (d *driver) setupMounts(container *libcontainer.Container, c *execdriver.Command) error {
|
|
| 151 |
+func (d *driver) setupMounts(container *libcontainer.Config, c *execdriver.Command) error {
|
|
| 152 | 152 |
for _, m := range c.Mounts {
|
| 153 | 153 |
container.MountConfig.Mounts = append(container.MountConfig.Mounts, mount.Mount{
|
| 154 | 154 |
Type: "bind", |
| ... | ... |
@@ -162,7 +162,7 @@ func (d *driver) setupMounts(container *libcontainer.Container, c *execdriver.Co |
| 162 | 162 |
return nil |
| 163 | 163 |
} |
| 164 | 164 |
|
| 165 |
-func (d *driver) setupLabels(container *libcontainer.Container, c *execdriver.Command) error {
|
|
| 165 |
+func (d *driver) setupLabels(container *libcontainer.Config, c *execdriver.Command) error {
|
|
| 166 | 166 |
container.Context["process_label"] = c.Config["process_label"][0] |
| 167 | 167 |
container.Context["mount_label"] = c.Config["mount_label"][0] |
| 168 | 168 |
|
| ... | ... |
@@ -27,7 +27,7 @@ const ( |
| 27 | 27 |
|
| 28 | 28 |
func init() {
|
| 29 | 29 |
execdriver.RegisterInitFunc(DriverName, func(args *execdriver.InitArgs) error {
|
| 30 |
- var container *libcontainer.Container |
|
| 30 |
+ var container *libcontainer.Config |
|
| 31 | 31 |
f, err := os.Open(filepath.Join(args.Root, "container.json")) |
| 32 | 32 |
if err != nil {
|
| 33 | 33 |
return err |
| ... | ... |
@@ -54,7 +54,7 @@ func init() {
|
| 54 | 54 |
} |
| 55 | 55 |
|
| 56 | 56 |
type activeContainer struct {
|
| 57 |
- container *libcontainer.Container |
|
| 57 |
+ container *libcontainer.Config |
|
| 58 | 58 |
cmd *exec.Cmd |
| 59 | 59 |
} |
| 60 | 60 |
|
| ... | ... |
@@ -83,7 +83,7 @@ func NewDriver(root, initPath string) (*driver, error) {
|
| 83 | 83 |
} |
| 84 | 84 |
|
| 85 | 85 |
func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
|
| 86 |
- // take the Command and populate the libcontainer.Container from it |
|
| 86 |
+ // take the Command and populate the libcontainer.Config from it |
|
| 87 | 87 |
container, err := d.createContainer(c) |
| 88 | 88 |
if err != nil {
|
| 89 | 89 |
return -1, err |
| ... | ... |
@@ -110,7 +110,7 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba |
| 110 | 110 |
|
| 111 | 111 |
term := getTerminal(c, pipes) |
| 112 | 112 |
|
| 113 |
- return namespaces.Exec(container, term, c.Rootfs, dataPath, args, func(container *libcontainer.Container, console, rootfs, dataPath, init string, child *os.File, args []string) *exec.Cmd {
|
|
| 113 |
+ return namespaces.Exec(container, term, c.Rootfs, dataPath, args, func(container *libcontainer.Config, console, rootfs, dataPath, init string, child *os.File, args []string) *exec.Cmd {
|
|
| 114 | 114 |
// we need to join the rootfs because namespaces will setup the rootfs and chroot |
| 115 | 115 |
initPath := filepath.Join(c.Rootfs, c.InitPath) |
| 116 | 116 |
|
| ... | ... |
@@ -229,7 +229,7 @@ func (d *driver) GetPidsForContainer(id string) ([]int, error) {
|
| 229 | 229 |
return fs.GetPids(c) |
| 230 | 230 |
} |
| 231 | 231 |
|
| 232 |
-func (d *driver) writeContainerFile(container *libcontainer.Container, id string) error {
|
|
| 232 |
+func (d *driver) writeContainerFile(container *libcontainer.Config, id string) error {
|
|
| 233 | 233 |
data, err := json.Marshal(container) |
| 234 | 234 |
if err != nil {
|
| 235 | 235 |
return err |
| ... | ... |
@@ -7,8 +7,8 @@ import ( |
| 7 | 7 |
) |
| 8 | 8 |
|
| 9 | 9 |
// New returns the docker default configuration for libcontainer |
| 10 |
-func New() *libcontainer.Container {
|
|
| 11 |
- container := &libcontainer.Container{
|
|
| 10 |
+func New() *libcontainer.Config {
|
|
| 11 |
+ container := &libcontainer.Config{
|
|
| 12 | 12 |
Capabilities: []string{
|
| 13 | 13 |
"CHOWN", |
| 14 | 14 |
"DAC_OVERRIDE", |