I need to setup a Docker JupyterLab image to port 7777 instead of the default 8888. I tried to setup the Dockerfile with
ENV JUPYTER_PORT 7777
and also using “-e” parameter through “docker run” command line. This is how I tried to ran the image:
#!/bin/bash
docker run -p 7777:7777 -e JUPYTER_PORT=7777 -v "$PWD":/home/jovyan/work jupyter/mytest
None of them worked so far, with the following log:
Container must be run with group root to update passwd file
Executing the command: jupyter notebook
[I 07:15:53.098 NotebookApp] Writing notebook server cookie secret to /home/jovyan/.local/share/jupyter/runtime/notebook_cookie_secret
[W 07:15:53.457 NotebookApp] WARNING: The notebook server is listening on all IP addresses and not using encryption. This is not recommended.
[I 07:15:53.519 NotebookApp] JupyterLab beta preview extension loaded from /opt/conda/lib/python3.6/site-packages/jupyterlab
[I 07:15:53.519 NotebookApp] JupyterLab application directory is /opt/conda/share/jupyter/lab
[I 07:15:53.538 NotebookApp] Serving notebooks from local directory: /home/jovyan
[I 07:15:53.538 NotebookApp] 0 active kernels
[I 07:15:53.538 NotebookApp] The Jupyter Notebook is running at:
[I 07:15:53.538 NotebookApp] http://[all ip addresses on your system]:8888/?token=9a9c4cde9e9b167a1d21ac494ec0377626045a7d5c7181eb
[I 07:15:53.538 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 07:15:53.539 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=9a9c4cde9e9b167a1d21ac494ec0377626045a7d5c7181eb
Is there any way to setup the file ~/.jupyter/jupyter_notebook_config.py as suggested here as this:
c.NotebookApp.port = 7777
in the Dockerfile?
My current Dockerfile is:
FROM jupyter/datascience-notebook:9f9e5ca8fe5a
# Install in the default python3 environment
COPY requirements.txt /tmp/
RUN pip install --requirement /tmp/requirements.txt && \
fix-permissions $CONDA_DIR && \
fix-permissions /home/$NB_USER
I tried but unfortunately it didn’t worked. I don’t know in which case I would need to change the internal container port, or if would it help. I need to access this notebook from external world, so that could be an issue?
Any other ideas are more than welcome
-e JUPYTER_PORT=8117 - Changes the port in the container that Jupyter is using to the value of the ${JUPYTER_PORT} environment variable. This may be useful if you run multiple instances of Jupyter in swarm mode and want to use a different port for each instance.