welcome: please sign in

Seiteninhalt hochladen

Sie können für die unten genannte Seite Inhalt hochladen. Wenn Sie den Seitennamen ändern, können Sie auch Inhalt für eine andere Seite hochladen. Wenn der Seitenname leer ist, leiten wir den Seitennamen vom Dateinamen ab.

Datei, aus der der Seiteninhalt geladen wird
Seitenname
Kommentar

location: SingularityDefinitionFile

Definition File

Ein Defnition-File ist wie eine Bauanleitung zu verstehen für den Bau eines Containers. Immer absolute Pfade angeben bzw. Umgebungsvariablen benutzen!

Was ist ein Definition File?

Es legt fest:

Definition File eines Containers anzeigen

$ singularity inspect -d CONTAINER.sif

Beispiel für ein komplettes Definition-File

Folgend ist ein komplettes Definition File aufgeführt. Die einzelnen Abschnitte werden in den folgenden Abschnitten erläutert. Würde man daraus einen Container bauen, so würde diesem ein Ubuntu 18.04 zugrunde liegen und eine netcat-Installation enthalten. Für die praktische Anwendung ist dieser eher ungeeignet, da das Definition File nur zur Veranschaulichung zusammengestellt wurde. Praktikablere Beispiele sind im letzten Abschnitt zu finden.

Bootstrap: library
From: ubuntu:18.04

%setup
touch /file1
touch${SINGULARITY_ROOTFS}/file2

%files
/file1
/file1 /opt

%environment
export LISTEN_PORT=12345
export LC_ALL=C

%post
apt-get update && apt-get install -y netcat
NOW=`date`echo "
export NOW=\"${NOW}\"" >> $SINGULARITY_ENVIRONMENT

%runscript
echo "Container was created $NOW"
echo "Arguments received: $*"exec echo "$@"

%startscript
nc -lp $LISTEN_PORT

%test
grep -q NAME=\"Ubuntu\"/etc/os-release
if[ $? -eq 0 ];then
echo "Container base is Ubuntu as expected."
else
echo "Container base is not Ubuntu."
fi

%labels
Author d@sylabs.io
Version v0.0.1

%help
This is a demo container used to illustrate a def file that uses allsupported sections.

Komponenten

Bootstrap: library
From: debian:7

oder

Bootstrap: library
From: ubuntu:18.04

Sections

%setup

%setup
 touch /file1
 touch${SINGULARITY_ROOTFS}/file2

%files

%files
 /file1
 /file1 /opt

%environment

%environment
 export LISTEN_PORT=12345
 export LC_ALL=C

%post

%post
 apt-get update && apt-get install -y netcat
 NOW=`date`
 echo "export NOW=\"${NOW}\"" >> $SINGULARITY_ENVIRONMENT

%runscript

%runscript
 echo "Container was created $NOW"
 echo "Arguments received: $*"
 exec echo "$@"

$ ./my_container.sif
Container was created Thu Dec  6 20:01:56 UTC 2018
Arguments received:

oder

$ ./my_container.sif this that and the other
Container was created Thu Dec  6 20:01:56 UTC 2018
Arguments received: this that and the other
this that and the other

%startscript

%startscript
 nc -lp $LISTEN_PORT

$ singularity instance start my_container.sif instance1
$ lsof | grep LISTEN
$ singularity instance stop instance1

%test

%test
 grep -q NAME=\"U buntu\"/etc/os-release
 if[ $? -eq 0 ]; then
        echo "Container base is Ubuntu as expected."
 else
        echo "Container base is not Ubuntu."
 fi

%labels

%labels
 Author d@sylabs.io
 Version v0.0.1

$ singularity inspect my_container.sif

%help

%help
 This is a demo container used to illustrate a def file that uses allsupported sections.

Zeitliche Einordnung der Komponenten

definitionFileTime.png

Was sind Apps?

Durch die Nutzung von Sinularity-Apps baut man das Definition File modular auf. Somit kann man mehrere Skripte und Anwendungsfälle separat bearbeiten. Für weitere Informationen siehe Singularity-Apps.

Beispiele für Definiton Files

Aus folgendem Definition File lässt sich ein Container bauen, welcher ein Ubuntu 14.04 enthält, sowie das x11-apps-Paket. Wird er gestartet, so wird xeyes ausgeführt.

Bootstrap: library #Container stammt aus der Sylans.io Cloud Library
From:ubuntu:14.04 #Läd den ubuntu-Container der Version 14.04.

%post
apt-get update && apt-get install -y x11-apps #installiert das x11-apps-Paket aus dem ubuntu 14.04 Paketarchiv

%runscript
xeyes #startet xeyes, wenn der container mit "$ singularity run" ausgeführt wird

%labels
Author thunert@cbs.mpg.de
Version 1.0

%help
This container holds an ubuntu 14.04 and x11-apps version 7.7+2.

Folgender Container enthält ein Ubuntu 18.04 aus dem Docker-Hub und ein bonnie++ Paket aus dem Ubuntu-Paketarchiv in der Version 1.97.3. Wenn der Container gestartet wird, wird aus den von bonnie++ gemessenen Ergebnissen ein CSV-File erstellt.

Bootstrap: docker
From: ubuntu:18.04

%post
echo "BaseOS created"
apt-get update && apt-get install -y bonnie++

%runscript
echo "Container started"
bonnie -r 2G -s 4G -f -b -n 0 > bonnieSingCont.csv


%labels
Author thunert@cbs.mpg.de
Version 1.0

%help
This container contains an ubuntu 18.04 and simply runs bonnie++. A CSV-File will be generated.

Der Container, welcher aus folgendem Definition File erstellt wird, enthält ein 18.04 Ubuntu mit Miniconda, Phyton und mne. Beim Starten des Containers wird eine bash gestartet in der man mit $ conda activate mne auf entsprechende mne-Tools zugreifen kann.

Bootstrap: library
From:ubuntu:18.04

%post
export PATH=/opt/conda/bin:${PATH}
apt-get update -y
apt-get upgrade -y
apt-get install -y curl sudo nano libxt-dev libglu1-mesa.dev wget
wget -q https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O $HOME/miniconda.sh && bash $HOME/miniconda.sh -b -p $HOME/miniconda
$HOME/miniconda/bin/conda update -n base -c defaults conda
$HOME/miniconda/bin/conda init bash
echo 'conda activate mne' >> $HOME/.bashrc

curl -O https://raw.githubusercontent.com/blakecaldwell/mne-python/mayavi_linux/environment.yml
$HOME/miniconda/bin/conda env create -f environment.yml
$HOME/miniconda/envs/mne/bin/pip install https://api.github.com/repos/enthought/mayavi/zipball/226189a
mkdir $HOME/shared

%runscript
export PATH=/miniconda/bin:${PATH}
conda init bash
bash

%test
$HOME/miniconda/bin/conda --version 
$HOME/miniconda/bin/python --version

%help
This container contains a version 4.6.14 of Miniconda, Version 3.7.3 of Python and mne based on a 18.04 Ubuntu.
$ conda activate mne #to start mne

%labels
Author thunert@cbs.mpg.de
Version v1.0

Ein mit folgendem Definition File gebauter Container baut auf einen schon vorhandenen Container (siehe x11-apps Definition File Beispiel) auf. Zusätzlich wird hier Vim installiert. Startet man den Container, wird wieder xeyes ausgeführt.

Bootstrap: localimage #baut auf einem lokal vorhandenen Container auf
From: /path/to/container

%post
apt-get update && apt-get install -y vim

%runscript
xeyes

%labels
Author thunert@cbs.mpg.de
Version 1.1

%help
This container holds ubuntu 14.04 xtools and vim.