singularity-containercontainer-registryapptainer

How to make aliases of apptainer container tags?


Apptainer (and singularity) can interact with container registries, much like docker can. Common practice for these registries is to have a (semantic version) tag for each image pushed and maintain the tag "latest" to point to the most recent version.

In apptainer, the tag is part of the target URI in the push command:

apptainer push /path/to/mycontainer_v1.2.1.sif oras://registry.tld/foo/mycontainer:1.2.1

As near as I can tell, if I want my "latest" tag to be the same as 1.2.1, the only way to accomplish this is to upload the image twice, wasting both bandwidth for the upload and storage space in the registry, which may not be insignificant when images often run to several GB.

Is there a way to define tag aliases without uploading and storing multiple copies of the container image? If it's registry-dependent, I am specifically interested in solutions relevant to the gitlab container registry.


Solution

  • As far as I can tell, there is no way to do this with apptainer directly. There is however an oras client for interacting with OCI registries, and it does have a tag option that does exactly what I want.

    1. Install the oras client following instructions at https://oras.land/cli/
    2. oras login -u user -p token registry.gitlab.com
      • (note a leading oras:// as one would use with apptainer remote login will not work)
      • This step is optional, user and password can be specified on latter steps instead
    3. It should be possible to list repositories in the registry, but it seems to generate 401 errors no matter what I do
    4. To list the tags for the target repository: oras repo tags registry.gitlab.com/owner/repo/image
    5. To alias 'tag1' to 'tag2': oras tag registry.gitlab.com/owner/repo/image:tag1 tag2