introduce workingdir
option for docker exec
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
parent
3a9ab941ad
commit
19f2749d39
4 changed files with 10 additions and 1 deletions
|
@ -7269,6 +7269,9 @@ paths:
|
|||
User:
|
||||
type: "string"
|
||||
description: "The user, and optionally, group to run the exec process inside the container. Format is one of: `user`, `user:group`, `uid`, or `uid:gid`."
|
||||
WorkingDir:
|
||||
type: "string"
|
||||
description: "The working directory for the exec process inside the container."
|
||||
example:
|
||||
AttachStdin: false
|
||||
AttachStdout: true
|
||||
|
|
|
@ -50,6 +50,7 @@ type ExecConfig struct {
|
|||
Detach bool // Execute in detach mode
|
||||
DetachKeys string // Escape keys for detach
|
||||
Env []string // Environment variables
|
||||
WorkingDir string // Working directory
|
||||
Cmd []string // Execution commands and args
|
||||
}
|
||||
|
||||
|
|
|
@ -122,6 +122,7 @@ func (d *Daemon) ContainerExecCreate(name string, config *types.ExecConfig) (str
|
|||
execConfig.Tty = config.Tty
|
||||
execConfig.Privileged = config.Privileged
|
||||
execConfig.User = config.User
|
||||
execConfig.WorkingDir = config.WorkingDir
|
||||
|
||||
linkedEnv, err := d.setupLinkedContainers(cntr)
|
||||
if err != nil {
|
||||
|
@ -131,6 +132,9 @@ func (d *Daemon) ContainerExecCreate(name string, config *types.ExecConfig) (str
|
|||
if len(execConfig.User) == 0 {
|
||||
execConfig.User = cntr.Config.User
|
||||
}
|
||||
if len(execConfig.WorkingDir) == 0 {
|
||||
execConfig.WorkingDir = cntr.Config.WorkingDir
|
||||
}
|
||||
|
||||
d.registerExecCommand(cntr, execConfig)
|
||||
|
||||
|
@ -211,7 +215,7 @@ func (d *Daemon) ContainerExecStart(ctx context.Context, name string, stdin io.R
|
|||
Args: append([]string{ec.Entrypoint}, ec.Args...),
|
||||
Env: ec.Env,
|
||||
Terminal: ec.Tty,
|
||||
Cwd: c.Config.WorkingDir,
|
||||
Cwd: ec.WorkingDir,
|
||||
}
|
||||
if p.Cwd == "" {
|
||||
p.Cwd = "/"
|
||||
|
|
|
@ -31,6 +31,7 @@ type Config struct {
|
|||
Tty bool
|
||||
Privileged bool
|
||||
User string
|
||||
WorkingDir string
|
||||
Env []string
|
||||
Pid int
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue