make a url accessible from one job to another on circleci

  automated-tests, circleci, docker, testcafe, testing

I have two jobs, ‘build’ and ‘test’. ‘build’ job builds and runs the docker image. I’m able to access the url http://0.0.0.0:3000 to run my tests from the same job. But when I run my tests from ‘test’ job, it doesn’t recognize http://0.0.0.0:3000.

jobs:
  build:
    .
    .<other code>
    .
    steps:
      - run:
          docker build . -t company/project:${CIRCLE_SHA1}
          docker run --net=host -e DOPPLER_TOKEN=${DOPPLER_TOKEN} -d company/project:${CIRCLE_SHA1} "npm run dev"
          docker run --net=host -v ~/projects/project_name/tests/:/tests -v ~/projects/project_name/node_modules/:/node_modules -it testcafe/testcafe chromium:headless

The above code seems to run perfectly fine.

jobs:
  build:
    .
    .<other code>
    .
    steps:
      - run:
          docker build . -t company/project:${CIRCLE_SHA1}
          docker run --net=host -e DOPPLER_TOKEN=${DOPPLER_TOKEN} -d company/project:${CIRCLE_SHA1} "npm run dev"
  test:
    working_directory: ~/projects/project_name
    machine: true
    steps:
      - checkout
      - run:
          docker run --net=host -v ~/projects/project_name/tests/:/tests -v ~/projects/project_name/node_modules/:/node_modules -it testcafe/testcafe chromium:headless

This doesn’t work. It gives an error

A request to "http://0.0.0.0:3000" has failed. You can find troubleshooting information for this issue at "https://go.devexpress.com/TestCafe_FAQ_ARequestHasFailed.aspx". Error details: Failed to find a DNS-record for the resource at "http://0.0.0.0:3000"

I’ve also tried the curl command to access the url and it gives an error
curl -o - http://0.0.0.0:3000 curl: (7) Failed to connect to 0.0.0.0 port 3000: Connection refused

Any help regarding this would be very helpful.

Source: Docker Questions

LEAVE A COMMENT