docker / for-linux

Docker Engine for Linux
https://docs.docker.com/engine/installation/
754 stars 85 forks source link

Multiple docker deamon leads to swarm problem #673

Closed silgon closed 1 year ago

silgon commented 5 years ago

This is somehow a continuation of this answer about multiple docker deamons.

They use the following script to create the second docker deamon:

#!/bin/sh
## name: altdocker.sh
set -e -x

: ${bridge=altdocker}
: ${base=$HOME/$bridge}

# Set up bridge network:
if ! ip link show $bridge > /dev/null 2>&1
then
   sudo ip link add name $bridge type bridge
   sudo ip addr add ${net:-"10.20.30.1/24"} dev $bridge
   sudo ip link set dev $bridge up
fi

sudo dockerd \
  --bridge=$bridge \
  --data-root=$base.data \
  --exec-root=$base.exec \
  --host=unix://$base.socket \
  --pidfile=$base.pid

Now, I set my DOCKER_HOST to the unix socket that was created. I initialize a docker swarm with docker swarm init with absolutely no problem. However, once I create a stack with docker stack deploy -c myfile.yaml I have to problems:

Note: I created a stackoverflow question, however I realized that it might be better here. Anyway, here is the link to the question.

cpuguy83 commented 5 years ago

You also will have issues with iptables, swarm socket addresses... honestly you should not run two dockerd's in the same host unless they are isolated by containers.

silgon commented 5 years ago

The thing is in my case, I need one swarm configuration which is connected to another computer and another to be isolated in local for development. Another use-case is for people who want several isolated docker environments in a single computer, let's say one dockerd for every user, thus they can have isolated configurations.

Looking a bit more in depth, I saw in the documentation the configuration that should be enable in order to use swarm mode:

I realized because I saw an error message given by dockerd:

 ERRO[2019-05-21T14:46:02.807800662+02:00] error in agentInit: failed to create memberlist: Could not set up network transport: failed to obtain an address: Failed to start TCP listener on "0.0.0.0" port 7946: listen tcp 0.0.0.0:7946: bind: address already in use 

Is there a way to change these ports?

thaJeztah commented 1 year ago

Let me close this ticket for now, as it looks like it went stale.