We can use the
singularity inspect command to see the run script that a container is configured to run by default. What if we want to run a different command within a container?
If we know the path of an executable that we want to run within a container, we can use the
singularity exec command. For example, using the
fastqc-0.11.9--0.sif container that we’ve already downloaded, we can run the following within the current directory where the
fastqc-0.9.11--0.sif file is located
singularity exec fastqc-0.11.9--0.sif fastqc -h
Above we used the
singularity exec command. In earlier sections of this course we used
singularity run. To clarify, the difference between these two commands is:
singularity run: This will run the default command set for containers based on the specified image. This default command is set within the image metadata when the image is built (we’ll see more about this in later episodes). You do not specify a command to run when using
singularity run, you simply specify the image file name. As we saw earlier, you can use the
singularity inspectcommand to see what command is run by default when starting a new container based on an image.
singularity exec: This will start a container based on the specified image and run the command provided on the command line following
singularity exec <image file name>. This will override any default command specified within the image metadata that would otherwise be run if you used
Singularity run is not so common for HPC uses but will be used for instances (servers).
singularity shell fastqc-0.11.9--0.sif Singularity> whoami default Singularity> ls <listing current working directory of the host> Singularity>
exit command to exit from the container shell.