Database operations

In the previous chapters, we explained that you can have single or multiple databases for your application. This is one of the advantages of microservices; you can scale a single microservice when you realize that it is getting a big load by dividing the database into a single database for a specific microservice.

For our example, we will create a single database for the secrets microservice. For storage software, we decided to use Percona (a MySQL fork), but feel free to use any database you like.

To create a database container in Docker is very easy. We only need to edit our docker-compose.yml file, and change the links section of the microservice_secret_fpm service with the following:

    links:    - autodiscovery    - microservice_secret_database ...

Get PHP Microservices now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.