summaryrefslogtreecommitdiff
path: root/docker/docker-compose-update-all-running-projects
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-10-19 10:04:14 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-10-19 10:04:14 +0200
commitac93ed4d29dd85409fb4c0cd9c2af266e90777c1 (patch)
tree6a0b4487439bfe068d4b7d412be70d4f90faa2a5 /docker/docker-compose-update-all-running-projects
initial commitHEADmain
Diffstat (limited to 'docker/docker-compose-update-all-running-projects')
-rw-r--r--docker/docker-compose-update-all-running-projects22
1 files changed, 22 insertions, 0 deletions
diff --git a/docker/docker-compose-update-all-running-projects b/docker/docker-compose-update-all-running-projects
new file mode 100644
index 0000000..6d6d899
--- /dev/null
+++ b/docker/docker-compose-update-all-running-projects
@@ -0,0 +1,22 @@
+#!/usr/bin/env python3
+
+import sys, os
+import subprocess
+
+
+process_docker_ps = subprocess.run(['docker', 'ps', '-q'], stdout=subprocess.PIPE)
+
+container_ids = process_docker_ps.stdout.decode('utf-8').split('\n')
+
+docker_compose_project_paths = []
+for id in container_ids:
+ if id:
+ process_docker_inspect = subprocess.run(['docker', 'inspect', '--format', '{{ index .Config.Labels "com.docker.compose.project.working_dir" }}', id], stdout=subprocess.PIPE)
+ docker_compose_project_paths.append(process_docker_inspect.stdout.decode('utf-8').strip())
+
+docker_compose_project_paths = set(docker_compose_project_paths)
+
+for path in docker_compose_project_paths:
+ subprocess.run(['docker-compose', 'down'], cwd=path)
+ subprocess.run(['docker-compose', 'pull'], cwd=path)
+ subprocess.Popen(['docker-compose', 'up', '-d'], cwd=path)