Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Run multiple docker-compose (one per machine)

I'm testing a lot of micro-services. I group some of them in a docker-compose file like:

agent:
  image: php:fpm
  volumes:
    - ./GIT:/reposcm:ro
  expose:
    - 9000
  links:
    - elastic

elastic:
  image: elasticsearch
  expose:
    - 9200
    - 9300

Then I start the first one by $docker-compose up

In another directory I would start another "micro-service" by $docker-compose up. But I get:

ERROR: Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.

How can I specify the docker machine for a docker-compose.yml?

$docker-machine ls
NAME      ACTIVE   DRIVER       STATE     URL                         SWARM
default   -        virtualbox   Running   tcp://192.168.99.101:2376
my_test   -        virtualbox   Running   tcp://192.168.99.102:2376

Only the default machine can run a "micro-service".

How can I specify a target machine of a docker-compose.yml?

like image 818
C Würtz Avatar asked Sep 25 '22 12:09

C Würtz


1 Answers

Make sure that, in the shell you want to run your second docker-compose up, you have done first a docker-machine env:

docker-machine env <machine name>
eval "$(docker-machine env <machine name>)

That will configure the right environment variables for docker commands to contact the right machine (the right docker daemon).

like image 182
VonC Avatar answered Sep 28 '22 04:09

VonC