How to deal with persistent storage (e.g. databases) in Docker

前端 未结 14 1275
野的像风
野的像风 2020-11-22 11:54

How do people deal with persistent storage for your Docker containers?

I am currently using this approach: build the image, e.g. for PostgreSQL, and then start the c

14条回答
  •  -上瘾入骨i
    2020-11-22 12:05

    There are several levels of managing persistent data, depending on your needs:

    • Store it on your host
      • Use the flag -v host-path:container-path to persist container directory data to a host directory.
      • Backups/restores happen by running a backup/restore container (such as tutumcloud/dockup) mounted to the same directory.
    • Create a data container and mount its volumes to your application container
      • Create a container that exports a data volume, use --volumes-from to mount that data into your application container.
      • Backup/restore the same as the above solution.
    • Use a Docker volume plugin that backs an external/third-party service
      • Docker volume plugins allow your datasource to come from anywhere - NFS, AWS (S3, EFS, and EBS)
      • Depending on the plugin/service, you can attach single or multiple containers to a single volume.
      • Depending on the service, backups/restores may be automated for you.
      • While this can be cumbersome to do manually, some orchestration solutions - such as Rancher - have it baked in and simple to use.
      • Convoy is the easiest solution for doing this manually.

提交回复
热议问题