Dockerized Telegram Bot API server.
4.5K
Dockerized Telegram Bot API server with a minimal Alpine runtime image and a configurable entrypoint.
docker pull ragnarok22/telegram-bot-api-docker
.env:
TELEGRAM_API_ID=12345
TELEGRAM_API_HASH=1234567890abcdef1234567890abcdef
# Optional overrides:
# TELEGRAM_HTTP_PORT=8081
# TELEGRAM_HTTP_STAT_PORT=8082
# TELEGRAM_DIR=/data
# TELEGRAM_TEMP_DIR=/tmp
# TELEGRAM_LOG_FILE=/data/logs/telegram-bot-api.log
# TELEGRAM_LOCAL=true
# TELEGRAM_EXTRA_ARGS=--max-webhook-connections 80
docker run -d --name telegram-bot-api \
--env-file .env \
-p 8081:8081 -p 8082:8082 \
-v "$(pwd)/data:/data" \
ragnarok22/telegram-bot-api-docker
curl http://localhost:8081/bot<TOKEN>/getMe
The default log file is /data/logs/telegram-bot-api.log inside the container.
This repository includes compose.yml, which builds from the local Dockerfile:
docker compose up -d --build
Compose service details:
telegram-api8081 (API), 8082 (statistics)./data:/data.envIf you prefer using the published image directly, use this minimal compose snippet:
services:
telegram-bot-api:
image: ragnarok22/telegram-bot-api-docker
env_file: .env
ports:
- "8081:8081"
- "8082:8082"
volumes:
- ./data:/data
| Variable | Required | Default | Description |
|---|---|---|---|
TELEGRAM_API_ID | Yes | - | API ID from https://my.telegram.org |
TELEGRAM_API_HASH | Yes | - | API hash from https://my.telegram.org |
TELEGRAM_HTTP_PORT | No | 8081 | HTTP API listen port |
TELEGRAM_HTTP_STAT_PORT | No | 8082 | HTTP statistics port |
TELEGRAM_DIR | No | /data | Bot data directory |
TELEGRAM_TEMP_DIR | No | /tmp | Temp directory for HTTP files |
TELEGRAM_LOG_FILE | No | /data/logs/telegram-bot-api.log | Log file path |
TELEGRAM_LOCAL | No | disabled | Enable --local mode with 1 or true |
TELEGRAM_EXTRA_ARGS | No | empty | Extra flags passed verbatim to telegram-bot-api |
Run with defaults:
docker run -d --env-file .env -p 8081:8081 -p 8082:8082 ragnarok22/telegram-bot-api-docker
Run with custom ports and local mode:
docker run -d --env-file .env \
-e TELEGRAM_HTTP_PORT=9000 \
-e TELEGRAM_HTTP_STAT_PORT=9001 \
-e TELEGRAM_LOCAL=true \
-p 9000:9000 -p 9001:9001 \
ragnarok22/telegram-bot-api-docker
Pass through additional upstream flags:
docker run -d --env-file .env \
-e TELEGRAM_EXTRA_ARGS="--max-webhook-connections 50 --log-verbosity-level 3" \
-p 8081:8081 -p 8082:8082 \
ragnarok22/telegram-bot-api-docker
Bypass default startup logic and execute a custom command:
docker run --rm ragnarok22/telegram-bot-api-docker ./telegram-bot-api --version
The image is multi-arch (linux/amd64, linux/arm64), so Docker usually picks the correct variant automatically.
Build locally on Apple Silicon:
docker build -t telegram-bot-api:dev .
If you need to force a platform at runtime:
docker run --rm --platform linux/arm64/v8 ragnarok22/telegram-bot-api-docker ./telegram-bot-api --version
docker build -t telegram-bot-api:dev .bash tests/run.shdocker compose up -d --buildThe Dockerfile pins the upstream Telegram Bot API commit for reproducible builds. To test another revision, pass --build-arg TELEGRAM_BOT_API_COMMIT=<commit> to docker build.
GitHub Actions workflows:
test: runs bash tests/run.sh on push/PR to main.docker-smoke: reusable/manual workflow for Docker build and smoke checks.docker-release: runs on pushed tags matching v*.*, then builds and pushes multi-arch images.Release examples that match the current workflow trigger:
v10.3v10.3.0Publishing requires repository secrets:
DOCKERHUB_USERNAMEDOCKERHUB_TOKENTELEGRAM_API_ID and TELEGRAM_API_HASH are present in .env../data before first run and ensure it is writable.TELEGRAM_HTTP_PORT and/or TELEGRAM_HTTP_STAT_PORT and map matching host ports./data/logs/telegram-bot-api.log.Security note:
TELEGRAM_LOCAL allows serving local files and should be enabled only in trusted environments with proper network isolation.To guarantee that your bot receives all updates, first deregister it from https://api.telegram.org by calling logOut.
After logout, point your bot client to your local server address. If launched with --local, ensure your bot can handle absolute file paths in getFile responses.
If the same bot is logged in on multiple servers, update delivery is not guaranteed.
To move safely:
Telegram Bot API server source code is licensed under the Boost Software License. See LICENSE for details.
Content type
Image
Digest
sha256:833770f67…
Size
39.9 MB
Last updated
20 days ago
docker pull ragnarok22/telegram-bot-api-docker