|
13 | 13 | "\n",
|
14 | 14 | "[Docker](https://www.docker.com) is an open-source project that automates the deployment of applications inside software containers. Those containers wrap up a piece of software in a complete filesystem that contains everything it needs to run: code, system tools, software libraries, such as Python, FSL, AFNI, SPM, FreeSurfer, ANTs, etc. This guarantees that it will always run the same, regardless of the environment it is running in.\n",
|
15 | 15 | "\n",
|
16 |
| - "<font color='red'>Important:</font> **You don't need Docker to run Nipype on your system**. For Mac and Linux users, it probably is much simpler to install Nipype directly on your system. For more information on how to do this see the [Installation Section](resources_installation.ipynb) of this tutorial. But for Windows user, or users that don't want to setup all the dependencies themselves, Docker is the way to go." |
| 16 | + "<font color='red'>Important:</font> **You don't need Docker to run Nipype on your system**. For Mac and Linux users, it probably is much simpler to install Nipype directly on your system. For more information on how to do this see the [Nipype website](http://nipype.readthedocs.io/en/latest/users/install.html). But for Windows user, or users that don't want to setup all the dependencies themselves, Docker is the way to go." |
17 | 17 | ]
|
18 | 18 | },
|
19 | 19 | {
|
|
22 | 22 | "source": [
|
23 | 23 | "# Docker Image for the interactive Nipype Tutorial\n",
|
24 | 24 | "\n",
|
25 |
| - "If you want to run this Nipype Tutorial with the example dataset locally on your own system, you need to use the docker image, provided under [miykael/nipype_course](https://github.com/miykael/nipype_course). This docker image sets up a Linux environment on your system, with functioning Python, Nipype, FSL, AFNI, ANTs and SPM12 software package, some example data and all the tutorial notebooks to learn Nipype." |
| 25 | + "If you want to run this Nipype Tutorial with the example dataset locally on your own system, you need to use the docker image [satra/nih-workshop-2017](https://hub.docker.com/r/satra/nih-workshop-2017/). This docker image was created using [Neurodocker](https://github.com/kaczmarj/neurodocker) and sets up a Linux environment on your system, with functioning Python, Nipype, FSL, AFNI, ANTs and SPM12 software package." |
26 | 26 | ]
|
27 | 27 | },
|
28 | 28 | {
|
|
31 | 31 | "source": [
|
32 | 32 | "# Install Docker\n",
|
33 | 33 | "\n",
|
34 |
| - "Before you can do anything, you first need to install [Docker](https://www.docker.com) on your system. The installation process differes per system. Luckily, the docker homepage has nice instructions for...\n", |
| 34 | + "Before you can do anything, you first need to install [Docker](https://www.docker.com). Depending on your system you should get a proper version of Docker:\n", |
35 | 35 | "\n",
|
36 |
| - " - [Ubuntu](https://docs.docker.com/engine/installation/linux/ubuntu/) or [Debian](https://docs.docker.com/engine/installation/linux/debian/)\n", |
37 |
| - " - [Windows 7/8/9/10](https://docs.docker.com/toolbox/toolbox_install_windows/) or [Windows 10Pro](https://docs.docker.com/docker-for-windows/install/)\n", |
38 |
| - " - [OS X (from El Capitan 10.11 on)](https://docs.docker.com/docker-for-mac/install/) or [OS X (before El Capitan 10.11)](https://docs.docker.com/toolbox/toolbox_install_mac/).\n", |
| 36 | + " - [Docker for Ubuntu](https://docs.docker.com/engine/installation/linux/ubuntu/) or [Debian](https://docs.docker.com/engine/installation/linux/docker-ce/debian/)\n", |
| 37 | + " - [Docker for Mac](https://docs.docker.com/docker-for-mac/)\n", |
| 38 | + " - [Windows for Windows](https://docs.docker.com/docker-for-windows/) o\n", |
39 | 39 | "\n",
|
40 | 40 | "Once Docker is installed, open up the docker terminal and test it works with the command:\n",
|
41 | 41 | "\n",
|
42 | 42 | " docker run hello-world\n",
|
43 | 43 | "\n",
|
44 |
| - "**Note:** Mac and Linux users might need to use ``sudo`` to run ``docker`` commands." |
| 44 | + "**Note:** Linux users might need to use ``sudo`` to run ``docker`` commands or follow [post-installation steps](https://docs.docker.com/engine/installation/linux/linux-postinstall/)." |
45 | 45 | ]
|
46 | 46 | },
|
47 | 47 | {
|
48 | 48 | "cell_type": "markdown",
|
49 | 49 | "metadata": {},
|
50 | 50 | "source": [
|
51 |
| - "# How to run ``miykael/nipype_course``\n", |
| 51 | + "# Pulling the Docker image\n", |
52 | 52 | "\n",
|
53 |
| - "After installing docker on your system and making sure that the ``hello-world`` example was running, we are good to go to start the Nipype Course image. The exact implementation is a bit different for Windows user, but the general command looks as follows:\n", |
| 53 | + "You can download various Docker images, but for this tutorial you will need ``satra/nih-workshop-2017``:\n", |
54 | 54 | "\n",
|
55 |
| - " docker run -ti --rm -p 8888:8888 -v /home/username/results:/output miykael/nipype_course\n", |
| 55 | + " docker pull satra/nih-workshop-2017:latest\n", |
| 56 | + " \n", |
| 57 | + "Once it's done you can check available images on your system:\n", |
| 58 | + "\n", |
| 59 | + " docker images" |
| 60 | + ] |
| 61 | + }, |
| 62 | + { |
| 63 | + "cell_type": "markdown", |
| 64 | + "metadata": {}, |
| 65 | + "source": [ |
| 66 | + "# How to run ``satra/nih-workshop-2017``\n", |
| 67 | + "\n", |
| 68 | + "After installing docker on your system and making sure that the ``hello-world`` example was running, we are good to go to start the Nipype Tutorial image. The exact implementation is a bit different for Windows user, but the general command looks as follows:\n", |
| 69 | + "\n", |
| 70 | + " docker run -it --rm -v path/to/nipype_tutorial:/opt/tutorial -v path/to/data/:/data -v path/to/output:/output -p 8888:8888 satra/nih-workshop-2017:latest jupyter-lab\n", |
56 | 71 | "\n",
|
57 | 72 | "But what do those flags mean?\n",
|
58 | 73 | "\n",
|
59 | 74 | "- The ``-ti`` flag tells docker that it should open an interactive container instance.\n",
|
60 | 75 | "- The ``--rm`` flag tells docker that the container should automatically be removed after we close docker.\n",
|
61 | 76 | "- The ``-p`` flag specifies which port we want to make available for docker.\n",
|
62 |
| - "- The ``-v`` flag tells docker which folder (here: ``/home/username/results`` it should mount to make it accesible inside the container. The second part of the ``-v`` flag (here: ``/output``) specifies under which path the mounted folder can be found inside the container. This means that we can use the folder ``/output`` inside the tutorial to save data outside the docker container under ``/home/username/results``. **Important**: To use the ``results`` folder, you first need to create it on your system!\n", |
63 |
| - "- The last argument ``miykael/nipype_course`` tells docker that we want to run this docker image.\n", |
64 |
| - "\n", |
65 |
| - "To run a docker image, docker will look for the specified image on [Docker Hub](https://hub.docker.com/r/miykael/nipype_course/). If the docker image was already download to your system, it will be directly opened. Otherwise, it first needs to download all containers, which might take some time. \n", |
66 |
| - "\n", |
67 |
| - "\n", |
68 |
| - "## Run a docker image on Linux or Mac\n", |
69 |
| - "\n", |
70 |
| - "Running a docker image on a Linux or Mac OS is very simple. Make sure that you've created a results folder on your system (e.g. ``mkdir -p /home/username/results``). Then just open a new terminal and use the command from above:\n", |
71 |
| - "\n", |
72 |
| - " docker run -ti --rm -p 8888:8888 -v /home/username/results:/output miykael/nipype_course\n", |
73 |
| - "\n", |
74 |
| - "Once the docker image is downloaded, open the shown URL link in your browser and you are good to go. The URL will look something like:\n", |
75 |
| - "\n", |
76 |
| - " http://localhost:8888/?token=0312c1ef3b61d7a44ff5346d3d150c23249a548850e13868\n", |
77 |
| - "\n", |
78 |
| - "\n", |
79 |
| - "## Run a docker image on Windows\n", |
80 |
| - "\n", |
81 |
| - "Running a docker image on Windows is a bit trickier than on Ubuntu. Assuming you've installed the DockerToolbox, open the Docker Quickstart Terminal (encircled in red).\n", |
82 |
| - "\n", |
83 |
| - "<center><img src=\"../static/images/docker_terminal.png\" width=600></center>\n", |
84 |
| - "\n", |
85 |
| - "Once the docker terminal is ready (when you see the whale), we can execute the following steps (see also figure):\n", |
| 77 | + "- The ``-v`` flag tells docker which folders should be mount to make them accesible inside the container. Here: ``/path/to/nipype_tutorial`` is your local directory where you downloaded [Nipype Tutorial repository](https://github.com/djarecka/nipype_tutorial). ``path/to/data/`` is a directory where you have dataset ``ds000114``, and ``path/to/output`` can be an empty directory that will be used for output. The second part of the ``-v`` flag (here: ``/opt/tutorial``, ``/data`` or ``/output``) specifies under which path the mounted folders can be found inside the container. \n", |
| 78 | + "- ``satra/nih-workshop-2017:latest`` tells docker which image you want to run.\n", |
| 79 | + "- ``jupyter-lab`` tells that you want to go directly to the ``jupyter-lab`` within the container.\n", |
86 | 80 | "\n",
|
87 |
| - "1. We need to check the IP adress of your docker machine. For this, use the command: \n", |
88 |
| - "\n", |
89 |
| - " ``docker-machine ip``\n", |
90 |
| - "\n", |
91 |
| - " In my case, this returned ``192.168.99.100``\n", |
92 |
| - "\n", |
93 |
| - "2. If you haven't already created a new folder to store your container output into, do so. You can create the folder either in the explorer as usual or do it with the command ``mkdir -p`` in the docker console. For example like this:\n", |
94 |
| - "\n", |
95 |
| - " ``mkdir -p /c/Users/username/results``\n", |
96 |
| - "\n", |
97 |
| - " Please replace ``username`` with the name of the current user on your system. **Pay attention** that the folder paths in the docker terminal are not backslash (``\\``) as we usually have in Windows. Also, ``C:\\`` needs to be specified as ``/c/``.\n", |
98 |
| - "\n", |
99 |
| - "3. Now, we can open run the container with the command from above:\n", |
100 |
| - "\n", |
101 |
| - " ``docker run -ti --rm -p 8888:8888 -v /c/Users/username/outputs:/output miykael/nipype_course``\n", |
102 |
| - "\n", |
103 |
| - "4. Once the docker image is downloaded, it will show you an URL that looks something like this:\n", |
104 |
| - "\n", |
105 |
| - " ``http://localhost:8888/?token=0312c1ef3b61d7a44ff5346d3d150c23249a548850e13868``\n", |
106 |
| - " \n", |
107 |
| - " This URL will not work on a Windows system. To make it work, you need to replace the string ``localhost`` with the IP address of your docker machine, that we acquired under step 1. Afterwards, your URL should look something like this:\n", |
108 |
| - "\n", |
109 |
| - " ``http://192.168.99.100:8888/?token=0312c1ef3b61d7a44ff5346d3d150c23249a548850e13868``\n", |
110 |
| - "\n", |
111 |
| - " Copy this link into your webbrowser and you're good to go!" |
| 81 | + "**Note** that when you run ``jupyter-lab`` you will need to copy paste into your browser a URL shown in your terminal after running the command. " |
112 | 82 | ]
|
113 | 83 | },
|
114 | 84 | {
|
|
117 | 87 | "source": [
|
118 | 88 | "# Docker tips and tricks\n",
|
119 | 89 | "\n",
|
| 90 | + "**Note** this is a very short list of Docker commands that you might want to use. You can find more on Docker website or in ths [presentation](http://nipy.org/workshops/2017-03-boston/lectures/lesson-container/#1).\n", |
120 | 91 | "\n",
|
121 |
| - "## Access Docker Container with ``bash`` or ``ipython``\n", |
122 |
| - "\n", |
123 |
| - "You don't have to open a jupyter notebook when you run ``miykael/nipype_course``. You can also access the docker container directly with ``bash`` or ``ipython`` by adding it to the end of your command, i.e.:\n", |
| 92 | + "## Access Docker Container with bash or ipython\n", |
124 | 93 | "\n",
|
125 |
| - " docker run -ti --rm -v /home/username/results:/output miykael/nipype_course bash\n", |
| 94 | + "You don't have to open a ``jupyter-lab`` when you satra/nih-workshop-2017:latest. You can also access the docker container directly with ``bash`` or ``ipython`` by adding it to the end of your command, i.e.:\n", |
126 | 95 | "\n",
|
127 |
| - "This also works with other software commands, such as ``bet`` etc.\n", |
| 96 | + " docker run -it --rm -v path/to/nipype_tutorial:/opt/tutorial -v path/to/data/:/data -v path/to/output:/output satra/nih-workshop-2017:latest bash\n", |
128 | 97 | "\n",
|
| 98 | + "This also works with other software commands, such as bet etc.\n", |
129 | 99 | "\n",
|
130 | 100 | "## Stop Docker Container\n",
|
131 | 101 | "\n",
|
|
144 | 114 | "To delete a specific docker image, first use the ``docker images`` command to list all installed containers and than use the ``IMAGE ID`` and the ``rmi`` instruction to delete the container:\n",
|
145 | 115 | "\n",
|
146 | 116 | " docker rmi -f 7d9495d03763\n",
|
147 |
| - "\n", |
148 |
| - "\n", |
149 |
| - "## Export and Import a docker image\n", |
150 |
| - "\n", |
151 |
| - "If you don't want to depend on a internet connection, you can also export an already downloaded docker image and than later on import it on another PC. To do so, use the following two commands:\n", |
152 |
| - "\n", |
153 |
| - "\n", |
154 |
| - " # Export docker image miykael/nipype_course\n", |
155 |
| - " docker save -o nipype_course.tar miykael/nipype_course\n", |
156 |
| - "\n", |
157 |
| - " # Import docker image on another PC\n", |
158 |
| - " docker load --input nipype_course.tar\n", |
159 |
| - " \n", |
160 |
| - "It might be possible that you run into administrator privileges isssues because you ran your docker command with ``sudo``. This means that òther users don't have access rights to ``nipype_course.tar``. To avoid this, just change the rights of ``nipype_course.tar`` with the command:\n", |
161 |
| - "\n", |
162 |
| - " sudo chmod 777 nipype_course.tar" |
| 117 | + "\n" |
163 | 118 | ]
|
164 | 119 | }
|
165 | 120 | ],
|
166 | 121 | "metadata": {
|
167 | 122 | "anaconda-cloud": {},
|
168 | 123 | "kernelspec": {
|
169 |
| - "display_name": "Python [default]", |
| 124 | + "display_name": "Python 3", |
170 | 125 | "language": "python",
|
171 |
| - "name": "python2" |
| 126 | + "name": "python3" |
172 | 127 | },
|
173 | 128 | "language_info": {
|
174 | 129 | "codemirror_mode": {
|
175 | 130 | "name": "ipython",
|
176 |
| - "version": 2 |
| 131 | + "version": 3 |
177 | 132 | },
|
178 | 133 | "file_extension": ".py",
|
179 | 134 | "mimetype": "text/x-python",
|
180 | 135 | "name": "python",
|
181 | 136 | "nbconvert_exporter": "python",
|
182 |
| - "pygments_lexer": "ipython2", |
183 |
| - "version": "2.7.13" |
| 137 | + "pygments_lexer": "ipython3", |
| 138 | + "version": "3.5.2" |
184 | 139 | }
|
185 | 140 | },
|
186 | 141 | "nbformat": 4,
|
187 |
| - "nbformat_minor": 0 |
| 142 | + "nbformat_minor": 1 |
188 | 143 | }
|
0 commit comments