6

so I am trying to setup a laravel ci server with github actions. And, i am using edbizarro/gitlab-ci-pipeline-php:7.3 as my container, and I use the official mariadb docker as mysql service.:

services:
      mysql:
        image: mariadb:10.3
        env:
          MYSQL_USER: root
          MYSQL_PASSWORD: root
          MYSQL_ROOT_PASSWORD: root
        ports:
          - 13306:3306 
...

and I am trying to run, run mysql command to import db:

  - name: Setting Up DB
        run: |
          mysql -Tv -h mysql -P 13306 --protocol=tcp -u root -proot < ./storage/test.sql

And here are the several attempts I did:

| host               | error message                                                          |
|--------------------|------------------------------------------------------------------------|
| mysql,"${DB_HOST}" | ERROR 2005 (HY000): Unknown MySQL server host 'mysql' (-2)             |
| 0.0.0.0            | ERROR 2002 (HY000): Can't connect to MySQL server on '0.0.0.0' (115)   |
| 127.0.0.1          | ERROR 2002 (HY000): Can't connect to MySQL server on '127.0.0.1' (115) |
| (without host)     | ERROR 2002 (HY000): Can't connect to MySQL server on 'localhost' (99)  |

Not sure what else I can do here ...

here is what I also tried, all tells me that option don't exist:

 services:
      mysql:
        image: mariadb:10.3
        options: --bind_address=""
        env:
          MYSQL_USER: root
          MYSQL_PASSWORD: root
          MYSQL_ROOT_PASSWORD: root
        ports:
          - 13306:3306 

and I tried with options :

  1. --disable_bind_address
  2. --bind-address=""

Here are some log messages I got from github: (-Tv did not give anything useful)

docker.io/library/mariadb:10.3
/usr/bin/docker create --name 607ae471e5844570b9e2fcf4f57ed78a_mariadb103_d94369 --label 2b5be7 --workdir /__w/laravel/laravel --network github_network_ab8a7ba8c1624f95bdc2784147b4b5e1 --network-alias mysql -p 13306:3306 -e "MYSQL_USER=root" -e "MYSQL_PASSWORD=root" -e "MYSQL_ROOT_PASSWORD=root" -e "HOME=/github/home" -v "/home/runner/work":"/__w" -v "/home/runner/runners/2.157.3/externals":"/__e":ro -v "/home/runner/work/_temp":"/__w/_temp" -v "/home/runner/work/_actions":"/__w/_actions" -v "/opt/hostedtoolcache":"/__t" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" mariadb:10.3
 c3b10a5c4799a671f55c2f2b7a33803abd9228830be5e8821b51f10a2b2951b3
/usr/bin/docker start c3b10a5c4799a671f55c2f2b7a33803abd9228830be5e8821b51f10a2b2951b3
c3b10a5c4799a671f55c2f2b7a33803abd9228830be5e8821b51f10a2b2951b3
/usr/bin/docker ps --all --filter id=c3b10a5c4799a671f55c2f2b7a33803abd9228830be5e8821b51f10a2b2951b3 --filter status=running --no-trunc --format "{{.ID}} {{.Status}}"
c3b10a5c4799a671f55c2f2b7a33803abd9228830be5e8821b51f10a2b2951b3 Up Less than a second
/usr/bin/docker port c3b10a5c4799a671f55c2f2b7a33803abd9228830be5e8821b51f10a2b2951b3
3306/tcp -> 0.0.0.0:13306
9
  • from where you run the import script? is it in same docker-compose?
    – Adiii
    Sep 4, 2019 at 18:08
  • it is github actions, so in steps
    – Shuyi
    Sep 4, 2019 at 18:35
  • github action running inside docker or same docker-compose file?
    – Adiii
    Sep 4, 2019 at 18:36
  • docker, I don't think they use docker compose
    – Shuyi
    Sep 4, 2019 at 18:41
  • ` mysql -Tv -h mysql -P 13306 ` here -h mysql host is only accesible in container if it launch in same docker compose
    – Adiii
    Sep 4, 2019 at 18:43

1 Answer 1

8

Maybe try like this :

 mysql: 
    image: mariadb:10.3 
    env:    
        MYSQL_ROOT_PASSWORD: root   
    ports:  
    - 3306:3306 
    options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3

There is a healthcheck to be sure the service is healthy before connexion

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.