A self-hosted VS Code Server instance with authentication via Traefik reverse proxy. This setup provides a web-based VS Code editor accessible through your browser with basic auth protection.
- Docker
- Docker Compose
- Git
vscode-server/
├── docker-compose.yml # Docker Compose configuration
├── .env.example # Environment variables template
├── vscode/ # VS Code Server Dockerfile
│ ├── Dockerfile
│ └── vscode.sources
├── traefik/ # Traefik configuration
│ └── usersfile # Basic auth credentials
├── data/ # VS Code Server data volume
└── README.md
Copy the example environment file and update it with your desired configuration:
cp .env.example .envEdit .env and set the PROJECTS_DIR to point to your local projects directory:
PROJECTS_DIR=/path/to/your/projects
To set up or change basic authentication credentials, edit the traefik/usersfile. You can generate credentials using:
htpasswd -c traefik/usersfile usernameOr use online tools to generate the format: username:hashed_password
docker compose up -dThis will:
- Build and start the VS Code Server container
- Start the Traefik reverse proxy
- Create a bridge network connecting both services
docker compose downdocker compose logs -fOnce running, access VS Code Server at:
http://localhost:8080
You will be prompted for basic authentication credentials (configured in traefik/usersfile).
/home/vscode/data- Mounted to./data/on the host (VS Code configuration and extensions)/home/vscode/projects- Mounted to the directory specified inPROJECTS_DIRenvironment variable
- Container name:
vscode-server - Network:
web - Port: Exposed via Traefik on port 8080
- Container name:
vscode-traefik - Image:
traefik:v2.10 - Port:
8080:8080(HTTP access) - Authentication: Basic auth using
traefik/usersfile
| Variable | Description | Example |
|---|---|---|
PROJECTS_DIR |
Path to local projects directory | /home/user/projects |