|
| 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`. |
0 commit comments