Skip to content

Docker guide

We use Docker through colima macOS backend. Config is handled via Docker Compose tool.

The following services are

  1. PostGIS (PostgreSQL) DB: port 5432
  2. PgAdmin (DB admin): port 5050
  3. Prometheus (metrics agg): port 9090
  4. Grafana (data viz): port 3000
  5. Loki (logs storage): port 3100
  6. Alloy (logs adapter sending them to Loki): ports 9999 (for apps hosted on host) + 12345 (for UI)

[!NOTE] All third-party Docker images are started and run on default port for coherence

Run the following command to get a clean and running Docker setup:

docker compose down
colima stop
colima start --network-address  # important to access services via host machine (= mac)
colima status | grep address
docker compose up -d
docker compose ps

The --network-address flag assigns a reachable IP address to the VM (macOS only).

[!WARNING] When two services need to communicate, you need to use the IP address provided by colima instead of localhost

[!WARNING] When a service needs to communicate with a public API exposed on host machine, use host.docker.internal DNS alias instead of localhost

[!NOTE] Loki is shutting down its Ingester when main volume (host storage) exceeds a threshold (90% of storage used)

When first imported, Loki logs are displayed as JSON body in Grafana. Here's the filtering Loki query (to be set in Grafana) to only display specific fields

{job="python-app"} |= `` | json | line_format "[{{.asctime}}] {{.levelname}} | {{.message}}"

Docs: https://grafana.com/docs/loki/latest/query/log_queries/