> ## Documentation Index
> Fetch the complete documentation index at: https://docs.langtrace.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Docker Compose Setup

> Setup langtrace using docker compose

<iframe width="560" height="315" src="https://www.youtube.com/embed/fHghIPl_i0g?si=CTHXh0tFaLOX4SGV" title="YouTube video player" frameBorder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerPolicy="strict-origin-when-cross-origin" allowFullScreen />

# Steps

<Note>
  Make sure Docker and Docker compose versions are newer. To verify the
  versions, run the following commands: For docker `docker --version` and for
  docker compose `docker compose --version`
</Note>

## Step 1: Clone the repository

Clone the repository using the following command:

```bash theme={null}
git clone https://github.com/Scale3-Labs/langtrace
cd langtrace
```

## Step 2: Configure environment variables

Repo already has `.env` file for common usecases, modify this file to suit your needs.

### Authentication Configuration

Langtrace supports multiple authentication methods. Make sure to configure the necessary environment variables for your chosen authentication method(s) in the `.env` file. For detailed instructions, refer to our [Authentication](/hosting/auth) guide.

## Step 3: Start the services

```bash theme={null}
docker compose up -d
```

The application will be available at `http://localhost:3000`.

<Info>
  if you wish to build the docker image locally and use it, run the `docker
      compose up` command with the `--build` flag.
</Info>

## Step 4: Stop the services

To delete containers and volumes

```bash Bash theme={null}
docker compose down -v
```

`-v` flag is used to delete volumes.

<Warning>
  Deleting the volumes also wipes out the data stored in postgres and
  clickhouse.
</Warning>

## Useful Ops Commands

<AccordionGroup>
  <Accordion title="Connecting to postgres db">
    To connect to the postgres db, run the following command:

    ```bash theme={null}
    docker exec -it langtrace-postgres psql --dbname=langtrace --username=ltuser --password
    ```
  </Accordion>

  <Accordion title="Connecting to clickhouse db">
    To connect to the clickhouse db, run the following command:

    ```bash theme={null}
    docker exec -it langtrace-clickhouse clickhouse-client
    ```
  </Accordion>

  <Accordion title="Viewing logs of Langtrace App">
    To view the logs of the Next JS app, run the following command:

    ```bash theme={null}
    docker logs langtrace
    ```

    If you want to follow the logs, run the following command:

    ```bash theme={null}
    docker logs -f langtrace
    ```
  </Accordion>

  <Accordion title="Running prisma schema apply command">
    To create tables manually

    ```bash theme={null}
    docker exec -it langtrace npm run create-tables
    ```
  </Accordion>
</AccordionGroup>

## Troubleshooting

The following are some common issues that you may face while setting up langtrace using docker compose

<AccordionGroup>
  <Accordion title="Table not found error OR Column not found errors">
    Its likely that schema is not applied to the database or the schema is not in sync with the database. To fix this, run the following command:

    ```bash theme={null}
    docker exec -it langtrace npm run create-tables
    ```
  </Accordion>

  <Accordion title="Prisma schema not in sync with database">
    If you have made changes to the prisma schema and want to apply the changes to the database, run the following command:

    ```bash theme={null}
    docker exec -it langtrace npm run create-tables
    ```
  </Accordion>

  <Accordion title="Docker compose failing to setup with `Additional property required is not allowed` errors">
    Its likely that you are using an older version of docker-compose. Update
    docker-compose to the latest version. Certain docker compose schema used in
    this project are only supported in newer versions of docker-compose. Either
    you update the docker compose version OR remove the `depends_on property` that
    maybe causing the error.
  </Accordion>

  <Accordion title="Clickhouse server not starting">
    If clickhouse server is not starting, it is likely that the port `8123` is
    already in use. You can change the port in the docker-compose file.
  </Accordion>
</AccordionGroup>

## Next Steps

After setting up Langtrace using Docker Compose, ensure that you've properly configured your chosen authentication method(s) and created the necessary user accounts. Refer to the [Authentication](/hosting/auth) guide for detailed instructions on setting up and managing authentication.
