Skip to content

Commit 2b6f83c

Browse files
committed
NF: SINGULARITY_CMD env var to override default "run" with e.g. "exec"
README.md provides more details but the main use case to overcome hardcodeness of which command to use (run) in singularity invocation. It opens the door for using containers-run in interactive sessions with containers which configured for execution of main entry point commands, e.g. SINGULARITY_CMD=exec datalad containers-run -n repronim-reproin bash
1 parent 2280a99 commit 2b6f83c

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,24 @@ so we just use uniform `.sing` extension.
6464
data/bids {outputs} participant
6565

6666

67+
## Environment variables
68+
69+
A few environment variables (in addition to those consulted by datalad
70+
and datalad-container) are considered in the scripts of this
71+
repository:
72+
73+
### `SINGULARITY_CMD`
74+
75+
The default command (as "hardcoded" in [.datalad/config][]) is `run`
76+
so running the container executes its default "entry point". Setting
77+
`SINGULARITY_CMD=exec` makes it possible to run an alternative command
78+
in them (e.g. `bash` for interactive sessions)::
79+
80+
SINGULARITY_CMD=exec datalad containers-run --explicit -n repronim-reproin bash
81+
82+
and then have `datalad` record any of the introduced changes. Such
83+
runs will not be reproducible but at least clearly annotated in what
84+
environment corresponding actions were taken.
6785

6886
[git-annex]: http://git-annex.branchable.com
6987
[DataLad]: http://datalad.org

scripts/singularity_cmd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ function info() {
4040
thisdir=$(dirname $0| xargs readlink -f)
4141
updir=$(dirname "$thisdir")
4242

43-
cmd="$1"; shift
43+
cmd="${SINGULARITY_CMD:-$1}"; shift
4444

4545
if [ ! -z "${DATALAD_CONTAINER_NAME:-}" ]; then
4646
export SINGULARITYENV_DATALAD_CONTAINER_NAME="$DATALAD_CONTAINER_NAME"

0 commit comments

Comments
 (0)