Hello,
can I somehow pass a service (specifically a database connection) to a Docker action?
When I try to pass options like this:
with: database_user: myUser ... database_port: "${{ job.services.mysql.ports['3306'] }}"
and use this information inside my entrypoint.sh file
I get the following error:
mysql -h 127.0.0.1 --port 32768 -u myUser -pxy -e "CREATE DATABASE IF NOT EXISTS myDB;" ERROR 2002 (HY000): Can't connect to MySQL server on '127.0.0.1' (115)
Is there any possibility to map the connection? Or do I need to setup MySQL inside my Docker container?
Thanks for your advice,
Axel
There are some of the possible causes of this error:
1) Network failure especially if mysql database server is running on remote host.
2) No mysql server is running on the mentioned host.
3) Firewall blocking TCP-IP connection or other related reasons.
You can try using ping command to test the client-server connectivity, such as “ping 127.0.0.1”.
The following are two Docker container actions for MySQL and docs for MySQL image, maybe you can reference them:
I already have a MySQL server setup like this:
services: mysql: image: mysql:5.7 env: MYSQL_USER: myUser MYSQL_PASSWORD: myPass MYSQL_DATABASE: myDB MYSQL_ROOT_PASSWORD: myPass ports: - 3306 options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
But my special use case is that I do not want to use it directly in the workflow, but within a docker action used by the workflow. I will try to use the default mysql available in virtual environments instead.
This thread at stack overflow contains several possible solutions:
Is it possible with GitHub actions to call a docker image in host mode by setting/appending
--network=host or --net=host
?