Strumenti Utente

Strumenti Sito


oph:cluster:apptainer

Apptainer

Some useful links:

  • Recording of the meeting with betatesters (ITA)
  • A tutorial (skip to “Building Singularity Containers” and remember you don't have 'sudo' access on the cluster!)
  • Another tutorial, more in-depth

Examples

Python Container

By Amalie Louise Stokholm

apptainer build --sandbox rockylinux8/ docker://rockylinux:8 
find rockylinux8 -type d -not -writable -exec chmod +w {} +
apptainer run -f --writable rockylinux8/ yum groupinstall -y "Development Tools"
apptainer run -f --writable rockylinux8/ yum install -y zlib-devel libffi-devel openssl-devel bzip2-devel readline-devel sqlite-devel xz-devel
mv .pyenv/versions/3.9.12{,_old4}
apptainer run rockylinux8/ ~/.pyenv/bin/pyenv install 3.9.12
.pyenv/versions/3.9.12/bin/python3 -c 'import ctypes'

Graphical applications with ssh X forwarding

By Vsevolod Chestnov

How to setup `X11` forwarding on `compute_node` via `apptainer`

  1. Create a file `config` with the following content:
    Bootstrap: docker
    From: ubuntu:16.04
    
    %post
        apt-get update -y
        apt-get install -y openssh-server
        # some tools, remove if not needed
        apt-get install -y vim firefox
    
    %startscript
        echo 'root:12345' | chpasswd
        sed -i 's/Port.*/Port 12121/'                                      /etc/ssh/sshd_config
        sed -i 's/PermitRootLogin prohibit-password/PermitRootLogin yes/'  /etc/ssh/sshd_config
        sed -i 's/UsePrivilegeSeparation yes/UsePrivilegeSeparation no/'   /etc/ssh/sshd_config
        sed -i 's/#PasswordAuthentication yes/PasswordAuthentication yes/' /etc/ssh/sshd_config
        mkdir /var/run/sshd
        chmod 700 /var/run/sshd
        # /usr/sbin/sshd
  2. Then build the container, here we call it `ubuntu16`
    apptainer build --sandbox --force ubuntu16 config
  3. Next go to the `compute_node` (say `mtx27` – you need to have an active reservation)
    ssh compute_node
  4. Create an instance of the `ubuntu16` container and call it `test`
    apptainer instance start -f -w ubuntu16 test
  5. Jump into the `test` instance
    apptainer shell instance://test
  6. Once inside, run the `sshd` daemon
    /usr/sbin/sshd

    which will listen to the `Port 12121`, as prescribed by the file `config` file above.

  7. In a new shell to test things connect to the running instance use `root` as the username
    ssh -X -p 12121 root@localhost

    after which you'll be prompted for `root`'s password, which was set to `12345` in the `config` file above. Now you may run some GUI application, for example:

    firefox

    At this stage `X11` forwarding will allow the application to use your machine's display to show the GUI.

  8. To connect from the outside one possibility is to setup port forwarding from `2010` on your machine to `12121` on the `compute_node` (where the instance is running) via the frontend node:
    ssh -L2010:compute_node_id:12121 your_unibo_username@137.204.50.71
  9. And then access via
    ssh -X -p 2010 root@localhost

    from your machine

  10. Done! Now you may run GUI applications on `compute_node` (like `firefox` and `Mathematica` frontend) and their graphical output will be forwarded to your machine's display.
oph/cluster/apptainer.txt · Ultima modifica: 2024/04/19 12:07 da diego.zuccato@unibo.it

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki