mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Merge pull request #19155 from coolljt0725/create_cwd_on_create
Create the working directory on container creation
This commit is contained in:
commit
a225e39667
3 changed files with 14 additions and 2 deletions
|
@ -23,6 +23,10 @@ func (daemon *Daemon) createContainerPlatformSpecificSettings(container *contain
|
|||
}
|
||||
defer daemon.Unmount(container)
|
||||
|
||||
if err := container.SetupWorkingDirectory(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for spec := range config.Volumes {
|
||||
name := stringid.GenerateNonCryptoID()
|
||||
destination := filepath.Clean(spec)
|
||||
|
|
|
@ -6170,8 +6170,8 @@ func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *check.C) {
|
|||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
if res != wdVal {
|
||||
c.Fatalf("Config.WorkingDir value mismatch. Expected: %s, got: %s", wdVal, res)
|
||||
if res != filepath.Clean(wdVal) {
|
||||
c.Fatalf("Config.WorkingDir value mismatch. Expected: %s, got: %s", filepath.Clean(wdVal), res)
|
||||
}
|
||||
|
||||
err = inspectFieldAndMarshall(imgName, "Config.Env", &resArr)
|
||||
|
|
|
@ -415,3 +415,11 @@ func (s *DockerSuite) TestCreateStopSignal(c *check.C) {
|
|||
c.Assert(res, checker.Contains, "9")
|
||||
|
||||
}
|
||||
|
||||
func (s *DockerSuite) TestCreateWithWorkdir(c *check.C) {
|
||||
testRequires(c, DaemonIsLinux)
|
||||
name := "foo"
|
||||
dir := "/home/foo/bar"
|
||||
dockerCmd(c, "create", "--name", name, "-w", dir, "busybox")
|
||||
dockerCmd(c, "cp", fmt.Sprintf("%s:%s", name, dir), "/tmp")
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue