Skip to content

Commit 63d8398

Browse files
committed
a quick update to the docker intro
1 parent b2cce3e commit 63d8398

File tree

1 file changed

+41
-86
lines changed

1 file changed

+41
-86
lines changed

notebooks/introduction_docker.ipynb

Lines changed: 41 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"\n",
1414
"[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",
1515
"\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."
1717
]
1818
},
1919
{
@@ -22,7 +22,7 @@
2222
"source": [
2323
"# Docker Image for the interactive Nipype Tutorial\n",
2424
"\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."
2626
]
2727
},
2828
{
@@ -31,84 +31,54 @@
3131
"source": [
3232
"# Install Docker\n",
3333
"\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",
3535
"\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",
3939
"\n",
4040
"Once Docker is installed, open up the docker terminal and test it works with the command:\n",
4141
"\n",
4242
" docker run hello-world\n",
4343
"\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/)."
4545
]
4646
},
4747
{
4848
"cell_type": "markdown",
4949
"metadata": {},
5050
"source": [
51-
"# How to run ``miykael/nipype_course``\n",
51+
"# Pulling the Docker image\n",
5252
"\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",
5454
"\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",
5671
"\n",
5772
"But what do those flags mean?\n",
5873
"\n",
5974
"- The ``-ti`` flag tells docker that it should open an interactive container instance.\n",
6075
"- The ``--rm`` flag tells docker that the container should automatically be removed after we close docker.\n",
6176
"- 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",
8680
"\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. "
11282
]
11383
},
11484
{
@@ -117,15 +87,15 @@
11787
"source": [
11888
"# Docker tips and tricks\n",
11989
"\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",
12091
"\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",
12493
"\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",
12695
"\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",
12897
"\n",
98+
"This also works with other software commands, such as bet etc.\n",
12999
"\n",
130100
"## Stop Docker Container\n",
131101
"\n",
@@ -144,45 +114,30 @@
144114
"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",
145115
"\n",
146116
" 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"
163118
]
164119
}
165120
],
166121
"metadata": {
167122
"anaconda-cloud": {},
168123
"kernelspec": {
169-
"display_name": "Python [default]",
124+
"display_name": "Python 3",
170125
"language": "python",
171-
"name": "python2"
126+
"name": "python3"
172127
},
173128
"language_info": {
174129
"codemirror_mode": {
175130
"name": "ipython",
176-
"version": 2
131+
"version": 3
177132
},
178133
"file_extension": ".py",
179134
"mimetype": "text/x-python",
180135
"name": "python",
181136
"nbconvert_exporter": "python",
182-
"pygments_lexer": "ipython2",
183-
"version": "2.7.13"
137+
"pygments_lexer": "ipython3",
138+
"version": "3.5.2"
184139
}
185140
},
186141
"nbformat": 4,
187-
"nbformat_minor": 0
142+
"nbformat_minor": 1
188143
}

0 commit comments

Comments
 (0)