Nipype tutorial: issues running image in docker to see jupyter notebook

Hi,

I was following the guide below to install docker and run the image for the nipype tutorial:

https://miykael.github.io/nipype_tutorial/notebooks/introduction_docker.html

I am new to docker. My host OS is W10 Enterprise 64bit, I installed docker v18.06.

I sucessfully installed docker in that I could pull and run hello world. I could pull the image I was interested in (miykael/nipype_tutorial), but on trying to run the image, the URL I am given does not work in my browser (firefox). I have tried replacing the front of the URL with localhost, host machine i/p and the DockerNAT i/p (I thought this would be the right one), but with no luck. Any ideas what is going wrong here?

See my powershell command and o/p:

PS C:\Users\MCLEAJO685> docker run -it --rm -p 8888:8888 miykael/nipype_tutorial jupyter notebook
[I 09:50:53.936 NotebookApp] [nb_conda_kernels] enabled, 2 kernels found
[I 09:50:53.956 NotebookApp] Writing notebook server cookie secret to /home/neuro/.local/share/jupyter/runtime/notebook_cookie_secret
[I 09:50:54.166 NotebookApp] [jupyter_nbextensions_configurator] enabled 0.4.0
[I 09:50:54.198 NotebookApp] JupyterLab extension loaded from /opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/jupyterlab
[I 09:50:54.198 NotebookApp] JupyterLab application directory is /opt/miniconda-latest/envs/neuro/share/jupyter/lab
[I 09:50:54.348 NotebookApp] [nb_conda] enabled
[I 09:50:54.349 NotebookApp] Serving notebooks from local directory: /home/neuro/nipype_tutorial
[I 09:50:54.350 NotebookApp] The Jupyter Notebook is running at:
[I 09:50:54.351 NotebookApp] http://(815a6c95e372 or 127.0.0.1):8888/?token=e013619cdebfe111d69c1952ede336dd7a688813cd05d3c0
[I 09:50:54.351 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 09:50:54.354 NotebookApp] No web browser found: could not locate runnable browser.
[C 09:50:54.354 NotebookApp]

Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://(815a6c95e372 or 127.0.0.1):8888/?token=e013619cdebfe111d69c1952ede336dd7a688813cd05d3c0

Heyo!

I think you did everything correctly, and just need to copy the code into your browser:

If 127.0.0.1 doesn’t work you can also try the container uri or localhost. That usually works for me on Linux, although I’m not sure about Windows.

Thanks for the response. Been playing around with this. I’m happy it isn’t a docker issue, I can run the image and login via bash. My issue seems to be with launching the jupyter notebook from the docker. I can’t get past the jupyter token/password page on my browser (have tried firefox and chrome). Been looking at the jupyter notebook password config files, tried to configure password from within docker (using bash) but haven’t got this to work.

but have you tried in your browser localhost:8888/?token=... or http://localhost:8888/?token=....?

This is probably a silly suggestion, but to start could you copy paste (verbatim) the starting up of a new container, the message in the console, and then exactly what you are copy pasting into the browser? Notably, take note (haha I just said that…) that the url shown gives you an option for two different urls and won’t work copy pasted as is. E.g., the one above you would likely want:

Note that there is also a --ip variable to control.

Just for testing - could you try this command (from this repo)

docker run -it --name repo2docker -p 8888:8888 vanessa/repo2docker-jupyterlab jupyter lab --ip 0.0.0.0

I know for certain that one works. I need to jump internet connections but give me a few minutes and I’ll test out the one that is giving you trouble! It might be some customization to the container.

hey @John_McLean I just tested the command and I had no trouble with the container, notebook, or token. Can you please verify the command you are doing:

$ docker run -it --rm -p 8888:8888 miykael/nipype_tutorial jupyter notebook

and then copy paste the output to the console:

