I have two separate projects which have their own docker-compose.yml files. They both want to start a database.
Is it possible that if the DB instance already exists and is running, the second Docker Compose can just use that running instance instead of trying to create its own?
The database is a simple example. Let's say the DB is setup to run on port 5555:5555. When I first run docker compose up and the DB starts, it's running on port 5555. Great! Now later on I run docker compose up for the second project (yes, I'll need to have both running at the same time) and it's setup to run the exact same DB on the exact same port, but that will fail/crash with a 'port in use' error.
I know I can just have each file have their own instance run on their own port. I get that. But it's annoying because then I'll need to have different connection strings for tooling, like DB Administration UI tools.
So I just want ONE instance of the DB to be running on my localhost to "keep things simple". Is this possible?
docker-compose.ymlfile for the additional instance that specifies the network for the first instance. Here you don't need to spin up a database service, just spin up the new instances you need.docker-compose.ymlfiles use? and when a someone runs the seconddocker-compose.ymlbecause it's the same custom network, it will check to see if the instances asked for (in the 2nd file) are running and if so ... skip/ignore?docker psetc. Then I'd start up just the new service, or all services, depending on the answer.