I'm trying to configure CI with GitHub Actions and I'd like to re-use 'docker-compose'-based logic/scripts in workflow scenario. In first step I start some background services using 'docker-compose'(or docker) and in the following step I'd like to reach those background services using host:port, but it fails. For example:
- name: Start background service
run: docker-compose up -d mysql
- name: Wait and check mysql container is running
run: |
sleep 120
docker ps
- name: Check connection
run: mysql -uroot -ppassword -hlocalhost -p3306
# or
- name: Check connection
run: mysql -uroot -ppassword -hmysql -p3306
# here I get 'could not resolve host' error
I'll get connection failure in both cases, despite connection params are correct and according 'docker ps' I have 'mysql' container running and ports are exposed properly.
Is there any way I can reach docker containers from a step? Preferably without need to run step's logic in another container.
I know that for such things GitHub Actions provide 'services', but I have quite a big piece of logic in docker/docker-compose and I'd really like to use it to avoid duplication.