mirror of https://github.com/docker/docs.git
Remove container env var from libcontainer
Update tests to use native driver Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
8db740a38e
commit
431d510cae
|
@ -1,10 +1,48 @@
|
|||
package native
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/dotcloud/docker/execdriver"
|
||||
"github.com/dotcloud/docker/pkg/cgroups"
|
||||
"github.com/dotcloud/docker/pkg/libcontainer"
|
||||
)
|
||||
|
||||
// createContainer populates and configrues the container type with the
|
||||
// data provided by the execdriver.Command
|
||||
func createContainer(c *execdriver.Command) *libcontainer.Container {
|
||||
container := getDefaultTemplate()
|
||||
|
||||
container.Hostname = getEnv("HOSTNAME", c.Env)
|
||||
container.Tty = c.Tty
|
||||
container.User = c.User
|
||||
container.WorkingDir = c.WorkingDir
|
||||
container.Env = c.Env
|
||||
|
||||
if c.Network != nil {
|
||||
container.Network = &libcontainer.Network{
|
||||
Mtu: c.Network.Mtu,
|
||||
Address: fmt.Sprintf("%s/%d", c.Network.IPAddress, c.Network.IPPrefixLen),
|
||||
Gateway: c.Network.Gateway,
|
||||
Type: "veth",
|
||||
Context: libcontainer.Context{
|
||||
"prefix": "dock",
|
||||
"bridge": c.Network.Bridge,
|
||||
},
|
||||
}
|
||||
}
|
||||
container.Cgroups.Name = c.ID
|
||||
if c.Privileged {
|
||||
container.Capabilities = nil
|
||||
container.Cgroups.DeviceAccess = true
|
||||
}
|
||||
if c.Resources != nil {
|
||||
container.Cgroups.CpuShares = c.Resources.CpuShares
|
||||
container.Cgroups.Memory = c.Resources.Memory
|
||||
container.Cgroups.MemorySwap = c.Resources.MemorySwap
|
||||
}
|
||||
return container
|
||||
}
|
||||
|
||||
// getDefaultTemplate returns the docker default for
|
||||
// the libcontainer configuration file
|
||||
func getDefaultTemplate() *libcontainer.Container {
|
||||
|
|
|
@ -231,39 +231,3 @@ func (d *dockerStateWriter) WritePid(pid int) error {
|
|||
func (d *dockerStateWriter) DeletePid() error {
|
||||
return d.dsw.DeletePid()
|
||||
}
|
||||
|
||||
func createContainer(c *execdriver.Command) *libcontainer.Container {
|
||||
container := getDefaultTemplate()
|
||||
|
||||
container.Hostname = getEnv("HOSTNAME", c.Env)
|
||||
container.Tty = c.Tty
|
||||
container.User = c.User
|
||||
container.WorkingDir = c.WorkingDir
|
||||
container.Env = c.Env
|
||||
|
||||
container.Env = append(container.Env, "container=docker")
|
||||
|
||||
if c.Network != nil {
|
||||
container.Network = &libcontainer.Network{
|
||||
Mtu: c.Network.Mtu,
|
||||
Address: fmt.Sprintf("%s/%d", c.Network.IPAddress, c.Network.IPPrefixLen),
|
||||
Gateway: c.Network.Gateway,
|
||||
Type: "veth",
|
||||
Context: libcontainer.Context{
|
||||
"prefix": "dock",
|
||||
"bridge": c.Network.Bridge,
|
||||
},
|
||||
}
|
||||
}
|
||||
container.Cgroups.Name = c.ID
|
||||
if c.Privileged {
|
||||
container.Capabilities = nil
|
||||
container.Cgroups.DeviceAccess = true
|
||||
}
|
||||
if c.Resources != nil {
|
||||
container.Cgroups.CpuShares = c.Resources.CpuShares
|
||||
container.Cgroups.Memory = c.Resources.Memory
|
||||
container.Cgroups.MemorySwap = c.Resources.MemorySwap
|
||||
}
|
||||
return container
|
||||
}
|
||||
|
|
|
@ -1044,7 +1044,6 @@ func TestEnv(t *testing.T) {
|
|||
goodEnv := []string{
|
||||
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
|
||||
"HOME=/",
|
||||
"container=docker",
|
||||
"HOSTNAME=" + utils.TruncateID(container.ID),
|
||||
"FALSE=true",
|
||||
"TRUE=false",
|
||||
|
|
|
@ -190,6 +190,7 @@ func newTestEngine(t utils.Fataler, autorestart bool, root string) *engine.Engin
|
|||
job := eng.Job("initserver")
|
||||
job.Setenv("Root", root)
|
||||
job.SetenvBool("AutoRestart", autorestart)
|
||||
job.Setenv("ExecDriver", "native")
|
||||
// TestGetEnabledCors and TestOptionsRoute require EnableCors=true
|
||||
job.SetenvBool("EnableCors", true)
|
||||
if err := job.Run(); err != nil {
|
||||
|
|
|
@ -713,7 +713,7 @@ func NewRuntimeFromDirectory(config *DaemonConfig, eng *engine.Engine) (*Runtime
|
|||
case "native":
|
||||
ed, err = native.NewDriver(config.Root)
|
||||
default:
|
||||
return nil, fmt.Errorf("unknow exec driver %s", config.ExecDriver)
|
||||
return nil, fmt.Errorf("unknown exec driver %s", config.ExecDriver)
|
||||
}
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
Loading…
Reference in New Issue