Files
mokeegateway/check_docker.py
2026-07-15 16:13:27 +08:00

30 lines
874 B
Python

import paramiko
HOST = '10.1.1.170'
USER = 'root'
PASS = 'mokee.'
c = paramiko.SSHClient()
c.set_missing_host_key_policy(paramiko.AutoAddPolicy())
c.connect(HOST, username=USER, password=PASS, timeout=15)
# 列出所有运行中的 Docker 容器
_, stdout, _ = c.exec_command('docker ps --format "table {{.Names}}\t{{.Image}}\t{{.Status}}\t{{.Ports}}" 2>&1')
out = stdout.read().decode()
print('=== Docker 容器列表 ===')
print(out)
# 也检查一下 /opt/mokee 目录结构
_, stdout2, _ = c.exec_command('ls -la /opt/mokee/ 2>&1')
out2 = stdout2.read().decode()
print('=== /opt/mokee 目录 ===')
print(out2)
# 查找与 mokee 相关的所有容器
_, stdout3, _ = c.exec_command('docker ps -a --format "table {{.Names}}\t{{.Image}}\t{{.Status}}" --filter name=mokee 2>&1')
out3 = stdout3.read().decode()
print('=== mokee 相关容器 ===')
print(out3)
c.close()