mirror of
https://github.com/jupyter/docker-stacks.git
synced 2025-10-18 07:22:57 +00:00
Use correct ServerApp options in examples and tests (#1947)
This commit is contained in:
@@ -11,19 +11,19 @@ This page describes the options supported by the startup script and how to bypas
|
||||
You can pass [Jupyter server options](https://jupyter-server.readthedocs.io/en/latest/operators/public-server.html) to the `start-notebook.sh` script when launching the container.
|
||||
|
||||
1. For example, to secure the Notebook server with a [custom password](https://jupyter-server.readthedocs.io/en/latest/operators/public-server.html#preparing-a-hashed-password)
|
||||
hashed using `jupyter_server.auth.security.passwd()` instead of the default token,
|
||||
hashed using `jupyter_server.auth.passwd()` instead of the default token,
|
||||
you can run the following (this hash was generated for the `my-password` password):
|
||||
|
||||
```bash
|
||||
docker run -it --rm -p 8888:8888 jupyter/base-notebook \
|
||||
start-notebook.sh --NotebookApp.password='argon2:$argon2id$v=19$m=10240,t=10,p=8$JdAN3fe9J45NvK/EPuGCvA$O/tbxglbwRpOFuBNTYrymAEH6370Q2z+eS1eF4GM6Do'
|
||||
start-notebook.sh --PasswordIdentityProvider.hashed_password='argon2:$argon2id$v=19$m=10240,t=10,p=8$JdAN3fe9J45NvK/EPuGCvA$O/tbxglbwRpOFuBNTYrymAEH6370Q2z+eS1eF4GM6Do'
|
||||
```
|
||||
|
||||
2. To set the [base URL](https://jupyter-server.readthedocs.io/en/latest/operators/public-server.html#running-the-notebook-with-a-customized-url-prefix) of the notebook server, you can run the following:
|
||||
|
||||
```bash
|
||||
docker run -it --rm -p 8888:8888 jupyter/base-notebook \
|
||||
start-notebook.sh --NotebookApp.base_url=/customized/url/prefix/
|
||||
start-notebook.sh --ServerApp.base_url=/customized/url/prefix/
|
||||
```
|
||||
|
||||
## Docker Options
|
||||
@@ -148,8 +148,8 @@ docker run -it --rm -p 8888:8888 \
|
||||
-v /some/host/folder:/etc/ssl/notebook \
|
||||
jupyter/base-notebook \
|
||||
start-notebook.sh \
|
||||
--NotebookApp.keyfile=/etc/ssl/notebook/notebook.key \
|
||||
--NotebookApp.certfile=/etc/ssl/notebook/notebook.crt
|
||||
--ServerApp.keyfile=/etc/ssl/notebook/notebook.key \
|
||||
--ServerApp.certfile=/etc/ssl/notebook/notebook.crt
|
||||
```
|
||||
|
||||
Alternatively, you may mount a single PEM file containing both the key and certificate.
|
||||
@@ -160,7 +160,7 @@ docker run -it --rm -p 8888:8888 \
|
||||
-v /some/host/folder/notebook.pem:/etc/ssl/notebook.pem \
|
||||
jupyter/base-notebook \
|
||||
start-notebook.sh \
|
||||
--NotebookApp.certfile=/etc/ssl/notebook.pem
|
||||
--ServerApp.certfile=/etc/ssl/notebook.pem
|
||||
```
|
||||
|
||||
In either case, Jupyter Notebook expects the key and certificate to be a **base64 encoded text file**.
|
||||
|
@@ -475,15 +475,16 @@ For JupyterLab:
|
||||
```bash
|
||||
docker run -it --rm \
|
||||
jupyter/base-notebook:2023-07-25 \
|
||||
start.sh jupyter lab --LabApp.token=''
|
||||
start-notebook.sh --IdentityProvider.token=''
|
||||
```
|
||||
|
||||
For jupyter classic:
|
||||
For Jupyter Notebook:
|
||||
|
||||
```bash
|
||||
docker run -it --rm \
|
||||
-e DOCKER_STACKS_JUPYTER_CMD=notebook \
|
||||
jupyter/base-notebook:2023-07-25 \
|
||||
start.sh jupyter notebook --NotebookApp.token=''
|
||||
start-notebook.sh --IdentityProvider.token=''
|
||||
```
|
||||
|
||||
## Enable nbclassic-extension spellchecker for markdown (or any other nbclassic-extension)
|
||||
|
@@ -19,8 +19,8 @@ services:
|
||||
PASSWORD: ${PASSWORD}
|
||||
command: >
|
||||
start-notebook.sh
|
||||
--NotebookApp.certfile=/etc/letsencrypt/fullchain.pem
|
||||
--NotebookApp.keyfile=/etc/letsencrypt/privkey.pem
|
||||
--ServerApp.certfile=/etc/letsencrypt/fullchain.pem
|
||||
--ServerApp.keyfile=/etc/letsencrypt/privkey.pem
|
||||
|
||||
volumes:
|
||||
work:
|
||||
|
@@ -52,8 +52,8 @@ letsencrypt-notebook: DOCKER_ARGS:=-e USE_HTTPS=yes \
|
||||
-e PASSWORD=$(PASSWORD) \
|
||||
-v $(SECRETS_VOLUME):/etc/letsencrypt
|
||||
letsencrypt-notebook: ARGS:=\
|
||||
--NotebookApp.certfile=/etc/letsencrypt/fullchain.pem \
|
||||
--NotebookApp.keyfile=/etc/letsencrypt/privkey.pem
|
||||
--ServerApp.certfile=/etc/letsencrypt/fullchain.pem \
|
||||
--ServerApp.keyfile=/etc/letsencrypt/privkey.pem
|
||||
letsencrypt-notebook: check
|
||||
@test -n "$(PASSWORD)" || \
|
||||
(echo "ERROR: PASSWORD not defined or blank"; exit 1)
|
||||
|
@@ -38,7 +38,7 @@
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"jupyter_server_config.py": "import os\n\npassword = os.environ.get('JUPYTER_NOTEBOOK_PASSWORD')\n\nif password:\n import notebook.auth\n c.NotebookApp.password = notebook.auth.passwd(password)\n del password\n del os.environ['JUPYTER_NOTEBOOK_PASSWORD']\n\nimage_config_file = '/home/jovyan/.jupyter/jupyter_server_config.py'\n\nif os.path.exists(image_config_file):\n with open(image_config_file) as fp:\n exec(compile(fp.read(), image_config_file, 'exec'), globals())\n"
|
||||
"jupyter_server_config.py": "import os\n\npassword = os.environ.get('JUPYTER_NOTEBOOK_PASSWORD')\n\nif password:\n from jupyter_server.auth import passwd\n c.ServerApp.password = passwd(password)\n del password\n del os.environ['JUPYTER_NOTEBOOK_PASSWORD']\n\nimage_config_file = '/home/jovyan/.jupyter/jupyter_server_config.py'\n\nif os.path.exists(image_config_file):\n with open(image_config_file) as fp:\n exec(compile(fp.read(), image_config_file, 'exec'), globals())\n"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@@ -221,7 +221,7 @@
|
||||
}
|
||||
},
|
||||
"data": {
|
||||
"jupyter_server_config.py": "import os\n\npassword = os.environ.get('JUPYTER_NOTEBOOK_PASSWORD')\n\nif password:\n import notebook.auth\n c.NotebookApp.password = notebook.auth.passwd(password)\n del password\n del os.environ['JUPYTER_NOTEBOOK_PASSWORD']\n\nimage_config_file = '/home/jovyan/.jupyter/jupyter_server_config.py'\n\nif os.path.exists(image_config_file):\n with open(image_config_file) as fp:\n exec(compile(fp.read(), image_config_file, 'exec'), globals())\n"
|
||||
"jupyter_server_config.py": "import os\n\npassword = os.environ.get('JUPYTER_NOTEBOOK_PASSWORD')\n\nif password:\n from jupyter_server.auth import passwd\n c.ServerApp.password = passwd(password)\n del password\n del os.environ['JUPYTER_NOTEBOOK_PASSWORD']\n\nimage_config_file = '/home/jovyan/.jupyter/jupyter_server_config.py'\n\nif os.path.exists(image_config_file):\n with open(image_config_file) as fp:\n exec(compile(fp.read(), image_config_file, 'exec'), globals())\n"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@@ -16,7 +16,7 @@ def test_cli_args(container: TrackedContainer, http_client: requests.Session) ->
|
||||
(e.g., disabling token security)"""
|
||||
host_port = find_free_port()
|
||||
running_container = container.run_detached(
|
||||
command=["start-notebook.sh", "--NotebookApp.token=''"],
|
||||
command=["start-notebook.sh", "--IdentityProvider.token=''"],
|
||||
ports={"8888/tcp": host_port},
|
||||
)
|
||||
resp = http_client.get(f"http://localhost:{host_port}")
|
||||
@@ -103,7 +103,7 @@ def test_custom_internal_port(
|
||||
host_port = find_free_port()
|
||||
internal_port = env.get("JUPYTER_PORT", 8888)
|
||||
running_container = container.run_detached(
|
||||
command=["start-notebook.sh", "--NotebookApp.token=''"],
|
||||
command=["start-notebook.sh", "--IdentityProvider.token=''"],
|
||||
environment=env,
|
||||
ports={internal_port: host_port},
|
||||
)
|
||||
|
@@ -22,23 +22,23 @@ LOGGER = logging.getLogger(__name__)
|
||||
(["RESTARTABLE=yes"], None, None),
|
||||
(["JUPYTER_PORT=8171"], None, None),
|
||||
(["JUPYTER_PORT=8117", "DOCKER_STACKS_JUPYTER_CMD=notebook"], None, None),
|
||||
(None, ["start-notebook.sh", "--NotebookApp.base_url=/test"], None),
|
||||
(None, ["start-notebook.sh", "--NotebookApp.base_url=/test/"], None),
|
||||
(["GEN_CERT=1"], ["start-notebook.sh", "--NotebookApp.base_url=/test"], None),
|
||||
(None, ["start-notebook.sh", "--ServerApp.base_url=/test"], None),
|
||||
(None, ["start-notebook.sh", "--ServerApp.base_url=/test/"], None),
|
||||
(["GEN_CERT=1"], ["start-notebook.sh", "--ServerApp.base_url=/test"], None),
|
||||
(
|
||||
["GEN_CERT=1", "JUPYTER_PORT=7891"],
|
||||
["start-notebook.sh", "--NotebookApp.base_url=/test"],
|
||||
["start-notebook.sh", "--ServerApp.base_url=/test"],
|
||||
None,
|
||||
),
|
||||
(["NB_USER=testuser", "CHOWN_HOME=1"], None, "root"),
|
||||
(
|
||||
["NB_USER=testuser", "CHOWN_HOME=1"],
|
||||
["start-notebook.sh", "--NotebookApp.base_url=/test"],
|
||||
["start-notebook.sh", "--ServerApp.base_url=/test"],
|
||||
"root",
|
||||
),
|
||||
(
|
||||
["NB_USER=testuser", "CHOWN_HOME=1", "JUPYTER_PORT=8123"],
|
||||
["start-notebook.sh", "--NotebookApp.base_url=/test"],
|
||||
["start-notebook.sh", "--ServerApp.base_url=/test"],
|
||||
"root",
|
||||
),
|
||||
],
|
||||
@@ -75,12 +75,12 @@ def test_health(
|
||||
(["NB_USER=testuser", "CHOWN_HOME=1"], None, None),
|
||||
(
|
||||
["NB_USER=testuser", "CHOWN_HOME=1"],
|
||||
["start-notebook.sh", "--NotebookApp.base_url=/test"],
|
||||
["start-notebook.sh", "--ServerApp.base_url=/test"],
|
||||
None,
|
||||
),
|
||||
(
|
||||
["NB_USER=testuser", "CHOWN_HOME=1", "JUPYTER_PORT=8123"],
|
||||
["start-notebook.sh", "--NotebookApp.base_url=/test"],
|
||||
["start-notebook.sh", "--ServerApp.base_url=/test"],
|
||||
None,
|
||||
),
|
||||
],
|
||||
|
@@ -45,7 +45,6 @@ def test_start_notebook(
|
||||
running_container = container.run_detached(
|
||||
tty=True,
|
||||
environment=env,
|
||||
command=["start-notebook.sh"],
|
||||
ports={"8888/tcp": host_port},
|
||||
)
|
||||
# sleeping some time to let the server start
|
||||
|
@@ -18,11 +18,8 @@ def check_pluto_proxy(
|
||||
token = secrets.token_hex()
|
||||
container.run_detached(
|
||||
command=[
|
||||
"start.sh",
|
||||
"jupyter",
|
||||
"lab",
|
||||
"--port=8888",
|
||||
f"--LabApp.token={token}",
|
||||
"start-notebook.sh",
|
||||
f"--IdentityProvider.token={token}",
|
||||
],
|
||||
ports={"8888/tcp": host_port},
|
||||
)
|
||||
|
Reference in New Issue
Block a user