skip to Main Content

I’m creating a course that will require students to run some software called PyStan. It turns out that this is only partially supported on Windows.

Someone gave me an idea to use Docker so that students wouldn’t have any issue getting the software they need to do assignments. The end goal is that students can do very little to get Jupyter Lab up and running on their own machines, with as little effort as possible.

I tried writing the following to be run with sudo docker compose up

version: '3'
services:
  ubuntu_anaconda:
    image: continuumio/anaconda3:latest
    container_name: ubuntu_anaconda
    environment:
      - LANG=C.UTF-8
      - JUPYTER_TOKEN=my_secret_token  # Set your desired token here
    ports:
      - "8888:8888"  # Expose Jupyter Lab port
    volumes:
      - ./data:/data  # Add this line if you want to mount a local directory to the container
    command: /bin/bash -c "/opt/conda/bin/conda install -y -c conda-forge pystan && /opt/conda/bin/jupyter lab --ip=0.0.0.0 --port=8888 --allow-root --NotebookApp.token=$${JUPYTER_TOKEN}"

However, when I open up a web browser and navigate to http://localhost:8888/ or http://localhost:8888/?token=my_secret_token it says

The connection was reset

The connection to the server was reset while the page was loading.

  • The site could be temporarily unavailable or too busy. Try again in a few moments.
  • If you are unable to load any pages, check your computer’s network connection.
  • If your computer or network is protected by a firewall or proxy, make sure that Firefox is permitted to access the web.

On the other hand, when I navigate to https://127.0.0.1:8888/ it says

Secure Connection Failed

An error occurred during a connection to 127.0.0.1:8888.
PR_END_OF_FILE_ERROR

Error code: PR_END_OF_FILE_ERROR

  • The page you are trying to view cannot be shown because the authenticity of the received data could not be verified.
    Please contact the website owners to inform them of this problem.

2

Answers


  1. Root Cause

    Seems your container is not reachable by some network setting… Not sure what happened, I would need to know your whole set up. Maybe or necessary just restart the pc and try the following steps.

    Solution

    I tested your docker compose file on an ubuntu 24 host and it works fine. I started up the jupyter session as follows (I allowed root just because it is intended to be local and non production env):

    docker compose up
    docker exec -it <container_name> bash
    jupyter notebook --allow-root
    

    Extra Ball

    In your use case It maybe more intuitive with Visual Studio pluggings

    1. Open the folder which contains the docker-compse.yml with Visual Studio
    2. Click on Add dev container configuration files
      enter image description here
    3. Click on From docker-compose.yml (it will detect your file)
      enter image description here
    4. It will build the container and then attach to it.
      enter image description here
    5. Open a terminal from visual studio and you will be ready to up the jupyter server and run whatever you or your students need in the server
      enter image description here

    I hope this two insights help you! 🙂

    Login or Signup to reply.
  2. Here is docker-compose that works for me, it only requires create directory ./notebooks with permission 777 or to be owner by user id 1000

    version: "3.9"
    
    services:
      jupyter:
        image: jupyter/scipy-notebook
        ports:
          - "8888:8888"
        volumes:
          - ./notebooks:/home/jovyan/
        environment:
          JUPYTER_ENABLE_LAB: "yes"
          JUPYTER_TOKEN: 1234
        command: bash -c "pip install pystan && start-notebook.sh --NotebookApp.token='${JUPYTER_TOKEN}'"
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search