Commit Graph

83 Commits

Author SHA1 Message Date
Daniel J Walsh fc6baddc97
Update to containers/common v0.3.0
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-18 17:45:01 -05:00
Nalin Dahyabhai f3a5653c92 run: adjust the order in which elements are added to $PATH
When building the slice of environment variables to add to the
configuration for a container that we're about to run, in case of
conflicts, we want the values from the base image or working container
to override the global defaults, and we want values that were passed to
us through the API to override them both.

In cases of conflicts, values which occur later in the slice override
values which occurred earlier, so we want to add them in this order:
* values from containers.conf
* values from the base image or working container
* values passed to us through the API

We previously applied the containers.conf defaults after the base image
or working container's value, and that meant that containers.conf's
values always took precedence over the values in the image.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>
2020-02-17 15:40:42 -05:00
Daniel J Walsh cca09881c3
Repair buildah so it can use containers.conf on the server side
In porting containers.conf to libpod, we found that buildah needed
to handle the containers.conf on the server side rather then from
the CLI.

Since the `podman-remote build` would probably not have the same content
as containers.conf on the server, the processesing of the defaults needs
to be handled in imagebuildah.  The CapAdd and CapDrop values need to be
passed in.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-02-10 09:41:31 -05:00
Daniel J Walsh 09d1c24e3d Add support for containers.conf
This is a rework of Qi Wang's patches.
Import package pkg/config from containers/common to read containers.conf
This patch allows users to specify default values stored in containers.conf
that will modify the behaviour of buildah tool.

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

Closes: #2011
Approved by: TomSweeneyRedHat
2020-01-15 17:24:36 +00: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 fb7d2b6bd6
Add support for FIPS-Mode backends
If host is running in fips mode, then RHEL8.2 and beyond container images
will come with a directory /usr/share/crypto-policies/back-ends/FIPS.
This directory needs to be bind mounted over /etc/crypto-policies/back-ends in
order to make all tools in the container follow the FIPS Mode rules.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-12-19 08:53:56 -05: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
Urvashi Mohnani 54ef0073bc Add disableFips option to secrets pkg
If disableFips is set, then we don't mount the FIPS
secret even if the machine is in FIPs mode. This is
to help users run workloads that are not fips compliant
in openshift even if their machine is in FIPs mode.
This is needed in CRI-O.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2019-10-31 10:04:01 -04:00
Daniel J Walsh 20a33e0791 Add --devices flag to bud and from
Some Dockerfiles (fuse-overlay) require additional devices to be in the
build environment.

This patch allows the user to specify additional devices.

Also I noticed that CapAdd and CapDrop was not working in buildah bud situations,
so this patch also fixes this.

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

Closes: #1820
Approved by: @TomSweeneyRedHat
2019-09-07 17:32:43 +00:00
Daniel J Walsh 7f0b60c6f7
Add support for /run/.containerenv
Container processes want to check for the existence of this file
to determine if they are running inside of a container.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2019-09-06 11:56:27 -04:00
Nalin Dahyabhai 6b5f8badc1 Correctly detect ExitError values from Run()
Correctly detect ExitError error values returned by buildah.Run().

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1816
Approved by: TomSweeneyRedHat
2019-08-22 18:29:17 +00:00
Nalin Dahyabhai db2b3e48ac add: add a DryRun flag to AddAndCopyOptions
Add a DryRun flag to AddAndCopyOptions, so that we can "copy" content to
digest it.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1792
Approved by: TomSweeneyRedHat
2019-08-16 20:16:40 +00:00
Giuseppe Scrivano 7180312fdf run_linux: fix mounting /sys in a userns
fix the detection code for running in a user namespace.  When buildah
is running in rootless mode, a user namespace is automatically created
even if there are no mappings configured.

Closes: https://github.com/containers/libpod/issues/2972

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

Closes: #1775
Approved by: rhatdan
2019-08-11 12:41:51 +00:00
Nalin Dahyabhai be51b9bd24 Update to match updated runtime-tools API
Some method argument types changed in runtime-tools. Compensate.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1720
Approved by: vrothberg
2019-07-17 12:41:32 +00:00
Sascha Grunert 16e301031e Add unparam linter and apply fixes
This commit enabled the `unparam` linter and applies all reported issues.

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

Closes: #1719
Approved by: rhatdan
2019-07-16 21:21:32 +00:00
Qi Wang 130cf4516f Add --mount for buildah run
support mount type of bind and tmpfs

Signed-off-by: Qi Wang <qiwan@redhat.com>

Closes: #1673
Approved by: rhatdan
2019-07-02 08:48:55 +00:00
Giuseppe Scrivano 4d9da85473 rootless: add the built-in slirp DNS server
add the slirp built-in DNS server when using slirp4netns.

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

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

