Can't communicate between docker containers in Gitlab-CI

Viewed 317

In the second stage of my CI pipeline (after building a fresh docker image). I'm using other docker containers to test the new image, but I'm not able to get send any requests between these containers. My CI config is as follows:

stages:
    - build
    - test

services:
    - docker:dind

variables:
    # Enable network-per-build to allow gitlab services to see one another
    FF_NETWORK_PER_BUILD: "true"
    DOCKER_DRIVER: overlay2
    DOCKER_HOST: tcp://docker:2376
    DOCKER_TLS_CERTDIR: '/certs'
    IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG
    # IMAGE SETTINGS
    NODE_ENV: "development"
    API_URL: "http://danielgtaylor-apisprout:8000"
    PORT: 8080

build:
    stage: build
    image: docker
    script:
        - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
        - docker build -t ${CI_REGISTRY_IMAGE}:test .
        - docker push ${CI_REGISTRY_IMAGE}:test

test:
    stage: test
    image: docker
    services:
    - docker:dind
    - name: ${CI_REGISTRY_IMAGE}:test
      alias: server
    script:
        - docker run --rm --name apisprout -d -v $CI_PROJECT_DIR/v2-spec.yml:/api.yaml danielgtaylor/apisprout /api.yaml
        - docker run --rm --name newman -v $CI_PROJECT_DIR:/etc/newman postman/newman run 'Micros V2.postman_collection.json'

And receive the following error ENOTFOUND server server:8080

I have also tried with a new bridge network:

test:
    stage: test
    image: docker
    services:
    - docker:dind
    script:
        - docker network create -d bridge mynet
        - docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY 
        - docker run -d --network=mynet --hostname=server ${CI_REGISTRY_IMAGE}:test
        - docker run --rm --network=mynet --hostname=apisprout --name apisprout -d -v $CI_PROJECT_DIR/v2-spec.yml:/api.yaml danielgtaylor/apisprout /api.yaml
        - docker run --rm --network=mynet --name newman -v $CI_PROJECT_DIR:/etc/newman postman/newman run 'Micros V2.postman_collection.json'

But I receive the same error ENOTFOUND server server:8080.

I am unable to run the docker run containers as services as I don't believe attaching volumes is supported yet. I'm also running this on Gitlab.com, not a private runner.

0 Answers
Related