mathworks-ref-arch / matlab-integration-for-jupyter

Create Jupyter Docker images with MATLAB integration
Other
26 stars 8 forks source link

[Bug Report] VNC screen goes black #2

Closed yezhengkai closed 3 years ago

yezhengkai commented 3 years ago

Description

As the title, after VNC is idle for a period of time, the screen turns black.

Steps to Reproduce

The following is the dockerfile used to generate the container in JupyterHub.

# Copyright 2020 The MathWorks, Inc.

# Argument shared across multi-stage build to hold location of installed MATLAB 
ARG BASE_ML_INSTALL_LOC=/tmp/matlab-install-location

# Replace "matlab" with the Docker image that contains MATLAB
# MATLAB should be available on the path in the Docker image
FROM mathworks/matlab:r2020b AS matlab-install-stage
ARG BASE_ML_INSTALL_LOC

# Run code to locate a MATLAB install in the base image and softlink
# to BASE_ML_INSTALL_LOC for a latter stage to copy 
RUN export ML_INSTALL_LOC=$(which matlab) \
    && if [ ! -z "$ML_INSTALL_LOC" ]; then \
        ML_INSTALL_LOC=$(dirname $(dirname $(readlink -f ${ML_INSTALL_LOC}))); \
        echo "soft linking: " $ML_INSTALL_LOC " to" ${BASE_ML_INSTALL_LOC}; \
        ln -s ${ML_INSTALL_LOC} ${BASE_ML_INSTALL_LOC}; \
    elif [ $BASE_ML_INSTALL_LOC = '/tmp/matlab-install-location' ]; then \
        echo "MATLAB was not found in your image."; exit 1; \
    else \
        echo "Proceeding with user provided path to MATLAB installation: ${BASE_ML_INSTALL_LOC}"; \
    fi

FROM jupyter/base-notebook:hub-1.4.2
ARG BASE_ML_INSTALL_LOC

# Switch to root user
USER root

# Copy MATLAB install from Docker image
COPY --from=matlab-install-stage ${BASE_ML_INSTALL_LOC} /usr/local/MATLAB

# Add MATLAB to the path
RUN ln -s /usr/local/MATLAB/bin/matlab /usr/local/bin/matlab

