Linux Desktop inside a Container in the Browser

· 2 min read
Linux Desktop inside a Container in the Browser

Have you ever thought about running a Linux desktop inside of a container?LinuxServer.io introduced this concept of Webtop, which is a Lightweight Linux-based container with a Full Desktop Environment running in the Browser with A basic window manager, Pixel-perfect resolution for rendering, Audio support, Clipboard support, On-screen keyboard support, and remote file management for uploads/downloads.

Docker Setup

How to Install Docker and Docker Compose
Install Dockersudo apt-get update sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release -y curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg echo \ "deb [arch=$(dpkg --print-architecture) si…

Files and folders

mkdir webtop
cd webtop
mkdir config
cd ..
nano docker-compose.yml

We can spin up the webtop using either docker-compose.yml

docker-compose.yml

---
    version: "2.1"
    services:
      webtop:
        image: ghcr.io/linuxserver/webtop:ubuntu-mate #choose your flavor
        container_name: webtop
        privileged: true #optional but not needed unless you are running kde or i3 or other tools
        environment:
          - PUID=1000 # based on id
          - PGID=1000 # based on group
          - TZ=Europe/Sofia # your timezone
        volumes:
          - /home/user/webtop/config:/config #home directory
          - /var/run/docker.sock:/var/run/docker.sock #optional only if you need access to docker winthin this container
        ports:
          - 3000:3000
        shm_size: "2gb" #optional but set to 1GB or higher to prevent browser crashes
        restart: unless-stopped
        env_file:  #only necessary if you want to change the password, see .env file
          - .env

.env

PASSWORD=Y0RSecr3tP@ssw0rd!

Create Webtop container

docker-compose up -d

It will take some to spin up. After the container started running, go to the browser and type http://localhost:3000/ in URL
Now, you can see Linux desktop is running in your browser with full functionality.

Traefik Routes Config

http:
  routers:
    webtop:
      entryPoints:
        - "https"
      rule: "Host(`webtop.yourdomain.com`)"
      middlewares:
        - default-headers
      tls: {}
      service: webtop
  services:
    webtop:
      loadBalancer:
        servers:
          - url: "https://192.168.1.50:3000"
        passHostHeader: true
  middlewares:
    https-redirect:
      redirectScheme:
        scheme: https

    default-headers:
      headers:
        frameDeny: true
        sslRedirect: true
        browserXssFilter: true
        contentTypeNosniff: true
        forceSTSHeader: true
        stsIncludeSubdomains: true
        stsPreload: true
        stsSeconds: 15552000
        customFrameOptionsValue: SAMEORIGIN
        customRequestHeaders:
          X-Forwarded-Proto: https

    default-whitelist:
      ipWhiteList:
        sourceRange:
        - "10.0.0.0/8"
        - "192.168.0.0/16"
        - "172.16.0.0/12"

    secured:
      chain:
        middlewares:
        - default-whitelist
        - default-headers
docker-compose up -d --force-recreate

Now Webtop URL is https://webtop.yourdomain.com without port 3000