Commit Graph

27 Commits

Author SHA1 Message Date
Nalin Dahyabhai 96e8e9710c pkg/overlay: add a MountLabel flag to Options
Add a way to pass a "set the SELinux contexts" labels to
MountWithOptions.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Signed-off-by: David Shea <dshea@redhat.com>
2025-01-21 10:28:44 -05:00
Nalin Dahyabhai 0d125ad3cd pkg/overlay: add a ForceMount flag to Options
Add a ForceMount flag to pkg/overlay.Options that forces mounting the
overlay filesystem and returning a bind mount to it instead of trying to
leave that for later in cases where we're able to have the kernel do it.

This is mainly for the sake of callers that want to do more things with
the mounted overlay filesystem before passing them to the (presumably)
OCI runtime.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
Signed-off-by: David Shea <dshea@redhat.com>
2025-01-21 10:22:32 -05:00
Giuseppe Scrivano 4d0eb18796
overlay: always honor mountProgram
if a mountProgram is specified, use it also in rootfull mode.

Closes: https://github.com/containers/buildah/issues/3281

[NO NEW TESTS NEEDED]

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-27 12:14:42 +01:00
Giuseppe Scrivano 5a25fc6f83
overlay: move mount program invocation to separate function
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-27 11:01:55 +01:00
Giuseppe Scrivano a0d3ce33eb
overlay: move mount program lookup to separate function
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-01-27 11:00:55 +01:00
Aditya R 316e34d268
mount: add support for custom upper and workdir with overlay mounts
Allow users to specify non-volatile `upper` and `workdir` with overlay
mounts.

Usage

```console
buildah from alpine
buildah run -v /something/lower:/test:z,O,upperdir=/somewhere/upperdir,workdir=/somwhere/workdir alpine-working-container cat /test/hello
```

Signed-off-by: Aditya R <arajan@redhat.com>
2022-01-20 21:35:34 +05:30
Aditya Rajan db6943a170
overlay: add MountWithOptions to API which extends support for advanced overlay
Expose `MountWithOptions` for overlay which allows users to pass more
verbose configuration for overlay mounts.

For instance `upperdir, workerdir` and in future `volatile`.

Signed-off-by: Aditya R <arajan@redhat.com>
2022-01-20 14:54:02 +05:30
chenk008 03186a3307 Support overlayfs path contains colon
In linux, directory can contains colon.
Add support to mount path contains colon.

buildah run --volume /root/a\\🅱️/root/test:O

Signed-off-by: chenk008 <kongchen28@gmail.com>
2021-10-20 14:40:38 +08:00
Daniel J Walsh 4dc36e85b4
Add support for rootless overlay mounts
This patch sets the userxattr field when run in rootless mode.

Fixes: https://github.com/containers/buildah/issues/3503

Patch came from @flouthoc  Aditya Rajan <arajan@redhat.com>

[NO TESTS NEEDED] Since this can not be tested in CI/CD system yet.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-09-09 13:27:46 -04:00
Nalin Dahyabhai 32c68951a4 imagebuildah: handle --manifest directly
When we're told to add built images to a manifest list, manipulate the
list ourselves, so that if we're creating a list, we won't have a
partially-populated list if some of the builds fail.

