Docker Community Forums

Share and learn in the Docker community.

Variable substitution for replicas in Docker stack


(Ndutertry) #1

Hi,

I would like to use variable substitution in docker compose file for the replicas value. For instance:

version: "3.3"
  services:
  test:
    image: nginx
    deploy:
      replicas: ${NGINX_REPLICAS}
    ports:
      - 8080:80

But when deploying such a stack (with NGINX_REPLICAS=2 for instance), I run into the following error:

services.test.deploy.replicas must be a integer

Do you know if there is a way to make it work ?


(Kirkbdh) #2

I’m seeing the same issue with compose version 3.x, also having issues for restart_policy.delay and restart_policy.max_attemps which leads me to think that variable substtuion just doesn’t work in the stack deploy section.