Hello,
I'm trying to use my local docker-compose configuration to run functional tests over a bitbucket pipeline.
Important to say that I was able to download and install docker-compose on the container image and all the containers have been built successfully.
The problem is when one container tries to connect to another container it can't find it's address using the DNS. It seems that they don't share the same network and therefore, I can't access these containers.
here is the error
Trying to connect to server...
Server Error: getaddrinfo ENOTFOUND container1 container1:4000
I have read that bitbucket pipeline uses a bitbucket-pipeline docker plugin to restrict network access, but I can't figure out how to make these 2 containers communicate with each other - which seems like a trivial scenario for testing.
attaching here the docker-compose.yml and bitbucket-pipelines.yml configuration files
version: "3.6"
networks:
bitbucketnet:
driver: bridge
services:
mysql:
image: mysql:5.6
container_name: mysql
volumes:
- ../../deps/db-local/:/docker-entrypoint-initdb.d/
networks:
- bitbucketnet
environment:
MYSQL_LOG_CONSOLE: "false"
MYSQL_ROOT_PASSWORD: "somepass"
ports:
- 3306:3306
container1:
container_name: container1
depends_on:
- mysql
networks:
- bitbucketnet
build: ../../services/container1
volumes:
- "../../services/c1/src:/app/src"
- "../../services/c1/package.json:/app/package.json"
- "../../services/c1/package-lock.json:/app/package-lock.json"
environment:
NODE_ENV: test
DB_HOST: mysql
DB_NAME: dbname
DB_USER: root
DB_PASSWORD: somepass
DB_PORT: 3306
PORT: 4000
ports:
- 4000:4000
# Functional tests
tests:
container_name: container1-tests
depends_on:
- container1
networks:
- bitbucketnet
build: ./
environment:
SERVER_URL: http://container1:4000
DB_ENDPOINT: mysql://root:somepass@mysql:3306/dbname
I have created the following bitbucket-pipeline configuration like this:
image: node:11.10.1
pipelines:
custom: # defines that this can only be triggered manually or by a schedule
ManualBuild: # The name that is displayed in the list in the Bitbucket Cloud GUI
- step:
name: Run Functional Tests
services:
- docker
caches:
- docker
script:
- set -eu
# Add python pip and bash
- apt-get update && apt-get -y install python3-minimal python3-pip
# Install docker-compose via pip
- pip3 install docker-compose
- docker -v
- docker-compose -v
- cd ./services/tests
- docker-compose build tests
- docker-compose run tests
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.