Attaching Docker volumes to an existing application
The previous chapter was focused on a Task Manager application using a Redis database. Being a database, Redis is subject to backups and other disk operations.
Our previous Redis Compose configuration is as follows:
services: redis: image: redis ports: - 6379:6379 labels: - com.packtpub.compose.app=task-manager
Redis has various options for persistence options (https://redis.io/topics/persistence). There are options from point-in-time to AOF (Append-Only File)-based persistence. We will focus on the point-in-time snapshot option that Redis provides, and we will use a volume to store those snapshots.
By default, .rdb
backups on the Redis Docker image are stored within the /data
directory. We will mount a volume to that location.
First, we will create the volume...