OCI-SIF Container Images: Unraveling Their Features and Benefits

Jul 12, 2024 | Blog

Among the container industry, OCI (Open Container Initiative) and SIF (Singularity Image Format) stand out as two prominent formats, each offering unique features and benefits. Understanding their distinct characteristics is crucial for HPC developers seeking optimal solutions for their containerized applications. In this blog post, we delve into the realm of OCI-SIF container images, highlighting their features and enumerating the benefits they bring to the table.

OCI-SIF

OCI, a project within the Linux Foundation, maintains the OCI image specification, which has emerged as the de facto standard for container images. This format aims to bring compatibility across different container runtimes and platforms. SIF, developed at Sylabs, offers a compelling alternative, particularly in scientific computing and high-performance computing (HPC) environments. OCI-SIF is a hybrid format poised to revolutionize containerization by merging the standardization of the OCI image spec with the portability and mobility of SIF. In addition, it adheres to a standardized specification and facilitates even more integration.

Examples

In SingularityCE 4.0 and above, there is a new feature called OCI-mode. It is enabled with the –oci flag (or in singularity.conf) and uses runc or crun as a low-level runtime to guarantee OCI compatibility. When pulling an image in this mode, the image is automatically converted to OCI-SIF instead of SIF. If a native SIF image is still needed, drop the flag and reissue the command.

To pull an OCI-SIF image, look at the below example:
$ singularity pull --oci docker://ubuntu:24.04
27.5MiB / 27.5MiB [=========================================] 100 % 0.0 b/s 0s
INFO:    Converting OCI image to OCI-SIF format
INFO:    Squashing image to single layer
INFO:    Writing OCI-SIF image
INFO:    Cleaning up.
The resulting file is named ubuntu_24.04.oci.sif. One can infer that this is an OCI image spec file and technically confirm this with the following command.
singularity sif list ubuntu_24.04.oci.sif
-----------------------------------------------------------------------
ID   |GROUP   |LINK    |SIF POSITION (start-end)  |TYPE
-----------------------------------------------------------------------
1    |1       |NONE    |32176-29117872            |OCI.Blob
2    |1       |NONE    |29117872-29118680         |OCI.Blob
3    |1       |NONE    |29118680-29119089         |OCI.Blob
4    |1       |NONE    |29119089-29119329         |OCI.RootIndex
In this case, the image format contains 3 OCI.Blob entries, which contains the root filesystem as a single layer, the image configuration, and the image manifest. The OCI.RootIndex is for internal use. It is important to note that this format does not include a definition file or Singularity-specific JSON metadata.
The more compelling example is the ability to run a container in one line:
$ singularity exec --oci ubuntu_24.04.oci.sif head -1 /etc/os-release
PRETTY_NAME="Ubuntu 24.04 LTS"
It can also run without pulling an image:
$ singularity exec --oci docker://ubuntu:24.04 head -1 /etc/os-release
INFO:    Using cached OCI-SIF image
PRETTY_NAME="Ubuntu 24.04 LTS"
Interacting with private registries is achieved by the use of the registry subcommand.

Example

$ singularity registry login -u username registry.domain.name
OCI-SIF images can be pushed to and pulled from OCI registries, as well as the Singularity Container Services library.
Push to a registry as an OCI image:
$ singularity push container-image.sif \
  docker://registry.DOMAIN/namespace/image:tag
Or maintain the OCI-SIF as a single file by pushing with an ORAS URI:
$ singularity push container-image.sif \
    oras://registry.DOMAIN/namespace/image:tag
OCI-SIF images can be pushed to a registry as an OCI image; however, other runtimes do not support the squashFS layer format. The images can only be retrieved and run by SingularityCE 4 and later.

Conclusion

In the ever-evolving landscape of containerization, OCI-SIF container images emerge as a powerful format, offering unique features and benefits. While OCI is the preferred choice for mainstream container deployments, SIF caters to specialized use cases, such as scientific computing, focusing on reproducibility and mobility, and its simplicity in a single file reduces I/O operations, avoiding metadata overhead. This means it can be hosted in a parallel filesystem. By understanding the strengths of both OCI and SIF container images, developers and researchers can make informed decisions that align with their specific requirements, paving the way for efficient and resilient containerized workflows

Finally, if you have any questions or comments about the information this blog covers, connect with us! You can join our Slack Channel, connect with us on Google Groups, or start a discussion on GitHub! We can also be found on X at @SylabsIO. We are here to help and would happily take suggestions for future posts.

Related Posts