pierrecdn / phpipam

phpIPAM Docker image
GNU Lesser General Public License v3.0
94 stars 111 forks source link

phpipam user denied access during setup #12

Closed DavidRawling closed 6 years ago

DavidRawling commented 6 years ago

I have configured this container to run on a private network; port 80 is already in use on the host and I would prefer to have it on a private net anyway. I'm pretty sure I have the docker compose YAML configured right, but setup complains that the phpipam user is denied access.

docker-compose.yml follows:

ipam:
  image: pierrecdn/phpipam
  container_name: phpipam
  ports:
    - 29030:80
  environment:
    - MYSQL_ENV_MYSQL_ROOT_PASSWORD=${MYSQLPASSWORD}
  links:
    - phpipam-mysql:mysql
  restart:
    always
phpipam-mysql:
  image: mysql:5.6
    container_name: phpipam-mysql
  environment:
    - MYSQL_ROOT_PASSWORD=${MYSQLPASSWORD}
  volumes:
    - /opt/appdata/phpipam:/var/lib/mysql
  restart:
    always

It looks like the link to the MySQL container doesn't work completely; the container attempts to connect to the wrong IP:

Database error: Could not connect to database! SQLSTATE[HY000] [1045] Access denied for user 'phpipam'@'172.18.0.5' (using password: YES).

Note that 172.18.0.5 is the IP of the phpipam container - the MySQL container has no internal IP. The password is defined in an environment file and there are other containers using variables from that file

Suggestions welcome (and I hope this formatting works).

pierrecdn commented 6 years ago

Sorry for the delay in answering.

To me you've simply an error in your compose file, leading to a mismatch by Docker in some way.

By blindly copying your docker-compose.yml I end up having timeouts from the frontend to reach the DB in the PDO MySQL driver, like what you seem to describe.

But, if I do the same as I documented, I get:

Attaching to phpipam-mysql, phpipam
(logs stream)

And it works as expected.

So you probably forgot to add:

version: '2'

services:
(...)

on top of your docker-compose.yml