Signed-off-by: John Howard <jhoward@microsoft.com>
John Howard authored on 2016/10/30 10:43:04... | ... |
@@ -16,6 +16,14 @@ func (daemon *Daemon) createContainerPlatformSpecificSettings(container *contain |
16 | 16 |
hostConfig.Isolation = daemon.defaultIsolation |
17 | 17 |
} |
18 | 18 |
|
19 |
+ if err := daemon.Mount(container); err != nil { |
|
20 |
+ return nil |
|
21 |
+ } |
|
22 |
+ defer daemon.Unmount(container) |
|
23 |
+ if err := container.SetupWorkingDirectory(0, 0); err != nil { |
|
24 |
+ return err |
|
25 |
+ } |
|
26 |
+ |
|
19 | 27 |
for spec := range config.Volumes { |
20 | 28 |
|
21 | 29 |
mp, err := volume.ParseMountRaw(spec, hostConfig.VolumeDriver) |
... | ... |
@@ -1865,10 +1865,6 @@ func (s *DockerSuite) TestBuildWindowsWorkdirProcessing(c *check.C) { |
1865 | 1865 |
func (s *DockerSuite) TestBuildWindowsAddCopyPathProcessing(c *check.C) { |
1866 | 1866 |
testRequires(c, DaemonIsWindows) |
1867 | 1867 |
name := "testbuildwindowsaddcopypathprocessing" |
1868 |
- // TODO Windows (@jhowardmsft). Needs a follow-up PR to 22181 to |
|
1869 |
- // support backslash such as .\\ being equivalent to ./ and c:\\ being |
|
1870 |
- // equivalent to c:/. This is not currently (nor ever has been) supported |
|
1871 |
- // by docker on the Windows platform. |
|
1872 | 1868 |
dockerfile := ` |
1873 | 1869 |
FROM busybox |
1874 | 1870 |
# No trailing slash on COPY/ADD |
... | ... |
@@ -1878,8 +1874,8 @@ func (s *DockerSuite) TestBuildWindowsAddCopyPathProcessing(c *check.C) { |
1878 | 1878 |
WORKDIR /wc2 |
1879 | 1879 |
ADD wc2 c:/wc2 |
1880 | 1880 |
WORKDIR c:/ |
1881 |
- RUN sh -c "[ $(cat c:/wc1) = 'hellowc1' ]" |
|
1882 |
- RUN sh -c "[ $(cat c:/wc2) = 'worldwc2' ]" |
|
1881 |
+ RUN sh -c "[ $(cat c:/wc1/wc1) = 'hellowc1' ]" |
|
1882 |
+ RUN sh -c "[ $(cat c:/wc2/wc2) = 'worldwc2' ]" |
|
1883 | 1883 |
|
1884 | 1884 |
# Trailing slash on COPY/ADD, Windows-style path. |
1885 | 1885 |
WORKDIR /wd1 |
... | ... |
@@ -7174,3 +7170,28 @@ RUN echo vegeta |
7174 | 7174 |
c.Assert(out, checker.Contains, "Step 2/3 : RUN echo grafana && echo raintank") |
7175 | 7175 |
c.Assert(out, checker.Contains, "Step 3/3 : RUN echo vegeta") |
7176 | 7176 |
} |
7177 |
+ |
|
7178 |
+// Verifies if COPY file . when WORKDIR is set to a non-existing directory, |
|
7179 |
+// the directory is created and the file is copied into the directory, |
|
7180 |
+// as opposed to the file being copied as a file with the name of the |
|
7181 |
+// directory. Fix for 27545 (found on Windows, but regression good for Linux too) |
|
7182 |
+func (s *DockerSuite) TestBuildCopyFileDotWithWorkdir(c *check.C) { |
|
7183 |
+ name := "testbuildcopyfiledotwithworkdir" |
|
7184 |
+ |
|
7185 |
+ ctx, err := fakeContext(`FROM busybox |
|
7186 |
+WORKDIR /foo |
|
7187 |
+COPY file . |
|
7188 |
+RUN ["cat", "/foo/file"] |
|
7189 |
+`, |
|
7190 |
+ map[string]string{}) |
|
7191 |
+ if err != nil { |
|
7192 |
+ c.Fatal(err) |
|
7193 |
+ } |
|
7194 |
+ defer ctx.Close() |
|
7195 |
+ if err := ctx.Add("file", "content"); err != nil { |
|
7196 |
+ c.Fatal(err) |
|
7197 |
+ } |
|
7198 |
+ if _, err = buildImageFromContext(name, ctx, true); err != nil { |
|
7199 |
+ c.Fatal(err) |
|
7200 |
+ } |
|
7201 |
+} |