Commit 8235c48f authored by Richard Berger's avatar Richard Berger
Browse files

Avoid errors due to host Lmod in containers

These changes ensure that environment variables that are automatically passed
to the container don't interfere with Lmod inside of the container. The previous
implementation would not take care of sticky packages from the outside and Lmod
would try to reload them.

Note that Lmod defines the 'module' bash function, which doesn't propagate to
the final shell when using 'singularity shell'. If the 'module' command is needed
a login shell needs to be launched:

$ singularity exec <CONTAINER> bash -l
parent 82b1fc71
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
@@ -14,9 +14,24 @@ From: centos:7
%environment
        LC_ALL=C
        export LC_ALL

        # we need to reset any module variables
        # inherited from the host.
        unset __LMOD_REF_COUNT__LMFILES_
        unset __LMOD_REF_COUNT_PATH
        unset __LMOD_REF_COUNT_LD_LIBRARY_PATH
        unset __LMOD_REF_COUNT_MANPATH
        unset __LMOD_REF_COUNT_MODULEPATH
        unset __LMOD_REF_COUNT_LOADEDMODULES
        unset _LMFILES_
        unset MODULEPATH
        unset MODULESHOME
        unset MODULEPATH_ROOT
        unset LOADEDMODULES
        . /etc/profile.d/z00_lmod.sh
        module purge
        unset LMOD_SYSTEM_DEFAULT_MODULES

        # load MPI by default
        . /etc/profile
        module load mpi

%labels
+17 −2
Original line number Diff line number Diff line
@@ -19,9 +19,24 @@ From: centos:8
%environment
        LC_ALL=C
        export LC_ALL

        # we need to reset any module variables
        # inherited from the host.
        unset __LMOD_REF_COUNT__LMFILES_
        unset __LMOD_REF_COUNT_PATH
        unset __LMOD_REF_COUNT_LD_LIBRARY_PATH
        unset __LMOD_REF_COUNT_MANPATH
        unset __LMOD_REF_COUNT_MODULEPATH
        unset __LMOD_REF_COUNT_LOADEDMODULES
        unset _LMFILES_
        unset MODULEPATH
        unset MODULESHOME
        unset MODULEPATH_ROOT
        unset LOADEDMODULES
        . /etc/profile.d/modules.sh
        module purge
        unset LMOD_SYSTEM_DEFAULT_MODULES

        # load MPI by default
        . /etc/profile
        module load mpi

%labels
+16 −3
Original line number Diff line number Diff line
@@ -38,12 +38,25 @@ From: fedora:30
%environment
        LC_ALL=C
        export LC_ALL

        # we need to reset any module variables
        # inherited from the host.
        unset __LMOD_REF_COUNT__LMFILES_
        unset __LMOD_REF_COUNT_PATH
        unset __LMOD_REF_COUNT_LD_LIBRARY_PATH
        unset __LMOD_REF_COUNT_MANPATH
        unset __LMOD_REF_COUNT_MODULEPATH
        unset __LMOD_REF_COUNT_LOADEDMODULES
        unset _LMFILES_
        unset MODULEPATH
        unset MODULESHOME
        unset MODULEPATH_ROOT
        unset LOADEDMODULES
        . /etc/profile.d/modules.sh
        module purge
        unset LMOD_SYSTEM_DEFAULT_MODULES

        # load MPI by default
        . /etc/profile
        module load mpi

%labels
        Author akohlmey
        Author akohlmey, rbberger
+15 −5
Original line number Diff line number Diff line
@@ -36,14 +36,24 @@ From: fedora:32
               texlive-needspace texlive-titlesec texlive-anysize texlive-dvipng

%environment
        LC_ALL=C
        export LC_ALL
        # we need to reset any module variables
        # inherited from the host.
        unset __LMOD_REF_COUNT__LMFILES_
        unset __LMOD_REF_COUNT_PATH
        unset __LMOD_REF_COUNT_LD_LIBRARY_PATH
        unset __LMOD_REF_COUNT_MANPATH
        unset __LMOD_REF_COUNT_MODULEPATH
        unset __LMOD_REF_COUNT_LOADEDMODULES
        unset _LMFILES_
        unset MODULEPATH
        unset MODULESHOME
        unset MODULEPATH_ROOT
        unset LOADEDMODULES
        . /etc/profile.d/modules.sh
        module purge
        unset LMOD_SYSTEM_DEFAULT_MODULES

        # load MPI by default
        . /etc/profile
        module load mpi

%labels
        Author akohlmey
        Author akohlmey, rbberger