Join 1M+ other developers and:
- Get help and share knowledge in Q&A
- Subscribe to topics of interest
- Get courses & tools that help you grow as a developer or small business owner
Persistent database with docker-compose not working
I am running a docker-compose project in a DigitalOcean Docker droplet.
I also have a persistent volume.
It has been mounted on
docker-compose.yml, I defined the volume for the database:
... db: image: postgres:12.0-alpine volumes: - postgres_data:/var/lib/postgresql/data/ env_file: - ./postgres/.env ... volumes: postgres_data: ...
and I’ve created the symbolic link with
sudo ln -s /mnt/volume_fra1_01 postgres_data
But I the database is not persistent. When I purge the containers the database is gone. Somehow
/var/lib/postgresql/data/ is not using the mounted volume.
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.×