Database not persistent

Hi!
I’ve got a problem with persistent data on a multi-container app on a revolution pi 3 (balenaOS 2.31.5+rev2):
On restarting the webmacs.mariadb container the database is deleted, even after following the docs https://www.balena.io/docs/learn/develop/runtime/
Do you have an idea what’s going wrong?

docker-compose file:
version: ‘2.1’

volumes:
  webmacs-data:

services:
#################################
# Setup webmacs.mysql container #
#################################
  webmacs.mariadb:
    container_name: webmacs.mariadb
    hostname: webmacs.mariadb
    image: webhippie/mariadb:latest
    ports:
      - 3306:3306
    volumes:
      - 'webmacs-data:/data'
    privileged: true
    build:
      context: ./webmacs.mysql
      dockerfile: Dockerfile
    environment:
      MYSQL_ROOT_PASSWORD: ####
      MYSQL_DATABASE: wirbelschicht_db
      MYSQL_USER: wirbelschicht
      MYSQL_PASSWORD: ####
      INSTALL_SAKILA: 1
      TZ: Europe/London

############################################
# Setup webmacs.phpmyadmin container #
############################################
  webmacs.phpmyadmin:
    container_name: webmacs.phpmyadmin
    hostname: webmacs.phpmyadmin
    image: jackgruber/phpmyadmin:armhf
    links:
      - webmacs.mariadb
    ports:
      - 80:80
    environment:
      PMA_HOST: webmacs.mariadb
      MYSQL_ROOT_PASSWORD: ####
    depends_on: 
      - webmacs.mariadb

Hi,

If I’m correct, the location of the mariadb data is located in /var/lib/mysql. You’ve created a volume named webmacs-data, and set it in your webmacs.mariadb container, but it’s linked to /data with the following row:

volumes:
  - 'webmacs-data:/data'

But because the data of mariadb is stored in /var/lib/mysql, you’ve to change it accordingly:

volumes:
  - 'webmacs-data:/var/lib/mysql'

Now the volume in the container is linked to /var/lib/mysql, and the data should be persistent :slight_smile:

Thank you for the answer! I tried it out but it still doesn’t work :sweat_smile:

Hi there,
have you already tried to take a look at this guide: https://hub.docker.com/r/bitnami/mariadb/ chapter Persisting your database ?

Solved the problem. The data directory for mariadb was set to /config/databases instead of /var/lib/mysql.

It works with /config/databases now, thanks for the help! :slightly_smiling_face: