Commit Graph

46 Commits

Author SHA1 Message Date
TomSweeneyRedHat 31cffe9040 Search for local runtime per values in containers.conf
After determining the type of runtime to use,
either "runc" or "crun" dependent upon the system, search
the list of that type of runtime in the containers.conf
file.  It includes the location of those runtimes in a
number of different architectures.  Once found, set the
runtime to use to that value.

Fixes: #2113

Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>
2020-02-26 19:35:37 -05:00
Sascha Grunert c0eed1c463
Improve remote manifest retrieval
Before this patch, it was not possible to retrieve a remote manifest
just by specifying the image name, like:

```
> buildah manifest inspect alpine
Invalid image name "alpine", expected colon-separated transport:reference
```

It was possible to get the manifest via:

```
> buildah manifest inspect docker://alpine
…
```

But after pulling the image into the local storage, this works not any
more:

```
> buildah pull alpine
e7d92cdc71feacf90708cb59182d0df1b911f8ae022d29e8e95d75ca6a99776a
> buildah manifest inspect docker://alpine
manifest from image … is of type
"application/vnd.docker.distribution.manifest.v2+json", which
is not a list type
ERRO exit status 1
```

This means we now collect a list of possible local or remote manifests
and try to resolve them sequentially. This enables us to fallback to the
remote location if the locally fetched manifest is not an actual
manifest. It also enables us to see the remote manifest via:

```
> ./buildah manifest inspect alpine
{
    …
}
```

Signed-off-by: Sascha Grunert <sgrunert@suse.com>
2020-02-21 14:59:37 +01:00
Daniel J Walsh c46f6e0321 Update vendor of containers/common to v0.1.0
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Closes: #2087
Approved by: giuseppe
2020-01-16 13:50:07 +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
Nalin Dahyabhai f0cf07bb60 Move to containers/image v5.0.0
Bump to containers/image's 5.0 release.

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

