Service containers in gitlab jobs don't have any way of communicating with other service containers in the same job
I'm attempting to create a job for running selenium tests.
I have three services:
- Web server service
- MYSQL service
- Selenium service
In this use case all the services need to be able to talk to each other. But I couldn't get it working, so I wrote a web script to cat /etc/hosts
in the web container, then curled it from the job script and saw this:
$ curl -s https://local.company.com/dummydebug.php 2>&1
string(174) "127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.8 e76cd5e56588
"
Here's an excerpt of my job:
end_to_end:
stage: 'test'
image: 'copmany/ci:production'
script:
- 'php artisan --env=local migrate --seed'
- 'curl -s https://local.company.com/user/login 2>&1'
- './vendor/bin/phpunit --group=BrowserTests'
services:
- 'mysql:5.7'
- name: 'company/testdummy:staging'
alias: 'local.company.com'
- name: 'selenium/standalone-chrome'
alias: 'selenium'
As you can see the web container doesn't have host entries for any of the services! However if I do a cat /etc/hosts
in the job script I see:
127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
172.17.0.7 local.company.com 9748c399f5f6 runner-UCu_5zqb-project-6070333-concurrent-0-company__testdummy-2
172.17.0.8 selenium__standalone-chrome 7122907a8059 runner-UCu_5zqb-project-6070333-concurrent-0-selenium__standalone-chrome-3
172.17.0.8 selenium-standalone-chrome 7122907a8059 runner-UCu_5zqb-project-6070333-concurrent-0-selenium__standalone-chrome-3
172.17.0.8 selenium 7122907a8059 runner-UCu_5zqb-project-6070333-concurrent-0-selenium__standalone-chrome-3
172.17.0.2 mysql 0ce6ef257424 runner-UCu_5zqb-project-6070333-concurrent-0-mysql-0
172.17.0.7 company__testdummy 9748c399f5f6 runner-UCu_5zqb-project-6070333-concurrent-0-company__testdummy-2
172.17.0.7 company-testdummy 9748c399f5f6 runner-UCu_5zqb-project-6070333-concurrent-0-company__testdummy-2
172.17.0.9 runner-UCu_5zqb-project-6070333-concurrent-0
Giving services a way to communicate between each other would open up a lot of possibilities in this use case.