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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.