tobybatch / kimai2

Docker containers for the kimai2 web application including docker-compose and kubernetes/helm deployment.
MIT License
183 stars 97 forks source link

Quick start doesn't work for me (https://tobybatch.github.io/kimai2/) #331

Closed rjanossy closed 2 years ago

rjanossy commented 2 years ago

Hi, After starting the mysql container:

docker run --rm --name kimai-mysql-testing -e MYSQL_DATABASE=kimai -e MYSQL_USER=kimai -e MYSQL_PASSWORD=kimai -e MYSQL_ROOT_PASSWORD=kimai -p 3399:3306 -d mysql

I can connect to the mysql server like this :

mysql --host=127.0.0.1 --port=3399 -u kimai -p

and I see the kimai database

show databases;

+--------------------+ | Database
+--------------------+ | information_schema | | kimai | +--------------------+ 2 rows in set (0.03 sec)

But when I try to start kimai/kima2:

docker run --rm --name kimai-test -ti -p 8001:8001 -e DATABASE_URL=mysql://kimai:kimai@127.0.0.1:3399/kimai kimai/kimai2:apache

I get this error:

Testing DB:* new \PDO(mysql:host=127.0.0.1;dbname=kimai;port=3399, kimai, kimai, [ \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION ]);SQLSTATE[HY000] [2002] Connection refused (?)Checking DB: 10

If I try with localhost instead of 127.0.0.1 I get different error:

Testing DB:* new \PDO(mysql:host=localhost;dbname=kimai;port=3399, kimai, kimai, [ \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION ]);SQLSTATE[HY000] [2002] No such file or directory (?)Checking DB: 10

Any help would be greatly appreciated. Robert

kevinpapst commented 2 years ago

Port 3399 = host port Port 3306 = port inside docker Conclusion: adjust your DATABASE_URL

rjanossy commented 2 years ago

THX Kevin,

Do you mean DATABASE_URL=mysql://kimai:kimai@127.0.0.1:3306/kimai ?

This gives the same error: Testing DB:* new \PDO(mysql:host=127.0.0.1;dbname=kimai;port=3306, kimai, kimai, [ \PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION ]);SQLSTATE[HY000] [2002] Connection refused (?)Checking DB: 10

Robert

rjanossy commented 2 years ago

Solved!

I had to use the mysql -container-ip 172.17.0.3

docker run --rm --name kimai-test -ti -p 8001:8001 -e DATABASE_URL=mysql://kimai:kimai@172.17.0.3:3306/kimai kimai/kimai2:apache

Thank you Kevin! Robert

kreindo commented 1 year ago

hello, how do u fix this, how do u "use mysql -container-ip 172.17.0.5"?

tobybatch commented 1 year ago

Is this using docker compose or running dockers individually?

kreindo commented 1 year ago

inivdually