podman

What happens to podman import if reference is not present?


Documentation for podman import:

reference, if present, is a tag to assign to the image.

What happens to podman import if reference is not present?

Does podman save imported content from a tarball as a filesystem image? With what tag?

Here is an example:

$ podman import 758f677cf339-backup.tar
Getting image source signatures
Copying blob f49f459e4c71 done
Copying config 5bb687b1cc done
Writing manifest to image destination
Storing signatures
sha256:5bb687b1cc904a19a34bf8e63e2b1b5cc0d8400b0f2c6709ff44222176234369

Here we see that in podman import the reference is not present. How to find the tag (if any) assigned to the image?


Solution

  • No tag is used. For details see the following example with podman 5.1.1

    Create /tmp/backup.tar

    useradd test1
    machinectl shell --uid test1
    podman pull docker.io/library/alpine
    ctr=$(podman create docker.io/library/alpine)
    podman export $ctr > /tmp/backup.tar
    exit
    

    Import /tmp/backup.tar

    useradd test2
    machinectl shell --uid test2
    img=$(podman import --quiet /tmp/backup.tar)
    

    Inspect the image before and after tagging the image

    podman image inspect $img > inspect1.json
    podman image tag $img mytag
    podman image inspect $img > inspect2.json
    diff -u inspect1.json inspect2.json
    

    The diff command produces this output

    --- inspect1.json   2024-07-28 18:54:50.744204231 +0000
    +++ inspect2.json   2024-07-28 18:56:18.719279791 +0000
    @@ -2,8 +2,12 @@
          {
               "Id": "ee85a64cca8fc2eae7360f325b1d8dd32f09b408f8da5b6879c50ee6c9008e16",
               "Digest": "sha256:b4cad880b9456ed7b8dda95b5b9502e6ee59d7469f4de463fb075bb238054e6f",
    -          "RepoTags": [],
    -          "RepoDigests": [],
    +          "RepoTags": [
    +               "localhost/mytag:latest"
    +          ],
    +          "RepoDigests": [
    +               "localhost/mytag@sha256:b4cad880b9456ed7b8dda95b5b9502e6ee59d7469f4de463fb075bb238054e6f"
    +          ],
               "Parent": "",
               "Comment": "imported from tarball",
               "Created": "2024-07-28T18:54:24.838732101Z",
    @@ -38,6 +42,8 @@
                         "comment": "imported from tarball"
                    }
               ],
    -          "NamesHistory": null
    +          "NamesHistory": [
    +               "localhost/mytag:latest"
    +          ]
          }
     ]