Run project with docker-compose

Hello Gitlab community !

I try to launch my multi-layer project through docker-compose and run some end-to-end tests on it with cypress.
My .gitlab-ci.yml file :

test:
  stage: test
  image: docker
  variables:
     DOCKER_DRIVER: overlay
   services:
     - docker:dind
 
   before_script:
     - apk add --no-cache python python-dev py-pip libffi-dev openssl-dev gcc libc-dev make
     - pip install docker-compose
     - apk add --no-cache --update nodejs npm
     - npm install
   script:
     - docker-compose up -d
     - cypress run
     - docker-compose stop

But it seems that when gitlab-runner run this job, it creates a separate container to start my docker-compose containers and run my tests in another container. So when my tests try to reach the http://localhost URL, it fails.
When I execute a docker ps on my Gitlab host , I’ve got the following :

docker ps
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS               NAMES
07b867953ebc        61b2e482e9de        "docker-entrypoint.s…"   8 minutes ago       Up 8 minutes                            runner-vTpeNzvF-project-8-concurrent-0-build-4
1923a5d9c4ae        a6e51fd179fb        "dockerd-entrypoint.…"   8 minutes ago       Up 8 minutes        2375-2376/tcp       runner-vTpeNzvF-project-8-concurrent-0-docker-0

It’s probably a problem in my runner configuration but I can’t find a way to make it works.

Thanks in advance !

OK I found a solution to my problem !

Instead of running the cypress tests directly, I run them through a cypress image container, and I connect this container to the network of my app containers. Like that :

docker run --network my-app_default -v $PWD:/e2e -w /e2e cypress/included:4.0.2 cypress run --config baseUrl=http://web

And I had to change the baseURL to use the host of my web container from dock-compose.