Managing a landscape of microservices using Docker Compose
We’ve already seen how we can run a single microservice as a Docker container, but what about managing a whole system landscape of microservices?
As we mentioned earlier, this is the purpose of docker-compose
. By using single commands, we can build, start, log, and stop a group of cooperating microservices running as Docker containers.
Changes in the source code
To be able to use Docker Compose, we need to create a configuration file, docker-compose.yml
, that describes the microservices Docker Compose will manage for us. We also need to set up Dockerfiles for the remaining microservices and add a Docker-specific Spring profile to each of them. All four microservices have their own Dockerfile, but they all look the same as the preceding one.
When it comes to the Spring profiles, the three core services, product-
, recommendation-
, and review-service
, have the same docker
profile, which only specifies that...