I current play with docker, in details with docker swarm. And now I have two questions
I create 1 manager and 3 worker nodes. I create a service and can scale it. Everything works fine.
But current the manager will also used as container host for the service. And I think this is not the right way. So here my question. How can I prevent that the manager will be used for the service?
And I create the service with a httpd image for playing and the published port is 80. I can only access to this service over the manger url or ip. Is this the normal behavior? Maybe I have not read the documention enough Is this normal, how it works also in production environment?
Your placement constraint “node.role != manager” should be equal to “node.role == worker”.
You publish the port the good old way, which defaults to publishing the port to the ingress network, thus beeing affected by mash routing, all nodes in the swarm bind the port and forward it to a replica of the service.
Though, you might want to use the explicit long syntax to be sure. If you want to bypass the ingress network, you can use “mode: host” instead, which will bind the port to the workers only!
Why would you want to use 5 replicas on 3 worker nodes? If i were you, I would use the node.role==worker constraint, declare the deploy.mode to global and publish the port in mode:host
One more thing: beware of the restart_policy condition “on-failure”. It does not necessarily mean that an ended container will be recrated. You might want to stick to “any” instead.