Jump to content

Help with dockerized database

Go to solution Solved by leartonmai,

For anyone who has this problem I figured out a solution. I passed through root user and password in the fstab entry for the database.

Hello. I am kinda new to linux and docker. I am trying to have a dockerized central database for all of the docker apps to connect to. I was following Wendell's guide to set-up a truenas server and docker host. I noticed a lot of the docker apps I want to run also spin up a database for that app separately. I wanted to make a couple of centralized databases that all the apps can use. For some additional context, I decided to run the services on 2 separate machines instead of running a VM. One machine running TrueNAS Scale on bare metal and the other running Ubuntu Server on bare metal. I had quite a few issues with the guide one of them being Debian and the other NFS so I swapped to cifs for the share using this video.  I made a Portainer stack with MariaDB, Postgres, Redis, and Adminer.  I'm still running into issues with permissions. I can write and read to the share from multiple computers and portainer, homarr, redis, and adminer work. Mariadb and Postgres don't work though. I'm getting this error from Postgres.

initdb: error: could not change permissions of directory "/var/lib/postgresql/data": Operation not permitted
fixing permissions on existing directory /var/lib/postgresql/data ... 

This is the error I'm getting from MariaDB.

023-06-20 23:56:39+00:00 [Note] [Entrypoint]: Initializing database files
2023-06-20 23:56:39 0 [ERROR] InnoDB: The Auto-extending data file './ibdata1' is of a different size 0 pages than specified by innodb_data_file_path
2023-06-20 23:56:39 0 [ERROR] InnoDB: Plugin initialization aborted with error Generic error
2023-06-20 23:56:39 0 [ERROR] Plugin 'InnoDB' init function returned error.
2023-06-20 23:56:39 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2023-06-20 23:56:39 0 [ERROR] Unknown/unsupported storage engine: InnoDB
2023-06-20 23:56:39 0 [ERROR] Aborting
Installation of system tables failed!  Examine the logs in
/var/lib/mysql/ for more information.

I've been on a couple discords trying to get some help but nothing has worked.  This is the portainer stack I made just to double check I didn't mess up.

version: "3"
services: 
  db-mariadb:
    image: mariadb
    container_name: mariadb
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    environment:
      MARIADB_USER: xxxxxx
      MARIADB_PASSWORD: xxxxxx
      MARIADB_ROOT_PASSWORD: xxxxxx
      MARIADB_DATABASE: xxxxxx
    ports:
      - "3306:3306"
    volumes:
      - /mnt/xxxxxx/xxxxxx/database/MariaDB:/var/lib/mysql:rw
    networks:
      - mysql

  db-postgresdb:
    image: postgres
    container_name: postgres
    command: --transaction-isolation=READ-COMMITTED --binlog-format=ROW
    environment:
      POSTGRES_USER: xxxxxx
      POSTGRES_PASSWORD: xxxxxx
      POSTGRES_DB: xxxxxx
    ports:
      - "5432:5432"
    volumes:
      - /mnt/xxxxxx/xxxxxx/database/PostgresDB:/var/lib/postgresql/data:rw
    networks:
      - mysql
      
  db-redisdb:
    image: redis
    container_name: redis
    restart: always
    command: redis-server --save 20 1 --loglevel warning --requirepass xxxxxx
    ports:
      - "6379:6379"
    volumes:
      - /mnt/xxxxxx/xxxxxx/database/RedisDB:/data:rw
    networks:
      - mysql
      
  db-adminerdb:
    container_name: adminer
    image: adminer
    restart: always
    ports:
      - "8080:8080"
    networks:
      - mysql

networks:
  mysql:
    external: true

This is the fstab entry.

//xxx.xxx.xxx.xxx/xxxxxx/xxxxxx/xxxxxx  /xxxxxx/xxxxxx/xxxxxx  cifs  vers=2.0,username=xxxxxx,password=xxxxxx,file_mode=0777,dir_mode=0777 0 0

I've been at this for a couple days trying to figure out what I did wrong. I have reinstalled and started from scratch about 9 times.  I have tried to change the permissions of the directory with chown and chmod.  I'm not really sure what else to do. Let me know what else to add if needed. Thanks for your help and time. Have a good day. 

Link to comment
https://linustechtips.com/topic/1514525-help-with-dockerized-database/
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×