1

I've got an issue with running Cypress tests off a container.

In my docker-compose I've following services: users, client, users-db, nginx and they're all running.

my baseUrl is set to "http://nginx" because I read somewhere that I need to reference the service the server is running on which in my case is nginx.

I've tried also "http://localhost" and "http://client"

but when I run docker run -it -v $PWD:/e2e -w /e2e cypress/included:4.11.0 I keep getting Cypress could not verify that this server is running

Any feedback that will lead to resolution is much appreciated.

Mark
  • 1,385
  • 3
  • 16
  • 29

2 Answers2

0

This happens because your cypress container is not part of the network used by the docker-compose containers.

Use docker network ls to see the list of available networks. There should be one named <docker_compose.yml's directory>_default.

You can then run a container in a specific network by specifying the --network <network_name> flag in docker run.

This container should be able to talk with the compose containers by using their service name as the hostname

Omer Tuchfeld
  • 2,886
  • 1
  • 17
  • 24
  • Thank you so much ! This one was quite a headache for me. I noticed I was 1 vote away from my question being closed. Don't know why though. – Mark Aug 04 '20 at 15:59
  • So when running Cypress container outside of the network of other services I need to explicitly tell Cypress to which network to connect to to find the server. Nice ! – Mark Aug 04 '20 at 16:01
0

My issue is I have

network_mode: host

in my docker-compose file. Removing it made it pass.

xwa130
  • 579
  • 4
  • 6