Closes: #1902
Approved by: rhatdan
2019-10-28 15:15:34 +00:00
Miloslav Trmač 797e618cbe Update c/image to v4.0.1
This requires updating all import paths throughout.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1891
Approved by: vrothberg
2019-10-04 07:34:03 +00:00
W. Trevor King e9969bca8b util/util: Fix "configuraitno" -> "configuration" log typo
Typo from 765c09d6db (Update containers/image to v2.0.0, 2019-06-03, #1634).

Signed-off-by: W. Trevor King <wking@tremily.us>

Closes: #1861
Approved by: TomSweeneyRedHat
2019-09-16 13:03:55 +00:00
Sascha Grunert 9f2a682780 Truncate output of too long image names
Image names longer than 32 characters will now be truncated via `...` in
the default table output. For example this:

```
CONTAINER ID  BUILDER  IMAGE ID     IMAGE NAME                       CONTAINER NAME
579aa959bb4d     *     9b1a5a0c02f5 docker.io/clearlinux/golang:latest golang-working-container
```

Now looks like this:

```
CONTAINER ID  BUILDER  IMAGE ID     IMAGE NAME                       CONTAINER NAME
579aa959bb4d     *     9b1a5a0c02f5 docker.io/clearlinux/golang:l... golang-working-container
```

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

Closes: #1841
Approved by: rhatdan
2019-09-05 14:46:54 +00:00
Daniel J Walsh 689f8ed3c3 add support for cgroupsV2
We need to run with crun rather then runc on cgroupsV2 platforms.

runc does not currently support cgroups V2, so if the machine is
in cgroups V2 mode we have to use crun by default.

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

Closes: #1823
Approved by: @TomSweeneyRedHat
2019-08-28 20:12:36 +00:00
Valentin Rothberg 2329081817 util: use strings.ContainsRune instead of index check
Reported by golangci-lint.

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

Closes: #1624
Approved by: TomSweeneyRedHat
2019-06-17 18:45:00 +00:00
Miloslav Trmač 765c09d6db Update containers/image to v2.0.0
This adds v2 registries.conf format, including mirror support.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1634
Approved by: rhatdan
2019-06-14 02:53:21 +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 7ae362bced Vendor in latest containers/storage and containers/image
Container image also switched out the version of bolddb
we were uisng.

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

Closes: #1586
Approved by: vrothberg
2019-05-13 08:43:34 +00:00
Nalin Dahyabhai cc368cd4ec imagebuildah: don't remove intermediate images if we need them
In multistage builds without caching, if an intermediate stage's image
ended up being the final image (i.e., when the last instruction in the
Dockerfile is a FROM instruction that references a previous stage), we
would remove it when we finished building.  Fix that by modifying the
cleanup logic to compare the ID of an image that it's about to delete to
the final image's ID, if it has one, and skipping it if they match.

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

Closes: #1564
Approved by: vrothberg
2019-05-01 19:08:49 +00:00
Daniel J Walsh 135542ecf0 Move Host IDMAppings code from util to unshare
This will make vendoring in pkg/unshare easier into other
packages like skopeo.

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

Closes: #1532
Approved by: TomSweeneyRedHat
2019-04-18 19:46:22 +00:00
Miloslav Trmač 6fd4d61b6a Clean up "pulls" of local image IDs / ID prefixes
When ResolveName has already determined that the value is an
ID (prefix), and returned the full ID, rely on that knowledge
and don't try at all to pull the image from a 'remote transport ""';
also, don't try to match strings that are already known not to be
ID prefixes, or that are known to use a different transport, against
local storage.

Should not change behavior, except possibly in theoretical
inconsistency cases when store.Image(knownImageID) fails; the code
now does not report other unrelated errors on the transport == ""
path below.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1361
Approved by: rhatdan
2019-02-27 14:07:21 +00:00
Miloslav Trmač 003a2d2155 Simplify ExpandNames
No need to hard-code the :tag / @digest syntax when there
already is an API returning the string representation.

Should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1361
Approved by: rhatdan
2019-02-27 14:07:21 +00:00
Miloslav Trmač dcae0ac75c Document the semantics of transport+name returned by ResolveName
Does not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1361
Approved by: rhatdan
2019-02-27 14:07:21 +00:00
Daniel J Walsh f9e645a461 Fix pulling of images within buildah
Change references to Transfer to transfer to make it internal only.
It should be determined from the image specification and only determined
in one place.

Make buildah.Pull use registries.conf

Currently buildah pull does not resolve images based on registries.conf
This does not match the behaviour of buildah from or buildah bud

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

Closes: #1319
Approved by: rhatdan
2019-02-20 19:31:09 +00:00
Nalin Dahyabhai fa8653314a run: ignore EIO when flushing at the end, avoid double log
When reading the last of the output from a child process, ignore an EIO,
since we already got the HUP indication.

Avoid double-logging errors in our I/O loop when using isolation other
than chroot (spotted by @afbjorklund).

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

Closes: #1273
Approved by: rhatdan
2019-01-12 12:04:54 +00:00
Šimon Lukašík de7f480a27 Refactor: Use library shared idtools.ParseIDMap() instead of bundling it
Signed-off-by: Šimon Lukašík <isimluk@fedoraproject.org>

Closes: #1232
Approved by: rhatdan
2018-12-13 13:45:10 +00:00
Miloslav Trmač 9c65e5699c Update for sysregistriesv2 API changes
Mostly this is a straightforward elimination of manual GetRegistries calls.

In getCopyOptions, we just remove setting the DockerInsecureSkipTLSVerify
values because the docker:// tranport now does that automatically.  (This
actually changes behavior, because docker:// supports namespace prefixes
in addition to matching only by hostnames, but that's a superset of the
previous behavior.)

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #1214
Approved by: rhatdan
2018-12-03 20:07:00 +00:00
Giuseppe Scrivano 6fa2f7409e unshare: do not override the configuration
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>

Closes: #1124
Approved by: rhatdan
2018-10-24 15:30:14 +00:00
Daniel J Walsh 4a6f4aeb6b
Resolve image names with default transport in from command
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2018-10-21 06:33:35 -04:00
Miloslav Trmač ea7f5daad4 Return a "search registries were needed but empty" indication in util.ResolveName
pullImage now tries (incorrectly) to redundantly compute the same
value as part of error handling.  So, return the actually used
data in util.ResolveName.

