colinmollenhour / mariadb-galera-swarm

MariaDb Galera Cluster container based on official mariadb image which can auto-bootstrap and recover cluster state.
https://hub.docker.com/r/colinmollenhour/mariadb-galera-swarm
Apache License 2.0
217 stars 102 forks source link

Cannot reach cluster from outside server #61

Closed YeeP79 closed 5 years ago

YeeP79 commented 5 years ago

I have confirmed that all container ips are in the 10.0.0.* range (only have 3). I only modified the example docker-compose file to version 3.3, which does not allow for a "name" inside of volumes. Outside of that, the cluster is up and running, I can go inside the containers and connect, create data and it is replicated.

I am not seeing any external connection allowed to the containers. Are there some other settings that need to happen?

YeeP79 commented 5 years ago

telnet <server name> 3306 Trying 10.18.114.185... telnet: connect to address 10.18.114.185: Connection refused I also have added: - MYSQL_ROOT_HOST=0.0.0.0 to the environment for both the seed and the node services. Not sure if this gets handed straight to mariadb, but that was the hope as the MYSQL_USER etc.. ones do.

maverage commented 5 years ago

You currently only have an internal network within your swarm. In order to get access from externally, you need to add the port to your node config:

ports:
  - target: 3306
    published: 3306
    protocol: tcp
    mode: host

This will allow access to the db cluster on the hosts, on which your nodes are running. If you want use the swam internal load balancing and be able to reach the database on every host in your swam, exchange the last line against mode: ingress.

If by "outside" you only mean other containers within your swarm, you don't need to add ports, just connect them by using the same network-identifier.

See also Docker Compose v3 reference.

colinmollenhour commented 5 years ago

Thanks, @maverage

lawrencebensaid commented 4 years ago

@maverage I did what you said. But the container steel appears to be unreachable. Is there anything else it could be?