Create the working directory on container creation
if create a container with -w to specify the working directory and the directory does not exist in the container rootfs, the directory will be created until the container start. It make docker export of a created container and a running container inconsistent. Signed-off-by: Lei Jitang <leijitang@huawei.com>
This commit is contained in:
parent
af6c6dbf87
commit
cde0ed67a1
|
@ -22,6 +22,10 @@ func (daemon *Daemon) createContainerPlatformSpecificSettings(container *contain
|
||||||
}
|
}
|
||||||
defer daemon.Unmount(container)
|
defer daemon.Unmount(container)
|
||||||
|
|
||||||
|
if err := container.SetupWorkingDirectory(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
for spec := range config.Volumes {
|
for spec := range config.Volumes {
|
||||||
name := stringid.GenerateNonCryptoID()
|
name := stringid.GenerateNonCryptoID()
|
||||||
destination := filepath.Clean(spec)
|
destination := filepath.Clean(spec)
|
||||||
|
|
|
@ -6152,8 +6152,8 @@ func (s *DockerSuite) TestBuildBuildTimeArgExpansion(c *check.C) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.Fatal(err)
|
c.Fatal(err)
|
||||||
}
|
}
|
||||||
if res != wdVal {
|
if res != filepath.Clean(wdVal) {
|
||||||
c.Fatalf("Config.WorkingDir value mismatch. Expected: %s, got: %s", wdVal, res)
|
c.Fatalf("Config.WorkingDir value mismatch. Expected: %s, got: %s", filepath.Clean(wdVal), res)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = inspectFieldAndMarshall(imgName, "Config.Env", &resArr)
|
err = inspectFieldAndMarshall(imgName, "Config.Env", &resArr)
|
||||||
|
|
|
@ -415,3 +415,11 @@ func (s *DockerSuite) TestCreateStopSignal(c *check.C) {
|
||||||
c.Assert(res, checker.Contains, "9")
|
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 New Issue