ERROR 1130 (HY000) not allowed to connect to this MariaDB server facing issue in granting permission
The GRANT statement doesn't work because the user@host combination root@'%' doesn't exist (yet). You can create it and then re-run the GRANT:

CREATE USER root@'%' IDENTIFIED BY 'your_secret_password_here'; 
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' WITH GRANT OPTION;
FLUSH PRIVILEGES;


The WITH GRANT OPTION part gives the user the power to GRANT privileges to other users. 

Note that in order to be able to connect from the other container, you may also have to remove or comment out any restrictions in your configuration (i.e. files like /etc/my.cnf, /etc/my.cnf.d/server.cnf, /etc/mysql/*.cnf) such as any bind-address settings: 

bind-address  = 127.0.0.1


Comment out with a '#':

# bind-address  = 127.0.0.1


... and then restart MariaDB.