Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How do I construct a bitbucket pipeline such that several containers can use the same network?

arttu.taipale
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 28, 2024

In my current pipeline configuration I have to build and run several docker containers in the same step due to the lack of an image container in the system, which other pipeline tools might have. Somehow it still doesn't let me connect the containers into the same network. I run my app frontend and backend with dependencies and do a quick health check on them with curl, and they seem to be fine. When I start the third docker container which contains E2E tests, I try and connect it to the same network that the frontend is in, using

 

network_name=$(docker inspect frontend | jq -r '.[0].NetworkSettings.Networks | to_entries | .[0].key')
docker run --network=$network_name tests
where frontend is the name of the container where frontend runs, and tests is the name of the image that has been successfully built for tests.

How do I connect these images to the same network?

1 answer

1 vote
Syahrul
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 3, 2024

G'day, @arttu.taipale 

Welcome to the community.

Due to security reasons we no longer allow docker --network=host in Bitbucket pipeline

Changes to make your containers more secure on Bitbucket Pipelines. 

As mentioned in the page:

network=host will no longer be allowed, there are a few other ways you can communicate between your code and containers.

To still allow your containers and code to communicate please see the following guidance.

If you need to communicate with a service running in docker from your build container, when starting the service provide it a port mapping using -p <host-port>:<container-port> you can then access the service using localhost:<host-port>.

If you need to communicate from a service running in docker to a service running in your build container, when starting the service provide it the following host entry using --add-host host.docker.internal:$BITBUCKET_DOCKER_HOST_INTERNAL you can then access the service using host.docker.internal:<port>.

If you need to talk between services running in docker, they have to be attached to the same docker network so you can address the services using <container-name>:<container-port> or consider using docker compose to run the services which creates a custom network for the compose stack.

I hope this helps.

Regards,
Syahrul

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events