> For the complete documentation index, see [llms.txt](https://ztrust.gitbook.io/livestreamiq/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ztrust.gitbook.io/livestreamiq/readme/2.-installation/2.3-container-installation.md).

# 2.3 Container Installation

The Container installation deployment takes place to create two containers:

* **TimescaleDB (PostgreSQL)** for storing application and metrics data.
* **LivestreamIQ** application for monitoring and managing Apache Kafka environments.

### 1. Pre-Requisite:

Before proceeding with the installation, ensure the following requirements are met:

* Docker Engine 24.x or later
* Docker Compose v2
* Minimum 8 GB RAM
* At least 100 GB free disk space

### 2. Installation Steps:

Step 1: Create the Docker Compose File

1. Create a file named **`docker-compose.yml`** in your preferred working directory.<br>

   ```
   version: "3.9"
   services:
     postgres:
       image: timescale/timescaledb:latest-pg16
       container_name: timescale_pg
       restart: always
       ports:
         - "5432:5432"
       environment:
         POSTGRES_USER: postgres
         POSTGRES_PASSWORD: StrongPassword123
         POSTGRES_DB: lvs
         TZ: Asia/Kolkata
       command: postgres -c shared_preload_libraries=timescaledb
       volumes:
         - postgres_data:/var/lib/postgresql/data
       healthcheck:
         test: ["CMD-SHELL", "pg_isready -U postgres -d lvs"]
         interval: 10s
         timeout: 5s
         retries: 10
     livestreamiq:
       image: docker/livestreamiq/livestreqmiq:latest
       container_name: livestreamiq
       restart: always
       depends_on:
         postgres:
           condition: service_healthy
       ports:
         - "8080:8080"
       environment:
         LVS_DB_URL: r2dbc:postgresql://192.168.96.24:5432/lvs
         LVS_DB_USERNAME: postgres
         LVS_DB_PASSWORD: StrongPassword123
         ALLOW_ORIGIN: "http://192.168.96.24:8080"
   volumes:
     postgres_data:
   ```

Step 2: Deploy the Application Stack

1. Navigate to the directory containing the **`docker-compose.yml`** file.
2. Start the application stack in detached mode.<br>

   ```
   docker compose up -d
   ```
3. Verify that both containers are running successfully.<br>

   ```
   docker compose ps       
   ```

   \
   Expected Result: Both the **TimescaleDB** and **LivestreamIQ** containers should display a   **Running** or **Healthy** status.

Step 3: Verify the Deployment

1. Verify the PostgreSQL (TimescaleDB) container logs.<br>

   ```
   docker compose logs -f postgres
   ```
2. Verify the LivestreamIQ application logs.<br>

   ```
   docker compose logs -f livestreamiq
   ```

Step 4: Manage the Docker Deployment

Use the following Docker Compose commands to manage the LivestreamIQ deployment.

<table data-search="false"><thead><tr><th>Action</th><th>Command</th></tr></thead><tbody><tr><td>Start stack</td><td>docker compose up -d</td></tr><tr><td>Stop stack</td><td>docker compose down</td></tr><tr><td>Stop and remove volumes</td><td>docker compose down -v</td></tr><tr><td>Restart one service</td><td>docker compose restart livestreamiq</td></tr><tr><td>View status</td><td>docker compose ps</td></tr><tr><td>View logs</td><td>docker compose logs -f livestreamiq</td></tr><tr><td>Pull latest images</td><td>docker compose pull</td></tr><tr><td>Recreate after image update</td><td>docker compose up -d --force-recreate</td></tr></tbody></table>
