Jupyter Sandbox Setup Guide - ajgillis04/GillisDockerDepot GitHub Wiki

Jupyter Sandbox Setup Guide

Introduction

A locked-down Jupyter server where OpenWebUI Setup Guide (WSL2 Docker) runs Python written by the local model, for maths, data work and charts. Because the model writes this code, and web pages it reads could try to steer what it writes, the sandbox is isolated as tightly as possible.

Compose

compose/server2/jupyter-sandbox.yaml:

services:
  jupyter-sandbox:
    container_name: jupyter-sandbox.${HOST_NAME}
    image: quay.io/jupyter/scipy-notebook@sha256:<digest>   # pinned by digest
    command: ["start-notebook.py", "--IdentityProvider.token=${JUPYTER_SANDBOX_TOKEN}",
              "--ServerApp.allow_origin=*", "--ServerApp.disable_check_xsrf=True"]
    environment:
      TZ: ${TZ}
    networks:
      - llm_sandbox
    restart: always
    mem_limit: 4g
    cpus: 4
    pids_limit: 512
    cap_drop: [ALL]
    security_opt: [no-new-privileges:true]

networks:
  llm_sandbox:
    internal: true        # no internet, no LAN

How It's Isolated

  • llm_sandbox is an internal network: no internet and no LAN. Open WebUI is the only other member, so it's the only thing that can reach the sandbox.
  • No host folders mounted, so code can't touch your files. Anything it writes disappears when the container restarts.
  • Not root, no Linux capabilities, no-new-privileges.
  • Limits on memory, CPU and processes, so a runaway loop can't take the machine down.
  • No published ports.

Connecting Open WebUI

  1. Add llm_sandbox to Open WebUI's networks.
  2. Admin Panel → Settings → Code Execution: engine Jupyter, URL http://jupyter-sandbox:8888, auth Token, the token from .env.
  3. Turn on code execution and/or the code interpreter for the models that should use it.

Notes

  • The scipy-notebook image already has numpy, pandas, matplotlib and scipy. Without internet, pip install won't work, which is intentional.
  • Pinning by digest means updates are deliberate; Watchtower is off for it.
⚠️ **GitHub.com Fallback** ⚠️