Loading page...Загружаем страницу...正在加载页面...
AtlasRepo

Self-Hosting a Dockerized App on WSL2, Exposed with a Cloudflare Tunnel

Описание и применение

Успешно развернули Docker‑приложение Node/Express с PostgreSQL внутри WSL2 и открыли его через Cloudflare Tunnel, используя реальный домен, без внешнего хостинга.

Задача

Deploy a small Node/Express to-do app with Postgres persistence on Windows using WSL2, Docker Engine, and expose it via a real domain without paying for hosting.

Результат

Successfully self-hosted a Dockerized Node/Express to-do app with Postgres inside WSL2 and exposed it at a real domain using a Cloudflare Tunnel, avoiding external hosting costs.

Рабочий процесс

  • Install WSL2 Ubuntu via wsl --install -d Ubuntu and restart Windows
  • Create Unix user in Ubuntu
  • Install Docker Engine inside Ubuntu with curl -fsSL https://get.docker.com | sudo sh and add user to docker group
  • Log out/in to apply group membership
  • Set up project: copy .env.example to .env and edit DB credentials
  • Choose deployment path: either bare Dockerfile with host Postgres or docker-compose with Postgres container and crond sidecar
  • If using docker-compose, run sudo docker compose up --build -d
  • Verify app on localhost:3000 with curl -i http://localhost:3000
  • Install cloudflared Windows binary and login: cloudflared.exe tunnel login
  • Create tunnel: cloudflared.exe tunnel create todo-docker-poc
  • Route DNS: cloudflared.exe tunnel route dns todo-docker-poc todo-list-docker.gerardoleon.dev
  • Configure tunnel in cloudflared/config.yml with tunnel ID
  • Run tunnel from WSL2: cloudflared.exe tunnel --config "C:\%PROJECT%\todo-docker\cloudflared\config.yml" run todo-docker-poc
  • Access app via domain

Доказательства

A proof-of-concept to-do app — Node/Express and Postgres, running in Docker on WSL2 — reachable at a real domain through a named cloudflared tunnel.

Источник

If you already have WSL2 and a Cloudflare-managed domain, expect this to take a few minutes, not hours.

Источник

  • Дата записи: 2026-09-21T11:15:41.266Z