Can all docker swarm instances run on same machine? Can all docker swarm instances run on same machine? docker docker

Can all docker swarm instances run on same machine?


I've copied your questions and tried to answer them.

  • Do all instances in a swarm have to run on different machines or can they all run on the same? (if having limited amount of hardware and just wanting to try swarm mode)
    • You can have only one machine in a swarm and run multiple tasks of the same service or in other words your scale of a service can be more than the number of actual machines. I have a testing swarm with a single machine and one with three and it works the same way.
  • Do I have to run swarm mode to be able to communicate between instances?
    • You have to run your docker in swarm mode in order to create a service, please see this link
  • What is the key difference between swarm mode and just running a number of containers as regular?
    • The key difference afaik is, that when a task goes down, docker puts another task up automatically. And you can easily scale your services, which means you can easily have multiple tasks just by scaling your service (up or down). As of running a container - when it goes down you have to manually start another.
  • What are the options of communication between instances of containers? (in swarm and in regular mode) http? named pipes? other?
    • I've currently only tested with a couple of wildfly servers in a swarm, which are on the same network. I'm not sure about others, but would love to find out. I've only read about RabbitMQ, but can't seem to find the link atm.
  • If using http communication between containers on same machine, will it be roughly similarly as fast as named pipes?
    • I can't say.
  • Is there any built in support for a message bus or similar in Docker?
    • I can't say.
  • Are there any GUI's for designing, managing, testing and/or debugging Docker swarms?
    • I've tested rancher and portainer.io, for a list of them I found this link
  • Can a container list other containers, stop/restart some and start new ones?
    • I'm not sure why would you want to do that? And I guess it's possible, see this link
  • Can a container be given access to OS-features (Linux in my case) to configure for instance a reverse proxy or port forwarding on the WAN?
    • I can't say.


@namokarm did a great job, and I'm filling in the gaps:

  • Benefits of Swarm over docker run or docker-compose.
  • All communications between containers has to be TCP/UDP etc. You could force two containers to only run on a single machine, then bind-mount their socket so they skip the network, but that would be a bit of an anti-pattern. Swarm is designed for everything to be distributed and TCP/UDP.
  • In a few cases, such as PHP-FPM + Nginx, I recommend bundling both in the same container (against docker best practices, but trust me it's easier than separate containers). This will ensure they scale together (1-to-1 relationship) and stay fast since they use local sockets to communicate). I only recommend this for a few setups like this, the other being ColdFusion + Nginx because they are two parts of the same tool that provide a HTTP response... I don't recommend bundling images together in nearly all other cases, but I'm open to ideas :).
  • Rancher is no longer supporting Swarm. Portainer and SwarmPit are GUI options.
  • Yes a container running something like Portainer/SwarmPit or controlling the Docker socket through a bind-mount or TCP can control the whole Swarm. This is how all docker management works :)
  • For reverse proxy, you would run a container-based proxy like Traefik or Docker Flow Proxy, which sets up HAProxy for Docker and Swarm.

Many of these topics are discussed in my DockerCon talks: https://www.bretfisher.com/dockercon18/