help needed: mysql service does not work
My .gitlab-ci.yml looks like:
# Select what we should cache
cache:
paths:
- vendor/
before_script:
# Install git, the php image doesn't have installed
- apt-get update -yqq
- apt-get install git -yqq
# Install mysql driver
- docker-php-ext-install pdo pdo_mysql
# Install composer
- curl -sS https://getcomposer.org/installer | php
# Install all project dependencies
- php composer.phar install
services:
- mysql
variables:
# Configure mysql service (https://hub.docker.com/_/mysql/)
MYSQL_ROOT_PASSWORD: root123
MYSQL_ALLOW_EMPTY_PASSWORD: "1"
MYSQL_DATABASE: neeach
# Custom DB connection variable - docker requires using special host to be used inside PDO connection
MYSQL_HOST: mysql
# We test PHP5.6 (the default) with MySQL
test:php56:
image: php:5.6
script:
- ./vendor/bin/tester -p php -s -c ./tests/php-unix.ini ./tests
# We test PHP7 with MySQL, but we allow it to fail
test:php7:
image: php:7
script:
- ./vendor/bin/tester -p php -s -c ./tests/php-unix.ini ./tests
allow_failure: true
But this configuration obviously does not work, because I get 2 types of errors:
A] currently I'm not able to even pull docker image at all:
WARNING: Service mysql is already created. Ignoring.
...
*** WARNING: Service runner-0cd08893-project-921313-concurrent-0-mysql probably didn\'t start properly.
didn\'t respond in timely maner: runner-0cd08893-project-921313-concurrent-0-mysql (consider modifying wait_for_services_timeout: 30s).
...
Pulling docker image php:5.6-apache ...
ERROR: Build failed with: API error (500): Cannot start container 79fe94dd892de153c48aff8724be56326e770ff6970a70529fee4aff54a1ea06: Cannot link to a non running container: /runner-f6b6cbf0-project-921313-concurrent-0-mysql AS /runner-f6b6cbf0-project-921313-concurrent-0-pre/mysql
B] Following error I got yesterday, image was pulled but when trying to connect to mysql host using PHP PDO connection I recieved this error:
PDOException: SQLSTATE[HY000] [2002] No route to host
How to fix this? Is this a problem of shared runner or problem with .travis-ci.yml configuration?
Thank you for help.