diff --git a/docs/buildah-from.md b/docs/buildah-from.md index 891af1ddfde..7a055d15368 100644 --- a/docs/buildah-from.md +++ b/docs/buildah-from.md @@ -26,6 +26,9 @@ Multiple transports are supported: **docker-daemon:**_docker-reference_ An image _docker-reference_ stored in the docker daemon's internal storage. _docker-reference_ must include either a tag or a digest. Alternatively, when reading images, the format can also be docker-daemon:algo:digest (an image ID). + **oci:**_path_**:**_tag_** + An image tag in a directory compliant with "Open Container Image Layout Specification" at _path_. + **oci-archive:**_path_**:**_tag_ An image _tag_ in a directory compliant with "Open Container Image Layout Specification" at _path_. diff --git a/docs/buildah-pull.md b/docs/buildah-pull.md index d2e5a2da54e..aa3c50fc41d 100644 --- a/docs/buildah-pull.md +++ b/docs/buildah-pull.md @@ -25,6 +25,9 @@ Multiple transports are supported: **docker-daemon:**_docker-reference_ An image _docker-reference_ stored in the docker daemon's internal storage. _docker-reference_ must include either a tag or a digest. Alternatively, when reading images, the format can also be docker-daemon:algo:digest (an image ID). + **oci:**_path_**:**_tag_** + An image tag in a directory compliant with "Open Container Image Layout Specification" at _path_. + **oci-archive:**_path_**:**_tag_ An image _tag_ in a directory compliant with "Open Container Image Layout Specification" at _path_. diff --git a/pull.go b/pull.go index 02fb0284fc4..e802cceac5d 100644 --- a/pull.go +++ b/pull.go @@ -15,6 +15,7 @@ import ( "github.com/containers/image/docker/reference" tarfile "github.com/containers/image/docker/tarfile" ociarchive "github.com/containers/image/oci/archive" + oci "github.com/containers/image/oci/layout" "github.com/containers/image/signature" is "github.com/containers/image/storage" "github.com/containers/image/transports" @@ -112,6 +113,13 @@ func localImageNameForReference(ctx context.Context, store storage.Store, srcRef if name[:1] == "/" { name = name[1:] } + case oci.Transport.Name(): + // supports pull from a directory + name = split[1] + // remove leading "/" + if name[:1] == "/" { + name = name[1:] + } default: ref := srcRef.DockerReference() if ref == nil { diff --git a/tests/pull.bats b/tests/pull.bats index a632f715523..f4bfea317bb 100644 --- a/tests/pull.bats +++ b/tests/pull.bats @@ -197,3 +197,22 @@ load helpers [ "$status" -eq 0 ] [ $(wc -l <<< "$output") -ge 3 ] } + +@test "pull-from-oci-directory" { + run buildah pull --signature-policy ${TESTSDIR}/policy.json alpine + echo "$output" + [ "$status" -eq 0 ] + run buildah push --signature-policy ${TESTSDIR}/policy.json docker.io/library/alpine:latest oci:${TESTDIR}/alpine + echo "$output" + [ "$status" -eq 0 ] + run buildah rmi alpine + echo "$output" + [ "$status" -eq 0 ] + run buildah pull --signature-policy ${TESTSDIR}/policy.json oci:${TESTDIR}/alpine + echo "$output" + [ "$status" -eq 0 ] + run buildah images --format "{{.Name}}:{{.Tag}}" + echo "$output" + [ "$status" -eq 0 ] + [[ "$output" =~ "alpine" ]] +}