|
@@ -602,6 +602,78 @@ RUN [ $(cat "/test dir/test_file6") = 'test6' ]`, command, command, command, com
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+func (s *DockerSuite) TestBuildAddChownFlag(c *check.C) {
|
|
|
|
+ testRequires(c, DaemonIsLinux) // Linux specific test
|
|
|
|
+ name := "testaddtonewdest"
|
|
|
|
+ ctx, err := fakeContext(`FROM busybox
|
|
|
|
+RUN echo 'test1:x:1001:1001::/bin:/bin/false' >> /etc/passwd
|
|
|
|
+RUN echo 'test1:x:1001:' >> /etc/group
|
|
|
|
+RUN echo 'test2:x:1002:' >> /etc/group
|
|
|
|
+ADD --chown=test1:1002 . /new_dir
|
|
|
|
+RUN ls -l /
|
|
|
|
+RUN [ $(ls -l / | grep new_dir | awk '{print $3":"$4}') = 'test1:test2' ]`,
|
|
|
|
+ map[string]string{
|
|
|
|
+ "test_dir/test_file": "test file",
|
|
|
|
+ })
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+ defer ctx.Close()
|
|
|
|
+
|
|
|
|
+ if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
|
|
|
+ c.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (s *DockerDaemonSuite) TestBuildAddChownFlagUserNamespace(c *check.C) {
|
|
|
|
+ testRequires(c, DaemonIsLinux) // Linux specific test
|
|
|
|
+
|
|
|
|
+ c.Assert(s.d.StartWithBusybox("--userns-remap", "default"), checker.IsNil)
|
|
|
|
+
|
|
|
|
+ name := "testaddtonewdest"
|
|
|
|
+ ctx, err := fakeContext(`FROM busybox
|
|
|
|
+RUN echo 'test1:x:1001:1001::/bin:/bin/false' >> /etc/passwd
|
|
|
|
+RUN echo 'test1:x:1001:' >> /etc/group
|
|
|
|
+RUN echo 'test2:x:1002:' >> /etc/group
|
|
|
|
+ADD --chown=test1:1002 . /new_dir
|
|
|
|
+RUN ls -l /
|
|
|
|
+RUN [ $(ls -l / | grep new_dir | awk '{print $3":"$4}') = 'test1:test2' ]`,
|
|
|
|
+ map[string]string{
|
|
|
|
+ "test_dir/test_file": "test file",
|
|
|
|
+ })
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+ defer ctx.Close()
|
|
|
|
+
|
|
|
|
+ if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
|
|
|
+ c.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+func (s *DockerSuite) TestBuildCopyChownFlag(c *check.C) {
|
|
|
|
+ testRequires(c, DaemonIsLinux) // Linux specific test
|
|
|
|
+ name := "testaddtonewdest"
|
|
|
|
+ ctx, err := fakeContext(`FROM busybox
|
|
|
|
+RUN echo 'test1:x:1001:1001::/bin:/bin/false' >> /etc/passwd
|
|
|
|
+RUN echo 'test1:x:1001:' >> /etc/group
|
|
|
|
+RUN echo 'test2:x:1002:' >> /etc/group
|
|
|
|
+COPY --chown=test1:1002 . /new_dir
|
|
|
|
+RUN ls -l /
|
|
|
|
+RUN [ $(ls -l / | grep new_dir | awk '{print $3":"$4}') = 'test1:test2' ]`,
|
|
|
|
+ map[string]string{
|
|
|
|
+ "test_dir/test_file": "test file",
|
|
|
|
+ })
|
|
|
|
+ if err != nil {
|
|
|
|
+ c.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+ defer ctx.Close()
|
|
|
|
+
|
|
|
|
+ if _, err := buildImageFromContext(name, ctx, true); err != nil {
|
|
|
|
+ c.Fatal(err)
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
+
|
|
func (s *DockerSuite) TestBuildCopyFileWithWhitespaceOnWindows(c *check.C) {
|
|
func (s *DockerSuite) TestBuildCopyFileWithWhitespaceOnWindows(c *check.C) {
|
|
testRequires(c, DaemonIsWindows)
|
|
testRequires(c, DaemonIsWindows)
|
|
dockerfile := `FROM ` + testEnv.MinimalBaseImage() + `
|
|
dockerfile := `FROM ` + testEnv.MinimalBaseImage() + `
|