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

# Docker for MindsDB

MindsDB provides Docker images that facilitate running MindsDB in Docker containers.

<Tip>
  As MindsDB integrates with numerous [data sources](/integrations/data-overview) and [AI frameworks](/integrations/ai-overview), each integration requires a set of dependencies. Hence, MindsDB provides multiple Docker images for different tasks, as outlined below.

  * `mindsdb/mindsdb:latest` (or `mindsdb/mindsdb`)
    It is the lightweight Docker image of MindsDB that comes with mysql,postgresql,snowflake,bigquery,mssql and salesforce pre-installed.

  * `mindsdb/mindsdb:huggingface`
    It is the Docker image of MindsDB that comes with the Hugging Face integration preloaded.
</Tip>

## Prerequisites

Before proceeding, ensure you have installed Docker, following the [official Docker documentation](https://docs.docker.com/install).

## Setup

This setup of MindsDB uses one of the available Docker images, as listed above.

<Note>
  When running MindsDB in one container and the integration you want to connect to it (such as Ollama or PGVector) in another container, then use `http://host.docker.internal` instead of `localhost` when connecting this integration to MindsDB.
</Note>

Follow the steps to set up MindsDB in a Docker container.

### Install MindsDB

Run this command to create a Docker container with MindsDB:

```bash theme={null}
docker run --name mindsdb_container \
-e MINDSDB_APIS=http,mysql \
-p 47334:47334 -p 47335:47335 \
mindsdb/mindsdb
```

Where:

* `docker run` is a native Docker command used to spin up a container.
* `--name mindsdb_container` defines a name for the container.
* `-e MINDSDB_APIS=http,mysql` defines the APIs to be exposed by the MindsDB instance. All available APIs include `http`, `mysql`, and `postgres`.
* `-p 47334:47334 -p 47335:47335` defines the ports where the APIs are exposed (HTTP and MySQL respectively).
* `mindsdb/mindsdb` is a Docker image provided by MindsDB. You can choose a different one from the list above.

Once the container is created, you can use the following commands:

* `docker stop mindsdb_container` to stop the container. *Note that this may not always be necessary because when turning off the host machine, the container will also be shut down.*
* `docker start mindsdb_container` to restart a stopped container with all its previous changes (such as any dependencies that were installed) intact. *Note that `docker start` restarts a stopped container, while `docker run` creates a new container.*

<Tip>
  If you don't want to follow the logs and get the prompt back, add the `-d` flag that stands for *detach*.

  ```bash theme={null}
  docker run --name mindsdb_container -e MINDSDB_APIS=http -d -p 47334:47334 mindsdb/mindsdb
  ```
</Tip>

<Tip>
  If you want to persist your models and configurations in the host machine, run these commands:

  ```bash theme={null}
  mkdir mdb_data
  docker run --name mindsdb_container -e MINDSDB_APIS=http -p 47334:47334 -v $(pwd)/mdb_data:/root/mdb_storage mindsdb/mindsdb
  ```

  Where `-v $(pwd)/mdb_data:/root/mdb_storage` maps the newly created folder `mdb_data` on the host machine to the `/root/mdb_storage` inside the container.
</Tip>

Now you can access the MindsDB editor by going to `127.0.0.1:47334` in your browser.

<p align="center">
  <img src="https://mintcdn.com/mindsdb/iK5MN5UH2_93kMSg/assets/mindsdb-editor.png?fit=max&auto=format&n=iK5MN5UH2_93kMSg&q=85&s=60396544895f74128933e18098e8258a" width="1917" height="949" data-path="assets/mindsdb-editor.png" />
</p>

<Warning>
  If you experience any issues related to MKL or your training process does not complete, please add the `MKL_SERVICE_FORCE_INTEL` environment variable, as below.

  ```bash theme={null}
  docker run --name mindsdb_container -e MKL_SERVICE_FORCE_INTEL=1 -e MINDSDB_APIS=http -p 47334:47334 mindsdb/mindsdb
  ```
</Warning>

<Tip>
  If you want to enable authentication for MindsDB, you do so by passing the `MINDSDB_USERNAME` and `MINDSDB_PASSWORD` environment variables when running the container.

  ```bash theme={null}
  docker run --name mindsdb_container -e MINDSDB_USERNAME='admin' -e MINDSDB_PASSWORD='password' -e MINDSDB_APIS=http -p 47334:47334 mindsdb/mindsdb
  ```
</Tip>

### Install dependencies

MindsDB integrates with numerous data sources and AI frameworks. To use any of the integrations, you should ensure that the required dependencies are installed in the Docker container.

**Method 1**

Install dependencies directly from MindsDB editor. Go to *Settings* and *Manage Integrations*, select integrations you want to use and click on *Install*.

<p align="center">
  <img src="https://mintcdn.com/mindsdb/U8_C23ppbMIBDBSs/assets/install-dependencies-gui.png?fit=max&auto=format&n=U8_C23ppbMIBDBSs&q=85&s=3a56cbc1e76b7b7ed6140473ed7380e1" width="3688" height="2101" data-path="assets/install-dependencies-gui.png" />
</p>

**Method 2**

Start the MindsDB Docker container:

```bash theme={null}
docker start mindsdb_container
```

<Tip>
  If you haven't specified a container name when spinning up a container with `docker run`, you can find it by running `docker ps`.
</Tip>

<Tip>
  If you haven't yet created a container, use this command:

  ```bash theme={null}
  docker run --name mindsdb_container -e MINDSDB_APIS=http -d -p 47334:47334 mindsdb/mindsdb
  ```
</Tip>

Start an interactive shell in the container:

```bash theme={null}
docker exec -it mindsdb_container sh
```

Install the dependencies:

```bash theme={null}
pip install .[handler_name]
```

For example, run this command to install dependencies for the [OpenAI handler](https://github.com/mindsdb/mindsdb/tree/main/mindsdb/integrations/handlers/openai_handler):

```bash theme={null}
pip install .[openai]
```

Exit the interactive shell:

```bash theme={null}
exit
```

Restart the container:

```bash theme={null}
docker restart mindsdb_container
```

## Configuration

This is a configuration for MindsDB's Docker image that includes storage location, log level, debugging information, installed integrations, and API endpoints. These parameters can be customized by modifying a JSON file that stores default configuration.

### Default configuration

The default configuration for MindsDB's Docker image is stored as a JSON code, as below.

```json theme={null}
{
    "config_version":"1.4",
    "paths": {
        "root": "/root/mdb_storage"
    },
    "debug": false,
    "integrations": {},
    "api": {
        "http": {
            "host": "0.0.0.0",
            "port": "47334"
        },
        "mysql": {
            "host": "0.0.0.0",
            "password": "",
            "port": "47335",
            "user": "mindsdb",
            "database": "mindsdb",
            "ssl": true
        }
    }
}
```

### Custom configuration

To override the default configuration, you can mount a config file created in your host machine over `/root/mindsdb_config.json`, as below.

```bash theme={null}
docker run --name mindsdb_container -e MINDSDB_APIS=http -d -p 47334:47334 -v $(pwd)/mdb_config.json:/root/mindsdb_config.json mindsdb/mindsdb
```

<Tip>
  **What's next?**

  Now that you installed and started MindsDB locally in your Docker container, go ahead and find out how to create and train a model using the [`CREATE MODEL`](/sql/create/model) statement.

  Check out the [Use Cases](/use-cases/overview) section to follow tutorials that cover Large Language Models, Chatbots, Time Series, Classification, and Regression models, Semantic Search, and more.
</Tip>