$ docker run -it --rm -p 8888:8888 miykael/nipype_tutorial jupyter notebook
Unable to find image 'miykael/nipype_tutorial:latest' locally
latest: Pulling from miykael/nipype_tutorial
55cbf04beb70: Already exists 
41eb4533cb5c: Pull complete 
ba7e05b6d115: Pull complete 
95e967ce7bf8: Pull complete 
3bf444e47680: Pull complete 
a70e0e77f5f3: Pull complete 
bc52bd2b04a7: Pull complete 
afdd73f6a3dd: Pull complete 
ab3c79aef658: Pull complete 
34a173932170: Pull complete 
a015afb33252: Pull complete 
6f148b9962e3: Pull complete 
1d292d93bbee: Pull complete 
667893538b7c: Pull complete 
abced878c60b: Pull complete 
0b786fbc745d: Pull complete 
7e4cfa17687c: Pull complete 
5c97396849c9: Pull complete 
6560d1bcafc6: Pull complete 
2d6413800f5b: Pull complete 
ac3686495cde: Pull complete 
Digest: sha256:47b95501a67f115fd6ee6246c855cf15db0523908c8bf55f80e18db8b27b7986
Status: Downloaded newer image for miykael/nipype_tutorial:latest
[I 04:14:40.560 NotebookApp] [nb_conda_kernels] enabled, 2 kernels found
[I 04:14:40.592 NotebookApp] Writing notebook server cookie secret to /home/neuro/.local/share/jupyter/runtime/notebook_cookie_secret
[I 04:14:41.293 NotebookApp] [jupyter_nbextensions_configurator] enabled 0.4.0
[I 04:14:41.367 NotebookApp] JupyterLab extension loaded from /opt/miniconda-latest/envs/neuro/lib/python3.6/site-packages/jupyterlab
[I 04:14:41.368 NotebookApp] JupyterLab application directory is /opt/miniconda-latest/envs/neuro/share/jupyter/lab
[I 04:14:41.819 NotebookApp] [nb_conda] enabled
[I 04:14:41.820 NotebookApp] Serving notebooks from local directory: /home/neuro/nipype_tutorial
[I 04:14:41.820 NotebookApp] The Jupyter Notebook is running at:
[I 04:14:41.820 NotebookApp] http://(d95137a793a8 or 127.0.0.1):8888/?token=150acab2f0a5e4a1c5f971e8708592a2a1143855ea5690b5
[I 04:14:41.820 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[W 04:14:41.821 NotebookApp] No web browser found: could not locate runnable browser.
[C 04:14:41.821 NotebookApp] 
    
    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        http://(d95137a793a8 or 127.0.0.1):8888/?token=150acab2f0a5e4a1c5f971e8708592a2a1143855ea5690b5
[I 04:24:09.305 NotebookApp] 302 GET /?token=150acab2f0a5e4a1c5f971e8708592a2a1143855ea5690b5 (172.17.0.1) 1.27ms

and exactly the url you are copy pasting into the browser?

http://127.0.0.1:8888/?token=150acab2f0a5e4a1c5f971e8708592a2a1143855ea5690b5

Hi,

Sorry for the delay in getting back to you. Other things getting in the way. I did as you asked. See the powershell commands and output below.

Interestingly, I am now getting a different error message and am not being given the URL. I think this may be a result of me updating docker a day or two ago. I can’t explain that otherwise as commands were identical. New error looks to relate to proxy issues.

PS C:\Users\MCLEAJO685> docker run hello-world

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:

  1. The Docker client contacted the Docker daemon.
  2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
    (amd64)
  3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
  4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
$ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
https://hub.docker.com/

For more examples and ideas, visit:
https://docs.docker.com/engine/userguide/

PS C:\Users\MCLEAJO685> docker pull miykael/nipype_tutorial:latest
latest: Pulling from miykael/nipype_tutorial
Digest: sha256:47b95501a67f115fd6ee6246c855cf15db0523908c8bf55f80e18db8b27b7986
Status: Image is up to date for miykael/nipype_tutorial:latest
PS C:\Users\MCLEAJO685> docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
ubuntu latest 16508e5c265d 7 days ago 84.1MB
miykael/nipype_tutorial latest 00bcf07bfcbc 7 days ago 8.49GB
nginx latest c82521676580 5 weeks ago 109MB
hello-world latest 2cb0d9787c4d 7 weeks ago 1.85kB
docker4w/nsenter-dockerd latest cae870735e91 10 months ago 187kB
PS C:\Users\MCLEAJO685> docker run -it --rm -p 8888:8888 miykael/nipype_tutorial jupyter notebook
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint nervous_swirles (db2cf37428d0accb29f78ae030f0ed2628fe641adc4954d82269fdc26f3d4924): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:8888:tcp:172.17.0.2:8888: input/output error.
PS C:\Users\MCLEAJO685> docker run -it --name repo2docker -p 8888:8888 vanessa/repo2docker-jupyterlab jupyter lab --ip 0
.0.0.0
Unable to find image ‘vanessa/repo2docker-jupyterlab:latest’ locally
latest: Pulling from vanessa/repo2docker-jupyterlab
4ccdce43d1e0: Pull complete
c95f13c88d92: Pull complete
82656eee95ad: Pull complete
78ff727be57a: Pull complete
448bb314afa5: Pull complete
9d5385822d13: Pull complete
e8f408ef0128: Pull complete
63314e962953: Pull complete
2867b08a103c: Pull complete
065088584bae: Pull complete
7ca732810287: Pull complete
bf42a5848b89: Pull complete
9e1bf29de72e: Pull complete
620b0b10e90f: Pull complete
a3251e53fb06: Pull complete
ab7c93f12aee: Pull complete
6fb28c5245d1: Pull complete
8a0a536069f3: Pull complete
cbe359404675: Pull complete
a21061bee9b4: Pull complete
Digest: sha256:bc187c99851402d6980bc88413140e347383e8175db7324728d16542b898882a
Status: Downloaded newer image for vanessa/repo2docker-jupyterlab:latest
C:\Program Files\Docker\Docker\Resources\bin\docker.exe: Error response from daemon: driver failed programming external connectivity on endpoint repo2docker (d465975798ad34c94ec863f7712afba995d4a7dd99996dbf74bf2a329cf38f18): Error starting userland proxy: mkdir /port/tcp:0.0.0.0:8888:tcp:172.17.0.2:8888: input/output error.
PS C:\Users\MCLEAJO685>

Solved.

I was digging around on various forums looking into the new error i was receiving. I saw one post suggesting ‘experimental features’ from Docker settings > Daemon, should be turned off. In hope rather than expectation, I turned experimental features ‘on’, as my setting was already off. Miraculously, this allows me to run the image and jupyter notebook. No idea why.

The url i had to copy onto my browser went as follows:

http://(572887568e37 or 127.0.0.1):8888/?token=a069361e348d97b30b42db38dcaa725b0ff1ff3cf9b21a68

where I edited it in the browser and selected the 127.0.0.1 i/p

i.e. ran the following in the browser…

http://127.0.0.1:8888/?token=a069361e348d97b30b42db38dcaa725b0ff1ff3cf9b21a68

Thanks for the help
John

Webbrowser is part of the python standard library, you don’t have to install a separate package to use it because it comes bundled with your python installation. If you want to get recognized browsers on your system:

import webbrowser
print webbrowser._browsers

If you directly use webbrowser.open() - it will always open the link in the default browser. What you can do is to register the any other browser and then launch a new tab. Something like this:

webbrowser.register(name, constructor, instance=None)

Once a python browser type is registered, the get() function can return a controller for that browser type. You can run open, open_new and open_new_tab on the controller object. This will ensure the commands are executed on the same browser instance you opened.

import webbrowser    
url='https://www.google.com'
chrome_path="C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe"
webbrowser.register('chrome', None,webbrowser.BackgroundBrowser(chrome_path),1)
webbrowser.get('chrome').open_new_tab(url)