mirror of https://github.com/docker/docs.git
Default process user to container config user.
Signed-off-by: David Calavera <david.calavera@gmail.com>
This commit is contained in:
parent
389b806945
commit
0faa4518ed
|
@ -109,7 +109,6 @@ func (d *Daemon) getActiveContainer(name string) (*Container, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (d *Daemon) ContainerExecCreate(config *runconfig.ExecConfig) (string, error) {
|
func (d *Daemon) ContainerExecCreate(config *runconfig.ExecConfig) (string, error) {
|
||||||
|
|
||||||
// Not all drivers support Exec (LXC for example)
|
// Not all drivers support Exec (LXC for example)
|
||||||
if err := checkExecSupport(d.execDriver.Name()); err != nil {
|
if err := checkExecSupport(d.execDriver.Name()); err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
|
@ -123,11 +122,16 @@ func (d *Daemon) ContainerExecCreate(config *runconfig.ExecConfig) (string, erro
|
||||||
cmd := runconfig.NewCommand(config.Cmd...)
|
cmd := runconfig.NewCommand(config.Cmd...)
|
||||||
entrypoint, args := d.getEntrypointAndArgs(runconfig.NewEntrypoint(), cmd)
|
entrypoint, args := d.getEntrypointAndArgs(runconfig.NewEntrypoint(), cmd)
|
||||||
|
|
||||||
|
user := config.User
|
||||||
|
if len(user) == 0 {
|
||||||
|
user = container.Config.User
|
||||||
|
}
|
||||||
|
|
||||||
processConfig := execdriver.ProcessConfig{
|
processConfig := execdriver.ProcessConfig{
|
||||||
Tty: config.Tty,
|
Tty: config.Tty,
|
||||||
Entrypoint: entrypoint,
|
Entrypoint: entrypoint,
|
||||||
Arguments: args,
|
Arguments: args,
|
||||||
User: config.User,
|
User: user,
|
||||||
}
|
}
|
||||||
|
|
||||||
execConfig := &execConfig{
|
execConfig := &execConfig{
|
||||||
|
|
|
@ -445,7 +445,6 @@ func (s *DockerSuite) TestInspectExecID(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) {
|
func (s *DockerSuite) TestLinksPingLinkedContainersOnRename(c *check.C) {
|
||||||
|
|
||||||
var out string
|
var out string
|
||||||
out, _ = dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
|
out, _ = dockerCmd(c, "run", "-d", "--name", "container1", "busybox", "top")
|
||||||
idA := strings.TrimSpace(out)
|
idA := strings.TrimSpace(out)
|
||||||
|
@ -610,7 +609,6 @@ func (s *DockerSuite) TestRunMutableNetworkFiles(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *DockerSuite) TestExecWithUser(c *check.C) {
|
func (s *DockerSuite) TestExecWithUser(c *check.C) {
|
||||||
|
|
||||||
runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "parent", "busybox", "top")
|
runCmd := exec.Command(dockerBinary, "run", "-d", "--name", "parent", "busybox", "top")
|
||||||
if out, _, err := runCommandWithOutput(runCmd); err != nil {
|
if out, _, err := runCommandWithOutput(runCmd); err != nil {
|
||||||
c.Fatal(out, err)
|
c.Fatal(out, err)
|
||||||
|
@ -635,3 +633,22 @@ func (s *DockerSuite) TestExecWithUser(c *check.C) {
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DockerSuite) TestExecWithImageUser(c *check.C) {
|
||||||
|
name := "testbuilduser"
|
||||||
|
_, err := buildImage(name,
|
||||||
|
`FROM busybox
|
||||||
|
RUN echo 'dockerio:x:1001:1001::/bin:/bin/false' >> /etc/passwd
|
||||||
|
USER dockerio`,
|
||||||
|
true)
|
||||||
|
if err != nil {
|
||||||
|
c.Fatalf("Could not build image %s: %v", name, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
dockerCmd(c, "run", "-d", "--name", "dockerioexec", name, "top")
|
||||||
|
|
||||||
|
out, _ := dockerCmd(c, "exec", "dockerioexec", "whoami")
|
||||||
|
if !strings.Contains(out, "dockerio") {
|
||||||
|
c.Fatalf("exec with user by id expected dockerio user got %s", out)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue