summaryrefslogtreecommitdiff
path: root/libpod/container_internal.go
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2022-01-06 10:42:34 -0500
committerDaniel J Walsh <dwalsh@redhat.com>2022-01-06 10:42:34 -0500
commit13f3fd2555b1f02af4c183ef51d1707af1198eb9 (patch)
tree385b25f04df21cf41537227494fd2fb166eca62b /libpod/container_internal.go
parentc0b3df805999551db1da8ec2866457c555e627c7 (diff)
downloadpodman-13f3fd2555b1f02af4c183ef51d1707af1198eb9.tar.gz
podman-13f3fd2555b1f02af4c183ef51d1707af1198eb9.tar.bz2
podman-13f3fd2555b1f02af4c183ef51d1707af1198eb9.zip
Set volume NeedsCopyUp to false iff data was copied up
Currently Docker copies up the first volume on a mountpoint with data. Fixes: https://github.com/containers/podman/issues/12714 Also added NeedsCopyUP, NeedsChown and MountCount to the podman volume inspect code. Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'libpod/container_internal.go')
-rw-r--r--libpod/container_internal.go14
1 files changed, 7 insertions, 7 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 2d12a90d1..3361fb3b2 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -1700,13 +1700,6 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string)
if vol.state.NeedsCopyUp {
logrus.Debugf("Copying up contents from container %s to volume %s", c.ID(), vol.Name())
- // Set NeedsCopyUp to false immediately, so we don't try this
- // again when there are already files copied.
- vol.state.NeedsCopyUp = false
- if err := vol.save(); err != nil {
- return nil, err
- }
-
// If the volume is not empty, we should not copy up.
volMount := vol.mountPoint()
contents, err := ioutil.ReadDir(volMount)
@@ -1753,6 +1746,13 @@ func (c *Container) mountNamedVolume(v *ContainerNamedVolume, mountpoint string)
return vol, nil
}
+ // Set NeedsCopyUp to false since we are about to do first copy
+ // Do not copy second time.
+ vol.state.NeedsCopyUp = false
+ if err := vol.save(); err != nil {
+ return nil, err
+ }
+
// Buildah Copier accepts a reader, so we'll need a pipe.
reader, writer := io.Pipe()
defer reader.Close()