provide a simple interface for mobile applications to manage Docker
3.7K
A lightweight Docker management API service built with FastAPIβ . It is designed to provide a simple interface for mobile applications to manage Docker containers, images, networks, and volumes. It also includes a simple Web Admin UI for managing API keys and cluster nodes.
π± Companion App: This API is designed to work with the Mobile Portainer Flutter App.
π Get the App: https://github.com/CodeFuckee/mobile_portainer_flutterβ
X-API-Key.Ensure your server has the following installed:
Start the service directly using Docker Compose:
# Build and start in detached mode
docker-compose up -d --build
You can also run the pre-built image directly:
Docker CLI:
docker run -d \
--name mobile-portainer \
-p 8000:8000 \
-v /var/run/docker.sock:/var/run/docker.sock \
-v mobile_portainer_data:/app/data \
-v /:/hostfs:ro \
-e ADMIN_USER=admin \
-e ADMIN_PASSWORD=password \
--restart unless-stopped \
codefuckee/mobile_portainer:latest
Docker Compose:
version: '3.8'
services:
api:
image: codefuckee/mobile_portainer:latest
ports:
- "8000:8000"
environment:
- ADMIN_USER=admin
- ADMIN_PASSWORD=password
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./data:/app/data
- /:/hostfs:ro
restart: unless-stopped
Once started, you can access the following:
adminpassworddocker-compose.yml for production environments!You can configure the service by modifying the environment section in docker-compose.yml:
| Variable Name | Default Value | Description |
|---|---|---|
ADMIN_USER | admin | Username for Web Admin UI |
ADMIN_PASSWORD | ... | Password for Web Admin UI |
IGNORED_EVENTS | exec_create,exec_start,exec_die | Event types to ignore in Docker event stream |
HOST_FILESYSTEM_ROOT | /hostfs | Mount path of host root directory inside container |
.
βββ app/
β βββ core/ # Core config, security, utils
β βββ db/ # Database models and connection
β βββ mcp/ # MCP server (Model Context Protocol) tools and entry point
β βββ routers/ # API routers (Containers, Images, WebUI, etc.)
β βββ services/ # Background services (Docker Event Listener)
βββ data/ # Data persistence directory (SQLite database)
βββ docker-compose.yml # Docker Compose orchestration file
βββ Dockerfile # Docker image build file
βββ main.py # FastAPI application entry point
βββ requirements.txt # Python dependencies
All protected API endpoints require the X-API-Key header.
Get Container List:
GET /containers/json HTTP/1.1
Host: localhost:8000
X-API-Key: <Your-API-Key-From-Web-UI>
You can generate and manage these API Keys after logging into the Web Admin UI (/).
Mobile Portainer includes a built-in MCP (Model Context Protocol)β server that allows AI assistants (such as Claude Desktop, Cursor, and other MCP-compatible clients) to manage Docker resources directly through natural language conversations.
The MCP server runs as a standalone subprocess communicating via stdio. It does NOT run as part of the FastAPI HTTP service β instead, it is spawned directly by the AI client. The server exposes 24 Docker management tools across 5 categories:
| Category | Tools |
|---|---|
| Containers | list_containers, get_container, get_container_logs, start_container, stop_container, restart_container, kill_container, pause_container, unpause_container, remove_container, run_container |
| Images | list_images, get_image, pull_image, remove_image |
| Networks | list_networks, get_network |
| Volumes | list_volumes, get_volume, remove_volume |
| System | get_system_info, get_system_usage, list_stacks, get_stack_containers |
The get_system_info tool aggregates Docker stats, Git version info, and system resource usage into a single response. The run_container tool parses natural docker run-style commands, so you can ask "run nginx in the background" and it just works.
python -m app.mcp.server
Add the following to your claude_desktop_config.json:
{
"mcpServers": {
"mobile-portainer": {
"command": "python",
"args": ["-m", "app.mcp.server"],
"env": {
"MOBILE_PORTAINER_API_KEY": "your-api-key"
}
}
}
}
The MCP server checks API keys in the following priority order:
MOBILE_PORTAINER_API_KEY is set, the key must match exactly.api_keys database table (keys managed via the Web Admin UI).β οΈ For production use, it's strongly recommended to set
MOBILE_PORTAINER_API_KEYor manage keys via the Web Admin UI.
Content type
Image
Digest
sha256:f48a32ed2β¦
Size
117.1 MB
Last updated
3 months ago
docker pull codefuckee/mobile_portainer