mirror of
https://github.com/moby/moby.git
synced 2025-08-01 05:47:11 +03:00
COPY file . after WORKDIR (now always created)
Signed-off-by: John Howard <jhoward@microsoft.com>
This commit is contained in:
@ -1878,8 +1878,8 @@ func (s *DockerSuite) TestBuildWindowsAddCopyPathProcessing(c *check.C) {
|
||||
WORKDIR /wc2
|
||||
ADD wc2 c:/wc2
|
||||
WORKDIR c:/
|
||||
RUN sh -c "[ $(cat c:/wc1) = 'hellowc1' ]"
|
||||
RUN sh -c "[ $(cat c:/wc2) = 'worldwc2' ]"
|
||||
RUN sh -c "[ $(cat c:/wc1/wc1) = 'hellowc1' ]"
|
||||
RUN sh -c "[ $(cat c:/wc2/wc2) = 'worldwc2' ]"
|
||||
|
||||
# Trailing slash on COPY/ADD, Windows-style path.
|
||||
WORKDIR /wd1
|
||||
@ -7283,3 +7283,31 @@ func (s *DockerSuite) TestBuildWindowsUser(c *check.C) {
|
||||
}
|
||||
c.Assert(strings.ToLower(out), checker.Contains, "username=user")
|
||||
}
|
||||
|
||||
// Verifies if COPY file . when WORKDIR is set to a non-existing directory,
|
||||
// the directory is created and the file is copied into the directory,
|
||||
// as opposed to the file being copied as a file with the name of the
|
||||
// directory. Fix for 27545 (found on Windows, but regression good for Linux too).
|
||||
// Note 27545 was reverted in 28505, but a new fix was added subsequently in 28514.
|
||||
func (s *DockerSuite) TestBuildCopyFileDotWithWorkdir(c *check.C) {
|
||||
name := "testbuildcopyfiledotwithworkdir"
|
||||
ctx, err := fakeContext(`FROM busybox
|
||||
WORKDIR /foo
|
||||
COPY file .
|
||||
RUN ["cat", "/foo/file"]
|
||||
`,
|
||||
map[string]string{})
|
||||
|
||||
if err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
defer ctx.Close()
|
||||
|
||||
if err := ctx.Add("file", "content"); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
|
||||
if _, err = buildImageFromContext(name, ctx, true); err != nil {
|
||||
c.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user