Vultr DocsLatest Content

How to Deploy code-server For VS Code on Ubuntu 24.04

Updated on 05 December, 2025
Deploy code-server on Ubuntu 24.04 using Docker Compose, secure it with HTTPS via Traefik reverse proxy, and access full VS Code experience in a browser.
How to Deploy code-server For VS Code on Ubuntu 24.04 header image

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:

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.

  1. Create project directories.

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

    The project subdirectory stores your editable workspace files, config stores code-server settings and extensions, local holds user-specific data, and letsencrypt stores Traefik's ACME certificates for TLS management.

  2. Navigate to the project's root directory.

    console
    $ cd ~/vscode-server
    
  3. Find the UID and GID of your user account.

    console
    $ id $USER
    

    From the output, note the uid and gid of the user account.

  4. Add your user to the Docker group to run Docker commands without sudo.

    console
    $ sudo usermod -aG docker $USER
    
  5. Create and edit a Docker Compose manifest file.

    console
    $ nano docker-compose.yml
    
  6. Add the Following contents to the file.

    yaml
    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"
         - "--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:GID with the UID and GID from step 3.
    • SECURE_PASSWORD with a strong password.
    • CODE.EXAMPLE.COM with your domain.
    • ADMIN@EXAMPLE.COM with your email for Let's Encrypt notifications.
    • LINUXUSER with 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-server image.
      • 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.
    • 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 ./letsencrypt directory.
      • 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.
  7. Start the services.

    console
    $ docker compose up -d
    
  8. Verify the service's status.

    console
    $ docker compose ps
    
    Note
    For more information on managing a Docker Compose stack, see the How To Use Docker Compose article.
  9. Access and verify your code-server installation.

    1. Open https://CODE.EXAMPLE.COM in a browser.
    2. Enter your password.

    You should see the code-server home page.

    VS code server

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.

Comments