nuxsmin / docker-syspass

Docker stuff for running sysPass on Docker
GNU General Public License v3.0
39 stars 21 forks source link

No database connection #10

Closed nofear87 closed 6 years ago

nofear87 commented 6 years ago

I have the same problem like #5 using the default docker-compose.yml -> SQLSTATE[HY000] [1130] Host '172.18.0.1' is not allowed to connect to this MySQL server

I wonder why the syspass interface gets the 172.18.0.1 -> because container ip is ...0.2

version: '2'
services:
  app:
    container_name: syspass-app
    image: nuxsmin/docker-syspass:latest
    restart: always
    ports:
      - "3080:80"
      - "443:443"
    links:
      - db
    volumes:
      - /var/www/html/sysPass/config
      - /var/www/html/sysPass/backup
  db:
    container_name: syspass-db
    restart: always
    image: nuxsmin/docker-syspass:mysql
    ports:
      - "3306"
    environment:
      - DB_REMOTE_HOST=syspass-app.syspass_default
      - DB_REMOTE_ROOT_PASS=syspass
    volumes:
      - /var/lib/mysql

Db ist pingable without any problems:

docker exec -it 8460 ping syspass-db
PING syspass-db (172.18.0.2): 56 data bytes
64 bytes from 172.18.0.2: icmp_seq=0 ttl=64 time=0.130 ms
64 bytes from 172.18.0.2: icmp_seq=1 ttl=64 time=0.115 ms
64 bytes from 172.18.0.2: icmp_seq=2 ttl=64 time=0.085 ms
64 bytes from 172.18.0.2: icmp_seq=3 ttl=64 time=0.106 ms
they are both in the same network:

"Containers": {
            "31a4848ee1a9f59455ce4c4235bcc7ed3514777dd0c108dfd7046fc1794789f5": {
                "Name": "syspass-db",
                "EndpointID": "73edb4fcc9630d60aab9b723aedf8ba9d74878d37f6fca910d61574f86ba8d6a",
                "MacAddress": "02:42:ac:12:00:02",
                "IPv4Address": "172.18.0.2/16",
                "IPv6Address": ""
            },
            "84605c3f36ef48c0993eafd5d973250a074d90aac80d0e758131b4929433b651": {
                "Name": "syspass-app",
                "EndpointID": "ea399b6279631eed0b5371f980f4da2fca1fb11a03315265b62c5c2bb6c1016b",
                "MacAddress": "02:42:ac:12:00:03",
                "IPv4Address": "172.18.0.3/16",
                "IPv6Address": ""
            }
        },
nofear87 commented 6 years ago

If I could help you with some further information please feel free to ask ;-)

nuxsmin commented 6 years ago

It's weird, since 172.18.0.1 is the docker host itself...

There should be an error regarding a connection from 172.18.0.3, because syspass-app makes the connections to syspass-db container

nofear87 commented 6 years ago

yes you are right...its weird...in configuration I choose "syspass-db" as database host.

nofear87 commented 6 years ago

I have installed mysql client on syspass-app container with same result:

root@1c66e6ee5ff8:/var/www/html# mysql -u root -h syspass-db
ERROR 1130 (HY000): Host '172.18.0.1' is not allowed to connect to this MySQL server

Ping from syspass-db to syspass-app works fine, with correct ip resolution:

 docker exec -it syspass-db ping syspass-app
PING syspass-app (172.18.0.3): 56 data bytes
64 bytes from 172.18.0.3: icmp_seq=0 ttl=64 time=0.135 ms
64 bytes from 172.18.0.3: icmp_seq=1 ttl=64 time=0.104 ms
64 bytes from 172.18.0.3: icmp_seq=2 ttl=64 time=0.102 ms
64 bytes from 172.18.0.3: icmp_seq=3 ttl=64 time=0.109 ms
nuxsmin commented 6 years ago

I have installed mysql client on syspass-app container with same result:

Right, it's not allowed indeed. You need to issue docker exec -it syspass-db mysql to get into mysql CLI

Ping from syspass-db to syspass-app works fine, with correct ip resolution:

The weird issue is the IP address thrown in the error message.

ygross commented 5 years ago

i understand the issue is related to that the container change ip address after resatart of the host can you send what commands need to be done to fix the ips so the syspass will continue after restart ?