Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

running conda's jupyter on docker

I am using the docker image continuumio/anaconda3 and want to start jupyter notebook server with conda via browser ...

docker run -i -t -p 8888:8888 continuumio/anaconda3 /bin/bash -c "/opt/conda/bin/conda install jupyter -y --quiet && mkdir /opt/notebooks && /opt/conda/bin/jupyter notebook --notebook-dir=/opt/notebooks --ip='*' --port=8888 --no-browser"

which results in ...

Package plan for installation in environment /opt/conda:

The following packages will be UPDATED:

    anaconda: 5.0.1-py36hd30a520_1  --> custom-py36hbbc8b67_0
    conda:    4.3.30-py36h5d9f9f4_0 --> 4.4.10-py36_0        
    jupyter:  1.0.0-py36h9896ce5_0  --> 1.0.0-py36_4         
    pycosat:  0.6.2-py36h1a0ea17_1  --> 0.6.3-py36h0a5515d_0 

[I 14:59:00.461 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
[W 14:59:00.475 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 14:59:00.498 NotebookApp] JupyterLab alpha preview extension loaded from /opt/conda/lib/python3.6/site-packages/jupyterlab
JupyterLab v0.27.0
Known labextensions:
[I 14:59:00.499 NotebookApp] Running the core application with no additional extensions or settings
[C 14:59:00.502 NotebookApp] Running as root is not recommended. Use --allow-root to bypass.

and if I use

$ docker run -p 8888:8888 -i -t continuumio/anaconda3 /bin/bash
root@083f8fbb5d3b:/# jupyter notebook

it gives ...

[I 15:00:52.496 NotebookApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
Traceback (most recent call last):
  File "/opt/conda/bin/jupyter-notebook", line 11, in <module>
    sys.exit(main())
  File "/opt/conda/lib/python3.6/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/traitlets/config/application.py", line 657, in launch_instance
    app.initialize(argv)
  File "<decorator-gen-7>", line 2, in initialize
  File "/opt/conda/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error
    return method(app, *args, **kwargs)
  File "/opt/conda/lib/python3.6/site-packages/notebook/notebookapp.py", line 1296, in initialize
    self.init_webapp()
  File "/opt/conda/lib/python3.6/site-packages/notebook/notebookapp.py", line 1120, in init_webapp
    self.http_server.listen(port, self.ip)
  File "/opt/conda/lib/python3.6/site-packages/tornado/tcpserver.py", line 142, in listen
    sockets = bind_sockets(port, address=address)
  File "/opt/conda/lib/python3.6/site-packages/tornado/netutil.py", line 197, in bind_sockets
    sock.bind(sockaddr)
OSError: [Errno 99] Cannot assign requested address

How should I run Jupyter notebook?

like image 548
Mumbaikar007 Avatar asked Feb 17 '18 15:02

Mumbaikar007


People also ask

Can I use docker with Anaconda?

You can use Anaconda with Docker to build, containerize and share your data science applications with your team. Collaborative data science workflows with Anaconda and Docker make the transition from development to deployment as easy as possible.

Can I run Python in Docker?

Inside the dockerfile we will start by first taking the python base image from docker hub. A tag latest is used to get the latest official python image. It is very important to set your working directory inside your container.


1 Answers

Thanks Mr. darthbirth,

$ docker run -p 8888:8888 -i -t continuumio/anaconda3 /bin/bash

jupyter notebook --ip=0.0.0.0 --port=8888 --allow-root

and the you have Jupyter notebook up and running.

Press ctrl and click the "login with a token" link on your terminal that looks like,

http://0.0.0.0:8888/?token= ...

or

http://127.0.0.1:8888/?token= ...
like image 200
Mumbaikar007 Avatar answered Oct 22 '22 09:10

Mumbaikar007