Search code examples
dockerdocker-composedocker-swarmdocker-network

How to use Docker Compose with legacy Docker Swarm


I am trying to deploy my app with Compose and Swarm. Currently I don't want to upgrade my docker-compose.yaml from v2 to v3. So I am only able to do that with standalone(legacy) swarm rather that docker swarm mode based on Stoneman's answer and official Swarm documents.

Following the official instruction, I successfully set up a swarm cluster. I ran docker -H :4000 info on the swarm manager node to check the swarm cluster status, as shown below. There are two other worker nodes in this cluster. Next, I want to create an overlay network with this cluster and refer this network in the docker-compose.yaml. But when I ran docker -H :4000 network create -d overlay test on the swarm manager node to create the netwrok, it reported error: Error response from daemon: Error response from daemon: This node is not a swarm manager. Use "docker swarm init" or "docker swarm join" to connect this node to swarm and try again.

So, how can I create a network with a swarm cluster( without docker-machine and virtual box)? Currently, the swarm manager and worker nodes are running as docker containers. enter image description here


Solution

  • Did you setup overlay networking with it's own etcd backend first? https://docs.docker.com/network/overlay-standalone.swarm/

    Swarm "classic" is deprecated and replaced by docker swarm mode. Everything is harder in classic, including setting up overlay. I wouldn't recommend using it for anything new unless you had a hard requirement.