Cover image for Deploying code-server for VS Code on Ubuntu 24.04

Vultr profile image Sanskriti Harmukh

code-server is the open-source project that runs full VS Code including extensions, integrated terminal, Git, IntelliSense — on a remote server, accessible from any browser. This guide deploys it on Ubuntu 24.04 with Docker Compose, fronted by Traefik for automatic HTTPS.

Prerequisites: an Ubuntu 24.04 server (1GB RAM / 2 vCPU minimum), a domain A record (e.g. code.example.com), Docker and Docker Compose installed.


Set Up the Project

$ mkdir -p ~/vscode-server/{project,config,local,letsencrypt}
$ cd ~/vscode-server

Enter fullscreen mode Exit fullscreen mode

  • project — your editable workspace
  • config — code-server settings/extensions
  • local — user-specific data
  • letsencrypt — Traefik's ACME certificate storage

Find your UID/GID and add yourself to the docker group:

$ id $USER
$ sudo usermod -aG docker $USER

Enter fullscreen mode Exit fullscreen mode


Write the Compose File

$ nano docker-compose.yml

Enter fullscreen mode Exit fullscreen mode

services:
 code-server:
   image: codercom/code-server:latest
   container_name: code-server
   user: "UID:GID" # Replace with your user's UID and GID
   environment:
     - PASSWORD=SECURE_PASSWORD  # Replace with a strong password
     - DOCKER_USER=LINUXUSER  # Replace with your username
   volumes:
     - ./project:/home/coder/project
     - ./config:/home/coder/.config
     - ./local:/home/coder/.local
   networks:
     - internal
   restart: unless-stopped
   labels:
     - "traefik.enable=true"
     - "traefik.http.routers.code-server.rule=Host(`CODE.EXAMPLE.COM`)"  # Replace with your domain name
     - "traefik.http.routers.code-server.entrypoints=websecure"
     - "traefik.http.routers.code-server.tls.certresolver=myresolver"
     - "traefik.http.services.code-server.loadbalancer.server.port=8080"

 traefik:
   image: traefik:latest
   container_name: traefik
   ports:
     - "80:80"
     - "443:443"
   volumes:
     - /var/run/docker.sock:/var/run/docker.sock:ro
     - ./letsencrypt:/letsencrypt
   command:
     - "--providers.docker=true"
     - "--providers.docker.exposedbydefault=false"
     - "--providers.docker.network=internal"
     - "--entrypoints.web.address=:80"
     - "--entrypoints.websecure.address=:443"
     - "--entrypoints.web.http.redirections.entrypoint.to=websecure"
     - "--entrypoints.web.http.redirections.entrypoint.scheme=https"
     - "--certificatesresolvers.myresolver.acme.httpchallenge=true"
     - "--certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web"
     - "[email protected]"  # Replace with your email
     - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json"
   networks:
     - internal
   restart: unless-stopped

networks:
 internal:

Enter fullscreen mode Exit fullscreen mode

Replace UID:GID, SECURE_PASSWORD, CODE.EXAMPLE.COM, [email protected], and LINUXUSER with your actual values.

What's happening:

  • code-server runs as your host UID/GID (avoids bind-mount permission issues), keeps port 8080 internal-only, and carries Traefik labels routing your domain to it over HTTPS.
  • traefik listens on 80/443, gets certs via the ACME HTTP-01 challenge, discovers code-server through Docker labels, and force-redirects HTTP to HTTPS.
  • internal network — a private Docker network so Traefik can reach code-server without exposing its port to the host.

Start It

$ docker compose up -d
$ docker compose ps

Enter fullscreen mode Exit fullscreen mode

Visit https://code.example.com, enter your password — you should land on the code-server home page.


Next Steps

code-server is running with automatic HTTPS via Traefik. From here:

  • Install VS Code extensions directly from within the browser UI — they persist in the config volume
  • Mount additional project directories as needed for multiple workspaces
  • Put code-server behind an auth proxy (e.g. Authelia) if you want SSO instead of the single shared password

For the full guide, visit the original article on Vultr Docs.