Skip to content

Commit 8de9950

Browse files
Merge pull request #12211 from vrothberg/3.4-bz-2014149
[3.4] volumes: be more tolerant and fix infinite loop
2 parents 75023e9 + 9e78185 commit 8de9950

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

libpod/container_path_resolution.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ func isPathOnBindMount(c *Container, containerPath string) bool {
161161
if cleanedContainerPath == filepath.Clean(m.Destination) {
162162
return true
163163
}
164-
for dest := m.Destination; dest != "/"; dest = filepath.Dir(dest) {
164+
for dest := m.Destination; dest != "/" && dest != "."; dest = filepath.Dir(dest) {
165165
if cleanedContainerPath == dest {
166166
return true
167167
}

pkg/specgen/generate/storage.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,6 @@ func getImageVolumes(ctx context.Context, img *libimage.Image, s *specgen.SpecGe
214214
}
215215
for volume := range inspect.Config.Volumes {
216216
logrus.Debugf("Image has volume at %q", volume)
217-
if err = parse.ValidateVolumeCtrDir(volume); err != nil {
218-
return nil, nil, err
219-
}
220217
cleanDest := filepath.Clean(volume)
221218
switch mode {
222219
case "", "anonymous":

test/system/070-build.bats

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ EOF
3939
cat >$dockerfile <<EOF
4040
FROM $IMAGE
4141
RUN echo $rand_content > /$rand_filename
42+
VOLUME ['/etc/foo', '/etc/bar']
4243
EOF
4344

4445
run_podman buildx build --load -t build_test --format=docker $tmpdir
@@ -47,6 +48,14 @@ EOF
4748
run_podman run --rm build_test cat /$rand_filename
4849
is "$output" "$rand_content" "reading generated file in image"
4950

51+
# Make sure the volumes are created at surprising yet Docker-compatible
52+
# destinations (see bugzilla.redhat.com/show_bug.cgi?id=2014149).
53+
run_podman run --rm build_test find /[ /etc/bar\] -print
54+
is "$output" "/\[
55+
/\[/etc
56+
/\[/etc/foo,
57+
/etc/bar]" "weird VOLUME gets converted to directories with brackets and comma"
58+
5059
run_podman rmi -f build_test
5160
}
5261

0 commit comments

Comments
 (0)