# portainer-skill **Repository Path**: numen06/portainer-skill ## Basic Information - **Project Name**: portainer-skill - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-16 - **Last Updated**: 2026-04-16 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # Portainer SDK Portainer API Python SDK,用于自动化管理 Docker 容器、Stack、镜像。 ## 安装 ```bash pip install requests ``` ## 快速开始 ```python from portainer_sdk import PortainerClient # API Token 认证(推荐) with PortainerClient("http://10.100.10.83:9000", api_token="ptr_xxx") as p: # 列出所有 Stack for s in p.stacks.list(): print(s["Name"], s["Status"]) # 重部署 Stack stack = p.stacks.find_by_name("my-app") p.stacks.redeploy(stack["Id"]) # 列出运行中容器 for c in p.containers.list(all=False): print(c["Names"][0], c["Status"]) ``` ## 模块 | 模块 | 功能 | |------|------| | `p.endpoints` | 环境管理(列表、详情、状态) | | `p.stacks` | 堆栈管理(CRUD、启停、重部署) | | `p.containers` | 容器管理(列表、启停、日志、exec) | | `p.images` | 镜像管理(列表、拉取、清理) | 详见 [SKILL.md](./SKILL.md)