Docker Community Forums

Share and learn in the Docker community.

How to make a swarm work?


(Alexpaxis) #1

Hi guys. I’m new to docker and i have a project to create. I have a web site running as a docker container and i want to create another container to perform a process. I need these two containers to exchange data. So i though about putting them together in a swarm mode, the web containerA as a service running as manager and the containerB as a worker. Is my idea viable? And if yes how it is done? cause i read the documentation about swarm nodes and services but didn’t get much. thanks in advance


(Eldeberde) #2

Hi, I think you are not understanding some concepts

You can create a docker swarm with 1 or more nodes (servers or virtual machines)
#>docker swarm init --advertise-addr YOUR SERVER IP

Each node can be deployed as manager or worker (You will need at least 1 manager, and it is not recommended use a pair number of managers)

And then you can deploy the services, if you need communication between services you can use the same docker network to allow it (i think this is the easy way but there are many options, like a stack…)

about networks

Hope help you

Regards


(Alexpaxis) #3

thank you very much for your reply. i will look into these links you sent me. but this is the right way isn’t it? i mean i make my website the manager and the background processing unit the worker? or the website is independent and i make both manager and worker the background processing unit? thank you very much


(Eldeberde) #4

Hi Again.

manager or worker can only be the nodes (Virtual machines or physical servers)

The services (containers) can run on a manager or on a worker, but i cannot understand you with make website manager or make background process worker.

About communicate services i think it should be enough if you deploy both in the same network. Swarm has an “internal DNS” and you can use the service name instead the ip.

from the service 1, you can use the command ping service2 and it will be resolved internally if both containers are running on the same network.

Regards


(Alexpaxis) #5

hi eldeberde,
sorry for the trouble. I get it now. i was confused and thought that a container would be the manager. If i may ask i want for each user that logs in the website (service1), a docker container(service2) will start up and process the uploaded files from each user. Can this be done automatically? i mean for e.x. 10 users in service1 there will be created 10 service2 (containers) doing the same thing simultaneously each one for each user and then shut down.
Sorry for the trouble and thank you for your replies.