记录我的一些生活写照、无聊的牢骚、内心世界的活动 注册 | 登陆

Docker-panel简单自用docker管理面板

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

« 上一篇 | 下一篇 »

发表评论

评论内容 (必填):