# Install MATLAB dependencies
# Reference: https://github.com/mathworks-ref-arch/container-images/tree/master/matlab-deps
RUN export DEBIAN_FRONTEND=noninteractive && apt-get update && apt-get install --no-install-recommends -y \
        libasound2 \
        libatk1.0-0 \
        libc6 \
        libcairo-gobject2 \
        libcairo2 \
        libcrypt1 \
        libcups2 \
        libdbus-1-3 \
        libfontconfig1 \
        libgdk-pixbuf2.0-0 \
        libgstreamer-plugins-base1.0-0 \
        libgstreamer1.0-0 \
        libgtk-3-0 \
        libnspr4 \
        libnss3 \
        libpam0g \
        libpango-1.0-0 \
        libpangocairo-1.0-0 \
        libpangoft2-1.0-0 \
        libpython2.7 \
        libpython3.8 \
        libselinux1 \
        libsm6 \
        libsndfile1 \
        libtcl8.6 \
        libuuid1 \
        libx11-6 \
        libx11-xcb1 \
        libxcb1 \
        libxcomposite1 \
        libxcursor1 \
        libxdamage1 \
        libxext6 \
        libxfixes3 \
        libxft2 \
        libxi6 \
        libxinerama1 \
        libxrandr2 \
        libxrender1 \
        libxt6 \
        libxtst6 \
        libxxf86vm1 \
        zlib1g \
        xkb-data \
        procps \
        ca-certificates \
        sudo \
        locales locales-all \
    && apt-get clean \
    && apt-get -y autoremove \
    && rm -rf /var/lib/apt/lists/*

# Install jupyter-matlab-vnc dependencies
RUN export DEBIAN_FRONTEND=noninteractive \
    && apt-get -y update \
    && apt-get install -y \
    dbus-x11 \
    firefox \
    xfce4 \
    xfce4-panel \
    xfce4-session \
    xfce4-settings \
    xorg \
    xubuntu-icon-theme \
    curl \
    && apt-get clean \
    && apt-get -y autoremove \
    && rm -rf /var/lib/apt/lists/*

# Install tigervnc to /usr/local
# The original URL https://bintray.com/tigervnc/stable/download_file?file_path=tigervnc-1.10.1.x86_64.tar.gz is dead
RUN curl -sSfL 'https://sourceforge.net/projects/tigervnc/files/stable/1.10.1/tigervnc-1.10.1.x86_64.tar.gz/download' \
    | tar -zxf - -C /usr/local --strip=2

# noVNC provides VNC over browser capability
# Set default install location for noVNC
ARG NOVNC_PATH=/opt/noVNC

# Get noVNC
RUN mkdir -p ${NOVNC_PATH} \
     && curl -sSfL 'https://github.com/novnc/noVNC/archive/v1.2.0.tar.gz' \
     | tar -zxf - -C ${NOVNC_PATH} --strip=1 \
     && chown -R ${NB_USER}:users ${NOVNC_PATH}

# Change user to jovyan from root as we do not want any changes to be made as root in the container
# change $NB_USER to ${NB_UID}
USER ${NB_UID}

# Get websockify
RUN conda install -y -q websockify=0.9.0

# Set environment variable for python package jupyter-matlab-vnc-proxy
ENV NOVNC_PATH=${NOVNC_PATH}
# Pip install the integration
RUN python -m pip install https://github.com/mathworks/jupyter-matlab-vnc-proxy/archive/0.1.0.tar.gz

# Ensure jupyter-server-proxy JupyterLab extension is installed
RUN jupyter labextension install @jupyterlab/server-proxy

# Move MATLAB resource files to the expected locations
RUN export RESOURCES_LOC=$(python -c "import jupyter_matlab_vnc_proxy as pkg; print(pkg.__path__[0])")/resources \
  && mkdir -p ${HOME}/.local/share/applications ${HOME}/Desktop ${HOME}/.local/share/ ${HOME}/.icons \
  && cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/Desktop/ \
  && cp ${RESOURCES_LOC}/MATLAB.desktop ${HOME}/.local/share/applications\
  && ln -s ${RESOURCES_LOC}/matlab_icon.png ${HOME}/.icons/matlab_icon.png \
  && cp ${RESOURCES_LOC}/matlab_launcher.py ${HOME}/.local/share/ \
  && cp ${RESOURCES_LOC}/mw_lite.html ${NOVNC_PATH}

# Fixes occasional failure to start VNC desktop, which requires a reloading of the webpage to fix.
RUN touch ${HOME}/.Xauthority

# Uncomment and set the port and hostname to configure a network license manager for all users
# ENV MLM_LICENSE_FILE port@hostname

More Information

$ docker version
Client:
 Version:           18.09.9
 API version:       1.39
 Go version:        go1.11.13
 Git commit:        039a7df9ba
 Built:             Wed Sep  4 16:57:28 2019
 OS/Arch:           linux/amd64
 Experimental:      false

Server: Docker Engine - Community
 Engine:
  Version:          18.09.9
  API version:      1.39 (minimum version 1.12)
  Go version:       go1.11.13
  Git commit:       039a7df
  Built:            Wed Sep  4 16:19:38 2019
  OS/Arch:          linux/amd64
  Experimental:     false
$ docker-compose version
docker-py version: 3.7.2
CPython version: 3.6.8
OpenSSL version: OpenSSL 1.1.0j  20 Nov 2018 
vemonet commented 3 years ago

We have the same issue, we can't use at all the Matlab official docker image because it is not stable image and the screen goes black after a few minutes of idling

I think it is the same for anyone using matlab but noone use it anymore, so you probably never had to fix it

prabhakk-mw commented 3 years ago

Dear @yezhengkai & @vemonet,

Thank you for reporting the issue.

This is a known issue with the current container offerings, and a fix for it will make its way to the published containers on Dockerhub soon.

In the mean time, could you try the fix on your end, by either including the following commands into your Dockerfiles or by executing the following commands in your running containers:

To add these into the Dockerfile please add the lines RUN apt-get install xscreensaver && apt-get remove gnome-screensaver

Command to execute in the running Docker containers: sudo apt-get install xscreensaver sudo apt-get remove gnome-screensaver

Please re-open this issue if the solution listed above does not fix the issue.

prabhakk-mw commented 3 years ago

Support the above listed workaround will be submitted as a fix. Upon submit this issue should auto-close.