Hello, I would like some help or advice with a docker-compose on an ec2 instance. I am deploying an application called moodle with docker-compose. When I start it, it creates the following volumes:
#docker-compose.yml
volumes:
mariadb_data:
driver: local
moodle_data:
driver: local
moodledata_data:
driver: local
traefik_letsencrypt:
driver: local
#volumenes instance var/lib/docker/volumes
[root@ip-10-0-0-200 volumes]# ls
backingFsBlockDev metadata.db moodle_mariadb_data moodle_moodle_data moodle_moodledata_data moodle_traefik_letsencrypt
reference in docker-compose:
volumes:
- 'mariadb_data:/bitnami/mariadb'
volumes:
- 'moodle_data:/bitnami/moodle'
- 'moodledata_data:/bitnami/moodledata'
If I want to make my data persistent and more flexible, or for example terminate my instance and mount that ebs on another instance, should I change the volume path? Or is everything already structured well this way? I would also like to know if in case I have to reference the direct path of the docker volume in this case var/lib/docker/volumes/moodle_moodledata_data it does not affect the directory permissions because I can only enter this directory with the root user using sudo -i
In general I would like my data to never be lost even if I change instances, I would like some advice on good practices, thank you very much in advance.
By default, Docker volumes are stored in /var/lib/docker/volumes/, which works fine as long as the instance remains the same. However, if you terminate the EC2 instance, all of the data stored on that instance, including Docker volumes, will be lost unless you've attached an external EBS volume.