Docker-compose recommended way to use data containers

会有一股神秘感。 提交于 2019-12-06 13:37:38

The recommended way is to remove dependencies between containers since these dependencies don't logically apply to swarm where containers may be running on different hosts where they can't share files (this is why volumes-from was removed from the version 3 format). Data containers had already been deprecated after the introduction of of named volumes, despite some out of date documentation suggesting otherwise.

The options that I can think of off the top of my head include:

  1. Using a version 2 compose file and not using swarm mode. There's no need to upgrade to the version 3 format if you aren't using this with swarm mode.

  2. Directly add your data to each container.

  3. Rearchitecture your app to split apart components differently. I'm not clear on the use case of application code in both nginx and another container, seems like it should only be one or the other.

  4. Create a data sync utility container that has all of the app data, runs globally across the swarm, and pushes out changes to volumes on each of the swarm nodes on startup. This could also poll something like a git repo and constantly update the local volume on any changes. Your other containers then point to this local named volume.

  5. Point the containers to a remote volume, like NFS, so you only need to update the data once from any host and eliminate any hosts being out of sync, but also adding extra latency in any reads.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!