# Docker Compose

{% hint style="success" %}
This the easiest and recommended method to host Cat Userbot.
{% endhint %}

## ≡ Run your bot in docker with just simple steps

### 〣 ***Install required packages*** <a href="#install-packages" id="install-packages"></a>

{% code title="Install git & docker compose" overflow="wrap" %}

```batch
sudo apt install --no-install-recommends -y git docker-compose docker.io
```

{% endcode %}

### 〣 ***Clone the repo & make config*** <a href="#clone-repo" id="clone-repo"></a>

{% code title="Change dir to catuserbot & make config.py to save config values" overflow="wrap" %}

```batch
git clone https://github.com/TgCatUB/catuserbot && cd catuserbot && mv exampleconfig.py config.py
```

{% endcode %}

### 〣 ***Edit the config.py with your config values*** <a href="#edit-config" id="edit-config"></a>

* Modify the <mark style="color:green;">config.py</mark> with any text editor, like `nano config.py`
* **Check :** [<mark style="color:blue;">**Config Values**</mark>](https://tgcatub.gitbook.io/catuserbot/variables/config-vars#mandatory-vars)

### 〣 ***All setup completed, its time to run the bot.*** <a href="#run-bot" id="run-bot"></a>

* ***Run:*** `sudo docker-compose up`
* ***Run detached:*** `sudo docker-compose up -d`
* ***Stop:*** `sudo docker-compose stop`
* ***Check:*** `sudo docker-compose ps`

{% hint style="info" %}
Whenever there is an update to our base docker image (will be notified via the channel or support group), use the below steps to update your docker instances. This is not part of the main guide or not a method to update the Bot.
{% endhint %}

### 〣 *Steps to update base docker image\*\*.\*\** <a href="#run-bot" id="run-bot"></a>

{% code title="stop the running containers " overflow="wrap" %}

```batch
sudo docker-compose stop
```

{% endcode %}

{% code title="pull the latest image from hub" overflow="wrap" %}

```batch
sudo docker pull catub/core:bullseye
```

{% endcode %}

{% code title="build and run with latest image" overflow="wrap" %}

```batch
sudo docker-compose up --build
```

{% endcode %}
