MariaDB 10.3 Image refuses remote connections

Hello everyone,
I tried Maria DB a while ago (1 year or so) and i had no problems with it. Today I tried it again but can’t manage to remote connect to database from any sql clients(terminal or DataGrip) from my host.

So more info:

Host:

  • OS: macOS
  • Docker version: Version 18.03.0-ce-mac60 (23751)
  • Using docker-compose up -d command

What did I tried:

  • changing cnf file to deactivate bind 0.0.0.0 line, to activate it and to change it to 127.0.0.1
  • being sure that the user created in compose file exists and have remote access priv

What error i get:
when i use mysql --host=127.0.0.1 --port=8000 -u ****** -p on host’s terminal I get ERROR 2003 (HY000): Can't connect to MySQL server on '127.0.0.1' (61)
But when I try to connect to db from container is working.
custom cnf file correctly loaded in container:

[client]
default-character-set = utf8
[mysqld]
bind-address = 127.0.0.1
character-set-server  = utf8
collation-server      = utf8_general_ci
character_set_server   = utf8
collation_server       = utf8_general_ci

yaml file:

 version: '3'
services:
  mq:
    image: "rabbitmq:3-management"
    restart: always
    environment: 
      RABBITMQ_DEFAULT_USER: "******"
      RABBITMQ_DEFAULT_PASS: "******"
      RABBITMQ_DEFAULT_VHOST: "/"
    ports: 
      - "8080:15672"
      - "5672:5672"
      - "5671:5671"
    labels:
      NAME: 'rabbitmq1'
    volumes:
      - ./MountPoints/Data/RabbitMQ:/var/lib/rabbitmq/mnesia/
  DB:
    image: "mariadb:10.3"
    restart: always
    ports:
      - "3306:8000"
    environment: 
      MYSQL_ROOT_PASSWORD: "******"
      MYSQL_USER: "******"
      MYSQL_PASSWORD: "******"
      MYSQL_DATABASE: "******"
    volumes:
      - ./MountPoints/Data/projDB:/var/lib/mysql
      - ./MountPoints/Configs/SQL:/etc/mysql/conf.d/

Thank you for any ideas

This is definitely wrong. If you’re running a server process in a Docker container, and it’s set to only listen on 127.0.0.1 (or IPv6 ::1), nothing outside the container will ever be able to talk to it. 0.0.0.0 (or :: ) is pretty much always right.

and still it did not work even with 0.0.0.0 nor *

This tells Docker, when the host receives an inbound connection on port 3306, to send it to port 8000 in the container. But probably the database server is listening on port 3306 in the container and nothing is listening on port 8000. Try "3306:3306" instead here.

oh wow i did not saw that one … i inverted the mapping …