Skip to content

Local UI to run and train LLMs and diffusion models. Supports GGUF, MLX, Qwen3.8, DeepSeek-V4.1, MiniMax-H3, Gemma 4, FLUX and more.

Docker: pass JUPYTER_PORT and the notebook skip options through run.sh (#11484)

Nilay38ffe9aa94dd
diff --git a/docker/run.sh b/docker/run.sh
index d27e89cfd59..bb8c382d662 100755
--- a/docker/run.sh
+++ b/docker/run.sh
@@ -353,11 +353,13 @@ declare -a ENV_FORWARD=(-e HF_HUB_ENABLE_HF_TRANSFER=1)
[[ -n "${WANDB_API_KEY:-}" ]] && ENV_FORWARD+=(-e WANDB_API_KEY)
[[ -n "${UNSLOTH_LICENSE:-}" ]] && ENV_FORWARD+=(-e UNSLOTH_LICENSE)
[[ -n "${UNSLOTH_ALLOW_CPU:-}" ]] && ENV_FORWARD+=(-e UNSLOTH_ALLOW_CPU)
+[[ -n "${UNSLOTH_SKIP_GPU_CHECK:-}" ]] && ENV_FORWARD+=(-e UNSLOTH_SKIP_GPU_CHECK)
# gfx overrides for cards the installed ROCm build has no kernels for
[[ -n "${HSA_OVERRIDE_GFX_VERSION:-}" ]] && ENV_FORWARD+=(-e HSA_OVERRIDE_GFX_VERSION)
[[ -n "${UNSLOTH_ROCM_GFX_ARCH:-}" ]] && ENV_FORWARD+=(-e UNSLOTH_ROCM_GFX_ARCH)
# read by studio_launch.sh; without these it uses a random password and no sshd
[[ -n "${JUPYTER_PASSWORD:-}" ]] && ENV_FORWARD+=(-e JUPYTER_PASSWORD)
+[[ -n "${JUPYTER_PORT:-}" ]] && ENV_FORWARD+=(-e JUPYTER_PORT)
[[ -n "${UNSLOTH_STUDIO_PASSWORD:-}" ]] && ENV_FORWARD+=(-e UNSLOTH_STUDIO_PASSWORD)
[[ -n "${UNSLOTH_STUDIO_PORT:-}" ]] && ENV_FORWARD+=(-e UNSLOTH_STUDIO_PORT)
[[ -n "${UNSLOTH_STUDIO_BOOTSTRAP_TIMEOUT:-}" ]] && ENV_FORWARD+=(-e UNSLOTH_STUDIO_BOOTSTRAP_TIMEOUT)
@@ -367,6 +369,8 @@ declare -a ENV_FORWARD=(-e HF_HUB_ENABLE_HF_TRANSFER=1)
[[ -n "${PUBLIC_KEY:-}" ]] && ENV_FORWARD+=(-e PUBLIC_KEY)
[[ -n "${SSH_KEY:-}" ]] && ENV_FORWARD+=(-e SSH_KEY)
[[ -n "${UNSLOTH_JUPYTER_CLOUDFLARE:-}" ]] && ENV_FORWARD+=(-e UNSLOTH_JUPYTER_CLOUDFLARE)
+[[ -n "${UNSLOTH_SKIP_NOTEBOOK_SYNC:-}" ]] && ENV_FORWARD+=(-e UNSLOTH_SKIP_NOTEBOOK_SYNC)
+[[ -n "${UNSLOTH_SKIP_NOTEBOOK_REFRESH:-}" ]] && ENV_FORWARD+=(-e UNSLOTH_SKIP_NOTEBOOK_REFRESH)
# Studio's two exposure modes, read by studio_run.sh inside the container. The
# allowlist is explicit, so leaving them out made both silently inert through the
# helper the documentation recommends.
diff --git a/tests/python/test_docker_run_env_forward.py b/tests/python/test_docker_run_env_forward.py
new file mode 100644
index 00000000000..55bd6e0b30f
--- /dev/null
+++ b/tests/python/test_docker_run_env_forward.py
@@ -0,0 +1,88 @@
+# SPDX-License-Identifier: AGPL-3.0-only
+# Copyright 2026-present the Unsloth AI Inc. team. All rights reserved.
+
+import os
+import re
+import shutil
+import stat
+import subprocess
+from pathlib import Path
+
+import pytest
+
+DOCKER = Path(__file__).resolve().parents[2] / "docker"
+RUN_SH = DOCKER / "run.sh"
+
+pytestmark = pytest.mark.skipif(
+ os.name != "posix" or shutil.which("bash") is None,
+ reason = "POSIX shell required",
+)
+
+
+def _documented(page, heading):
+ table = (DOCKER / page).read_text(encoding = "utf-8").split(f"\n{heading}\n", 1)[1]
+ names = []
+ for row in table.split("\n## ", 1)[0].splitlines():
+ if row.startswith("| `"):
+ names += re.findall(r"`([A-Z][A-Z0-9_]+)(?:=[^`]*)?`", row.split("|")[1])
+ return names
+
+
+ROCM_DOCUMENTED = _documented("DOCKERHUB-ROCM.md", "## Environment")
+DOCUMENTED = list(
+ dict.fromkeys(_documented("DOCKERHUB.md", "## Environment variables") + ROCM_DOCUMENTED)
+)
+
+
+def _forwarded(tmp_path, **env_extra):
+ bindir = tmp_path / "bin"
+ bindir.mkdir()
+ argv_log = tmp_path / "argv"
+ docker = bindir / "docker"
+ docker.write_text(
+ f'#!/usr/bin/env bash\nprintf "%s\\n" "$@" > "{argv_log}"\n', encoding = "utf-8"
+ )
+ docker.chmod(docker.stat().st_mode | stat.S_IEXEC)
+ env = {k: v for k, v in os.environ.items() if k not in DOCUMENTED}
+ env.update(
+ PATH = f"{bindir}:/usr/bin:/bin",
+ HOME = str(tmp_path / "home"),
+ UNSLOTH_WORKDIR = str(tmp_path),
+ UNSLOTH_GPUS = "none",
+ **env_extra,
+ )
+ proc = subprocess.run(
+ [shutil.which("bash"), str(RUN_SH), "true"],
+ cwd = tmp_path,
+ env = env,
+ capture_output = True,
+ text = True,
+ timeout = 60,
+ )
+ assert proc.returncode == 0, proc.stderr
+ argv = argv_log.read_text(encoding = "utf-8").splitlines()
+ return [spec for flag, spec in zip(argv, argv[1:]) if flag == "-e"]
+
+
+def test_the_hub_pages_still_have_a_variable_table():
+ assert len(DOCUMENTED) >= 10, DOCUMENTED
+ assert "UNSLOTH_SKIP_GPU_CHECK" in ROCM_DOCUMENTED, ROCM_DOCUMENTED
+ # named one by one: a row reformatted out of the parser's reach would otherwise
+ # drop that variable's case silently, and the suite would still report all green
+ for name in (
+ "JUPYTER_PORT",
+ "UNSLOTH_SKIP_NOTEBOOK_SYNC",
+ "UNSLOTH_SKIP_NOTEBOOK_REFRESH",
+ "UNSLOTH_SKIP_GPU_CHECK",
+ ):
+ assert name in DOCUMENTED, (name, DOCUMENTED)
+
+
[email protected]("name", DOCUMENTED)
+def test_every_documented_variable_reaches_the_container(tmp_path, name):
+ assert name in _forwarded(tmp_path, **{name: "1"})
+
+
[email protected]("name", DOCUMENTED)
+def test_an_unset_variable_is_not_forwarded(tmp_path, name):
+ assert name not in _forwarded(tmp_path)