bitnami / containers

Bitnami container images
https://bitnami.com
Other
3.39k stars 4.85k forks source link

Bitnami mariadb mariadbbackup error #74027

Open devMls opened 2 days ago

devMls commented 2 days ago

Name and Version

mariadb-galera:10.6.10-debian-11-r10

What architecture are you using?

None

What steps will reproduce the bug?

I have a mariadb on docker swarm with portainer deployed. I use a mariadb bitnami solution

my docker compose file:

version: "3.7"
services:
  mariadb:
    image: bitnami/mariadb-galera:10.6.10-debian-11-r10
    ports:
      - "3307:3306"    
    hostname: mariadb
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_PASSWORD=password!!
      - MARIADB_ROOT_PASSWORD=password!!
      - MARIADB_USER=mariaUser
    networks:
      - network_general_internal    
    volumes:
      - mariadb_data:/bitnami/mariadb
      - mariadb_socket:/opt/bitnami/mariadb/tmp
    configs:
      - source: mariadb_config
        target: /opt/bitnami/mariadb/conf/my_custom.cnf
    deploy:
      mode: replicated
      replicas: 1    
      placement:
         constraints:  [node.labels.node==node1] 
    healthcheck:
      test: ['CMD', '/opt/bitnami/scripts/mariadb-galera/healthcheck.sh']
      interval: 15s
      timeout: 5s
      retries: 6
  backup:
    image: bitnami/mariadb-galera:10.6.10-debian-11-r10
    hostname: mariadbBackup    
    environment:
      - ALLOW_EMPTY_PASSWORD=yes
      - MARIADB_PASSWORD=password!!
      - MARIADB_ROOT_PASSWORD=password!!
      - MARIADB_USER=mariaUser    
      - MARIADB_INIT_SLEEP_TIME=20
    command: bash -c "mariabackup --backup --target-dir=/opt/bitnami/backups/ --user=mariabackup --password=mariabackup"
    depends_on:
      - mariadb
    volumes:
      - mariadb_backup:/opt/bitnami/backups
      - mariadb_socket:/opt/bitnami/mariadb/tmp   
      - mariadb_data:/bitnami/mariadb

    deploy:
      labels:
        - "swarm.cronjob.enable=true"
        - "swarm.cronjob.schedule=57 15 * * *" #=0 2 * * SUN
        - "swarm.cronjob.skip-running=true"
      replicas: 0
      restart_policy:
        condition: none

volumes:
  mariadb_data:
    external: true
    name: mariadb_data
  mariadb_backup:
    external: true
    name: mariadb_backup    
  mariadb_socket:
    external: true
    name:  mariadb_socket   
networks:
  network_general_internal  :
    name: network_general_internal  
    external: true
configs:
  mariadb_config:
    external: true 

the logs show an error, I try with different backup folders:

mariadb 14:57:01.02 Welcome to the Bitnami mariadb-galera container
mariadb 14:57:01.02 Subscribe to project updates by watching https://github.com/bitnami/containers
mariadb 14:57:01.02 Submit issues and feature requests at https://github.com/bitnami/containers/issues
mariadb 14:57:01.02 
[00] 2024-10-30 14:57:01 Connecting to MariaDB server host: localhost, user: mariabackup, password: set, port: 3306, socket: /opt/bitnami/mariadb/tmp/mysql.sock
[00] 2024-10-30 14:57:01 Using server version 10.6.10-MariaDB-log
[00] 2024-10-30 14:57:01 Warning: missing required privilege CONNECTION ADMIN on *.*
mariabackup based on MariaDB server 10.6.10-MariaDB Linux (x86_64)
[00] 2024-10-30 14:57:01 uses posix_fadvise().
[00] 2024-10-30 14:57:01 cd to /bitnami/mariadb/data/
[00] 2024-10-30 14:57:01 open files limit requested 0, set to 1048576
[00] 2024-10-30 14:57:01 mariabackup: using the following InnoDB configuration:
[00] 2024-10-30 14:57:01 innodb_data_home_dir = 
[00] 2024-10-30 14:57:01 innodb_data_file_path = ibdata1:12M:autoextend
[00] 2024-10-30 14:57:01 innodb_log_group_home_dir = ./
[00] 2024-10-30 14:57:01 InnoDB: Using Linux native AIO
2024-10-30 14:57:01 0 [Note] InnoDB: Number of pools: 1
mariabackup: Can't create file '/opt/bitnami/backups/ib_logfile0' **(errno: 13 "Permission denied")**
[00] 2024-10-30 14:57:01 Error: failed to open the target stream for 'ib_logfile0'.

If I run the command from the terminal inside container mariadb all goes right

What is the expected behavior?

backup creation

What do you see instead?

mariabackup: Can't create file '/opt/bitnami/backups/ib_logfile0' **(errno: 13 "Permission denied")**
carrodher commented 2 days ago

Bitnami containers are designed to operate as non-root by default. Consequently, any files or directories used by the application should be owned by the root group, as the random user (1001 by default) is a member of this root group. To ensure proper permissions, you'll need to adjust the ownership of your local directory accordingly.

For more comprehensive information about non-root containers and their significance for security, you can explore the following resources:

These references provide valuable insights into the best practices and considerations when working with non-root containers in Bitnami applications.