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.
Prerequisites
Before starting, ensure you have:Docker Installed
Install Docker for your platform
Telegram API Credentials
Get your API ID and Hash from my.telegram.org
Getting API Credentials: Visit my.telegram.org, log in with your phone number, go to “API development tools”, and create an application to receive your
api_id and api_hash.Option 1: Docker Run (Fastest)
This is the quickest way to get started with a single command.Pull the Docker image
Download the latest image from Docker Hub:The image is multi-arch and will automatically pull the correct version for your platform (amd64 or arm64).
Create environment file
Create a Replace the values with your actual credentials from my.telegram.org.
.env file with your Telegram API credentials:.env
Start the container
Run the container with your environment file:What this does:
-d: Runs in detached mode (background)--name telegram-bot-api: Names the container for easy reference--env-file .env: Loads your API credentials-p 8081:8081: Exposes the API endpoint on port 8081-p 8082:8082: Exposes the statistics endpoint on port 8082-v "$(pwd)/data:/data": Mounts a localdatadirectory for persistent storage
Verify the server is running
Check the container logs to confirm startup:You should see output like:
Option 2: Docker Compose (Recommended for Production)
Docker Compose makes it easier to manage configuration and restart the server.Create docker-compose.yml
Create a
docker-compose.yml file (or use the one from the repository):docker-compose.yml
Start the service
Launch the server using Docker Compose:This will:
- Pull the image (if not already present)
- Create and start the container
- Set up networking and volumes
- Run in the background
Advanced Usage Examples
Custom Ports
Run the server on different ports:Local Mode (Large Files)
Enable local mode for handling files up to 2000 MB:Extra Arguments
Pass additional flags to the upstreamtelegram-bot-api binary:
Check Server Version
Run a one-off command to check the version:Updating Your Bot Client
Once your server is running, update your bot client to use the local API:Important: Before switching from
api.telegram.org, call the logOut method to ensure your bot receives all updates. See the Migration Guide for details.Monitoring and Logs
Access logs to troubleshoot issues:Troubleshooting
Container fails to start with 'TELEGRAM_API_ID is not set'
Container fails to start with 'TELEGRAM_API_ID is not set'
Solution: Ensure your The file should have:
.env file contains valid TELEGRAM_API_ID and TELEGRAM_API_HASH values:Permission denied errors with /data directory
Permission denied errors with /data directory
Solution: Create the data directory before starting the container:The container runs as user
botapi (non-root) and needs write access.Port already in use error
Port already in use error
Solution: Change the ports in your configuration:And update the port mappings:
API calls return 'Unauthorized' or fail
API calls return 'Unauthorized' or fail
Next Steps
Configuration Guide
Learn about all environment variables and advanced options
Migration from api.telegram.org
Safely switch your existing bot to the local server
Docker Compose Setup
Production deployment with health checks and resource limits
Troubleshooting
Common issues and solutions