The computed value is not used yet, so should not change behavior.

Signed-off-by: Miloslav Trmač <mitr@redhat.com>

Closes: #909
Approved by: rhatdan
2018-10-13 11:56:07 +00:00
Giuseppe Scrivano 47deb80069 buildah: use the same logic for XDG_RUNTIME_DIR as podman
if XDG_RUNTIME_DIR is not set, try in the order:

- /var/run/user/$UID/run
- $HOME/rundir

also set the XDG_RUNTIME_DIR so that the OCI runtime will
use the same settings.

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

Closes: #1077
Approved by: rhatdan
2018-10-12 19:07:46 +00:00
Nalin Dahyabhai 8e64ce1de6 Let util.ResolveName() return parsing errors
Allow util.ResolveName() to return errors from libraries that it uses.

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

Closes: #948
Approved by: rhatdan
2018-08-23 03:12:51 +00:00
Nalin Dahyabhai 36e174e779 Switch to github.com/containers/image/pkg/sysregistriesv2
Switch from using github.com/containers/image/pkg/sysregistries to using
github.com/containers/image/pkg/sysregistriesv2 to complete unqualified
image names.  Keep v1 around because it'll tell us which configuration
file to name in an error message if things don't work right.

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

Closes: #904
Approved by: rhatdan
2018-08-03 17:26:09 +00:00
umohnani8 cf753ee6fe Fix buildah bud --layers
When building with layers, the last step wouldn't get implemented
if a cache already existed. This fix checks if every step in the dockerfile
is the same, and if it is it just creates a copy of the existing image
with the new name passed in by the user. The images will have the same
IDs and the new one will just be another tag of the original image.
This is what docker build does as well.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #832
Approved by: rhatdan
2018-06-28 20:31:30 +00:00
Nalin Dahyabhai 18063d19b6 main: if unprivileged, reexec in a user namespace
If our CLI is invoked as an unprivileged user (uid != 0),
* create a namespace using our own UID and GID as "0" followed by the
  ranges matching our name and our primary group's name that we find in
  /etc/subuid and /etc/subgid (the latter by way of using newuidmap and
  newgidmap)
* re-exec ourselves inside of that user namespace, prepending global CLI arguments that:
  * override the driver from storage.conf with "vfs"
  * override the storage root from storage.conf with a "containers/storage" subdirectory
    of $XDG_DATA_HOME, or $HOME/.local/share.
  * override the storage runroot from storage.conf with either "$XDG_RUNTIME_DIR/run" or
    "/var/run/user/$uid/run"
  * set default ID mapping settings to map all of the ranges matching
    our name and our primary group's name that we found in /etc/subuid
    and /etc/subgid
  * can still be overridden using the command line

Add a "buildah unshare" CLI that will start an arbitrary command in the
first namespace, so that manual cleanup of locations used by the second
namespace will be possible.

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

Closes: #823
Approved by: rhatdan
2018-06-28 18:22:35 +00:00
Nalin Dahyabhai edce842f54 Break out getProcIDMappings()
Break getProcIDMappings() out of run.go and turn it into
util.GetHostIDMappings(), and add util.GetSubIDMappings() and
util.ParseIDMappings().

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

Closes: #796
Approved by: rhatdan
2018-06-18 18:38:54 +00:00
Nalin Dahyabhai 002c18a3bb Break out SetupIntermediateMountNamespace()
Break runSetupIntermediateMountNamespace() into its own package.
Move stringInSlice(), getHostIDs(), and getHostRootIDs() into the util
subdirectory and export them.

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

Closes: #796
Approved by: rhatdan
2018-06-18 18:38:54 +00:00
Daniel J Walsh 3a849c02a6 Add environment variable BUILDAH_RUNTIME
Allow user to setup alternate runtimes to use rather then
runc.

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

