Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 725
matthias Avatar asked Oct 31 '22 20:10

matthias


1 Answers

"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.

like image 179
Markus Avatar answered Nov 08 '22 05:11

Markus