Skip to content

Commit c8fd70b

Browse files
committed
Move the jupyter server startup to a background process
1 parent 156e714 commit c8fd70b

File tree

4 files changed

+42
-6
lines changed

4 files changed

+42
-6
lines changed

.devcontainer/Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ RUN apt-get update && \
88
git \
99
make \
1010
curl \
11+
procps \
1112
&& rm -rf /var/lib/apt/lists/*
1213

1314
# Create non-root vscode user with sudo

.devcontainer/devcontainer.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
"dockerFile": "Dockerfile",
44
"workspaceFolder": "/workspaces/dev-container-templates",
55
"forwardPorts": [
6-
8080,
76
8888
87
],
98
"postCreateCommand": ".devcontainer/setup.sh",
10-
"postStartCommand": "uv run jupyter lab --ip=0.0.0.0 --port=8888 --no-browser --NotebookApp.token='' --NotebookApp.password=''",
9+
"postStartCommand": ".devcontainer/start.sh",
1110
"remoteUser": "vscode",
1211
"customizations": {
1312
"vscode": {

.devcontainer/start.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
LOG_FILE="/tmp/jupyter.log"
5+
6+
nohup uv run jupyter lab \
7+
--ip=0.0.0.0 \
8+
--port=8888 \
9+
--no-browser \
10+
--NotebookApp.token='' \
11+
--NotebookApp.password='' \
12+
> "$LOG_FILE" 2>&1 &
13+
14+
PID=$!
15+
echo "[$(date)] Jupyter Lab started with PID $PID" | tee -a "$LOG_FILE"

README.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
12
# Jupyter Notebook Dev Container Template
23

34
A ready-to-use [VS Code Dev Container](https://code.visualstudio.com/docs/devcontainers/containers) template for Python + Jupyter development.
@@ -17,10 +18,10 @@ Includes JupyterLab, classic Notebook, and common data science libraries (NumPy,
1718

1819
1. **Clone this repository**
1920

20-
```bash
21-
git clone <repository-url>
22-
cd dev-container-templates
23-
````
21+
```bash
22+
git clone <repository-url>
23+
cd dev-container-templates
24+
````
2425

2526
2. **Open in VS Code**
2627

@@ -50,6 +51,25 @@ cd dev-container-templates
5051

5152
---
5253

54+
## Connecting to Jupyter
55+
56+
The container automatically runs JupyterLab on **port 8888** with no token or password.
57+
58+
### Option A: Open Jupyter in your host browser
59+
60+
1. After the container starts, VS Code will forward port **8888** to your host.
61+
2. Open [http://localhost:8888](http://localhost:8888) in your browser.
62+
3. You should see JupyterLab running inside the dev container.
63+
64+
### Option B: Use Jupyter directly inside VS Code
65+
66+
1. Install the **Jupyter** extension (already included in `.devcontainer/devcontainer.json`).
67+
2. Open any `.ipynb` notebook file in VS Code.
68+
3. When prompted, select the **Python kernel** provided by the container (`.venv`).
69+
4. Run cells inline with `Shift+Enter` or the play button.
70+
71+
---
72+
5373
## Dev Container Features
5474

5575
* **Python 3.12** with isolated `.venv` created by **uv**
@@ -76,3 +96,4 @@ cd dev-container-templates
7696
## License
7797

7898
This project is licensed under the MIT License — see the [LICENSE](LICENSE) file for details.
99+

0 commit comments

Comments
 (0)