How to Install code-server (VS Code in the Browser, on Your Server)

Editing a compose file in nano is fine. Editing twelve of them, a Hugo site and a backup script is nicer in VS Code — and code-server is VS Code running on the server, in a browser tab, with the server's files, the server's terminal and your extensions. Open it from the laptop, the iPad, or a locked-down work machine, and you're editing the real thing with syntax highlighting, search across files and git.
Quick reference
| Task | What |
|---|---|
| Folder | ~/docker/code-server/compose.yaml |
| Web | http://server-ip:8443 |
| Password | PASSWORD in the environment, or HASHED_PASSWORD |
| Your files | mount ~/docker, ~/sites, ~/code into /workspace |
| Extensions | the Open VSX marketplace inside the editor |
| sudo | SUDO_PASSWORD if the terminal needs it |
1. The compose file
mkdir -p ~/docker/code-server/config && cd ~/docker/code-server
nano compose.yaml
services:
code-server:
image: lscr.io/linuxserver/code-server:latest
container_name: code-server
ports:
- "127.0.0.1:8443:8443"
environment:
PUID: 1000
PGID: 1000
TZ: Europe/London
PASSWORD: ${CODE_PASSWORD}
SUDO_PASSWORD: ${CODE_SUDO_PASSWORD}
DEFAULT_WORKSPACE: /workspace
volumes:
- ./config:/config
- /home/john/docker:/workspace/docker
- /home/john/sites:/workspace/sites
- /home/john/code:/workspace/code
restart: unless-stopped
Bound to localhost — reach it through the reverse proxy with HTTPS (VS Code's web build needs a secure context for some features) or an SSH tunnel (tutorial 62). PUID 1000 means files you save are owned by you.
docker compose up -d
2. Reverse proxy
code.example.com → 127.0.0.1:8443 with the WebSocket lines (tutorial 28) and HTTPS. Open it, enter the password. Behind Authelia (95) or VPN-only is the right place for something that can run commands as you.
3. First look
The left sidebar shows /workspace with your docker, sites and code folders. Open docker/nextcloud/compose.yaml: YAML highlighting, and the problems panel flags indentation mistakes before Docker does. Ctrl + Shift + F searches every file — "which compose file has port 8080?" answered instantly. *Ctrl + * opens a terminal on the server: docker compose up -d` right there.
4. Extensions
The marketplace is Open VSX (Microsoft's store isn't licensed for third-party builds); most things you want are there: YAML, Docker, GitLens, Python, Prettier, Markdown All in One, a theme. Settings sync between devices because it's one install.
5. Git
Your Gitea (tutorial 45) repos work as usual. Mount ~/.ssh read-only (- /home/john/.ssh:/config/.ssh:ro) so pushes use your key, or use HTTPS with a token. The Source Control view, diffs and blame are all there.
6. Docker from inside
To run docker compose from code-server's terminal, mount the socket (- /var/run/docker.sock:/var/run/docker.sock) and install the CLI in the container with a custom script, or simply use the terminal to ssh localhost. The socket route is convenient; remember it's root-equivalent, which is why the password and proxy matter.
Alternatives
- VS Code Remote-SSH from a desktop VS Code: same editing experience, nothing to host, but it needs a desktop. code-server is for the devices that don't have one.
- Gitea's built-in editor for quick single-file changes.
- Cockpit's terminal (tutorial 82) for a shell on a phone.
Troubleshooting
Blank page or "service worker" errors. Not HTTPS. Use the proxy with a certificate, or the SSH tunnel to localhost (which browsers treat as secure).
Can't save a file: permission denied. The file is owned by root (/etc things) — mount them read-only and edit with sudo in the terminal, or chown your own folders.
Extension missing from the marketplace. Download the .vsix from the publisher and Extensions → … → Install from VSIX.
Terminal has no docker command. It's a separate container; see step 6.
Wrapping up
One container with your folders mounted, HTTPS through the proxy, a password. VS Code with the server's own files and terminal in any browser — compose files with a linter, project-wide search, git, and the iPad finally useful for server work.
