DEV Community

Hasan Ali
Hasan Ali

Posted on

Run TimescaleDB with Docker in Minutes

Time-series data needs a database that’s fast, reliable, and production-ready.

That’s exactly what TimescaleDB (built on PostgreSQL) is great at 🐘⚡

In this post, we’ll spin up a TimescaleDB container using a clean Bash script.


🎯 Goal

  • 🐳 Run TimescaleDB in Docker
  • 🌐 Attach it to an existing Docker network (app-net)
  • 💾 Persist data using volumes
  • 🔁 Make restarts predictable

🧾 Bash Script


bash
#!/usr/bin/env bash
set -euo pipefail

DB="postgres"
USER="admin"
PASSWORD="PASSWORD"

CONTAINER="timescaledb"
IMAGE="timescale/timescaledb:2.24.0-pg18"

docker run -d \
  --name "$CONTAINER" \
  --network app-net \
  -e POSTGRES_PASSWORD="$PASSWORD" \
  -e POSTGRES_USER="$USER" \
  -e POSTGRES_DB="$DB" \
  -v timescale_data:/var/lib/postgresql/data \
  "$IMAGE"

echo "TimescaleDB is up 🚀 (image: $IMAGE)"
Enter fullscreen mode Exit fullscreen mode

Top comments (0)