Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
U
unix_tunis
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hub-courses
unix_tunis
Commits
e1b500a5
Commit
e1b500a5
authored
2 years ago
by
Bertrand NÉRON
Browse files
Options
Downloads
Patches
Plain Diff
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
2 years ago
Stage: build
Stage: deploy
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
source/Good_Practices/containers.rst
+94
-0
94 additions, 0 deletions
source/Good_Practices/containers.rst
with
94 additions
and
0 deletions
source/Good_Practices/containers.rst
+
94
−
0
View file @
e1b500a5
...
@@ -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
""""""""
""""""""
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment