@@ -101,6 +101,13 @@ The Docker Engine provides mounting filesystems into the container with the `-v`
101101where the trailing ` :ro ` specifies that the mount is read-only.
102102The mount permissions modifiers can be omitted, which means the mount
103103will have read-write permissions.
104+
105+ !!! warning "* Docker for Windows* requires enabling Shared Drives"
106+
107+ On *Windows* installations, the `-v` argument will not work
108+ by default because it is necessary to enable shared drives.
109+ Please check on this [Stackoverflow post](https://stackoverflow.com/a/51822083) how to enable them.
110+
104111In general, you'll want to at least provide two mount-points:
105112one set in read-only mode for the input data and one read/write
106113to store the outputs:
@@ -133,7 +140,48 @@ $ docker run -ti --rm \
133140 -w /work # override default directory
134141```
135142
136- * BIDS Apps* relying on [ TemplateFlow] ( https://www.templateflow.org )
143+ !!! tip "Best practices"
144+
145+ The [*ReproNim* initative](https://www.repronim.org/)
146+ distributes materials and documentation of best practices
147+ for containerized execution of neuroimaging workflows.
148+ Most of these are organized within the
149+ [*YODA* (Yoda's Organigram on Data Analysis)](https://github.com/myyoda) principles.
150+
151+ For example, mounting `$PWD` into `$PWD` and setting that path
152+ as current working directory can effectively resolve many issues.
153+ This strategy may be combined with the above suggestion about
154+ the application's work directory as follows:
155+
156+ ``` {.shell hl_lines="4 5 9"}
157+ $ docker run -ti --rm \
158+ -v path/to/data:/data:ro \
159+ -v path/to/output:/out \
160+ -v $PWD:$PWD \
161+ -w $PWD \ # DO NOT confuse with the application's work directory
162+ nipreps/fmriprep:<latest-version> \
163+ /data /out/out \
164+ participant
165+ -w $PWD/work
166+ ```
167+
168+ Mounting `$PWD` may be used with YODA so that all necessary *parts*
169+ in execution are reachable from under `$PWD`.
170+ This effectively
171+ (i) makes it easy to *transfer* configurations from
172+ *outside* the container to the *inside* execution runtime;
173+ (ii) the *outside*/*inside* filesystem trees are homologous, which
174+ makes post-processing and orchestration easier;
175+ (iii) execution in shared systems is easier as everything is
176+ sort of *self-contained*.
177+
178+ In addition to mounting `$PWD`, other advanced practices
179+ include mounting specific configuration files (for example, a
180+ [*Nipype* configuration file](https://miykael.github.io/nipype_tutorial/notebooks/basic_execution_configuration.html))
181+ into the appropriate paths within the container.
182+
183+
184+ * BIDS Apps* relying on [ * TemplateFlow* ] ( https://www.templateflow.org )
137185for atlases and templates management may require
138186the * TemplateFlow Archive* be mounted from the host.
139187Mounting the * Archive* from the host is an effective way
@@ -152,13 +200,26 @@ $ docker run -ti --rm \
152200 -w /work
153201```
154202
155- !!! warning " * Docker for Windows * requires enabling Shared Drives "
203+ !!! danger "Sharing the * TemplateFlow * cache can cause race conditions in parallel execution "
156204
157- On *Windows* installations, the `-v` argument will not work
158- by default because it is necessary to enable shared drives.
159- Please check on this [Stackoverflow post](https://stackoverflow.com/a/51822083) how to enable them.
205+ When sharing the *TemplateFlow* *HOME* folder across several parallel
206+ executions against a single filesystem, these instance will likely
207+ attempt to fetch unavailable templates without sufficient time between
208+ actions for the data to be fully downloaded (in other words,
209+ data downloads will be *racing* each other).
210+
211+ To resolve this issue, you will need to make sure all necessary
212+ templates are already downloaded within the cache folder.
213+ If the *TemplateFlow Client* is properly installed in your system,
214+ this is possible with the following command line
215+ (example shows how to fully download `MNI152NLin2009cAsym`:
216+
217+ ``` Shell
218+ $ templateflow get MNI152NLin2009cAsym
219+ ```
160220
161221### Running containers as a user
222+
162223By default, Docker will run the container with the
163224user id (uid) ** 0** , which is reserved for the default ** root**
164225account in * Linux* .
0 commit comments