Running multiple projects using docker which each runs with docker-compose

后端 未结 3 919
轮回少年
轮回少年 2020-12-24 13:32

We are using microservices approach to build our product. We are using some projects which each uses docker-compose to run. The problem is that in development environment, i

3条回答
  •  猫巷女王i
    2020-12-24 14:30

    Am not 100% sure on your question so this will be a wide answer.

    1) Everything can be in the same compose file if it's running on the same machine or server cluster.

    #proxy
    haproxy:
      image: haproxy:latest
      ports:
        - 80:80
    
    
    #setup 1
    ubuntu_1:
      image: ubuntu
      links:
        - db_1:mysql
      ports:
        - 80
    
    db1:
      image: ubuntu
      environment:
        MYSQL_ROOT_PASSWORD: 123
    
    
    #setup 2
    ubuntu_2:
       image: ubuntu
       links:
         - db_2:mysql
       ports:
        - 80
    
    db2:
      image: ubuntu
      environment:
        MYSQL_ROOT_PASSWORD: 123
    

    It's also possible to combine several yml files like
    $docker-compose -f [File A].yml -f [File B].yml up -d

    2) Every container in the build can be controlled separately with compose.
    $docker-compose stop/start/build/ ubuntu_1

    3) Using $docker-compose build it will only rebuild where changes have been done.

    Here is more information that could be useful https://docs.docker.com/compose/extends/#extending-services

    If none of above is correct please example of build.

提交回复
热议问题