Docker create network simultaneously with threading

Viewed 52

I have a simple python script that creates docker network with threads simultaneously:

import os
import threading
 
i = 0
def c(a):
  global i
  while True:
    if i:
      print(a + " ---- " + str(os.system('docker network create test1')))
      break

t1 = threading.Thread(target=c, args=('t1',))
t2 = threading.Thread(target=c, args=('t2',))

t1.start()
t2.start()
i = int(input("enter i: "))
t1.join()
t2.join()

In this case docker does not complain about network names and it is possible to have 2 networks with the same name. Of course it causes problems while using.

Should Docker be able to handle this type of cases or it is under the users' responsibility ?

0 Answers
Related