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 you begin, ensure you have:- Docker installed on your system (Download Docker)
- API credentials from my.telegram.org
- Port 8081 and 8082 available on your host machine
Pull the Image
The image is published to Docker Hub asragnarok22/telegram-bot-api-docker. It supports multiple architectures (linux/amd64 and linux/arm64), so Docker will automatically select the correct variant for your platform.
The image is multi-arch and works on both x86_64 and ARM64 platforms (including Apple Silicon Macs).
Basic Usage
Running with Environment File
The recommended approach is to use an.env file to manage your configuration:
Create the .env file
Create a Get your credentials from my.telegram.org.
.env file in your working directory with your API credentials:.env
Running with Inline Environment Variables
You can also pass environment variables directly via the-e flag:
Port Mappings
The server exposes two ports:| Port | Purpose | Environment Variable |
|---|---|---|
8081 | HTTP API endpoint | TELEGRAM_HTTP_PORT |
8082 | Statistics endpoint | TELEGRAM_HTTP_STAT_PORT |
Default Port Configuration
Custom Port Configuration
To use different ports, set the environment variables and update your port mappings:When changing the internal ports via environment variables, ensure your
-p port mappings match.Volume Mounts
Persistent storage is essential for maintaining bot data, logs, and session information.Data Directory
The default data directory inside the container is/data. Mount a host directory to preserve data across container restarts:
- Bot session data in
/data - Logs in
/data/logs/telegram-bot-api.log(by default)
Custom Data Directory
You can customize the data directory location:Logs Directory
By default, logs are written to/data/logs/telegram-bot-api.log. You can customize the log file path:
Advanced Examples
Running with Local Mode
Local mode (--local flag) allows the server to serve local files. Enable it with:
Passing Additional Upstream Flags
UseTELEGRAM_EXTRA_ARGS to pass additional flags to the underlying telegram-bot-api binary:
Running Without Data Persistence
For testing purposes, you can run without volume mounts (data will be lost on container restart):Custom Command Execution
Bypass the default entrypoint to run custom commands:Container Management
View Container Logs
View Live Logs
Stop the Container
Start the Container
Remove the Container
Platform-Specific Notes
Apple Silicon and ARM64
The image automatically selects the correct architecture. To explicitly force a platform:Building Locally
If you prefer to build from source:Troubleshooting
Missing Credentials
Ensure
TELEGRAM_API_ID and TELEGRAM_API_HASH are set in your .env file or passed via -e flags.Permission Issues
Create the
./data directory before first run and ensure it is writable:Port Conflicts
If ports 8081 or 8082 are already in use, change the port mappings:
API Call Failures
Check container logs for errors:And inspect the log file inside the container:
Next Steps
Docker Compose
Set up the server using Docker Compose for easier management
Configuration
Learn about all available configuration options