tobybatch / kimai2

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

Unable to bind/mount mysql volume and start kimai dokcer #553

Closed ProfaBG closed 6 months ago

ProfaBG commented 8 months ago

Greetings,

First I would like to express my gratitude for creating this excellent piece of software. I have been using it for testing purposes via single docker image on Ubuntu and it has been a blast! This is the first time for me to use Linux or Docker and for the past two weeks i have been struggling to resolve this issue. Documentation/reddit/aibots were no help and so i trun to you hopefully you can assist me. This is also the 1st time for me posting on github as well,

As for Kimai, time has come to put Kimai it in production and further learn it and configure it.

Describe the bug I wanted to use the mysql database I have create on my Ubuntu host machine folder but i cant seem to figure out syntax how to run a kimai docker command with it. I have created folder on the host VM and successfully ran mysql docker which saves data after host/container reboot, but can't mount it to running docker. The command i ran is described bellow under "Command used to run the container".

To Reproduce Steps to reproduce the behaviour: Create folder: sudo su Mkdir mysql_bind_folder

Run database docker: docker run --name mysql-kimai -p 3399:3306 -e MYSQL_ROOT_PASSWORD=fake_password-d --mount type=bind,source="$(pwd)"/mysql_bind_folder,target/var/lib/mysql mysql

Run kimai docker commands i've tried: 1) docker run --rm --name kimai -ti -p 8001:8001 -e DATABASE_URL=mysql://root:fake_password@host.docker.internal:3399/kimai -add-host=host.docker.internal:host-gateway kimai/kimai2:apache

2) docker run -d -p 8080:80 --name my-kimai-container --link mysql-kimai:mysql -e KIMAI_DATABASE_URL=mysql://root:fakepass@mysql:3306/my_kimai_db?serverVersion=5.7&charset=utf8 --entrypoint "/usr/bin/supervisord" kimai/kimai2

3) docker run -d -p 8080:80 --name my-kimai-container --link mysql-kimai:mysql -e KIMAI_DATABASE_URL=mysql://root:fakepass@mysql:3306/my_kimai_db?serverVersion=5.7&charset=utf8 kimai/kimai2

4) docker run --rm --name kimai -ti -p 8001:8001 -e DATABASE_URL=mysql://root:KokoPower23@host.docker.internal:3399/kimai -add-host=host.docker.internal:host-gateway kimai/kimai2:apache

6) docker run -d -p 8080:80 --name my-kimai-container --link mysql-kimai:mysql -e KIMAI_DATABASE_URL=mysql://root:fakepass@mysql:3306/my_kimai_db kimai/kimai2

5) i'have tried listed commands with port variations 8080:80 / 8001:80 and with :apache2 at very end.

Desktop (please complete the following information):

Command used to run the container

Docker compose file (with passwords redacted) I have not composed file

version: '3.5'
services:
   image: ...

Additional context I am not really skilled with any of this, so sorry for such a long post and probably bunch of nonsense and excessive info. I dont know how to compose docker image as well.

Thank you in advance.

tobybatch commented 8 months ago

That will never work. There is no mysql daemon running in the container. You need to connect to running mysql instance. in your case you could target the mysql instance in your host machine using a DATABASE_URL of something like DATABASE_URL=mysql://username:password@YOUR HOST IP HERE/databasename