docker-compose creating multiple instances for the same image

后端 未结 3 2092
长情又很酷
长情又很酷 2020-12-13 01:26

I need to start multiple containers for the same image. If i create my compose file as shown below, it works fine.

version: \'2\'

services:
  app01:
    im         


        
3条回答
  •  伪装坚强ぢ
    2020-12-13 02:03

    You can do it with replica as mentioned in https://docs.docker.com/compose/compose-file/#replicas

    version: '3'
    services:
      worker:
        image: dockersamples/examplevotingapp_worker
        networks:
          - frontend
          - backend
        deploy:
          mode: replicated
          replicas: 6
    

    Edit (from the comments): One can use docker-compose --compatibility up to make docker accept deploy section without using swarm.

提交回复
热议问题