Skip to content

Commit 10e14b4

Browse files
committed
docs for code-server
1 parent 74fb061 commit 10e14b4

File tree

4 files changed

+155
-0
lines changed

4 files changed

+155
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
# code-server start
2+
3+
## Description
4+
5+
The `start` sub-command under the `tools code-server` command launches a dedicated [code-server](https://github.com/coder/code-server) container that is pre-configured with the VSCode Containerlab extension. The container exposes a VS Code compatible web UI in your browser and mounts both the host lab directory and user home so you can browse, edit, and run labs.
6+
7+
On first start the command creates persistent directories under `~/.clab/code-server/<name>/` for configuration, extensions, and user data. It also seeds the extensions directory with the pre-baked extensions that ship in the container image and writes a default configuration (`password: clab`).
8+
9+
## Usage
10+
11+
```
12+
containerlab tools code-server start [flags]
13+
```
14+
15+
## Flags
16+
17+
### --image | -i
18+
19+
Container image to use for the code-server instance. Defaults to `ghcr.io/kaelemc/clab-code-server:main`.
20+
21+
### --name | -n
22+
23+
Container name to create. Defaults to `clab-code-server`.
24+
25+
### --labs-dir | -l
26+
27+
Host directory that will be mounted inside the container at `/labs`. Defaults to `~/.clab` when not provided.
28+
29+
### --port | -p
30+
31+
Host TCP port that will be forwarded to the container's port `8080`. Defaults to `0`, which lets the container runtime pick a random available port.
32+
33+
### --owner | -o
34+
35+
Label value stored on the container to record the creator/owner. If omitted, Containerlab derives the value from `SUDO_USER` or `USER`.
36+
37+
## Examples
38+
39+
Start with default settings and let Docker assign a random host port:
40+
41+
```bash
42+
❯ containerlab tools code-server start
43+
16:41:50 INFO Pulling image ghcr.io/kaelemc/clab-code-server:main...
44+
16:41:50 INFO Pulling image image=ghcr.io/kaelemc/clab-code-server:main
45+
main: Pulling from kaelemc/clab-code-server
46+
Digest: sha256:5d3b80127db6f74b556f1df1ad8c339f8bbd9694616e8325ea7e9b9fe6065fe9
47+
Status: Image is up to date for ghcr.io/kaelemc/clab-code-server:main
48+
16:41:50 INFO Done pulling image image=ghcr.io/kaelemc/clab-code-server:main
49+
16:41:50 INFO Creating code server container name=clab-code-server
50+
16:41:50 INFO Creating container name=clab-code-server
51+
16:41:50 INFO code-server container clab-code-server started successfully.
52+
16:41:50 INFO code-server available at: http://0.0.0.0:32779
53+
```
54+
55+
Expose the service on a specific host port with a custom labs directory:
56+
57+
```bash
58+
❯ containerlab tools code-server start --port 10080 --labs-dir /srv/containerlab/labs
59+
...[snip]...
60+
INFO code-server container clab-code-server started successfully.
61+
INFO code-server available at: http://0.0.0.0:10080
62+
```
63+
64+
After the container starts you can browse to the reported URL and log in with username `clab` / password `clab`.
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# code-server status
2+
3+
## Description
4+
5+
The `status` sub-command under the `tools code-server` command inspects the active code-server containers that were launched via `containerlab`. It reports each container's runtime state, exposed port, mounted labs directory, and owner label so that you can quickly find connection details or verify cleanup.
6+
7+
## Usage
8+
9+
```
10+
containerlab tools code-server status [flags]
11+
```
12+
13+
## Flags
14+
15+
### --format | -f
16+
17+
Output format for the listing. Accepts `table` (default) or `json`.
18+
19+
## Examples
20+
21+
List all running code-server containers in table form:
22+
23+
```bash
24+
❯ containerlab tools code-server status
25+
╭──────────────────┬─────────┬───────┬──────────┬───────╮
26+
│ NAME │ STATUS │ PORT │ LABS DIR │ OWNER │
27+
├──────────────────┼─────────┼───────┼──────────┼───────┤
28+
│ clab-code-server │ running │ 32779 │ ~/.clab │ clab │
29+
╰──────────────────┴─────────┴───────┴──────────┴───────╯
30+
```
31+
32+
Show the same information in JSON format (useful for scripting):
33+
34+
```bash
35+
❯ containerlab tools code-server status --format json
36+
[
37+
{
38+
"name": "clab-code-server",
39+
"state": "running",
40+
"host": "",
41+
"port": 32779,
42+
"labs_dir": "~/.clab",
43+
"owner": "clab"
44+
}
45+
]
46+
```
47+
48+
When no containers are active the command prints `No active code-server containers found` (or an empty JSON array when `--format json` is used).

docs/cmd/tools/code-server/stop.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# code-server stop
2+
3+
## Description
4+
5+
The `stop` sub-command under the `tools code-server` command removes a running code-server container. Use it to tear down the VS Code web terminal once you are done editing lab files. The command deletes the container but leaves the persistent configuration, extension, and user-data directories on disk so that the next start is nearly instant.
6+
7+
## Usage
8+
9+
```
10+
containerlab tools code-server stop [flags]
11+
```
12+
13+
## Flags
14+
15+
### --name | -n
16+
17+
Name of the code-server container to remove. Defaults to `clab-code-server`.
18+
19+
## Examples
20+
21+
Stop the default helper container:
22+
23+
```bash
24+
❯ containerlab tools code-server stop
25+
16:42:13 INFO Removing code-server container name=clab-code-server
26+
16:42:13 INFO Removed container name=clab-code-server
27+
16:42:13 INFO code server container removed name=clab-code-server
28+
```
29+
30+
Target a specific container name:
31+
32+
```bash
33+
❯ containerlab tools code-server stop --name dev-code-server
34+
16:45:01 INFO Removing code-server container name=dev-code-server
35+
16:45:01 INFO Removed container name=dev-code-server
36+
16:45:01 INFO code server container removed name=dev-code-server
37+
```
38+
39+
If the named container is not found the command returns an error from the underlying runtime (for example `container "dev-code-server" not found`).

mkdocs.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ nav:
119119
- start: cmd/tools/api-server/start.md
120120
- stop: cmd/tools/api-server/stop.md
121121
- status: cmd/tools/api-server/status.md
122+
- code-server:
123+
- start: cmd/tools/code-server/start.md
124+
- stop: cmd/tools/code-server/stop.md
125+
- status: cmd/tools/code-server/status.md
122126
- sshx:
123127
- attach: cmd/tools/sshx/attach.md
124128
- detach: cmd/tools/sshx/detach.md

0 commit comments

Comments
 (0)