Skip to content

Commit

Permalink
Bind docker daemon to tcp port as well.
Browse files Browse the repository at this point in the history
Fix the ports used by swarm manager and agent.
  • Loading branch information
gkvijay committed Jan 19, 2017
1 parent b1f49bd commit 6fe26f8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
4 changes: 2 additions & 2 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ fi
# setup docker cluster store
if [[ $7 == *"consul:"* ]]
then
perl -i -lpe 's!^ExecStart(.+)$!ExecStart$1 --cluster-store=consul://localhost:8500!' /lib/systemd/system/docker.service
perl -i -lpe 's!^ExecStart(.+)$!ExecStart$1 -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --cluster-store=consul://localhost:8500!' /lib/systemd/system/docker.service
else
perl -i -lpe 's!^ExecStart(.+)$!ExecStart$1 --cluster-store=etcd://localhost:2379!' /lib/systemd/system/docker.service
perl -i -lpe 's!^ExecStart(.+)$!ExecStart$1 -H tcp://0.0.0.0:2375 -H unix:///var/run/docker.sock --cluster-store=etcd://localhost:2379!' /lib/systemd/system/docker.service
fi
# setup docker remote api
Expand Down
20 changes: 14 additions & 6 deletions scripts/start-swarm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,25 @@ start)
echo "Setting IPtables rules for swarm"
sudo iptables -L INPUT | grep "swarm traffic 2375" || \
sudo iptables -I INPUT 1 -p tcp --dport 2375 -j ACCEPT -m comment --comment "swarm traffic 2375"
sudo iptables -L INPUT | grep "swarm traffic 3375" || \
sudo iptables -I INPUT 1 -p tcp --dport 3375 -j ACCEPT -m comment --comment "swarm traffic 3375"

echo starting swarm as master on $node_addr
/usr/bin/docker run -t -d -p 2375:2375 --name=swarm-manager \
echo starting swarm as manager on $node_addr
/usr/bin/docker run -t -d -p 3375:3375 --name=swarm-manager \
--privileged \
swarm:$swarm_version manage \
-H :2375 \
-H :3375 \
--strategy spread \
--replication --advertise=$node_addr:2375 \
--replication --advertise=$node_addr:3375 \
etcd://$node_addr:2379
/usr/bin/docker run -t --name=swarm-agent \

echo starting swarm as agent on $node_addr
/usr/bin/docker run -t --name=swarm-agent \
--privileged \
swarm:$swarm_version join \
--advertise=$node_addr:2385 \
--advertise=$node_addr:2375 \
etcd://$node_addr:2379

;;

stop)
Expand All @@ -54,6 +61,7 @@ stop)

echo "Clearing IPtables for docker swarm"
sudo iptables -D INPUT -p tcp --dport 2375 -j ACCEPT -m comment --comment "swarm traffic 2375"
sudo iptables -D INPUT -p tcp --dport 3375 -j ACCEPT -m comment --comment "swarm traffic 3375"
;;

*)
Expand Down

0 comments on commit 6fe26f8

Please sign in to comment.