Container basics

The example is a bit of C[*] compiled in an SL6 container while sitting on a run-of-the mill SL7 worker node at Imperial:

Prepare a directory and put your code in:
mkdir -p /tmp/data/tmp
mkdir /tmp/data/var_tmp
cp testproj.c /tmp/data/tmp/.

Start up SL6 (=cvm3) container:
/cvmfs/oasis.opensciencegrid.org/mis/singularity/current/bin/singularity shell -c -W /tmp/data /cvmfs/cernvm-prod.cern.ch/cvm3
WARNING: container does not have /.singularity.d/actions/shell, calling /bin/sh directly
sh-4.1$ cd /tmp/
sh-4.1$ ls
testproj.c
sh-4.1$ gcc -o testproj.container testproj.c
sh-4.1$ ls
testproj.c testproj.container
sh-4.1$ ./testproj.container
Morning Daniela
OS Ver: Scientific Linux release 6.9 (Carbon)
exit

Outside the container I can find the executable here:
[lt2-user@wj02 tmp]$ cd /tmp/data/tmp/
[lt2-user@wj02 tmp]$ ls
testproj.c testproj.container

But it's a different executable than if I compile it directly on the SL7 node:
[lt2-user@wj02 tmp]$ gcc -o testproj.sl7 testproj.c
[lt2-user@wj02 tmp]$ ls -l
total 24
-rw-r--r--. 1 lt2-user lt2-us 327 May 11 11:51 testproj.c
-rwxr-xr-x. 1 lt2-user lt2-us 7257 May 11 11:52 testproj.container
-rwxr-xr-x. 1 lt2-user lt2-us 8616 May 11 11:59 testproj.sl7


[*] (included for completeness)

include <stdio.h>
#define BUF_LEN 256

int main()
{
FILE *xFile;
char xVer[BUF_LEN + 1] = {};
fprintf(stderr, "Morning Daniela\n");
xFile = fopen("/etc/redhat-release", "r");
if (!xFile)
    return 1;
if (fread(xVer, 1, BUF_LEN, xFile) > 0)
    fprintf(stderr, "OS Ver: %s", xVer);
fclose(xFile);
return 0;
}