Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions daemon/mgr/container_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,8 @@ func (mgr *ContainerManager) getMountPointFromBinds(ctx context.Context, c *Cont
mp.Named = false
mp.Driver = ""
}
} else {
mp.CopyData = false
}

c.Mounts = append(c.Mounts, mp)
Expand Down
28 changes: 28 additions & 0 deletions test/cli_run_volume_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,34 @@ func (suite *PouchRunVolumeSuite) TestRunWithTmpFSVolume(c *check.C) {
c.Assert(strings.Contains(res.Stdout(), "1.0M"), check.Equals, true)
}

//TestRunWithVolumeCopyData tests binds copying data
//Pouch volumes should copy data, but host bind mount should not.
func (suite *PouchRunVolumeSuite) TestRunWithVolumeCopyData(c *check.C) {
volumeName := "volume-test-copydata"
hostdir := "/tmp/bind-test-copydata"
containerName1 := "copydata-test-1"
containerName2 := "copydata-test-2"

// create volume
command.PouchRun("volume", "create", "-n", volumeName).Assert(c, icmd.Success)
defer func() {
command.PouchRun("volume", "rm", volumeName).Assert(c, icmd.Success)
}()

command.PouchRun("run", "-t", "-v", volumeName+":/var", "--name", containerName1, busyboxImage, "ls", "/var").Assert(c, icmd.Success)
defer DelContainerForceMultyTime(c, containerName1)
output1 := icmd.RunCommand("ls", DefaultVolumeMountPath+"/"+volumeName).Stdout()
lines := strings.Split(output1, "\n")
c.Assert(lines[0], check.Equals, "spool")
c.Assert(lines[1], check.Equals, "www")

command.PouchRun("run", "-t", "-v", hostdir+":/var", "--name", containerName2, busyboxImage, "ls", "/var").Assert(c, icmd.Success)
defer DelContainerForceMultyTime(c, containerName2)
defer icmd.RunCommand("rm", "-rf", hostdir)
output2 := icmd.RunCommand("ls", hostdir).Stdout()
c.Assert(output2, check.Equals, "")
}

// TestRunWithHostFileVolume tests binding a host file as a volume into container.
// fixes https://github.com/alibaba/pouch/issues/813
func (suite *PouchRunVolumeSuite) TestRunWithHostFileVolume(c *check.C) {
Expand Down