Merge pull request #12025 from coolljt0725/add_exec_with_user
Add docker exec run command as a different user and in privileged mode Upstream-commit: 12f7db18309950785e873119edb03e0a1621e7a3 Component: engine
This commit is contained in:
@@ -138,6 +138,8 @@ func (d *Daemon) ContainerExecCreate(job *engine.Job) error {
|
||||
Tty: config.Tty,
|
||||
Entrypoint: entrypoint,
|
||||
Arguments: args,
|
||||
User: config.User,
|
||||
Privileged: config.Privileged,
|
||||
}
|
||||
|
||||
execConfig := &execConfig{
|
||||
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"github.com/docker/libcontainer/utils"
|
||||
)
|
||||
|
||||
// TODO(vishh): Add support for running in privileged 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 {
|
||||
@@ -28,7 +27,11 @@ func (d *driver) Exec(c *execdriver.Command, processConfig *execdriver.ProcessCo
|
||||
Args: append([]string{processConfig.Entrypoint}, processConfig.Arguments...),
|
||||
Env: c.ProcessConfig.Env,
|
||||
Cwd: c.WorkingDir,
|
||||
User: c.ProcessConfig.User,
|
||||
User: processConfig.User,
|
||||
}
|
||||
|
||||
if processConfig.Privileged {
|
||||
p.Capabilities = execdriver.GetAllCapabilities()
|
||||
}
|
||||
|
||||
if processConfig.Tty {
|
||||
|
||||
Reference in New Issue
Block a user