diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2020-10-26 11:35:02 +0100 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2020-10-29 15:06:22 +0100 |
commit | 65a618886efc48562e5b9ff99ca630c83622419b (patch) | |
tree | 09d19a7f6fe596a1b9e19fec6e45288f2b76de5a /test/system/060-mount.bats | |
parent | cce6c6cd40137c460f173300b36c5868383870c5 (diff) | |
download | podman-65a618886efc48562e5b9ff99ca630c83622419b.tar.gz podman-65a618886efc48562e5b9ff99ca630c83622419b.tar.bz2 podman-65a618886efc48562e5b9ff99ca630c83622419b.zip |
new "image" mount type
Add a new "image" mount type to `--mount`. The source of the mount is
the name or ID of an image. The destination is the path inside the
container. Image mounts further support an optional `rw,readwrite`
parameter which if set to "true" will yield the mount writable inside
the container. Note that no changes are propagated to the image mount
on the host (which in any case is read only).
Mounts are overlay mounts. To support read-only overlay mounts, vendor
a non-release version of Buildah.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'test/system/060-mount.bats')
-rw-r--r-- | test/system/060-mount.bats | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/test/system/060-mount.bats b/test/system/060-mount.bats index ece87acf6..73d210084 100644 --- a/test/system/060-mount.bats +++ b/test/system/060-mount.bats @@ -78,4 +78,77 @@ load helpers is "$output" "" "podman image mount, no args, after umount" } +@test "podman run --mount image" { + skip_if_rootless "too hard to test rootless" + + # Run a container with an image mount + run_podman run --rm --mount type=image,src=$IMAGE,dst=/image-mount $IMAGE diff /etc/os-release /image-mount/etc/os-release + + # Make sure the mount is read only + run_podman 1 run --rm --mount type=image,src=$IMAGE,dst=/image-mount $IMAGE touch /image-mount/read-only + is "$output" "touch: /image-mount/read-only: Read-only file system" + + # Make sure that rw,readwrite work + run_podman run --rm --mount type=image,src=$IMAGE,dst=/image-mount,rw=true $IMAGE touch /image-mount/readwrite + run_podman run --rm --mount type=image,src=$IMAGE,dst=/image-mount,readwrite=true $IMAGE touch /image-mount/readwrite + + skip_if_remote "mounting remote is meaningless" + + # The mount should be cleaned up during container removal as no other entity mounted the image + run_podman image umount $IMAGE + is "$output" "" "image mount should have been cleaned up during container removal" + + # Now make sure that the image mount is not cleaned up during container removal when another entity mounted the image + run_podman image mount $IMAGE + run_podman run --rm --mount type=image,src=$IMAGE,dst=/image-mount $IMAGE diff /etc/os-release /image-mount/etc/os-release + + run_podman image inspect --format '{{.ID}}' $IMAGE + iid="$output" + + run_podman image umount $IMAGE + is "$output" "$iid" "podman image umount: image ID of what was umounted" + + run_podman image umount $IMAGE + is "$output" "" "image mount should have been cleaned up via 'image umount'" + + # Run a container in the background (source is the ID instead of name) + run_podman run -d --mount type=image,src=$iid,dst=/image-mount,readwrite=true $IMAGE sleep infinity + cid="$output" + + # Unmount the image + run_podman image umount $IMAGE + is "$output" "$iid" "podman image umount: image ID of what was umounted" + run_podman image umount $IMAGE + is "$output" "" "image mount should have been cleaned up via 'image umount'" + + # Make sure that the mount in the container is unaffected + run_podman exec $cid diff /etc/os-release /image-mount/etc/os-release + run_podman exec $cid find /image-mount/etc/ + + # Clean up + run_podman rm -f $cid +} + +@test "podman run --mount image inspection" { + skip_if_rootless "too hard to test rootless" + + # Run a container in the background + run_podman run -d --mount type=image,src=$IMAGE,dst=/image-mount,rw=true $IMAGE sleep infinity + cid="$output" + + run_podman inspect --format "{{(index .Mounts 0).Type}}" $cid + is "$output" "image" "inspect data includes image mount type" + + run_podman inspect --format "{{(index .Mounts 0).Source}}" $cid + is "$output" "$IMAGE" "inspect data includes image mount source" + + run_podman inspect --format "{{(index .Mounts 0).Destination}}" $cid + is "$output" "/image-mount" "inspect data includes image mount source" + + run_podman inspect --format "{{(index .Mounts 0).RW}}" $cid + is "$output" "true" "inspect data includes image mount source" + + run_podman rm -f $cid +} + # vim: filetype=sh |