Using Docker images with Singularity#

When you direct Singularity to run a container based on pull a Docker image, Singularity pulls the slices or layers that make up the Docker image and converts them into a single-file Singularity SIF image.

Let us pull Official Python Docker image.

[s.1915438@sl2 test]$ singularity pull python-3.9.6.sif docker://python:3.9.6-slim-buster
INFO:    Converting OCI blobs to SIF format
INFO:    Starting build...
Getting image source signatures
Copying blob e1acddbe380c done
Copying blob ecc7ff4d2622 done
Copying blob dae1d9fd74c1 done
Copying blob 87bc5aa6fc42 done
Copying blob 76f124aca9af done
Copying config 7becefa709 done
Writing manifest to image destination
Storing signatures
2022/06/27 10:29:51  info unpack layer: sha256:e1acddbe380c63f0de4b77d3f287b7c81cd9d89563a230692378126b46ea6546
2022/06/27 10:29:51  info unpack layer: sha256:ecc7ff4d26223f4545c4fde4ca82a053f1152363c6a7d02715285751d8d721cd
2022/06/27 10:29:52  info unpack layer: sha256:dae1d9fd74c12f7e66b92cb4fc295edc0c538c6ec2a066aaa594e91c84912945
2022/06/27 10:29:52  info unpack layer: sha256:87bc5aa6fc4253b93dee0a9c996d962135b7d5131d739ce7cc6441b3bc9246c6
2022/06/27 10:29:52  info unpack layer: sha256:76f124aca9afaf3f75812d0509da1ca6807ac1891abc62d88280ea5ff6ccac75
INFO:    Creating SIF file...
[s.1915438@sl2 test]$ ls
hello-world.sif  python-3.9.6.sif
[s.1915438@sl2 test]$

Running pulled image#

In this example, we first printed the default Python version on Sunbird and then the Python version of the container is visible before the Python shell appears. * Default Python version on Sunbird: 2.7.5 * Container Python version: 3.9.6

singularity run#

[s.1915438@sl2 test]$ python --version
Python 2.7.5
[s.1915438@sl2 test]$ singularity run python-3.9.6.sif
Python 3.9.6 (default, Aug 17 2021, 02:38:04)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>
[s.1915438@sl2 test]$

singularity shell#

[s.1915438@sl2 test]$ singularity shell python-3.9.6.sif
Singularity> ls
hello-world.sif  python-3.9.6.sif
Singularity> ls /
apps  bin  boot  dev  environment  etc  home  lib  lib64  media  mnt  opt  proc  root  run  sbin  scratch  singularity  srv  sys  tmp  usr  var
Singularity> python --version
Python 3.9.6

singularity exec#

[s.1915438@sl2 test]$ singularity exec python-3.9.6.sif uname
Linux