Skip to content

Commit bf0cf6f

Browse files
committed
calling prune network
(cherry picked from commit 3170066)
1 parent adfc659 commit bf0cf6f

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

experiments/schedule.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,22 @@ def checkDocker():
5353
if result.returncode != 0:
5454
print("Docker is not running. Error:", result.stderr, file=sys.stderr, flush=True)
5555
sys.exit(1)
56+
57+
# Unfortunately it seems by default Docker has very low network count...
58+
# So must make sure to clean up any un-used ones.
59+
# Had issues where previous experiments did not clean up properly, and all new failed for
60+
# lack of available networks
61+
print("Going to prune all unused networks ('docker network prune -f').", result.stderr, file=sys.stderr, flush=True)
62+
result = subprocess.run(
63+
['docker', 'network', 'prune', '-f'],
64+
stdout=subprocess.PIPE,
65+
stderr=subprocess.PIPE,
66+
text=True
67+
)
68+
if result.returncode != 0:
69+
print("Failed to prune networks. Error:", result.stderr, file=sys.stderr, flush=True)
70+
sys.exit(1)
71+
5672
return True
5773
except FileNotFoundError:
5874
print("Error: Docker is not installed or not in PATH", file=sys.stderr, flush=True)

0 commit comments

Comments
 (0)