matthias
matthias

Reputation: 947

Docker Swarm Linking

I want to create a Docker Swarm Cluster running an elastic search instance, a MongoDB instance and a grails app, each on a separate machine. I'm using Docker Machine to set up my Docker Swarm Cluster

swarm-01:
mongodb
mongodb_ambassador

swarm-02:
elasticsearch
elasticsearch_ambassador

swarm-03:
mongodb_ambassador
elasticsearch_ambassador
grails

The last step of my setup, running the actual grails app, using the following command:

docker run -p 8080:8080 -d --name grails-master --volumes-from maven --link mongo:mongo-master --link es:es-master my-grails-image

fails with error:

Error response from daemon: Unable to find a node fulfilling all dependencies: --volumes-from=maven --link=mongo:mongo-master --link=es:es-master

The ambassador containers and the maven data container are all running on the same node.

CONTAINER ID        IMAGE                     COMMAND                  CREATED             STATUS              PORTS                                                          NAMES
74677dad09a7        svendowideit/ambassador   "/bin/sh -c 'env | gr"   18 minutes ago      Up 18 minutes       9200/tcp, 9300/tcp                                             swarm-03/es
98b38c4fc575        svendowideit/ambassador   "/bin/sh -c 'env | gr"   18 minutes ago      Up 18 minutes       27107/tcp                                                      swarm-03/mongo
7d45fb82eacc        debian:jessie             "/bin/bash"              20 minutes ago                                                                                         swarm-03/maven

I'm not able to get the Grails app running on the Swarm cluster; any advice would be appreciated. Running all containers on a single machine works, so I guess I'm making a mistake linking the mongo and es instances to the grails app.

Btw I'm using latest Docker Toolbox installation on OS X.

Upvotes: 5

Views: 973

Answers (1)

Markus
Markus

Reputation: 3148

"linking" is deprecated in docker. Don't use it. It's complicated and not flexible enough. Just create an overlay network for swarm mode.

docker network create -d overlay mynetwork

In swarm mode (even in single container mode), just add every service who should communicate with another service to the same network.

docker service create --network mynetwork --name mymongodb ...

Other services in the same network can reach your mongodb service just over the hostname mymongodb. That's all. Docker swarm mode has battery included.

Upvotes: 2

Related Questions