
code-server enables you to run VS Code on a remote server and access it through a web browser from anywhere. code-server, the open-source implementation, offers the full VS Code experience, including extensions, an integrated terminal, Git integration, and IntelliSense support through a browser interface.
This article shows how to deploy code-server on Ubuntu 24.04 with Docker Compose and secure it using HTTPS with a Traefik reverse proxy.
Prerequisites
Before you begin:
- Have access to an Ubuntu 24.04 server with at least 1 GB RAM and 2 CPU cores.
- Configure a domain name pointing to your server's external IP address, such as
code.example.com. - Install Docker and Docker Compose on your server..
Install code-server
This section deploys code-server using a Docker Compose configuration that defines two services: a code-server container that provides the browser-based VS Code environment, and a Traefik container that acts as the reverse proxy. Traefik automatically provisions HTTPS certificates with Let’s Encrypt and routes incoming traffic to the code-server service.
Create project directories.
console$ mkdir -p ~/vscode-server/{project,config,local,letsencrypt}
The
projectsubdirectory stores your editable workspace files,configstores code-server settings and extensions,localholds user-specific data, andletsencryptstores Traefik's ACME certificates for TLS management.Navigate to the project's root directory.
console$ cd ~/vscode-server
Find the UID and GID of your user account.
console$ id $USER
From the output, note the
uidandgidof the user account.Add your user to the Docker group to run Docker commands without sudo.
console$ sudo usermod -aG docker $USER
Create and edit a Docker Compose manifest file.
console$ nano docker-compose.yml
Add the Following contents to the file.
yamlservices: 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" - "--certificatesresolvers.myresolver.acme.email=ADMIN@EXAMPLE.COM" # Replace with your email - "--certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json" networks: - internal restart: unless-stopped networks: internal:
Replace the following placeholder in the above manifest:
UID:GIDwith the UID and GID from step 3.SECURE_PASSWORDwith a strong password.CODE.EXAMPLE.COMwith your domain.ADMIN@EXAMPLE.COMwith your email for Let's Encrypt notifications.LINUXUSERwith your username.
Save and close the file. This Docker Compose file deploys code-server behind Traefik, which provides automatic HTTPS using Let’s Encrypt. Here’s what each part does:
code-server service
- Runs the
codercom/code-serverimage. - Uses your host user’s UID and GID to avoid permission issues.
- Stores your project files and configuration in local bind-mounted folders.
- Exposes port 8080 internally only.
- Includes Traefik labels to route traffic from your domain (
CODE.EXAMPLE.COM) to the code-server container over HTTPS.
- Runs the
traefik service
- Listens on ports 80 and 443.
- Automatically obtains TLS certificates using Let's Encrypt via the ACME HTTP-01 challenge.
- Reads Docker labels to discover and route traffic to the code-server container.
- Stores certificates in the
./letsencryptdirectory. - Forces all HTTP requests to redirect to HTTPS.
internal network
- A private Docker network used by both containers so Traefik can route traffic to code-server securely without exposing the internal port.
Start the services.
console$ docker compose up -d
Verify the service's status.
console$ docker compose ps
For more information on managing a Docker Compose stack, see the How To Use Docker Compose article.NoteAccess and verify your code-server installation.
- Open
https://CODE.EXAMPLE.COMin a browser. - Enter your password.
You should see the code-server home page.

- Open
Conclusion
By following this article, you successfully deployed code-server on Ubuntu 24.04 using Docker Compose and secured it with Traefik, providing a powerful cloud-based development environment accessible from any browser. For more information, refer to the code-server Documentation.