Reputation:
I'm trying to dockerize the Jupyter Lab and so I tried to create a Dockerfile
as below,
FROM python:3.6
WORKDIR /jup
RUN pip install jupyter -U && pip install jupyterlab
EXPOSE 8888
ENTRYPOINT ["jupyter", "lab"]
and run the commands, docker build . -t jupyter
then docker run jupyter
. But unfortunately I got some error as below
[I 07:56:34.123 LabApp] Writing notebook server cookie secret to /root/.local/share/jupyter/runtime/notebook_cookie_secret
Traceback (most recent call last):
File "/usr/local/bin/jupyter-lab", line 11, in <module>
sys.exit(main())
File "/usr/local/lib/python3.6/site-packages/jupyter_core/application.py", line 266, in launch_instance
return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
File "/usr/local/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 "/usr/local/lib/python3.6/site-packages/traitlets/config/application.py", line 87, in catch_config_error
return method(app, *args, **kwargs)
File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 1507, in initialize
self.init_webapp()
File "/usr/local/lib/python3.6/site-packages/notebook/notebookapp.py", line 1297, in init_webapp
self.http_server.listen(port, self.ip)
File "/usr/local/lib/python3.6/site-packages/tornado/tcpserver.py", line 142, in listen
sockets = bind_sockets(port, address=address)
File "/usr/local/lib/python3.6/site-packages/tornado/netutil.py", line 197, in bind_sockets
sock.bind(sockaddr)
OSError: [Errno 99] Cannot assign requested address
How can I dockerize jupyter lab
? [ by solving this error ]
Upvotes: 19
Views: 22652
Reputation: 9680
You really don't have to roll your own. The Jupyter Docker Stack provides ready-made JupyterLab images that work together with a JupyterHub docker image. The Hub can "spawn" a separate container for each user running a given JupyterLab (search for the DockerSpawner
class that's responsible for the magic).
The reason I am adding this as a separate answer is the CAVEAT: while useful links are available on the Internet, they are often outdated and there are inconsistencies between the documentation and reality that make the "productive Dockerisation of Jupyter" rather painful. Just to name a few that I encountered:
jovyan
, UID=1000. This can lead to unexpected surprises regarding file ownerships and permissions..sh
extension because then it's meant to do something different...YMMV, of course. And despite all this, when it works then it's a rather elegant setup. I am going to try it out for real on some unlucky students soon :-)
Upvotes: 2
Reputation: 564
As an alternative to building your own Docker image with JupyterLab, you can also use the ML Workspace image. The ML Workspace is an open-source web IDE that combines Jupyter, JupyterLab, VS Code, and many other tools & libraries into one convenient Docker image. Deploying a single workspace instance is as simple as:
docker run -p 8080:8080 mltooling/ml-workspace:latest
All tools are accessible from the same port and integrated into the Jupyter UI. You can find further information on how to access JupyterLab here.
Upvotes: 0
Reputation: 2993
Whilst searching around I came across this question, before going on to discover a reference to Jupyter Labs in the 'Read The Docs' pages for Jupyter Docker Stacks (see here). The documentation says:
JupyterLab is preinstalled as a notebook extension starting in tag c33a7dc0eece.
and they suggest using a command like:
docker run -it --rm -p 8888:8888 jupyter/datascience-notebook start.sh jupyter lab
I thought I might as well add the reference here in case it's useful for others. (It's not immediately obvious on Docker Hub for example, that there is support for Jupyter Labs.)
Upvotes: 6
Reputation: 28713
When you start jupyter lab
you should define --ip
parameter. For example, --ip=0.0.0.0
.
After this you will have another error:
[C 08:14:56.973 LabApp] Running as root is not recommended. Use --allow-root to bypass.
So, if you want to proceed you need to add --allow-root
as well.
The final Dockerfile
is:
FROM python:3.6
WORKDIR /jup
RUN pip install jupyter -U && pip install jupyterlab
EXPOSE 8888
ENTRYPOINT ["jupyter", "lab","--ip=0.0.0.0","--allow-root"]
Upvotes: 28