Giter Site home page Giter Site logo

singularity-example's Introduction

singularity-example

Simple example showing of the features of singularity

Interactive image creation.

First of I want to show of a way to create an image interactivilly. This could be a good way to start to get all your dependencies in order before you write your container file.

To start this process you create an image inside of an a directory on your machine. Then you start a session as writable against that directory in order to work with the data.

sudo singularity build --sandbox ubuntu/ library://ubuntu
sudo singularity exec --writable ubuntu /bin/bash

Inside of the container

First we need to upgrade the distribution and then install the dependencies required for our maven build.

apt upgrade
apt install maven openjdk-11-jdk

Next up we move over to the /opt directory. And it's important not to put your files inside of a home directory or in root. These files will be mounted from the host system. So if you put something inside of your /root directory in the image it will be created in the /root of the host system.

Below we go to /opt and create a new quickstart archetype.

cd /opt
mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes \
    -DarchetypeArtifactId=maven-archetype-quickstart \
    -DarchetypeVersion=1.4 \
    -DgroupId=org.ea \
    -DartifactId=basic \
    -Dversion=0.0.1-SNAPSHOT \
    -DpackageName=org.ea

We enter the newly created hello world application and package it with maven.

cd /opt/basic
mvn package

Next up you need to press CTRL-D on your keyboard to exit the guest system out to your host system.

Then we will bake the directory into a sif file which is an singularity image file.

sudo singularity build work.sif ubuntu

Next up we will run our new image with a command that will run the hello world application inside of our image.

singularity exec work.sif java -cp /opt/basic/target/basic-0.0.1-SNAPSHOT.jar org.ea.App

Building container from definition.

In this example we will bake a already prepared definition file for singularity into an image.

sudo singularity build singularity-java.sif singularity-java.def

Next up we will run the image in order to run the hello world application baked inside of the image.

singularity run singularity-java.sif

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.