Skip to content
This repository has been archived by the owner on Aug 14, 2020. It is now read-only.

Converting local files from buildah fails "Could not find image" #257

Open
orthecreedence opened this issue Jan 16, 2018 · 3 comments
Open

Comments

@orthecreedence
Copy link

orthecreedence commented Jan 16, 2018

Hello. I'm really excited about using rkt and have started playing with it a bit. One problem I'm having is that it's really difficult to create images that rkt can use without using Docker. I had hoped docker2aci could help, but it's giving me problems.

I'm currently using buildah (buildah version 0.10 (image-spec 1.0.0, runtime-spec 1.0.0)) and docker2aci (docker2aci version v0.17.1-2-g365911f-dirty / appc version 0.8.10) with both docker outputs and oci outputs:

# try with OCI
$ #sudo buildah bud /path/to/docker/repo
# success, creates image 183427cef41c
$ sudo buildah push 183427cef41c oci:my-app.oci:latest
# success, creates my-app.oci
$ docker2aci -debug ./my-app.oci
Getting image info...
getting image id...
Error: conversion error: Could not find image
# try with docker
$ sudo buildah bud /path/to/docker/repo
# success, creates image 183427cef41c
$ sudo buildah push 183427cef41c docker-archive:my-app.docker:latest
# success, creates my-app.docker
$ docker2aci -debug ./my-app.docker
Getting image info...
getting image id...
Error: conversion error: Could not find image

I've searched through a lot of the issues/PRs and it seems like OCI support and various Docker formats are supported, but after adding some debug info to lib/internal/backend/file/file.go it looks like it gets hung up on looking for repositories or refs/latest (seems like it's only checking for one specific format and giving up if it doesn't find it).

Any tips? Thanks!

@tommie-lie
Copy link

I stumbled over the same issue and thanks to you I figured out what is going on:

Support for OCI images in docker2aci was introduced well before OCI image spec 1.0.0 was released. The code has not seen too much of an update since then, at least not functionally. At the time, the refs/ directory was still the way to go.
Shortly after, image-spec 1.0.0-rc5 was released which merged opencontainers/image-spec#533 which removed the refs/ directory and introduced index.json as the canonical place to identify refs.

Long story short: docker2aci does seem to only implement OCI image spec up until v1.0.0-rc4. buildah creates v1.0.0 (final) images. They are not compatible.

I could work around for my usecase by doing:

buildah push ID oci:my-app:latest
cd my-app
mkdir -p refs/
jq -j '.manifests[] | (tostring + "\u0000")' index.json  |xargs -0 -n1 sh -c 'tag=$(echo $0 | jq .annotations[\"org.opencontainers.image.ref.name\"] -r); echo $0 > refs/$tag'
cd ..
tar cf my-app.oci -C my-app .
docker2aci --image my-app:latest my-app.oci

My go-fu is to weak to fix this right away, but the difference between refs/* and index.json seems easy enough. Basically, what used to be refs/* is now the .manifests array and what used to be the filename of the ref is now annotations["org.opencontainers.image.ref.name"] in each element.

@tommie-lie
Copy link

I found someone who already did this: woofwoofinc@d4e8e83

Their docker2aci works well with buildah's v1.0.0 oci images, but support for pre-v1.0.0-rc5 seems to be removed from their source (which is okay for my usecase).

@orthecreedence
Copy link
Author

Oh, this is great! Thanks for pointing me in the right direction. I'm very familiar with go at all (same with all the different manifest formats floating around) so this is really helpful. I'll check out woofwoofinc's branch.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants