Mysql – Timeout error on MariaDB in Docker container

dockermariadbMySQLufw

I have an ArchLinux installation with Docker and MariaDB running in a container.

Now when I try to connect to the database, I get the following euro: MySQL said: Can't connect to MySQL server on '$mydomain' (4).

Things I did to make it available:

  • Created root-user and granted % access.
  • Mounted folder with custom.cnf with following contents:

    [mysqld]
    bind-address=0.0.0.0
    
  • Exposed 3306:3306 in docker run
  • Configured UFW ufw status | grep 3306:

    3306                       ALLOW       Anywhere
    3306 (v6)                  ALLOW       Anywhere (v6)
    

I'm not sure what I'm missing. I can connect with the given password from within the container, but not from my local host.

Thanks in advance!

Edit: I managed to connect from another container via the internal ip of the container, so it works on the host I think? Maybe it's a firewall issue (but that doesn't make sense since disabling ufw and iptables does not help anything).

Best Answer

It's a Docker issue, adding --net=host to docker run fixes it. See #13914 for more information.

Related Topic