Running Jupyter Server from a Docker Container

I need to present a series of results and calculations that use GPUs. I concluded that I should create a Docker Container that can I can use in creating and installing my python package AND that can run my notebooks on the python package.
I decided to start with this base image: nvidia/cuda:12.3.1-devel-ubuntu22.04
and created this Dockerfile

FROM nvidia/cuda:12.3.1-devel-ubuntu22.04

# Set DEBIAN_FRONTEND to noninteractive to prevent tzdata configuration dialog
ENV DEBIAN_FRONTEND=noninteractive

USER root

RUN mkdir /app && cd /app
# Set the working directory
# Mark /app as a volume to be mounted

# Install gnupg
RUN apt-get update && apt-get upgrade -y && \
    apt-get install -y gnupg cmake && \
    apt-get install -y build-essential dkms wget apt-utils && \
    apt-get install -y pkg-config libcairo2-dev && \
    apt-get install -y software-properties-common && \
    apt-get install -y python3-cairo-dev && \
    apt-get install -y netstat-nat telnet && \
    apt-get clean && \
    rm -rf /var/lib/apt/lists/*

# Download and install pip for Python 3 using script
RUN apt-get update && apt-get install -y curl python3-venv
RUN apt-get install -y python3-dev
RUN ln -s /usr/bin/python3 /usr/bin/python
# Add a line to activate the virtual environment in ~/.bashrc
RUN echo "source /myvenv/bin/activate" >> /root/.bashrc

# Copy requirements and install Python packages
COPY requirements.txt .

# Create and activate a virtual environment
RUN python3 -m venv /myvenv && \
    . /myvenv/bin/activate && \
    pip install pycairo && \
    pip install -r requirements.txt


# Copy the start script and make it executable
RUN chmod +x

# Start your application with CMD
CMD ["source /myvenv/bin/activate", "/bin/bash", "/app/"]

The docker-compose.yml is this:

version: '3'

      context: /home/mp74207/CLionProjects/HU_GalaxyPackage  # Replace with the path to the directory containing your Dockerfile
      dockerfile: Dockerfile  # Replace with the actual name of your Dockerfile if it's different
      - /home/mp74207/CLionProjects/HU_GalaxyPackage:/app
    working_dir: /app
#    command:
#      - /bin/bash
#      - -c
#      - "tail -f /dev/null"
#      - source /myvenv/bin/activate && jupyter-server
      - /bin/bash
      - -c
      - |
        cd /app
        source /myvenv/bin/activate
        jupyter server --allow-root --ip --port 8888 --notebook-dir='/app'

    container_name: hu-galaxy-container
      - "8888:8888"

I can run the container and start the jupyter server. When I go to the on the host I find a page with “Jupyter is running”.

Somehow I cannot pass the starting directory. I hoped to see the same thing I see when I run anaconda-navigator. I don’t.

I tried several combinations of jupyter server , jupyter notebook, and jupyter commands but failed to find the correct combination.

So, this is not really about JupyterHub. I couldn’t find an option for just Jupyter Server.

Of course, if one know how to make it work with jupyterhub, I will be happy to change program. The network seems to be ok since I can see the Jupyter is Working in the host.

Any help would be amazing…

Thanks in advance.

I figured out what was missing. I needed the package notebook. After installing it, i changed the command in docker-compose.yml to
jupyter notebook --allow-root --ip --port 8888 --notebook-dir=‘/app’

and life was great again.