"Data Persistence Issues in Metabase with PostgreSQL on Docker Compose: Losing Data After Restart

Good morning,

I am running the latest version of Metabase on Java 11 using Docker Compose, with PostgreSQL as the database. The logs confirm a successful connection to the PostgreSQL database: "Successfully verified PostgreSQL 17.0 (Debian 17.0-1.pgdg120+1) application database connection."

However, in the Metabase admin panel, I still see the sample H2 database, which I haven't removed. Each time I restart the Docker Compose setup, my login credentials and the titles of previously inserted CVs are retained, but all data and dashboards are lost.

I have configured PostgreSQL to persist within Docker Compose, and the Metabase environment variables are set to use PostgreSQL. Additionally, there is no metabase.db file present.

Could you please advise on how to resolve this issue?

Thank you in advance.

{
"browser-info": {
"language": "it-IT",
"platform": "Win32",
"userAgent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36",
"vendor": "Google Inc."
},
"metabase-info": {
"databases": [
"h2",
"postgres"
],
"run-mode": "prod",
"plan-alias": "",
"version": {
"date": "2024-09-24",
"tag": "v0.50.27",
"hash": "8b9a8fc"
},
"settings": {
"report-timezone": null
},
"hosting-env": "unknown",
"application-database": "postgres",
"application-database-details": {
"database": {
"name": "PostgreSQL",
"version": "17.0 (Debian 17.0-1.pgdg120+1)"
},
"jdbc-driver": {
"name": "PostgreSQL JDBC Driver",
"version": "42.7.3"
}
}
},
"system-info": {
"file.encoding": "UTF-8",
"java.runtime.name": "OpenJDK Runtime Environment",
"java.runtime.version": "11.0.24+8",
"java.vendor": "Eclipse Adoptium",
"java.vendor.url": "https://adoptium.net/",
"java.version": "11.0.24",
"java.vm.name": "OpenJDK 64-Bit Server VM",
"java.vm.version": "11.0.24+8",
"os.name": "Linux",
"os.version": "5.15.153.1-microsoft-standard-WSL2",
"user.language": "en",
"user.timezone": "GMT"
}
}

Containers are ephemeral, unless you pierce them and persist some files in external volumes.

What's happening here is that the Metabase container is losing the h2 files, but the postgres db is actually being retained.

I would strongly suggest you check how containers work and also check How to run Metabase in production

Thank you for your reply. At the end I performed the migration but to solve I kind removed from the Metabase admin panel the H2 database.

I don't know if it was the right approach. But not being present at container level enymore I didn't find any another solution.

Thank you