This also lets us include all of the platform information (including
variant info, which we can't sniff out after the fact) that we were
given when we started building the images.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2021-08-17 11:05:28 -04:00
flouthoc e62df2b67a Adds GenerateStructure helper function to support rootfs-overlay.
Following function generates a permanent overlayfs struct as compared to tempdir.

[NO NEW TESTS NEEDED]

Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2021-08-12 00:48:36 +05:30
Daniel J Walsh 2e1b71c3ef
Preserve ownership of lower directory when doing an overlay mount
Overlay mounts should work like volume bind mounts and preserve the
underlyng source directories permissions.

Fixes: https://github.com/containers/podman/issues/9947

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-07 07:19:18 -04:00
Daniel J Walsh 08201577e5
Remove some stuttering on returns errors
Golangs os.* functions return the name of the file/directory they
fail to use.  We should not wrap these errors with the file/directory
to use names, causes stuttering when the user sees the errors, and looks
bad having huge error messages.

Since this is just code cleanup, existing tests should handle the
changes.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-03 06:03:13 -04:00
Daniel J Walsh b7197a1e10
Set upperdir permissions based on source
We are setting the permissions based on the dest dir rather
then the source dir.  Since we want this to work identical to a bind
mount, we need to have the permissions align.

There is also an issue where overlays on existing mounts is blowing up.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-03-03 16:20:30 -05:00
Daniel J Walsh 0fcc8ff8f5
If destination does not exists, do not throw error
When using volume mounts, the destination directory will get
created if it does not exists. The current code blows up when
the destination directory did not exists.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-14 21:42:32 -05:00
Daniel J Walsh 84a261dd10
Upper directory should match mode of destination directory
When we mount over a destination directory inside of the container
we need to preserve the mode of the destination.

Needed to fix: https://github.com/containers/podman/issues/8801

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-06 14:44:38 -05:00
Valentin Rothberg efb3d21596 overlay.MountReadOnly: support RO overlay mounts
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-10-28 16:49:34 +01:00
Giuseppe Scrivano 777256bd51
overlay: use fusermount for rootless umounts
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-28 09:06:20 +01:00
Giuseppe Scrivano 2eb5b6f5e6
overlay: fix umount
there can be multiple overlay mounts for a container.  Each mount is
performed in a ../userdata/overlay subdirectory.

Iterate the subdirectories and attempt to unmount them.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-10-28 09:06:20 +01:00
Daniel J Walsh b2e7110255
vendor in latest containers/storage 1.18.0 and containers/common v0.7.0
This vendor moves containers/common/pkg/unshare to containers/storage/pkg/unshare

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-03-31 09:56:18 -04:00
Daniel J Walsh af05f5aa3c
Add codespell support
Check codespell on each PR in make validate.

Add fixes for issues found with codespell.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-01-10 12:12:30 -05:00
Daniel J Walsh 41b7852611 Rework overlay pkg for use with libpod
Podman uses the overlay mounts differently then in buildah.  Specifically the
overlay mount points can be used over and over again when starting and stopping
the container.  Since the paths are backed into the contianer config, we have
to be able to cleanout just the Upper and Merged directory rather then destroying
and recreating the overlay directories on each container start.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1822
Approved by: vrothberg
2019-12-22 12:04:13 +00:00
Daniel J Walsh 8fc5b0116f Start using containers/common
We have moved share code from buildah, podman and others into containers/common.

Specifically for this PR we are moving to use containers/common/pkg/unshare and
containers/common/pkg/cgroups.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #2010
Approved by: QiWang19
2019-12-06 14:37:27 +00:00
Giuseppe Scrivano 1ac63a264d rootless, overlay: use fuse-overlayfs
when running in rootless mode, use fuse-overlayfs for mounting the
overlay file system on the host.  Then create a bind mount inside the
container.

Closes: https://github.com/containers/buildah/issues/1741

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1743
Approved by: rhatdan
2019-07-29 23:46:00 +00:00
Sascha Grunert 6b214d2921 Add golint linter and apply fixes
This commit enabled to golint linter in golangci-lint and applies all
necessary fixes.

Signed-off-by: Sascha Grunert <sgrunert@suse.com>

Closes: #1740
Approved by: rhatdan
2019-07-27 09:45:49 +00:00
Daniel J Walsh fa67ecb27a Cleanup Overlay Mounts content
There is a chance that buildah crashed and left overlay
content.  This patch will remove any left over content
before creating the overlay mounts.

Also the previous patch would not be able to handle multiple
overlay volume mounts.  This patch fixes this issue as well.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1625
Approved by: TomSweeneyRedHat
2019-06-05 13:47:29 +00:00
Daniel J Walsh bcc5e51a94 Add support for Overlay volumes into the container.
Overlay mounts allow buildah bud and buildah from to
specify a directory on the disk that will be mounted
as an overlay into the container, where the overlay can be written to
but when the RUN or buildah run exits, the modified files will dissapear.

The basic idea is to be able to mount cache from the disk for things like yum/dnf/apt
to be able to be used and modified in the contianer on a run command, but to be
kept fresh for each RUN.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #1560
Approved by: giuseppe
2019-05-20 12:54:10 +00:00