Skip to content

Commit

Permalink
Restored removed docker init options
Browse files Browse the repository at this point in the history
Signed-off-by: Abin Shahab <[email protected]> (github: ashahab-altiscale)
  • Loading branch information
ashahab-altiscale committed Feb 24, 2015
1 parent 1a26ed0 commit 3bd3f78
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 10 deletions.
19 changes: 11 additions & 8 deletions daemon/execdriver/lxc/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"github.com/docker/libcontainer"
"github.com/docker/libcontainer/cgroups"
"github.com/docker/libcontainer/mount/nodes"
"github.com/docker/libcontainer/system"
"github.com/kr/pty"
)

Expand Down Expand Up @@ -135,6 +134,15 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
"--",
c.InitPath,
)
if c.Network.Interface != nil {
params = append(params,
"-g", c.Network.Interface.Gateway,
"-i", fmt.Sprintf("%s/%d", c.Network.Interface.IPAddress, c.Network.Interface.IPPrefixLen),
)
}
params = append(params,
"-mtu", strconv.Itoa(c.Network.Mtu),
)

if c.ProcessConfig.User != "" {
params = append(params, "-u", c.ProcessConfig.User)
Expand Down Expand Up @@ -217,19 +225,14 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
return terminate(err)
}

started, err := system.GetProcessStartTime(pid)
if err != nil {
return terminate(err)
}
cgroupPaths, err := cgroupPaths(c.ID)
if err != nil {
return terminate(err)
}

state := &libcontainer.State{
InitPid: pid,
InitStartTime: started,
CgroupPaths: cgroupPaths,
InitPid: pid,
CgroupPaths: cgroupPaths,
}

if err := libcontainer.SaveState(dataPath, state); err != nil {
Expand Down
6 changes: 6 additions & 0 deletions daemon/execdriver/lxc/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ func getArgs() *InitArgs {
var (
// Get cmdline arguments
user = flag.String("u", "", "username or uid")
gateway = flag.String("g", "", "gateway address")
ip = flag.String("i", "", "ip address")
workDir = flag.String("w", "", "workdir")
privileged = flag.Bool("privileged", false, "privileged mode")
mtu = flag.Int("mtu", 1500, "interface mtu")
capAdd = flag.String("cap-add", "", "capabilities to add")
capDrop = flag.String("cap-drop", "", "capabilities to drop")
)
Expand All @@ -89,9 +92,12 @@ func getArgs() *InitArgs {

return &InitArgs{
User: *user,
Gateway: *gateway,
Ip: *ip,
WorkDir: *workDir,
Privileged: *privileged,
Args: flag.Args(),
Mtu: *mtu,
CapAdd: *capAdd,
CapDrop: *capDrop,
}
Expand Down
4 changes: 2 additions & 2 deletions integration-cli/docker_cli_help_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,8 @@ func TestHelpWidth(t *testing.T) {
if len(line) > 80 {
t.Fatalf("Line is too long(%d chars):\n%s", len(line), line)
}
if home != "" && strings.Contains(line, home) {
t.Fatalf("Help for %q should use ~ instead of %q on:\n%s", command, home, line)
if scanForHome && strings.Contains(line, `=`+home) {
t.Fatalf("Line should use '%q' instead of %q:\n%s", homedir.GetShortcutString(), home, line)
}
if runtime.GOOS != "windows" {
i := strings.Index(line, homedir.GetShortcutString())
Expand Down

0 comments on commit 3bd3f78

Please sign in to comment.