linuxserver / docker-mariadb

GNU General Public License v3.0
212 stars 46 forks source link

[BUG] Volume mapping issue - user not created #142

Closed marioqqq closed 7 months ago

marioqqq commented 8 months ago

Is there an existing issue for this?

Current Behavior

I wanted to create dedicated DB for my services. So with help of docs I created .yaml file with few changes.

services:
  mariadb:
    container_name: mariadb
    image: lscr.io/linuxserver/mariadb:latest
    ports:
      - 3306:3306
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Bratislava
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=nextcloud
    volumes:
      - ./config:/config
    network_mode: bridge
    restart: unless-stopped

DB was created, user as well. Great! image But I run all my services in TrueNas Scale VM (Ubuntu image). So I wanted to isolate nextcloud DB. In volumes I added: - ./nextcloud:/config/databases/nextcloud NOTE - for testing I mapped it locally into VM

image DB was created, but user wasn't. What could cause it? It is highly possible, that I missed something or configured wrong.

Expected Behavior

User should be created as well

Steps To Reproduce

  1. Use .yaml file provided in Docker creation
  2. Run docker-compose up -d

Environment

- OS: Ubuntu server 22.04.1
- How docker service was installed: apt

CPU architecture

x86-64

Docker creation

services:
  mariadb:
    container_name: mariadb
    image: lscr.io/linuxserver/mariadb:latest
    ports:
      - 3306:3306
    environment:
      - PUID=1000
      - PGID=1000
      - TZ=Europe/Bratislava
      - MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
      - MYSQL_DATABASE=nextcloud
      - MYSQL_USER=nextcloud
      - MYSQL_PASSWORD=nextcloud
    volumes:
      - ./config:/config
      - ./nextcloud:/config/databases/nextcloud
    network_mode: bridge
    restart: unless-stopped

Container logs

[migrations] started
[migrations] no migrations found
───────────────────────────────────────
      ██╗     ███████╗██╗ ██████╗
      ██║     ██╔════╝██║██╔═══██╗
      ██║     ███████╗██║██║   ██║
      ██║     ╚════██║██║██║   ██║
      ███████╗███████║██║╚██████╔╝
      ╚══════╝╚══════╝╚═╝ ╚═════╝
   Brought to you by linuxserver.io
