Containers at NHR

From HPC Wiki
Revision as of 15:41, 29 October 2024 by Benjamin-juhl-d3d3@tu-darmstadt.de (talk | contribs) (Created page with "Category:BasicsCategory:HPC-User == General == Many users (especially new users) want to run docker containers on the NHR infratructure. However the NHR centers prov...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search


General

Many users (especially new users) want to run docker containers on the NHR infratructure. However the NHR centers provide singularity/apptainer as a container framework, and these cannot run docker containers natively. Singularity and apptainer commands can be used mostly interchangeably.



Converting Containers

While it is not possible to run docker containers directly with the singularity/apptainer framework, there are several methods to convert a docker container into another format (e.g. sif or oci), and then use these converted containers with apptainer.

Build a sif container from a container in a docker registry

One can use the singualrity build command to build a singularity container directly from a container available from a docker repository.

Example:

singularity build lolcow.sif docker://godlovedc/lolcow
singularity run lolcow.sif

Build a sif container from a docker container archive file

If you have a localy developed docker container, or a container from a registry with local changes, you can save it as a docker archive. You can then use singualrity build to build a singularity container from the archive.

Example:

singularity build lolcow_from_archive.sif docker-archive://$(pwd)/lolcow_docker_archive.tar
singularity run lolcow_from_archive.sif

Use spython to translate a docker recipe into a singularity recipe and build from that recipe

In same cases, there might only be a docker recipe (also called a docker file) available, which is usualy used to build a docker container localy. Apptainer and singularity can also use such recipes to build containers, but the format is different. The singularity project provides a tool (spython ) to translate a docker recipe into a singularity recipe.