Docker MySQL connection DBeaver

Instead of giving localhost_compliant-db as the Server Host in dbeaver, try giving it localhost.

3306 port is bind on the host machine as well hence localhost:3306 from your host machine should work.

PS - I presume dbeaver and docker compose stack both are on the same machine. If not, you need to map localhost_compliant-db to certain IP which your host machine can understand.

For those who are running DB on different machine, you can do the following:

First, from where the container is, run docker ps to get the containers details including the Container ID

[[email protected] ~]# docker ps 
CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                    NAMES
1b02333fb3b9        tutum/nginx              "/usr/sbin/nginx"        6 weeks ago         Up 7 days >80/tcp       docker_nginx_1
8c1d234a3731        mariadb                  "docker-entrypoint.s…"   6 weeks ago         Up 7 days >3306/tcp   docker_mysql_1

After you get the ID of your database container, run docker inspect CONTAINER_ID to get the related IP address of that container.

[[email protected] ~]# docker inspect 8c1d234a3731 | grep -i IPAddress
            "SecondaryIPAddresses": null,
            "IPAddress": "",
                    "IPAddress": "",

On Dbeaver, after selecting the DB type on adding new connection window, Go to network settings (SSH, ...) then put your docker machine details. and from the main page, in the Server Host: add the IP you got from the docker inspect command, then your credentials.

This should work

In my case I was using DBBeaver to connect to MariaDB on port 3306 however my container port was not mapped to my local 3306 port so I just needed to add the ports config into the docker-compose.yml

- "3306:3306"