Closes: #1688
Approved by: TomSweeneyRedHat
2019-06-26 13:33:12 +00:00
Valentin Rothberg d3b5960957 run_linux.go: ignore unchecked errors
Reported by golangci-lint.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>

Closes: #1678
Approved by: rhatdan
2019-06-19 11:33:36 +00:00
TomSweeneyRedHat fcc05b7d60 buildah-run: fix-out-of-range panic (2)
Fix an out-of-range panic in buildah-run by moving the call to
setNonbloc() to the appropriate place (i.e., only when the copyPipes
parameter is set).

Replaces #1672.  Needed to make two smaller functions to make gofmt
happy.

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1674
Approved by: rhatdan
2019-06-15 09:40:55 +00:00
Giuseppe Scrivano dc7b50c9da run: fix hang with run and --isolation=chroot
make the stdin pipe not blocking, so that it won't hang if the other
end is not reading from it.

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

Closes: #1668
Approved by: rhatdan
2019-06-13 13:26:46 +00:00
Giuseppe Scrivano 7a5afdb452 run: fix hang when using run
make the stdin pipe not blocking, so that it won't hang if the other
end is not reading from it.

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

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

Closes: #1668
Approved by: rhatdan
2019-06-13 13:26:46 +00:00
Jordan Webb 94e095aaf8 Always close stdin pipe
Fixes: https://github.com/containers/buildah/issues/1650
Signed-off-by: Jordan Webb <jordemort@github.com>

Closes: #1653
Approved by: rhatdan
2019-06-12 08:35:10 +00:00
Lawrence Chan 49d8eb5b77 Only set default network sysctls if not rootless
Signed-off-by: Lawrence Chan <element103@gmail.com>

Closes: #1663
Approved by: rhatdan
2019-06-11 10:05:59 +00:00
Jordan Webb 5892f9db57 Support --dns=none like podman
Signed-off-by: Jordan Webb <jordemort@github.com>

Closes: #1649
Approved by: giuseppe
2019-06-11 07:20:50 +00:00
Nalin Dahyabhai 3bdc9edd67 imagebuildah: handle ID mappings for COPY --from
Fix handling of ID mapping for COPY: when copying from other containers,
use their mappings, and when copying from the host, use host mappings.

Signed-off-by: Nalin Dahyabhai <nalin@redhat.com>

Closes: #1630
Approved by: TomSweeneyRedHat
2019-06-06 13:11:25 +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
Giuseppe Scrivano fa7f030da8 linux: add check for sysctl before using it
check that the sysctl we'd like to use is supported by the kernel
before using it.

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

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

Closes: #1619
Approved by: rhatdan
2019-05-28 17:40:32 +00:00
TomSweeneyRedHat e43b864952 Add default /root if empty on chroot iso
Checks to see if the $HOME envvar has been set
and if not, trys to set it as best as possible.

Fixes: #1592

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1594
Approved by: rhatdan
2019-05-22 06:53:33 +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
Daniel J Walsh 7793c51a41 Fix rootless handling of /dev/shm size
Rootless mode was ignoreing the --shm-size option.
For some reason the test that would have caught this was disabled.

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

Closes: #1595
Approved by: vrothberg
2019-05-18 09:31:58 +00:00
TomSweeneyRedHat 78fb869817 Don't create directory on container
In a prior PR, we were creating the directory from the
translated symlink onto the host container.  Instead
try to create that in the container and if it exists
already, just continue.

Fixes: #1562

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #1565
Approved by: rhatdan
2019-05-01 21:42:12 +00:00
baude 34e7eba408 allow podman to build a client for windows
the podman remote-client for windows pulls in some buildah code for
things like commit and build.  we need to perform some slight
refactoring of buildah code to accomodate that build.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #1551
Approved by: rhatdan
2019-04-26 19:16:11 +00:00
baude 5cd9be61ef allow buildah cross compile for a darwin target
the goal here is to allow ourselves to cross compile buildah for a darwin
target.  we are doing this to eventually protect from regressions that could
creep into buildah so we don't dig ourselves a deeper hole.

the simplified and non-variable approach to the make darwin was done with
intent to keep this simple until we can exploit things a little more.

once this PR merges, i will create a CI test that will test for regressions
on a make darwin.  we should also be doing a gofmt with a darwin target so the
!linux|darwin tagged files are also checked for completeness.  initially the
test can be optional for passing with the long-term idea that it be made
a firm requirement at the buildah maintainers behest.

Signed-off-by: baude <bbaude@redhat.com>

Closes: #840
Approved by: rhatdan
2018-07-01 09:13:39 +00:00