MySQL/MariaDB in Docker - allow access from all hosts

There is a environment variable to be add in the configuration if you cannot access the database locally:

MYSQL_ROOT_HOST: "%"
If you have mounted volumes, after stopping the container - delete them and run the container again with this environment variable.
This is the hostname part of the root user created.
By default this is %, however it can be set to any default MySQL/MariaDB allowed hostname component.
Setting this to localhost will prevent any root user being accessible except via the unix socket.
Example of docker-compose.yaml:
version: '3.4'
services:
  mariadb:
    image: mariadb
    environment:
      MYSQL_ROOT_PASSWORD: changeme
      MYSQL_DATABASE: mybb
      MYSQL_USER: mybb
      MYSQL_PASSWORD: changeme
      MYSQL_ROOT_HOST: "%"
    networks:
      - backend
    restart: on-failure
    volumes:
     - ${PWD}/mariadb:/var/lib/mysql
networks:
  frontend:
    driver: bridge         
  backend:
    driver: bridge
If you access the container - here is the user list:
MariaDB [(none)]> SELECT user, host FROM mysql.user;
+-------------+-----------+
| User        | Host      |
+-------------+-----------+
| mybb        | %         |
| root        | %         |
| mariadb.sys | localhost |
| root        | localhost |
+-------------+-----------+