hpc-containers
  • Introduction
  • Docker
    • Fundamentals
    • Installation
    • Get started
    • Dockerfile
    • Advanced
    • Commands
  • Singularity
    • Installing
    • Running a container
      • Hands-on #1
    • Building a container: Configuration file
      • Hands-on #2
      • Hands-on #3
    • Building a container: Docker
      • Hands-on #4
    • Hands-on #5: TensorFlow and GPU
Powered by GitBook
On this page
  • Singularity and Docker
  • Running LAMMPS Docker image in Singularity
  1. Singularity
  2. Building a container: Docker

Hands-on #4

PreviousBuilding a container: DockerNextHands-on #5: TensorFlow and GPU

Last updated 7 years ago

Singularity and Docker

Singularity is compatible with Docker. You can shell, import, run, and exec Docker container in Singularity.

singularity exec docker://centos:latest factor 9876543
# 9876543: 3 227 14503
singularity shell docker://centos:latest

Create a Singularity container image, and import a docker container.

singularity image.create centos.img
singularity import centos.img docker://centos:latest
singularity exec centos.img echo "Hello Dinosaur!"

Running LAMMPS Docker image in Singularity

Run docker.io/cbgeo/lammps:latest Docker container directly in Singularity.

singularity exec docker://cbgeo/lammps:latest /opt/lammps/src/lmp_serial -i /opt/lammps/examples/granregion/in.granregion.mixer

converts Docker specification file to a Singularity file.

LAMMPS Docker file

FROM centos:latest
MAINTAINER Krishna Kumar <kks32@cam.ac.uk>

# Update to latest packages and development tools
RUN yum update -y && \
    yum -y groupinstall "Development Tools" && \
    yum install -y wget && \
    yum clean all

# Download and compile LAMMPS
RUN cd /opt && wget http://lammps.sandia.gov/tars/lammps-stable.tar.gz && \
    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_serial

LAMMPS Singularity file (lammps.cfg)

bootstrap:docker
From:centos:latest

%post
# Krishna Kumar <kks32@cam.ac.uk>
  yum update -y && \
  yum -y groupinstall "Development Tools" && \
  yum install -y wget && \
  yum clean all

cd /opt && wget http://lammps.sandia.gov/tars/lammps-stable.tar.gz && \
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_serial

Create and import Singularity file.

singularity image.create --size 2048 lammps.img
sudo singularity build lammps.img lammps.cfg
Singularity-Hub