Import nsenter in docker.

Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
This commit is contained in:
Vishnu Kannan 2014-09-09 17:36:13 +00:00
parent 985d579586
commit e1cf95b593
4 changed files with 13 additions and 15 deletions

View file

@ -18,8 +18,8 @@ import (
type ExecConfig struct {
ProcessConfig execdriver.ProcessConfig
StreamConfig StreamConfig
OpenStdin bool
StreamConfig
OpenStdin bool
}
func (d *Daemon) ContainerExec(job *engine.Job) engine.Status {
@ -92,7 +92,6 @@ func (d *Daemon) ContainerExec(job *engine.Job) engine.Status {
attachErr = d.Attach(&execConfig.StreamConfig, config.AttachStdin, false, config.Tty, cStdin, cStdinCloser, cStdout, cStderr)
}()
log.Debugf("Exec Config is %+v\n", execConfig)
go func() {
err := container.Exec(execConfig)
if err != nil {

View file

@ -22,6 +22,7 @@ import (
"github.com/docker/libcontainer/cgroups/systemd"
consolepkg "github.com/docker/libcontainer/console"
"github.com/docker/libcontainer/namespaces"
_ "github.com/docker/libcontainer/namespaces/nsenter"
"github.com/docker/libcontainer/system"
)

View file

@ -37,6 +37,7 @@ func nsenterExec() {
}
}
// TODO(vishh): Add support for running in priviledged mode and running as a different user.
func (d *driver) Exec(c *execdriver.Command, processConfig *execdriver.ProcessConfig, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
active := d.activeContainers[c.ID]
if active == nil {

View file

@ -15,7 +15,6 @@ type ExecConfig struct {
AttachStdout bool
Detach bool
Cmd []string
Hostname string
}
func ExecConfigFromJob(job *engine.Job) *ExecConfig {
@ -37,14 +36,11 @@ func ExecConfigFromJob(job *engine.Job) *ExecConfig {
func ParseExec(cmd *flag.FlagSet, args []string) (*ExecConfig, error) {
var (
flPrivileged = cmd.Bool([]string{"#privileged", "-privileged"}, false, "Give extended privileges to this container")
flStdin = cmd.Bool([]string{"i", "-interactive"}, false, "Keep STDIN open even if not attached")
flTty = cmd.Bool([]string{"t", "-tty"}, false, "Allocate a pseudo-TTY")
flHostname = cmd.String([]string{"h", "-hostname"}, "", "Container host name")
flUser = cmd.String([]string{"u", "-user"}, "", "Username or UID")
flDetach = cmd.Bool([]string{"d", "-detach"}, false, "Detached mode: run command in the background")
execCmd []string
container string
flStdin = cmd.Bool([]string{"i", "-interactive"}, false, "Keep STDIN open even if not attached")
flTty = cmd.Bool([]string{"t", "-tty"}, false, "Allocate a pseudo-TTY")
flDetach = cmd.Bool([]string{"d", "-detach"}, false, "Detached mode: run command in the background")
execCmd []string
container string
)
if err := cmd.Parse(args); err != nil {
return nil, err
@ -56,12 +52,13 @@ func ParseExec(cmd *flag.FlagSet, args []string) (*ExecConfig, error) {
}
execConfig := &ExecConfig{
User: *flUser,
Privileged: *flPrivileged,
// TODO(vishh): Expose '-u' flag once it is supported.
User: "",
// TODO(vishh): Expose '-p' flag once it is supported.
Privileged: false,
Tty: *flTty,
Cmd: execCmd,
Container: container,
Hostname: *flHostname,
Detach: *flDetach,
}