Closes: #786
Approved by: rhatdan
2018-06-13 07:40:46 +00:00
Daniel J Walsh c306342ee1 Shouldn't add insecure registries to list of search registries
The search registries and insecure registries are separate lists,
and should not be merged just because the InsecureSkipTLSVerify is
set

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

Closes: #759
Approved by: mtrmac
2018-06-07 13:33:47 +00:00
Nalin Dahyabhai 8db406b683 util.ResolveName(): handle completion for tagged/digested image names
When checking if an image name includes a registry name, when checking
for cases where parsing it inserts additional path components, handle
cases where the name includes a tag or digest component.

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

Closes: #710
Approved by: rhatdan
2018-05-19 07:53:10 +00:00
Nalin Dahyabhai 44468f811c Force "localhost" as a default registry
Extend util.ResolveName() to prepend "localhost" to the list of
registries, and teach util.FindImage(), util.ExpandNames(), and
util.AddImageNames() to use util.ResolveName().

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

Closes: #648
Approved by: rhatdan
2018-05-02 19:52:53 +00:00
Nalin Dahyabhai d0b8769fbd Drop util.GetLocalTime()
util.GetLocalTime() duplicates time.Time.Local(), so drop it.

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

Closes: #649
Approved by: rhatdan
2018-05-02 12:41:46 +00:00
TomSweeneyRedHat 6583273185 Allow umount to have multi-containers
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #561
Approved by: rhatdan
2018-04-08 13:07:37 +00:00
TomSweeneyRedHat 78b0a37293 Change image time to locale, add troubleshooting.md, add logo to other mds
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #544
Approved by: rhatdan
2018-03-30 11:41:45 +00:00
umohnani8 1ca41dcbcb Add various transport support to buildah from
buildah from now supports pulling images using the following transports:
docker-archive, oci-archive, and dir.

Signed-off-by: umohnani8 <umohnani@redhat.com>

Closes: #524
Approved by: TomSweeneyRedHat
2018-03-22 17:22:47 +00:00
TomSweeneyRedHat 68a6c0a4c0 Display full error string instead of just status
Signed-off-by: TomSweeneyRedHat <tsweeney@redhat.com>

Closes: #485
Approved by: rhatdan
2018-02-24 09:12:53 +00:00
Boaz Shuster ad49b24d0b Return a better error message when failed to resolve an image
During the creation of a new builder object there are errors
that are only logged into "logrus.Debugf".

If in the end of the process "ref" or "img" are nil and "options.FromImage"
is set then it means that there was an issue.
By default, it was assumed that the image name is wrong. Yet,
this assumption isn't always correct. For example, it might fail due to
authorization or connection errors.

In this patch, I am attempting to fix this problem by checking the
last error stored in the "err" variable and returning the cause
of the failure.

Signed-off-by: Boaz Shuster <ripcurld.github@gmail.com>

Closes: #406
Approved by: rhatdan
2018-01-24 14:03:28 +00:00
Nalin Dahyabhai 47ac96155f Use configured registries to resolve image names
When locating an image for pulling, inspection, or pushing, if we're
given an image name that doesn't include a domain/registry, try building
a set of candidate names using the configured registries as domains, and
then pull/inspect/push using the first of those names that works.

If a name that we're given corresponds to a prefix of the ID of a local
image, skip completion and use the ID directly instead.

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

Closes: #360
Approved by: rhatdan
2017-12-14 22:21:16 +00:00
Nalin Dahyabhai c11936323a Fix inspect/tag-by-truncated-image-ID
Teach inspect and tag about image IDs, truncated and otherwise.

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

Closes: #138
Approved by: rhatdan
2017-06-08 18:31:31 +00:00
Dan Walsh 8ced1276e5 Change functions that use a fmt.Errorf to wrap an err to error.Wrapf
Impove error reporting by wrapping all returned err functions with
error.Wrapf

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

Closes: #124
Approved by: nalind

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

Closes: #125
Approved by: nalind
2017-06-02 14:17:04 +00:00
Nalin Dahyabhai 3065ea3d16 Add a "tag" command
Add a "tag" command, for adding names to locally-stored images.

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

Closes: #110
Approved by: rhatdan
2017-05-19 19:59:47 +00:00