Docker Community Forums

Share and learn in the Docker community.

Different settings (configuration) for each replica

Hi all, Iā€™m pretty new to docker :slight_smile:

I want to have different settings for each replica - different volume mounts. My searches havent come up with anything useful, so I dont think this can be done.

The closest hint I could find was this topic

But Im not sure, are multiple replicas the same as multiple services in a stack (defined in a single compose.yml file)?
Both multiple replicas and multiple services result in multiple containers, right? So whats the difference? Will the docker orchestrator work differently when using replicas instead of services?

Snipped docker compose file with multiple replicas:

version: "3.7"
services:
  web:
    image: portal:0.0.1
    --- snipped content ---
    volumes:
      - "/home/portal/Dev/Data:/app/Data"
    deploy:
      replicas: 3

Snipped docker compose file with multiple services:

version: "3.7"
services:
  web1:
    image: portal:0.0.1
    --- snipped content ---
    volumes:
      - "/home/portal/Dev/Data1:/app/Data"
    deploy:
      replicas: 1
  web2:
    extends: web1
    volumes:
      - "/home/portal/Dev/Data2:/app/Data"
  web3:
    extends: web1
    volumes:
      - "/home/portal/Dev/Data3:/app/Data"

TL;DR: I want to have data from each container in a separate folder on the docker host. Is this possible when using replicas?

Thanks, BR
Nejc