KitDevguides

KitDev / Guides / Docker

Docker

With Docker, KitDev runs inside a container that already includes Python and all its dependencies. It works the same on any VPS or PC, you don’t need to install Python or create a virtual environment, and it restarts on its own if it crashes or if you reboot the server.

If you’d rather not use Docker, follow the regular installation and the background guide.

Requirements

  • A VPS or a PC running Linux, Windows or macOS
  • Docker Engine with Docker Compose v2 (the docker compose command). On Windows and macOS, Docker Desktop
  • Git
  • API_ID and API_HASH from my.telegram.org

Termux (Android) can’t run Docker. Use the regular installation there.

1. Install Docker

On Linux, the official script installs everything. Then add your user to the docker group and log out and back in over SSH so you can use it without sudo:

curl -fsSL https://get.docker.com | shsudo usermod -aG docker $USER

Check that it works:

docker --versiondocker compose version

On Windows and macOS, install Docker Desktop and open it before continuing. On Windows, use PowerShell.

2. Download KitDev

Create the data folder yourself before starting: if Docker creates it, it will belong to root and KitDev won’t be able to write to it.

git clone https://github.com/ronnypro1/KitDev.gitcd KitDevmkdir -p datacp .env.example .env

3. Get the SESSION_STRING

The session is generated inside the container, on your own device. It will ask for API_ID, API_HASH, your phone number and the code Telegram sends you. At the end it sends the SESSION_STRING to your Saved Messages.

docker compose builddocker compose run --rm kitdev python gen_session.py

Generate the session only on your own device. Don’t use websites, bots or third-party services for it: they would see your login code and gain access to your account. Use a different session for each installation: if the same session is used in two places at once, Telegram invalidates it.

4. Fill in the .env

Open the .env with nano .env and fill in these variables. The value goes after the =, without quotes or spaces:

API_ID=123456
API_HASH=tu_api_hash
SESSION_STRING=la_cadena_completa
PREFIX=.

The .env is not copied into the image: Docker Compose reads it from your folder and passes it to the container as environment variables. The other optional variables are in the installation guide.

5. Start it

docker compose up -d --builddocker compose logs -f

-d keeps it running in the background. The logs show the logo, the loaded plugins and KitDev activo; press Ctrl+C to leave the logs without stopping KitDev. On the first run it creates the assistant bot and the KitDev Logs group, just like any other installation.

Useful commands

Run them inside the KitDev folder.

What you want to do Command
Watch the logs live docker compose logs -f
Check that it is running docker compose ps
Restart it docker compose restart (or .restart from Telegram)
Stop it docker compose stop
Stop it and remove the container docker compose down (data/ is not deleted)
Apply .env changes docker compose up -d --force-recreate
Open a shell inside docker compose exec kitdev sh

Data and backups

The data/ folder on your server is mounted inside the container, so your data survives even if you delete or rebuild the container. It holds state.json (with your assistant bot’s token), the kitdev.sqlite3 database, addons/ and media/.

  • .backup and .restore work as usual: see Backup and migration.
  • To move, copy data/ and the .env to the new server and start with docker compose up -d --build.

Don’t use the same SESSION_STRING in two places at once. Before starting on the new server, stop the old one with docker compose down.

Updating

cd KitDevgit pulldocker compose up -d --build

data/ and .env are not touched. The Update available button in Telegram doesn’t appear with Docker, because the container doesn’t include the git repository: always update with the commands above.

Without Docker Compose

If you only have Docker, build the image and start the container by hand. In PowerShell, replace $(pwd) with ${PWD}.

docker build -t kitdev .docker run -d --name kitdev --init --restart unless-stopped --env-file .env -v "$(pwd)/data:/app/data" kitdev

Common problems

Problem Fix
Permission denied writing to data/ The folder belongs to another user. Run sudo chown -R 1000:1000 data
It stops on startup with “Revisa tu archivo .env” A variable is missing or wrong. Fix it in the .env and run docker compose up -d --force-recreate
I changed the .env and nothing happens Docker reads the .env when it creates the container: run docker compose up -d --force-recreate
env file .env not found The file is missing. Create it with cp .env.example .env
docker: command not found or permission denied on the socket Install Docker (step 1) or log out and back in after usermod
More errors See Troubleshooting