Docker-compose exclude service by default

后端 未结 3 1535
栀梦
栀梦 2021-02-14 03:59

If I have a great many services defined in a docker-compose project, how can I exclude a service from the default docker-compose up command?

For example, I

3条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-14 04:28

    Hey I hit this question on github today: "Define services which are not started by default" https://github.com/docker/compose/issues/1896

    Well, you can't. But I have done this workaround since I have quite a lot of services and adding more. I did dummy service with just some dummy image and custom command and then I set my desired services as dependencies:

      main-services:
        image: docker4w/nsenter-dockerd # you want to put there some small image
        command: sh -c "echo start"
        depends_on:
          - postgres
          - consumer-backend
          - prisma
          - api-gateway
          - adminer
          - frontend
    

    Then I wrote into my readme.md:

    Use this to run everything
    docker-compose up -d main-services

    Create database structures
    docker-compose up deploy

    Seed database with data
    docker-compose up seed

    Using dummy services to group things was easier than anything else I have seen so far.

提交回复
热议问题