It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Is it possible to run multiple containers (using docker compose) and make a network connection

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

 

1 answer

1 accepted

0 votes
Answer accepted

This ticket can be closed.

The reason the DNS couldn't find container1 is because the container1 exited with an error. (the logs didn't describe it)

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Bitbucket Pipelines

What We Learned When We Researched Open Source Vulnerabilities in 7 Popular Coding Languages

...hey are a part of us, shaping how we interact with the world around us. The same holds true for programming languages when we think about how different kinds of vulnerabilities raise their heads in t...

1,055 views 0 3
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you