Scaling Docker containers in Rancher with different but persistent volumes

 ̄綄美尐妖づ 提交于 2019-12-04 21:29:07

In current versions of rancher (v1.4 at this time) storage drivers can be plugged in at the environment infrastructure level. This allows you to create volumes that are scoped at the environment, stack, or container.

For your use case, it sounds like per-container scope is what you need. Using rancher-compose you do something like:

version: '2'
services:
  foo:
    image: busybox
    volumes:
    - bar:/var/lib/storage
    command: /bin/sh -c 'while true; do sleep 500; done'
volumes:
  bar:
    per_container: true

Then, rancher-compose up -d will create the stack and service with one container and a unique volume. rancher scale foo=2 will create another container with its own volume, etc. You can also specify volume storage drivers for each volume like rancher-ebs or rancher-nfs with their respective options.

I think what you want is to have difference instances of the entire project. scale implies identical clones, but if they have different data, they are not identical.

Instead of using scale, I would start different instances with different project names: https://docs.docker.com/compose/overview/#multiple-isolated-environments-on-a-single-host

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