I am trying to connect to an service (rabbitmq) from a container that I manually run in my bitbucket pipeline. But with no luck. Is this even possible?
Problem is that I have no glue what address/ip/name I could provide to my container for the service. The rabbitmq service starts fine and would be accessible under localhost:5672, but not from within my container, cause this will run in a diffrent network.
Here´s a small example what my setup looks like
image: microsoft/dotnet:sdk
pipelines:
default:
- step:
caches:
- dotnetcore
script: # Modify the commands below to build your repository.
- docker build -t company/image:tag -f ./company/service/Dockerfile ./company/service
- docker run -d --name mycontainer -p 8000:80 -e ASPNETCORE_ENVIRONMENT=Development -e MESSAGEBUS="$CONNECTIONSTRINGS__APITESTSRABBITMQ" company/image:tag
services:
- docker
- rabbitmq
definitions:
services:
rabbitmq:
image: rabbitmq:3-alpine
options:
docker: true
I have defined an environment variable CONNECTIONSTRINGS__APITESTSRABBITMQ with value rabbitmq://guest:guest@localhost:5672, but this is wrong cause rabbitmq is not accessible under this address from my container.
So is it possible to access a service from my container?