Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 4

MySQL connection from Docker action?


can I somehow pass a service (specifically a database connection) to a Docker action?


When I try to pass options like this:

    database_user: myUser
    database_port: "${{['3306'] }}"

and use this information inside my file

I get the following error:

mysql -h --port 32768 -u myUser -pxy -e "CREATE DATABASE IF NOT EXISTS myDB;"

ERROR 2002 (HY000): Can't connect to MySQL server on '' (115)

Is there any possibility to map the connection? Or do I need to setup MySQL inside my Docker container?


Thanks for your advice,



3 Replies
GitHub Partner
Message 2 of 4

Re: MySQL connection from Docker action?

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”.

The following are two Docker container actions for MySQL and docs for MySQL image, maybe you can reference them:

Setup MySQL

Start MySQL

Copilot Lvl 2
Message 3 of 4

Re: MySQL connection from Docker action?

I already have a MySQL server setup like this:

        image: mysql:5.7
          MYSQL_USER: myUser
          MYSQL_PASSWORD: myPass
          MYSQL_DATABASE: myDB
          MYSQL_ROOT_PASSWORD: myPass
          - 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.

Copilot Lvl 2
Message 4 of 4

Re: MySQL connection from Docker action?

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