i have created a repository to optimise development on Mac, using Traefik to handle multiple projects.
I'm not able to make the correct configuration inside traefik and docker-compose file, in order to access to mysql containers from any tool.
This is the issue and the repository on github: https://github.com/zioDocker/DockerDevelopmentOnMac/issues/4
Can you please post the exact Traefik configuration and docker-compose file? I'm trying to find it on your repo but I wasn't succesfull
you can use this docker-compose example:
And the configuration is the one you can find in https://github.com/zioDocker/DockerDevelopmentOnMac/blob/master/configuration/traefik/traefik2.2.toml
But u can use any mysql container: the point is, how to access with a tool to a docker container that run under Traefik on port 3306.
Thank u very much.
But in that example, you're not configuring your mariadb container to proxied through Traefik, like you're doing with your web container.
I suggest you to lookup Traefik dynamic configuration on docker https://docs.traefik.io/routing/providers/docker/ and try agian
Yes i know that the configuration is missing...
i have tried, looking into the documentation and set up a configuration but i was not able to make it works... so i asked
Then, I'd like, that you post your "broken" configuration and we'll try to fix it
ok, it makes sense
This is the configuration that i have tried but doesn't work: https://github.com/zioDocker/DockerDevelopmentOnMac/blob/issue/%234-traefik-mysql/docker-compose-examples/magento2.yml
Container is visible inside Traefik and without error but if i try to connect via any tool, i get connection refused.
If I remember correctly, the tcp connection of mysql is not making use of TLS and thus, no SNI. Therefore, you can't use the
) matcher like that. You rather have to use it as a wildcard
) and connect to the Traefik Container on Port 3306, as this is the port of your mysql entrypoint.
Does it make sense?
mmm not sure if it makes sense but at the end it doesn't work.
I have tried this conf:
and when i try to connect i get this:
Not sure what you're trying, but I'm able to connect through a mysql cli just fine with that compose file
Thanks u very much for your effort... it works now.....
I was so stupid... after having change the rule... i forgot to expose again the port 3306....
Just one question: is there a way to handle two database connections having the same params?
Technically if u have 2 docker-compose files, with same db containers and same environment variables, in docker they work because they run on two different services.
The problem comes when u try to connect to them using Traefik, because using the same wildcad(*) for both, Traefik has not chance to distinguish them.
i.e. try to use your configuration for two projects...
Thank u again
From what I understand in this case you must have 1 port to 1 database. If you want to access 2 databases, you must have 2 ports (2 entrypoints), each one for a different database.