Connect Metabase to database of choice by default using docker compose
I have the following docker-compose.yml
file
networks:
default:
driver: bridge
services:
timescale:
image: timescale/timescaledb:latest-pg15
ports:
- "5432:5432"
environment:
POSTGRES_USER: timescaledb
POSTGRES_PASSWORD: pass123
volumes:
- ./timescaledb-data:/var/lib/postgresql/data
metabase_admin_mysql:
image: mysql:latest
restart: always
environment:
MYSQL_ROOT_PASSWORD: your_root_password
MYSQL_DATABASE: metabase
MYSQL_USER: metabase_user
MYSQL_PASSWORD: metabase_password
healthcheck:
test: ["CMD", "mysqladmin", "ping", "-umetabase_user", "-pmetabase_password"]
interval: 10s
retries: 30
metabase:
image: metabase/metabase:latest
restart: always
ports:
- "3001:3000" # Changed port mapping to 3001:3000
environment:
MB_DB_TYPE: mysql
MB_DB_DBNAME: metabase
MB_DB_PORT: 3306
MB_DB_USER: metabase_user
MB_DB_PASS: metabase_password
MB_DB_HOST: metabase_admin_mysql
MB_DB_TZ: UTC # Setting timezone
MB_DB_DBNAME_EXTRA: postgres
MB_DB_SERVER_EXTRA: timescale
MB_DB_PORT_EXTRA: 5432
MB_DB_USERNAME_EXTRA: timescaledb
MB_DB_PASSWORD_EXTRA: pass123
depends_on:
metabase_admin_mysql:
condition: service_healthy
What i am attempting to do?
I am trying to spin up a metabase
service which connects to mysql for admin related data and timescaledb
for analytics purpose my default.
What happens right now?
When i run docker compose up
the service spins up fine. I can see Metabase
spin up fine and i can see that it is connected to mysql for admin related data. However i manually have to add the timescaledb
and i am wondering if there is a way to have it connect to timescaledb
by default?
I could not find any documents on Metabase
page and looked around everywhere. I am wondering is this even possible?
I thought by adding the following block i would have success but i don't
MB_DB_DBNAME_EXTRA: postgres
MB_DB_SERVER_EXTRA: timescale
MB_DB_PORT_EXTRA: 5432
MB_DB_USERNAME_EXTRA: timescaledb
MB_DB_PASSWORD_EXTRA: pass123
I could not find anything in metabase documentation so i am starting to think this is not possible but just wondering if it is and if so how would i do it?
Answer
Seems like you need to add a dependency to the timescale container like the one you have to the mysql admin container. It's just a guess, but probably postgres is not ready when metabase tries to connect.