Files
CVExplorer/main.py
T

28 lines
980 B
Python
Raw Normal View History

2025-12-01 18:00:23 +03:00
import docker
from ctypes.wintypes import tagSIZE
client = docker.from_env()
running_containers = []
sleeping_containers = []
for c in client.containers.list(all=True):
info = c.attrs # словарь со всеми данными
image = info["Config"]["Image"] # образ
created = info["Created"] # время создания
labels = info["Config"].get("Labels", {}) # лейблы
ports = info["NetworkSettings"]["Ports"] # проброшенные порты ЪЪЪ
mounts = info.get("Mounts", []) # маунты
status = c.status # статус контейнера (вкл-выкл)
tags = c.image.tags
container = {
"name": c.name,
"image": image,
"id": c.id[:12],
"create_time": created,
"mounted_data": mounts,
"labels": labels
}
if status == "running":
running_containers.append(container)
else:
sleeping_containers.append(container)
print(tags)