Skip to content
Snippets Groups Projects
Commit e1b500a5 authored by Bertrand  NÉRON's avatar Bertrand NÉRON
Browse files

add section about apptainer exec/shell command

parent 8b87cc8c
No related branches found
No related tags found
No related merge requests found
Pipeline #87472 passed
...@@ -322,6 +322,20 @@ So the complete command line will be: ...@@ -322,6 +322,20 @@ So the complete command line will be:
docker run -v $PWD:/home/msf -u $(id -u ${USER}):$(id -g ${USER}) gempasteur/macsyfinder:2.0 macsyfinder --sequence-db /home/msf/genome.fasta ... docker run -v $PWD:/home/msf -u $(id -u ${USER}):$(id -g ${USER}) gempasteur/macsyfinder:2.0 macsyfinder --sequence-db /home/msf/genome.fasta ...
You can also enter and work interactively in the container
you have to add options
* `-i` for *interactive*
* `-t` to allocates a pseudo tty
* and depending how the image is build override the entrypoint --entrypoint
.. code-block::
docker run -v $PWD:/home/msf -u $(id -u ${USER}):$(id -g ${USER}) -it --entrypoint /bin/bash gempasteur/macsyfinder:2.0
:code:`CTRL d` to exit of the container
Exercise Exercise
"""""""" """"""""
...@@ -502,6 +516,86 @@ For the other guys (mac, windows, ...) ...@@ -502,6 +516,86 @@ For the other guys (mac, windows, ...)
You have to install from the sources see https://apptainer.org/docs/user/main/quick_start.html#quick-start You have to install from the sources see https://apptainer.org/docs/user/main/quick_start.html#quick-start
Build macsyfinder Apptainer image from Docker image
'''''''''''''''''''''''''''''''''''''''''''''''''''
If there is a Docker image available on docker hub it is very easy to convert it into Apptainer image.
:code:`apptainer build <image_name> docker://<docker_image:tag>`
:code:`apptainer build macsyfinder.img docker://gempasteur/macsyfinder:2.0`
It will create a file `macsyfinder.img`. The Apptainer images are regular files.
You can manipulates as files mv/copy/transfert to a collaborator, ...
.. note::
build from docker is the only build way to build an image without to be root/sudoer
Run macsyfinder on real data
''''''''''''''''''''''''''''
:code:`apptainer run <image_name> <argument and options specific to the image>`
.. code-block::
apptainer run macsyfinder.img macsyfinder --sequence-db /home/msf/genome.fasta ...
If your data is in your HOME they are accessible inside the container with the same path.
If your data are elsewhere on the file system, you have to bind them explicitly
For instance if my data are */pasteur/projects/msf_analysis/data* I can bind /pasteur in the container
with the option `-B/ --bind <src on host>:<dest in container>` if *src* and *dest* are the same, dest can be omitted.
.. code-block::
apptainer run -B /pasteur macsyfinder.img macsyfinder --sequence-db /home/msf/genome.fasta ...
I bind */pasteur* on the host to */pasteur* inside the container. So the path will be identical on host and in container.
.. note::
It's not a problem to bind /pasteur even there are lot of project belonging to other teams.
I as run container under my id I have the same rights as on hosts. So if I cannot access to /pasteur/projects/whatever
on the host, I can bind it in container but I cannot access to it (read/write/...).
.. note::
You can run directly from docker image, apptainer will download it and convert it on the fly.
The resulting image is located in apptainer cache
:code:`apptainer run -B /pasteur docker:gempasteur/macsyfinder macsyfinder --sequence-db /home/msf/genome.fasta ...`
You can execute any arbitrary command line in a context of an Apptainer container
.. code-block::
apptainer exec -B /pasteur macsyfinder.img ls -l /pasteur
You can also enter interactively in the container
.. code-block::
apptainer shell -B /pasteur macsyfinder.img
.. warning::
By default the container is not writable.
To be allowed to write something in your interactive session
* you must run the command as `sudo`
* adn add the `-w/--writable` option
.. code-block::
sudo apptainer shell --writable macsyfinder.img
Exercise Exercise
"""""""" """"""""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment