I try to build CI with mysql service and building my code with dind configuration.
But I end up with: Can’t connect to MySQL server on ‘mysql’
I’m not sure if services can be used like that with dind so they are accessible later from inside of builded docker containers?
I haven’t used dind but I’m using docker image one for gitlab and one for mysql and it’s working fine.
I have --network=host on mysql container but not for the gitlab to avoid port 22 conflict. In my my.cnf, had to allow mysql access from 172.17.0.2 or the ip of gitlab container ip address.
I didn’t even could reach it by network. I’m just not sure if when using dind, the other services are visible inside of the docker?
As i assume dind is for separation purposes for parallel tests, so i don’t think that it is good idea to use same database.
So the question is if this configuration should create mysql service for each instance of test suite?
Remembered. Gitlab puts a restriction on community edition about MySQL. I think I had problem with Gitlab docker image accessing external MySQL. Postgresql doesn’t have this restriction so I’ve switched to using Postgresql with my Gitlab docker. So, use Postgresql for each test suite?
Did you manage to fix this? I’m trying the same thing but it can’t even find the host: ERROR 2005 (HY000): Unknown MySQL server host ‘mysql’ (0). using mysql:latest
Hi, I’m experiencing the same thing here. I have a docker-in-docker service running, using the Gitlab MySQL service. I want by docker image during the build phase to connect to the mysql service. However, the error I get is the following:
Connection Error: Error: getaddrinfo ENOTFOUND mysql mysql:3306
And my Docker build command looks like the following
Hi @albertkim , I know it’s been a while, but did you ever find a solution to this problem?
I’m having a very similar issue with the Redis service and was hopeing you perhaps had an answer.
Hi all. Same problem. I am using GitLab on-premises. Two gitlab-ci.yml services: mysql and docker:dind.
script:
# Run tests
- ping mysql -c 4
- docker run --name dummy -e DB_HOST=mysql devimage vendor/bin/phpunit --configuration phpunit.xml --coverage-text --colors=never --log-junit /tmp/report.xml
During docker run, my container cannot connect to mysql service. Running ping mysql outside the container, at the same level as docker run, ping works. But inside container mysql is not available. It is not able to resolve the host name. Is there any solution, or this is a limitation?