0

I'm trying to create a docker container 'bar_foo' on node1.com that links to another container on another node 'foo_bar:node2.com'.

The problem is i'm getting error.

"Could not get container for foo_bar" 

i've made sure that the foo_bar container is running successfully, other containers on the node2.com is linking correctly to it.

I have also tried to ping node2.com successfully.

Creating the container is done through ansible:

- name: start container
  docker_container:
    image: bar_foo_image
    name: bar_foo
    log_driver: json-file
    log_options:
      max-size: 100m
      max-file: "3"
    links:
      - "foo_bar:node2.com"
A.Jac
  • 1,443
  • 3
  • 17
  • 24

1 Answers1

1

What you are trying to is not possible just using docker-compose. Docker-compose works on a single machine to launch containers on that machine.

You need to use Docker Swarm if you are interested in setting up a multi node cluster.

On your node 1 you need to execute

docker swarm init

And on your node 2 execute the output from above command. Then you need to use docker stack deploy command. For more details refer to below

https://docs.docker.com/engine/reference/commandline/stack_deploy/

Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265