|
| 1 | +.. _neurodocker_tutorial: |
| 2 | + |
| 3 | +==================== |
| 4 | +Neurodocker tutorial |
| 5 | +==================== |
| 6 | + |
| 7 | +This page covers the steps to create containers with Neurodocker_. |
| 8 | + |
| 9 | +Neurodocker_ is a command-line program that enables users to generate Docker_ |
| 10 | +containers that include neuroimaging software. These containers can be |
| 11 | +converted to Singularity_ containers for use in high-performance computing |
| 12 | +centers. |
| 13 | + |
| 14 | +Requirements: |
| 15 | + |
| 16 | +* Docker_ |
| 17 | +* Internet connection |
| 18 | + |
| 19 | + |
| 20 | +Usage |
| 21 | +----- |
| 22 | + |
| 23 | +To view the Neurodocker help message |
| 24 | +:: |
| 25 | + docker run --rm kaczmarj/neurodocker:v0.3.2 generate --help |
| 26 | + |
| 27 | +1. Users must specify a base Docker image and the package manager. Any Docker |
| 28 | + image on DockerHub can be used as your base image. Common base images |
| 29 | + include ``debian:stretch``, ``ubuntu:16.04``, ``centos:7``, and the various |
| 30 | + ``neurodebian`` images. If users would like to install software from the |
| 31 | + NeuroDebian repositories, it is recommended to use a ``neurodebian`` base |
| 32 | + image. The package manager is ``apt`` or ``yum``, depending on the base |
| 33 | + image. |
| 34 | +2. Next, users should configure the container to fit their needs. This includes |
| 35 | + installing neuroimaging software, installing packages from the chosen package |
| 36 | + manager, installing Python and Python packages, copying files from the local |
| 37 | + machine into the container, and other operations. The list of supported |
| 38 | + neuroimaging software packages is available in the ``neurodocker`` help |
| 39 | + message. |
| 40 | +3. The ``neurodocker`` command will generate a Dockerfile. This Dockerfile can |
| 41 | + be used to build a Docker image with the ``docker build`` command. |
| 42 | + |
| 43 | + |
| 44 | +Create a Dockerfile with FSL, Python 3.6, and Nipype |
| 45 | +---------------------------------------------------- |
| 46 | + |
| 47 | +This command prints a Dockerfile (the specification for a Docker image) to the |
| 48 | +terminal. |
| 49 | +:: |
| 50 | + $ docker run --rm kaczmarj/neurodocker:v0.3.2 generate \ |
| 51 | + --base debian:stretch --pkg-manager apt \ |
| 52 | + --fsl version=5.0.10 \ |
| 53 | + --miniconda env_name=neuro \ |
| 54 | + conda_install="python=3.6 traits" \ |
| 55 | + pip_install="nipype" |
| 56 | + |
| 57 | + |
| 58 | +Build the Docker image |
| 59 | +---------------------- |
| 60 | + |
| 61 | +The Dockerfile can be saved and used to build the Docker image |
| 62 | +:: |
| 63 | + $ docker run --rm kaczmarj/neurodocker:v0.3.2 generate \ |
| 64 | + --base debian:stretch --pkg-manager apt \ |
| 65 | + --fsl version=5.0.10 \ |
| 66 | + --miniconda env_name=neuro \ |
| 67 | + conda_install="python=3.6 traits" \ |
| 68 | + pip_install="nipype" > Dockerfile |
| 69 | + $ docker build --tag my_image . |
| 70 | + $ # or |
| 71 | + $ docker build --tag my_image - < Dockerfile |
| 72 | + |
| 73 | + |
| 74 | +Use NeuroDebian |
| 75 | +--------------- |
| 76 | + |
| 77 | +This example installs AFNI and ANTs from the NeuroDebian repositories. It also |
| 78 | +installs ``git`` and ``vim``. |
| 79 | +:: |
| 80 | + $ docker run --rm kaczmarj/neurodocker:v0.3.2 generate \ |
| 81 | + --base neurodebian:stretch --pkg-manager apt \ |
| 82 | + --install afni ants git vim |
| 83 | + |
| 84 | +Note: the ``--install`` option will install software using the package manager. |
| 85 | +Because the NeuroDebian repositories are enabled in the chosen base image, AFNI |
| 86 | +and ANTs may be installed using the package manager. ``git`` and ``vim`` are |
| 87 | +available in the default repositories. |
| 88 | + |
| 89 | + |
| 90 | +Other examples |
| 91 | +-------------- |
| 92 | + |
| 93 | +Create a container with ``dcm2niix``, Nipype, and jupyter notebook. Install |
| 94 | +Miniconda as a non-root user, and activate the Miniconda environment upon |
| 95 | +running the container. |
| 96 | +:: |
| 97 | + $ docker run --rm kaczmarj/neurodocker:v0.3.2 generate \ |
| 98 | + --base centos:7 --pkg-manager yum \ |
| 99 | + --dcm2niix version=master \ |
| 100 | + --user neuro \ |
| 101 | + --miniconda env_name=neuro conda_install="jupyter traits nipype" \ |
| 102 | + > Dockerfile |
| 103 | + $ docker build --tag my_nipype - < Dockerfile |
| 104 | + |
| 105 | + |
| 106 | +Copy local files into a container. |
| 107 | +:: |
| 108 | + $ docker run --rm kaczmarj/neurodocker:v0.3.2 generate \ |
| 109 | + --base ubuntu:16.04 --pkg-manager apt \ |
| 110 | + --copy relative/path/to/source.txt /absolute/path/to/destination.txt |
| 111 | + |
| 112 | +.. include:: ../links_names.txt |
0 commit comments