summaryrefslogtreecommitdiff
path: root/.local/bin/docker-compose-update-all
diff options
context:
space:
mode:
authorDaniel Weipert <code@drogueronin.de>2023-11-14 13:33:14 +0100
committerDaniel Weipert <code@drogueronin.de>2023-11-14 13:33:14 +0100
commit9b41dbdcb2c810804417b9ffc4e74a7b3e534ac2 (patch)
treec4cf9ace30d0cd35aebb6ac70f2be43b1371f5d6 /.local/bin/docker-compose-update-all
initial commit
Diffstat (limited to '.local/bin/docker-compose-update-all')
-rwxr-xr-x.local/bin/docker-compose-update-all23
1 files changed, 23 insertions, 0 deletions
diff --git a/.local/bin/docker-compose-update-all b/.local/bin/docker-compose-update-all
new file mode 100755
index 0000000..99db85f
--- /dev/null
+++ b/.local/bin/docker-compose-update-all
@@ -0,0 +1,23 @@
+#!/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', 'build'], cwd=path)
+ subprocess.run(['docker', 'compose', 'pull'], cwd=path)
+ subprocess.Popen(['docker', 'compose', 'up', '-d'], cwd=path)