2023-10-19 08:55:30 +00:00
|
|
|
#!/usr/bin/python3
|
|
|
|
|
|
|
|
import subprocess
|
2023-10-19 11:27:45 +00:00
|
|
|
import time
|
2023-10-19 08:55:30 +00:00
|
|
|
|
2023-10-19 11:27:45 +00:00
|
|
|
start = time.time()
|
|
|
|
container_ids = subprocess.check_output("docker ps -q -f label=com.docker.compose.project=docker", encoding='utf-8')
|
|
|
|
containers = container_ids.strip().split()
|
2023-10-19 08:55:30 +00:00
|
|
|
|
2023-10-19 11:27:45 +00:00
|
|
|
if containers:
|
|
|
|
print("Stop all backend services (containers)")
|
|
|
|
subprocess.run(['docker', 'stop'] + containers, check=True)
|
|
|
|
else:
|
2023-10-19 08:55:30 +00:00
|
|
|
print("No containers to stop")
|
|
|
|
|
2023-10-19 11:27:45 +00:00
|
|
|
end = time.time()
|
|
|
|
print("\nElapsed time", end - start)
|