3

I am starting to learn Singularity for reproducible analysis of scientific pipelines. A colleague explained that an image was used to instantiate a container. However, in reading through the documentation and tutorials, the term instance is also used and the usage of image and container seems somewhat interchangeable. So, I am not sure I precisely understand the difference between an image, container, and instance. I do get that a recipe is a text file for building one of these (I think an image?).

For example, on this page it explains:

Now we can build the definition file into an image! Simply run build and the image will be ready to go:

$ sudo singularity build url-to-pdf-api.img Singularity

Okay, so this uses the recipe Singularity to build an image, with the intuitive extension of .img. However, the help description of the build command states:

$ singularity help build

USAGE: singularity [...] build [build options...]

The build command compiles a container per a recipe (definition file) or based on a URI, location, or archive.

So this seems to indicate we are building a container?

Then, there are image and instance sub-commands.

Are all these terms used interchangeably? It seems sometimes they are and sometimes there is a difference between them.

Fiver
  • 9,909
  • 9
  • 43
  • 63

1 Answers1

5

A container is the general concept of creating a sandboxed run environment and can be used as a general term to refer to either Docker or Singularity images. However it is sometimes used to also refer to the specific files being generated. This is probably not ideal, as it can clearly cause confusion to new users.

image is generally used to to refer to the actual files created by singularity build ...

instance refers to a specific way of running singularity images. Normally, if you singularity run some_image.sif or singularity some_image.sif some_command you can't easily access its environment while it's running. However, if you instead run singularity instance start some_image.sif some_instance1 it creates a persistent service that you can access like a docker container. The singularity service/instance documentation has some good examples of how instances are used differently than the basic exec and run commands.

tsnowlan
  • 3,472
  • 10
  • 15
  • 1
    I see, so it's similar to an ISO image for an OS, and an "instance" of it being installed (and possibly run), yet you hear people use the phrases "download Linux" or "I run Linux". – Fiver Oct 23 '19 at 12:51
  • I know this is an old thread but I don't want to post another question if it already has be answered. I have a follow-up question: can we refer an singularity instance in the same manner as creating an instance from a class? – VRComp Jul 16 '21 at 13:46
  • In a sense, but it may be more accurate to think of it this way: the image is an executable (e.g., a jar file, browser) and the instance is the specific process created when that executable is run. This is literally the case for Singularity, but a bit more abstractly for Docker – tsnowlan Jul 16 '21 at 14:17