Docker Community Forums

Share and learn in the Docker community.

Create a volume for each replica when create a service?

I need to deploy a nginx service with 4 replica using the compose file like the following.
Is is possible that it create a volume for each replica automatically? If it is possible, what is the format to specify
in the compose file?

version: “3”

services:

nginx:
image: nginx
ports:

  • "5000:80"
    volumes:
  • log:/var/log/nginx

deploy:
replicas: 4
restart_policy:
condition: on-failure
volumes:
log: