Examples

This page includes examples of using Neurodocker to build containers with popular neuroimaging packages. The commands generate Dockerfiles. To generate Singularity recipes, simply replace

neurodocker generate docker

with

neurodocker generate singularity

To see the options for each package, please run

neurodocker generate docker --help

or

neurodocker generate singularity --help

Note

Neurodocker is meant to create command-line environments. At the moment, graphical user interfaces (like FreeView and FSLEyes) are not installed properly. It is possible that this will change in the future.

FSL

Docker

neurodocker generate docker \
    --pkg-manager apt \
    --base-image debian:buster-slim \
    --fsl version=6.0.4 \
> fsl604.Dockerfile

docker build --tag fsl:6.0.4 --file fsl604.Dockerfile .

# Run fsl's bet program.
docker run --rm -it fsl:6.0.4 bet

AFNI

Docker

neurodocker generate docker \
    --pkg-manager apt \
    --base-image debian:buster-slim \
    --afni method=binaries version=latest \
> afni-binaries.Dockerfile

docker build --tag afni:latest --file afni-binaries.Dockerfile .

This does not install AFNI’s R packages. To install relevant R things, use the following:

neurodocker generate docker \
    --pkg-manager apt \
    --base-image debian:buster-slim \
    --afni method=binaries version=latest install_r_pkgs=true \
> afni-binaries-r.Dockerfile

docker build --tag afni:latest-with-r --file afni-binaries-r.Dockerfile .

One can also build AFNI from source. The code below builds the current master branch. Beware that this is AFNI’s bleeding edge!

neurodocker generate docker \
    --pkg-manager apt \
    --base-image debian:buster-slim \
    --afni method=source version=master \
> afni-source.Dockerfile

docker build --tag afni:master --file afni-source.Dockerfile .

FreeSurfer

Docker

The FreeSurfer installation is several gigabytes in size, but sometimes, users just the pieces for recon-all. For this reason, Neurodocker provides a FreeSurfer minified for recon-all.

neurodocker generate docker \
    --pkg-manager apt \
    --base-image debian:buster-slim \
    --freesurfer version=7.1.1-min \
> freesurfer7-min.Dockerfile

docker build --tag freesurfer:7.1.1-min --file freesurfer7-min.Dockerfile .

ANTS

neurodocker generate docker \
    --pkg-manager apt \
    --base-image debian:buster-slim \
    --ants version=2.3.4 \
> ants-234.Dockerfile

docker build --tag ants:2.3.4 --file ants-234.Dockerfile .

SPM

Note

Due to the version of the Matlab Compiler Runtime used, SPM12 should be used with a Debian Stretch base image.

neurodocker generate docker \
    --pkg-manager apt \
    --base-image debian:stretch-slim \
    --spm12 version=r7771 \
> spm12-r7771.Dockerfile

docker build --tag spm12:r7771 --file spm12-r7771.Dockerfile .

Miniconda

Todo

Add an example of building a Miniconda image.

Nipype tutorial

Docker

neurodocker generate docker \
--pkg-manager apt \
--base-image neurodebian:stretch-non-free \
--arg DEBIAN_FRONTEND=noninteractive \
--install convert3d ants fsl gcc g++ graphviz tree \
        git-annex-standalone vim emacs-nox nano less ncdu \
        tig git-annex-remote-rclone octave netbase \
--spm12 version=r7771 \
--miniconda \
version=latest \
conda_install="python=3.8 pytest jupyter jupyterlab jupyter_contrib_nbextensions
                traits pandas matplotlib scikit-learn scikit-image seaborn nbformat
                nb_conda" \
pip_install="https://github.com/nipy/nipype/tarball/master
                https://github.com/INCF/pybids/tarball/master
                nilearn datalad[full] nipy duecredit nbval" \
--run 'jupyter nbextension enable exercise2/main && jupyter nbextension enable spellchecker/main' \
--run 'mkdir /data && chmod 777 /data && chmod a+s /data' \
--run 'mkdir /output && chmod 777 /output && chmod a+s /output' \
--user neuro \
--run-bash 'cd /data
&& datalad install -r ///workshops/nih-2017/ds000114
&& cd ds000114
&& datalad update -r
&& datalad get -r sub-01/ses-test/anat sub-01/ses-test/func/*fingerfootlips*' \
--run 'curl -fL https://files.osf.io/v1/resources/fvuh8/providers/osfstorage/580705089ad5a101f17944a9 -o /data/ds000114/derivatives/fmriprep/mni_icbm152_nlin_asym_09c.tar.gz
&& tar xf /data/ds000114/derivatives/fmriprep/mni_icbm152_nlin_asym_09c.tar.gz -C /data/ds000114/derivatives/fmriprep/.
&& rm /data/ds000114/derivatives/fmriprep/mni_icbm152_nlin_asym_09c.tar.gz
&& find /data/ds000114/derivatives/fmriprep/mni_icbm152_nlin_asym_09c -type f -not -name ?mm_T1.nii.gz -not -name ?mm_brainmask.nii.gz -not -name ?mm_tpm*.nii.gz -delete' \
--copy . "/home/neuro/nipype_tutorial" \
--user root \
--run 'chown -R neuro /home/neuro/nipype_tutorial' \
--run 'rm -rf /opt/conda/pkgs/*' \
--user neuro \
--run 'mkdir -p ~/.jupyter && echo c.NotebookApp.ip = \"0.0.0.0\" > ~/.jupyter/jupyter_notebook_config.py' \
--workdir /home/neuro/nipype_tutorial \
--entrypoint jupyter-notebook \
> nipype-tutorial.Dockerfile

docker build --tag nipype-tutorial .