Skip to main content

Posts

Showing posts from December, 2020

How to get two docker-compose services to talk to each other

Imagine you have two services that are started by two different docker-compose files. And you would like these two services to talk to each other. How can we achieve this? Why would you want to do this in the first place? I had a use-case for this, that's why! The use case was as follows: I have a docker-compose file that contains linux-swag and mysql . These are resources that are not updated very often. So I can start them and forget about them. I have another docker-compose file that contains a Spring Boot application. This application can have different versions (prod, staging, dev). And these version get automatically deployed on each git-push.     The nginx serves HTTPS and reverse-proxies connections to the spring application. The spring application connects to the mysql to read and store stuff. The Secret Sauce The way to do this is with docker-compose networking . You see by default each docker-compse file creates it's own bridge network. So by default, in my exampl