I have two machines HostA and HostB with consul and docker daemon properly configured so that I can use docker network create -d overlay sharednet
I have a TestScript.sh
to check if a network exists and if not create the network. And this script is available on both HostA and HostB. I also have a MasterScript.sh
only on A, which basically just invoke TestScript.sh
on each machine. After I run my MasterScript.sh
, I see a surprising result, two network with the same name got created!!! This is arguably a docker daemon synchronization issue.
[HostA]# docker network ls
NETWORK ID NAME DRIVER
ad492bba9efa sharednet overlay
ba53d4e7b739 sharednet overlay
[HostB]# docker network ls
NETWORK ID NAME DRIVER
ad492bba9efa sharednet overlay
ba53d4e7b739 sharednet overlay
The expected behavior is that when I created a network testnw
on HostA, then on HostB I should see something like this
[HostB]# docker network ls
68994f95cd67 testnw overlay
[HostB]# docker network create -d overlay testnw
Error response from daemon: network with name testnw already exists
Due to some restrictions I cannot modify the MasterScript.sh
, but I can modify my TestScript.sh
. So the question is, is it possible for me to resolve this race condition under this restriction?
This issue had been reported to Docker Github, and is currently being tracked under https://github.com/docker/docker/issues/20648