───────────────────────────────────────
To support LSIO projects visit:
https://www.linuxserver.io/donate/
───────────────────────────────────────
GID/UID
───────────────────────────────────────
User UID:    1000
User GID:    1000
───────────────────────────────────────
Setting Up Initial Databases
Installing MariaDB/MySQL system tables in '/config/databases' ...
2024-03-13 10:52:02 1 [Warning] Failed to load slave replication state from table mysql.gtid_slave_pos: 1017: Can't find file: './mysql/' (errno: 2 "No such file or directory")
OK
To start mariadbd at boot time you have to copy
support-files/mariadb.service to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB root USER !
To do so, start the server, then issue the following command:
'/usr/bin/mariadb-secure-installation'
which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.
See the MariaDB Knowledgebase at https://mariadb.com/kb
You can start the MariaDB daemon with:
cd '/usr' ; /usr/bin/mariadb-safe --datadir='/config/databases'
You can test the MariaDB daemon with mysql-test-run.pl
cd '/usr/mysql-test' ; perl mariadb-test-run.pl
Please report any problems at https://mariadb.org/jira
The latest information about MariaDB is available at https://mariadb.org/.
Consider joining MariaDB's strong and vibrant community:
https://mariadb.org/get-involved/
2024-03-13 10:52:17 0 [Note] Starting MariaDB 10.11.6-MariaDB-log source revision fecd78b83785d5ae96f2c6ff340375be803cd299 as process 190
2024-03-13 10:52:17 0 [Note] InnoDB: Compressed tables use zlib 1.3.1
2024-03-13 10:52:17 0 [Note] InnoDB: Number of transaction pools: 1
2024-03-13 10:52:17 0 [Note] InnoDB: Using generic crc32 instructions
2024-03-13 10:52:17 0 [Note] mariadbd: O_TMPFILE is not supported on /tmp (disabling future attempts)
2024-03-13 10:52:17 0 [Note] InnoDB: Using Linux native AIO
2024-03-13 10:52:17 0 [Note] InnoDB: Initializing buffer pool, total size = 256.000MiB, chunk size = 4.000MiB
2024-03-13 10:52:17 0 [Note] InnoDB: Completed initialization of buffer pool
2024-03-13 10:52:17 0 [Note] InnoDB: File system buffers for log disabled (block size=512 bytes)
2024-03-13 10:52:17 0 [Note] InnoDB: End of log at LSN=46846
2024-03-13 10:52:17 0 [Note] InnoDB: 128 rollback segments are active.
2024-03-13 10:52:17 0 [Note] InnoDB: Setting file './ibtmp1' size to 12.000MiB. Physically writing the file full; Please wait ...
2024-03-13 10:52:17 0 [Note] InnoDB: File './ibtmp1' size is now 12.000MiB.
2024-03-13 10:52:17 0 [Note] InnoDB: log sequence number 46846; transaction id 14
2024-03-13 10:52:17 0 [Note] Plugin 'FEEDBACK' is disabled.
2024-03-13 10:52:17 0 [Note] InnoDB: Loading buffer pool(s) from /config/databases/ib_buffer_pool
2024-03-13 10:52:17 0 [Note] InnoDB: Buffer pool(s) load completed at 240313 10:52:17
2024-03-13 10:52:17 0 [Note] Server socket created on IP: '0.0.0.0'.
2024-03-13 10:52:17 0 [Note] Server socket created on IP: '::'.
ERROR: 1007  Can't create database 'nextcloud'; database exists
2024-03-13 10:52:17 0 [Note] mariadbd: ready for connections.
Version: '10.11.6-MariaDB-log'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  Alpine Linux
2024-03-13 10:52:19 0 [Note] mariadbd (initiated by: root[root] @ localhost []): Normal shutdown
2024-03-13 10:52:19 0 [Note] InnoDB: FTS optimize thread exiting.
2024-03-13 10:52:19 0 [Note] InnoDB: Starting shutdown...
2024-03-13 10:52:19 0 [Note] InnoDB: Dumping buffer pool(s) to /config/databases/ib_buffer_pool
2024-03-13 10:52:19 0 [Note] InnoDB: Buffer pool(s) dump completed at 240313 10:52:19
2024-03-13 10:52:19 0 [Note] InnoDB: Removed temporary tablespace data file: "./ibtmp1"
2024-03-13 10:52:19 0 [Note] InnoDB: Shutdown completed; log sequence number 46846; transaction id 16
2024-03-13 10:52:19 0 [Note] mariadbd: Shutdown complete
Database Setup Completed
[custom-init] No custom files found, skipping...
240313 10:52:20 mysqld_safe Logging to '/config/databases/2e502f5013c2.err'.
240313 10:52:20 mysqld_safe Starting mariadbd daemon with databases from /config/databases
Connection to localhost (127.0.0.1) 3306 port [tcp/mysql] succeeded!
[ls.io-init] done.
github-actions[bot] commented 8 months ago

Thanks for opening your first issue here! Be sure to follow the relevant issue templates, or risk having this issue marked as invalid.

j0nnymoe commented 8 months ago

As you can see from the log, when it's trying to create the database, it's already seeing the nextcloud folder there before the creation of database so it is assuming it already has files within it.

marioqqq commented 8 months ago

I see, so I removed - MYSQL_DATABASE=nextcloud from environment variables. Error is gone, but user is still not created.

j0nnymoe commented 8 months ago

The user creation on happens on first/clean run.

marioqqq commented 8 months ago

Before starting each container I removed all volumes and container it self as well.

homerr commented 7 months ago

As this isn't an issue with the container and more a problem with how the compose files are being used please continue this in Discord.