How to add noVNC in dockerised jupyterlab

489 Views Asked by At

I have created below the dockerfile and added novnc and websockify as per their documentation. After the docker run, I could see the connect page on the browser after copy-and-paste URL that is output by the novnc_proxy script inside the docker entry point.

However as soon as I tried to click connect it gives me an error message failed to connect the server. Does anyone know, how to fix this error? or Is there some configuration I'm missing out on to run the VNC?

Dockerfile

FROM python:3.8.0

ENV DISPLAY :1

RUN git clone --depth=1 https://github.com/Bash-it/bash-it.git ~/.bash_it && \
    bash ~/.bash_it/install.sh --silent


RUN curl -sL https://deb.nodesource.com/setup_12.x | bash - && \
    apt-get upgrade -y && \
    apt-get install -y nodejs \
                       supervisor \
                       openssl \
                       xvfb \
                       x11vnc \
                       openbox && apt-get clean && \
    rm -rf /var/lib/apt/lists/*

RUN pip install --upgrade pip && \
    pip install --upgrade \
    PyVirtualDisplay \
    pillow \
    numpy \
    pandas \
    dash \
    Jupyterlab \
    ipywidgets \
    jupyterlab-git \
    jupyter-server-proxy \
    jupyter-dash \
    jupyterlab-novnc \
    nbserverproxy

RUN jupyter lab build
# RUN pip install --upgrade pip && \
#     pip install --upgrade \
#     jupyterlab "pywidgets>=7.5"
RUN jupyter serverextension enable --py nbserverproxy

RUN jupyter labextension install \
    [email protected] \
    @jupyter-widgets/jupyterlab-manager \
    @jupyterlab/git \
    @jupyterlab/server-proxy

COPY config/ /root/.jupyter/


VOLUME /notebooks
WORKDIR /notebooks

RUN git clone https://github.com/novnc/noVNC.git ./novnc  && \
    git clone https://github.com/novnc/websockify.git ./novnc/utils/websockify

COPY entrypoint.sh .

RUN chmod -R 755 /notebooks/
EXPOSE 8888 8050 5901 6080 8081
ENTRYPOINT ["/notebooks/entrypoint.sh"]

entrypoint.sh

echo
jupyter lab --allow-root --ip=* --port=8888 &
/notebooks/novnc/utils/novnc_proxy --vnc localhost:5901 --listen 6080
fg %1

I build the docker image and run the docker image docker run -it -p 8888:8888 -p 8050:8050 -p 5901:5901 -p 6080:6080 <ImageName>

O/p of this docker run looks like this:

noVNCoutput

and instead of the url showing in std output, if I try to login http://localhost:6080/vnc.html?host=localhost&port=6080 it shows me the login browser of noVNC browser but as soon as I click on connect it shows failed to connect the server

and docker log shows me connection Refused

Inside the container, I could see websockify service is running

Inside container

I suspect it's because of websocket connection issue, but don't know what needs to be done here.

Websocket

0

There are 0 best solutions below