January 2019
Intermediate to advanced
520 pages
14h 32m
English
We created an application that consists of microservices, and that doesn't have a persistent state – the application is empty on every restart. Fixing this is simple: map the persistent volume to a folder of the container. Since no one microservice of our application keeps the data in files, but the PostgreSQL database does, we only need to attach a folder to a database container. Copy docker-compose.test.yml to docker-compose.prod.yml and add the following changes:
services: db: image: postgres:latest restart: always environment: - POSTGRES_USER=postgres - POSTGRES_PASSWORD=password volumes: - database_data:/var/lib/postgresql/data # other containers definitionvolumes: database_data: driver: local ...
Read now
Unlock full access