Docker-panel简单自用docker管理面板
支持自定义镜像,批量开机,批量删除,监控检测,ssh和nat端口范围
环境
基于Debian12,docker,python3开发
XML/HTML代码
- apt update -y
- apt install wget curl sudo git screen nano unzip -y
- git clone https://github.com/xkatld/docker-panel.git
- chmod +x ./docker-panel/setup.sh
- bash ./docker-panel/setup.sh
构建docker镜像
XML/HTML代码
- # 构建 Ubuntu 镜像
- docker build --target ubuntu -t ssh-ubuntu ./docker-panel/image
- # 构建 Debian 镜像
- docker build --target debian -t ssh-debian ./docker-panel/image
- # 构建 CentOS 镜像
- docker build --target centos -t ssh-centos ./docker-panel/image
- # 构建 Fedora 镜像
- docker build --target fedora -t ssh-fedora ./docker-panel/image
- # 构建 Arch Linux 镜像
- docker build --target arch -t ssh-arch ./docker-panel/image
- # 构建 Alpine Linux 镜像
- docker build --target alpine -t ssh-alpine ./docker-panel/image
以上均为基于官方原版镜像,默认端口密码都是22/password 。如需其他版本或者安装其他组件可以自行修改image/images.sh
也可以使用脚本直接完成构建
XML/HTML代码
- bash ./docker-panel/image/images.sh
启动web-api
XML/HTML代码
- python3 ./docker-panel/web/api/app.py
浏览器中访问 http://0.0.0.0:88 使用 Web 界面,或使用 API 客户端调用 /api/create_container 端点 API 使用示例(使用 curl):
XML/HTML代码
- #创建容器:
- curl -X POST http://0.0.0.0:88/api/create_container \
- -H "Content-Type: application/json" \
- -d '{
- "image": "ssh-ubuntu",
- "cpu": "1",
- "memory": 512,
- "disk_size": "2G"
- }'
- #删除容器(假设容器 ID 为 "35195543422b"):
- curl -X POST http://0.0.0.0:88/api/delete_container \
- -H "Content-Type: application/json" \
- -d '{
- "id": "35195543422b"
- }'
创建的镜像默认分配100个NAT映射端口和一个SSH端口。分配磁盘空间为 /mnt/data 并挂载主机,容量有限制,超过容量无法存储。非常适合测试研究,创建删除快速方便。