mirror of https://github.com/docker/docs.git
Import nsenter in docker.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
This commit is contained in:
parent
985d579586
commit
e1cf95b593
|
@ -18,8 +18,8 @@ import (
|
||||||
|
|
||||||
type ExecConfig struct {
|
type ExecConfig struct {
|
||||||
ProcessConfig execdriver.ProcessConfig
|
ProcessConfig execdriver.ProcessConfig
|
||||||
StreamConfig StreamConfig
|
StreamConfig
|
||||||
OpenStdin bool
|
OpenStdin bool
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Daemon) ContainerExec(job *engine.Job) engine.Status {
|
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)
|
attachErr = d.Attach(&execConfig.StreamConfig, config.AttachStdin, false, config.Tty, cStdin, cStdinCloser, cStdout, cStderr)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
log.Debugf("Exec Config is %+v\n", execConfig)
|
|
||||||
go func() {
|
go func() {
|
||||||
err := container.Exec(execConfig)
|
err := container.Exec(execConfig)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -22,6 +22,7 @@ import (
|
||||||
"github.com/docker/libcontainer/cgroups/systemd"
|
"github.com/docker/libcontainer/cgroups/systemd"
|
||||||
consolepkg "github.com/docker/libcontainer/console"
|
consolepkg "github.com/docker/libcontainer/console"
|
||||||
"github.com/docker/libcontainer/namespaces"
|
"github.com/docker/libcontainer/namespaces"
|
||||||
|
_ "github.com/docker/libcontainer/namespaces/nsenter"
|
||||||
"github.com/docker/libcontainer/system"
|
"github.com/docker/libcontainer/system"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -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) {
|
func (d *driver) Exec(c *execdriver.Command, processConfig *execdriver.ProcessConfig, pipes *execdriver.Pipes, startCallback execdriver.StartCallback) (int, error) {
|
||||||
active := d.activeContainers[c.ID]
|
active := d.activeContainers[c.ID]
|
||||||
if active == nil {
|
if active == nil {
|
||||||
|
|
|
@ -15,7 +15,6 @@ type ExecConfig struct {
|
||||||
AttachStdout bool
|
AttachStdout bool
|
||||||
Detach bool
|
Detach bool
|
||||||
Cmd []string
|
Cmd []string
|
||||||
Hostname string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ExecConfigFromJob(job *engine.Job) *ExecConfig {
|
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) {
|
func ParseExec(cmd *flag.FlagSet, args []string) (*ExecConfig, error) {
|
||||||
var (
|
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")
|
||||||
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")
|
||||||
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")
|
||||||
flHostname = cmd.String([]string{"h", "-hostname"}, "", "Container host name")
|
execCmd []string
|
||||||
flUser = cmd.String([]string{"u", "-user"}, "", "Username or UID")
|
container string
|
||||||
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 {
|
if err := cmd.Parse(args); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -56,12 +52,13 @@ func ParseExec(cmd *flag.FlagSet, args []string) (*ExecConfig, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
execConfig := &ExecConfig{
|
execConfig := &ExecConfig{
|
||||||
User: *flUser,
|
// TODO(vishh): Expose '-u' flag once it is supported.
|
||||||
Privileged: *flPrivileged,
|
User: "",
|
||||||
|
// TODO(vishh): Expose '-p' flag once it is supported.
|
||||||
|
Privileged: false,
|
||||||
Tty: *flTty,
|
Tty: *flTty,
|
||||||
Cmd: execCmd,
|
Cmd: execCmd,
|
||||||
Container: container,
|
Container: container,
|
||||||
Hostname: *flHostname,
|
|
||||||
Detach: *flDetach,
|
Detach: *flDetach,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue