Can't connect to MySQL service with .gitlab-ci.yml
This .gitlab-ci.yml
mysql sample does not work for me.
ERROR 2003 (HY000): Can't connect to MySQL server on 'mysql' (113)
Does anyone know any reason?
root@be3e21d9cba7:/my/my_tool# cat .gitlab-ci.yml
services:
- mysql
variables:
# Configure mysql service (https://hub.docker.com/_/mysql/)
MYSQL_DATABASE: hello_world_test
MYSQL_ROOT_PASSWORD: mysql
connect:
image: mysql
script:
- echo "SELECT 'OK';" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
root@be3e21d9cba7:/my/my_tool# gitlab-runner exec docker connect
WARNING: You most probably have uncommitted changes.
WARNING: These changes will not be tested.
Running with gitlab-ci-multi-runner 1.4.1 (fae8f18)
Using Docker executor with image mysql ...
Pulling docker image mysql:latest ...
Starting service mysql:latest ...
Waiting for services to be up and running...
*** WARNING: Service runner--project-1-concurrent-0-mysql probably didn't start properly.
container already exists
*********
Pulling docker image mysql ...
Running on runner--project-1-concurrent-0 via be3e21d9cba7...
Cloning repository...
Cloning into '/builds/project-1'...
done.
Checking out b21a51b2 as master...
$ echo "SELECT 'OK';" | mysql --user=root --password="$MYSQL_ROOT_PASSWORD" --host=mysql "$MYSQL_DATABASE"
mysql: [Warning] Using a password on the command line interface can be insecure.
ERROR 2003 (HY000): Can't connect to MySQL server on 'mysql' (113)
ERROR: Build failed: exit code 1
FATAL: exit code 1