Docker run - service mysql Connection Refused from CI
We have Github self runner latest version with container install. It create a service mysql database in container.
We are testing some Github Runners but we get error Connection Refused when we run one command from CI. And before that command we run mysql command and it can connect with success. When i put sleep in CI and connect to container and run manually the command is success. I add some print command to show me the connection and is the correct one.
The init database it finish with success, it failed to php artisan app:prepare -vvv
jobs:
test:
runs-on: [self-hosted, test]
services:
mysql:
image: mysql:8.0.23
env:
MYSQL_USER: test
MYSQL_ROOT_PASSWORD: test
ports:
- 3306
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Get the mysql host
id: get_host
run: |
host=`docker network inspect -f '{{(index .IPAM.Config 0).Gateway}}' bridge`
echo "db-host=$host" >> $GITHUB_OUTPUT
- name: Init Database
run: |
host=`docker network inspect -f '{{(index .IPAM.Config 0).Gateway}}' bridge`
mysql -uroot --password=test -h ${{ steps.get_host.outputs.db-host }} --port ${{ job.services.mysql.ports['3306'] }} -e "SET GLOBAL sql_mode = ''"
- name: PHP artisan command
run: |
cp -a .env.ci .env
sed -i 's/127.0.0.1/${{ steps.get_host.outputs.db-host }}/g' .env
sed -i 's/3306/${{ job.services.mysql.ports['3306'] }}/g' .env
mysql -uroot --password=test -h ${{ steps.get_host.outputs.db-host }} --port ${{ job.services.mysql.ports['3306'] -e "show databases;"
php artisan app:prepare -vvv
Error
Database
information_schema
mysql
performance_schema
sys
1 vendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:70
PDOException::("SQLSTATE[HY000] [2002] Connection refused")
$ telnet 172.26.0.1 32921
Trying 172.26.0.1...
Connected to 172.26.0.1.
Escape character is '^]'.
J
8.0.23^]
telnet> Connection closed.
Runner Version and Platform
Version of your runner? 2.304.0 Ubuntu 22.04.2 LTS
Did you resolve this? I have a similar problem.
@curtishall no i still have the issue.
This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 15 days.
This issue was closed because it has been stalled for 15 days with no activity.
the issue stll exist