Hands-on #2
Singularity configuration file
We will build a container image for LAMMPS code using CentOS as the base image. A template Singularity configuration file is shown below:
Create/use the lammps template configuration file
lammps.cfg
# Header
BootStrap:
OSVersion:
MirrorURL:
Include:
# Sections
%setup
%post
%runscriptHeader
We will BootStrap CentOS version 7 with package manager yum. The MirrorURL for downloading CentOS is http://mirror.centos.org/centos-%{OSVERSION}/%{OSVERSION}/os/$basearch/. Include: yum.
Sections
In this example, we will use %setup, %post and %runscript.
Download and copy LAMMPS to
/opt. Use$SINGULARITY_ROOTFSto access root file system in the container:
cd $SINGULARITY_ROOTFS/opt
wget http://lammps.sandia.gov/tars/lammps-stable.tar.gzInstall development tools:
yum -y groupinstall "Development Tools"Configure and compile LAMMPS
mkdir -p /opt/lammps
cd /opt/lammps
tar xf ../lammps-stable.tar.gz --strip-components 1
cd src
make yes-granular |& tee log.make_yes_granular
make -j serial |& tee log.make_serialConfigure the container to run
lmp_serialon execution of the container:
/opt/lammps/src/lmp_serial "$@"Creating the container image
Create a container called
lammpsand modify the size to 2048 MiB.
singularity image.create --size 2048 ./lammps.img`Build the lammps configuration file created in the previous step.
sudo singularity build ./lammps.img lammps.cfgNote Building step requires
rootaccess.
Running the container image
To execute the container
singularity run /local/lammps.img -i in.granregion.mixerLast updated