Documentation Index
Fetch the complete documentation index at: https://mintlify.com/ragnarok22/telegram-bot-api-docker/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Docker Compose provides a declarative way to configure and run the Telegram Bot API server. The repository includes a production-readycompose.yml file with health checks, resource limits, and proper restart policies.
Prerequisites
Before you begin:- Install Docker and Docker Compose (Get Docker)
- Obtain API credentials from my.telegram.org
- Create a
.envfile with your configuration
Quick Start
Repository compose.yml
The repository includes a completecompose.yml file that builds from source:
compose.yml
Service Configuration Breakdown
Using the Published Image
If you prefer to use the pre-built image from Docker Hub instead of building from source, create a minimalcompose.yml:
compose.yml
Using the published image is faster for deployment, while building from source gives you more control and allows you to modify the Dockerfile.
Health Checks
The health check configuration monitors the API endpoint to ensure the service is responsive:Health Check Behavior
- Test: Makes an HTTP request to the API endpoint
- Interval: Checks every 30 seconds
- Timeout: Waits up to 5 seconds for a response
- Retries: Marks the container as unhealthy after 3 consecutive failures
Viewing Health Status
STATUS column shows the health state:
healthy: Service is responding correctlyunhealthy: Service failed health checksstarting: Initial grace period before checks begin
Custom Health Check Port
If you change the HTTP port, update the health check accordingly:Resource Limits
Thedeploy.resources.limits section prevents the container from consuming excessive system resources:
Memory Limit
The 512M memory limit is suitable for most bot API deployments. Increase it if you:- Serve many concurrent bots
- Handle large file uploads/downloads
- Experience out-of-memory errors
CPU Limit
The1.0 CPU limit allows the container to use one full CPU core. Adjust based on your workload:
Resource limits help prevent a single service from degrading system performance. Monitor your actual usage with
docker stats to fine-tune these values.Configuration with Environment Variables
Override configuration values by adding them to your.env file:
.env
compose.yml
Building from Source vs Using Published Image
Building from Source
Advantages:- Full control over the build process
- Ability to modify the Dockerfile
- Can use a specific upstream commit or branch
- Useful for development and testing
- You need to customize the build
- You want to track a specific upstream version
- You’re contributing to the project
Using Published Image
Advantages:- Faster deployment (no build time)
- Consistent, tested releases
- Automatic platform detection (amd64/arm64)
- Smaller storage footprint
- You want quick deployment
- You trust the published releases
- You don’t need custom modifications
The published image is multi-arch and automatically selects the correct variant for your platform (x86_64 or ARM64).
Common Operations
Start Services
Stop Services
View Logs
Restart Service
Rebuild and Restart
View Service Status
Execute Commands Inside Container
Remove All Data
Advanced Configuration
Multiple Service Stacks
Run multiple API instances on different ports:compose.yml
Named Volumes
Use Docker-managed volumes instead of bind mounts:compose.yml
Network Configuration
Isolate the service in a custom network:compose.yml
Troubleshooting
Service Won’t Start
Check the logs for errors:- Missing
TELEGRAM_API_IDorTELEGRAM_API_HASHin.env - Port conflicts with existing services
- Permission issues with the
./datadirectory
Health Check Failures
If the service is marked as unhealthy:-
Check if the API is responding:
-
Verify the port configuration matches:
- Increase timeout or retries if needed
Build Failures
If building from source fails:Resource Exhaustion
Monitor container resource usage:Next Steps
Configuration
Explore all available environment variables and configuration options
Docker Setup
Learn about running with docker run commands