How do I suppress docker-compose up mapping to the host IP range (for multiple instances)?
Context: I'm looking to run unit tests in Jenkins where we have a docker engine on the master and each slave.
I want to spin up some containers for a unit-integration test and shut them down after.
I want multiple tests to be able to run the same docker compose file simultaneously, without contention.
docker-compose -f "my-test-docker-compose.yml" -p "ab2de2f38c" up -d -t 100
and for the second execution:
docker-compose -f "my-test-docker-compose.yml" -p "34cd832b7" up -d -t 100
I find the first network binds to 0.0.0.0/< port > which causes conflicts when the second execution happens.
Cannot start service zookeeper: driver failed programming external connectivity on endpoint 34cd832b7_zookeeper_1 (c2b928530cfdc7aee17): Bind for 0.0.0.0:22181 failed: port is already allocated
Have tried adding networking to each service and at the bottom and then created the network with docker network create
. No dice, thus far.
Ideally want a solution that doesn't require the docker-compose.yml file to change as this gives testers a burden.
Is there a way to suppress any mapping between the containers and the host's IP range and then get the IP from outside the network using docker ps
and docker inspect
in conjunction.
The ideal would be:
c, err := docker.New("my-test-docker-compose.yml")
//handle err
c.Up()
//connect to a service..
s, err := service1.New(c.GetSocket("serv:1234"))
//handle connection error
//do testing
c.Down()
Any suggestions would be ideal. It may be the only options are to re-work every docker-compose.yml to remove all external network mappings, which is painful or to spawn a docker within a docker to completely isolate the network. Painful.
Any suggestions how to pretty much specify --network=none
so we get no 0.0.0.0/ bindings would be great. I note there is a golang docker library (libcompose) in this area, but sadly it's no longer maintained.
Thank you,
alex