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

# Docker

> Run your container anywhere.

While using Docker is not necessary for this project, it simplifies deployment for a variety of environments. The pre-built Docker images are available on the [GitHub Container Registry](https://github.com/medama-io/medama/pkgs/container/medama).

## Tags

| Docker Tags                                 | Description                     |
| ------------------------------------------- | ------------------------------- |
| `ghcr.io/medama-io/medama:latest`           | Latest stable release.          |
| `ghcr.io/medama-io/medama:edge`             | Latest development build.       |
| `ghcr.io/medama-io/medama:<version>`        | Specific version.               |
| `ghcr.io/medama-io/medama:sha-<commit-sha>` | Specific commit (short format). |

## Setup

<Steps>
  <Step title="Run Container">
    <AccordionGroup>
      <Accordion title="Docker Run" icon="docker">
        Create a Docker volume to store the database files:

        ```sh theme={null}
        docker volume create medama-data
        ```

        Then run the container with the following command:

        ```sh theme={null}
        docker run -d -p 8080:8080 -v medama-data:/app/data ghcr.io/medama-io/medama:latest
        ```

        <Info>All database data is stored in the `/app/data` directory within the containers. You can create a volume or use bind mounts to redirect where data is stored on your local system. Learn more about Docker volumes [here](https://docs.docker.com/storage/volumes/).</Info>
      </Accordion>

      <Accordion title="Docker Compose" icon="cubes">
        If you prefer using Docker Compose, create a `docker-compose.yml` file with the following content:

        ```yaml theme={null}
        version: '3'

        services:
            medama:
                image: ghcr.io/medama-io/medama:latest
                ports:
                    - "8080:8080"
                volumes:
                    - medama-data:/app/data

        volumes:
            medama-data:
        ```

        Then start the container with the following command:

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

        <Tip>Docker Compose is a great solution for setting up reverse proxies, such as Nginx or Caddy, which can automatically provision SSL certificates and handle traffic routing.</Tip>
      </Accordion>

      <Accordion title="Build from source" icon="github">
        If you want to build from source using Docker, clone the `medama-io/medama` repository and build the image from there:

        ```sh theme={null}
        git clone https://github.com/medama-io/medama

        docker build -t medama .
        ```
      </Accordion>
    </AccordionGroup>
  </Step>

  <Step title="Configure Deployment">
    Before you can start collecting data, you may want to configure your analytics instance to suit your needs.  It is recommended to refer to the [Environment Variables](/config/environment-variables) configuration page.

    These variables can be set using the `-e` flag in `docker run` or the `environment` property in Docker Compose.

    Afterwards, ensure your analytics instance is configured to be accessible from the internet. You must also set up SSL certificates for your deployment.
  </Step>

  <Step title="Add Your First Website">
    Success! You can now add your first website to the analytics instance by visiting the web interface at `http://localhost:8080` or the publicly accessible hostname for your deployment.

    The default login credentials are:

    * Username: `admin`
    * Password: `CHANGE_ME_ON_FIRST_LOGIN`

    <Warning>To successfully login, you must either use `localhost` or a `HTTPS` connection. Logging in via an unencrypted `HTTP` connection will not work. <br /><br /> If your hosting provider does not automatically provision SSL certificates to your machine, you may want to use [the automatic SSL setup feature](../deployment/ssl).</Warning>

    <Note>It is recommended to change the username and password immediately after logging in for the first time. This can be changed in the settings menu.</Note>
  </Step>

  <Step title="Embed Tracking Snippet">
    Then, embed the following HTML tracking snippet in the `<head>` element of your website to start collecting data:

    ```html theme={null}
    <script defer src="https://[your-public-api-hostname].com/script.js"></script>
    ```

    <Info>Learn more about configuring your tracking snippet [here](/config/tracking-snippet).</Info>
  </Step>
</Steps>
