mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Restored removed docker init options
Signed-off-by: Abin Shahab <ashahab@altiscale.com> (github: ashahab-altiscale)
This commit is contained in:
parent
1a26ed09ee
commit
3bd3f7854a
3 changed files with 19 additions and 10 deletions
|
@ -24,7 +24,6 @@ import (
|
||||||
"github.com/docker/libcontainer"
|
"github.com/docker/libcontainer"
|
||||||
"github.com/docker/libcontainer/cgroups"
|
"github.com/docker/libcontainer/cgroups"
|
||||||
"github.com/docker/libcontainer/mount/nodes"
|
"github.com/docker/libcontainer/mount/nodes"
|
||||||
"github.com/docker/libcontainer/system"
|
|
||||||
"github.com/kr/pty"
|
"github.com/kr/pty"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -135,6 +134,15 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
|
||||||
"--",
|
"--",
|
||||||
c.InitPath,
|
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 != "" {
|
if c.ProcessConfig.User != "" {
|
||||||
params = append(params, "-u", c.ProcessConfig.User)
|
params = append(params, "-u", c.ProcessConfig.User)
|
||||||
|
@ -217,19 +225,14 @@ func (d *driver) Run(c *execdriver.Command, pipes *execdriver.Pipes, startCallba
|
||||||
return terminate(err)
|
return terminate(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
started, err := system.GetProcessStartTime(pid)
|
|
||||||
if err != nil {
|
|
||||||
return terminate(err)
|
|
||||||
}
|
|
||||||
cgroupPaths, err := cgroupPaths(c.ID)
|
cgroupPaths, err := cgroupPaths(c.ID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return terminate(err)
|
return terminate(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
state := &libcontainer.State{
|
state := &libcontainer.State{
|
||||||
InitPid: pid,
|
InitPid: pid,
|
||||||
InitStartTime: started,
|
CgroupPaths: cgroupPaths,
|
||||||
CgroupPaths: cgroupPaths,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := libcontainer.SaveState(dataPath, state); err != nil {
|
if err := libcontainer.SaveState(dataPath, state); err != nil {
|
||||||
|
|
|
@ -79,8 +79,11 @@ func getArgs() *InitArgs {
|
||||||
var (
|
var (
|
||||||
// Get cmdline arguments
|
// Get cmdline arguments
|
||||||
user = flag.String("u", "", "username or uid")
|
user = flag.String("u", "", "username or uid")
|
||||||
|
gateway = flag.String("g", "", "gateway address")
|
||||||
|
ip = flag.String("i", "", "ip address")
|
||||||
workDir = flag.String("w", "", "workdir")
|
workDir = flag.String("w", "", "workdir")
|
||||||
privileged = flag.Bool("privileged", false, "privileged mode")
|
privileged = flag.Bool("privileged", false, "privileged mode")
|
||||||
|
mtu = flag.Int("mtu", 1500, "interface mtu")
|
||||||
capAdd = flag.String("cap-add", "", "capabilities to add")
|
capAdd = flag.String("cap-add", "", "capabilities to add")
|
||||||
capDrop = flag.String("cap-drop", "", "capabilities to drop")
|
capDrop = flag.String("cap-drop", "", "capabilities to drop")
|
||||||
)
|
)
|
||||||
|
@ -89,9 +92,12 @@ func getArgs() *InitArgs {
|
||||||
|
|
||||||
return &InitArgs{
|
return &InitArgs{
|
||||||
User: *user,
|
User: *user,
|
||||||
|
Gateway: *gateway,
|
||||||
|
Ip: *ip,
|
||||||
WorkDir: *workDir,
|
WorkDir: *workDir,
|
||||||
Privileged: *privileged,
|
Privileged: *privileged,
|
||||||
Args: flag.Args(),
|
Args: flag.Args(),
|
||||||
|
Mtu: *mtu,
|
||||||
CapAdd: *capAdd,
|
CapAdd: *capAdd,
|
||||||
CapDrop: *capDrop,
|
CapDrop: *capDrop,
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,8 +58,8 @@ func TestHelpWidth(t *testing.T) {
|
||||||
if len(line) > 80 {
|
if len(line) > 80 {
|
||||||
t.Fatalf("Line is too long(%d chars):\n%s", len(line), line)
|
t.Fatalf("Line is too long(%d chars):\n%s", len(line), line)
|
||||||
}
|
}
|
||||||
if home != "" && strings.Contains(line, home) {
|
if scanForHome && strings.Contains(line, `=`+home) {
|
||||||
t.Fatalf("Help for %q should use ~ instead of %q on:\n%s", command, home, line)
|
t.Fatalf("Line should use '%q' instead of %q:\n%s", homedir.GetShortcutString(), home, line)
|
||||||
}
|
}
|
||||||
if runtime.GOOS != "windows" {
|
if runtime.GOOS != "windows" {
|
||||||
i := strings.Index(line, homedir.GetShortcutString())
|
i := strings.Index(line, homedir.GetShortcutString())
|
||||||
|
|
Loading…
Reference in a new issue