---
title: Install and run InfluxDB using Docker
description: Install and run InfluxDB OSS v1.12 using Docker. Configure and operate InfluxDB in a Docker container.
url: https://docs.influxdata.com/influxdb/v1/introduction/install/docker/
estimated_tokens: 1471
product: InfluxDB OSS v1
version: v1
publisher: InfluxData
canonical: https://docs.influxdata.com/influxdb/v1/introduction/install/docker/
date: '2026-01-15T14:55:06-06:00'
lastmod: '2026-01-15T14:55:06-06:00'
---

This page documents an earlier version of InfluxDB OSS.[InfluxDB 3 Core](/influxdb3/core/) is the latest stable version.

Install and run InfluxDB OSS v1.12 using Docker containers.
This guide covers Docker installation, configuration, and initialization options.

* [Install and run InfluxDB](#install-and-run-influxdb)
  * [Pull the InfluxDB v1.x image](#pull-the-influxdb-v1x-image)
  * [Start InfluxDB](#start-influxdb)

* [Configure InfluxDB](#configure-influxdb)
  * [Using environment variables](#using-environment-variables)
  * [Using a configuration file](#using-a-configuration-file)

* [Initialize InfluxDB](#initialize-influxdb)
  * [Automatic initialization (for development)](#automatic-initialization-for-development)
  * [Custom initialization scripts](#custom-initialization-scripts)

* [Access the InfluxDB CLI](#access-the-influxdb-cli)
* [Next steps](#next-steps)

## Install and run InfluxDB

### Pull the InfluxDB v1.x image

```bash
docker pull influxdb:1.12.4
```

### Volume permissions

> [!Important]
> The InfluxDB Docker container runs as user influxdb with UID/GID 1500.
> When mounting volumes for persistent storage, ensure the mounted directory on the host is owned by UID/GID 1500, or InfluxDB may not have permission to write data.

Set the correct ownership before starting the container:

#### Create the data directory

mkdir -p data

#### Set ownership to UID/GID 1500

sudo chown -R 1500:1500 data

### Start InfluxDB

> [!Important]
> On MacOS due to issues related to docker desktop’s VM and local binds
> you must use either a *delegated local directory* or a *named volume* when starting a container.

#### Linux/Windows ####

Start a basic InfluxDB container with persistent storage:

```bash
docker run -p 8086:8086 \
  -v $PWD/data:/var/lib/influxdb \
  influxdb:1.12.4
```

On MacOS, you must use either a *delegated local directory* or a *named volume* when starting an InfluxDB container.

**Option A: Use a delegated local directory**

```bash
docker run -p 8086:8086 \
    -v $PWD/data-test2:/var/lib/influxdb:delegated \
    influxdb:1.12.4
```

**Option B: Use a named docker volume (still local, but managed by Docker Desktop)**

```bash
docker run -d --name influxdb \
    -p 8086:8086 \
    -v influxdb-data:/var/lib/influxdb \
    influxdb:1.12.4
```

InfluxDB is now running and available at [http://localhost:8086](http://localhost:8086).

## Configure InfluxDB

### Using environment variables

Configure InfluxDB settings using environment variables:

```bash
docker run -p 8086:8086 \
  -v $PWD/data:/var/lib/influxdb \
  -e INFLUXDB_REPORTING_DISABLED=true \
  -e INFLUXDB_HTTP_AUTH_ENABLED=true \
  -e INFLUXDB_HTTP_LOG_ENABLED=true \
  influxdb:1.12.4
```

### Using a configuration file

Generate a default configuration file:

```bash
docker run --rm influxdb:1.12.4 influxd config > influxdb.conf
```

Start InfluxDB with your custom configuration:

```bash
docker run -p 8086:8086 \
  -v $PWD/influxdb.conf:/etc/influxdb/influxdb.conf:ro \
  -v $PWD/data:/var/lib/influxdb \
  influxdb:1.12.4
```

## Initialize InfluxDB

### Automatic initialization (for development)

> [!Warning]
> Automatic initialization with InfluxDB v1 is not recommended for production.
> Use this approach only for development and testing.

Automatically create a database and admin user on first startup:

```bash
docker run -p 8086:8086 \
  -v $PWD/data:/var/lib/influxdb \
  -e INFLUXDB_DB=mydb \
  -e INFLUXDB_HTTP_AUTH_ENABLED=true \
  -e INFLUXDB_ADMIN_USER=admin \
  -e INFLUXDB_ADMIN_PASSWORD=supersecretpassword \
  influxdb:1.12.4
```

Environment variables for user creation:

* `INFLUXDB_USER`: Create a user with no privileges
* `INFLUXDB_USER_PASSWORD`: Password for the user
* `INFLUXDB_READ_USER`: Create a user who can read from `INFLUXDB_DB`
* `INFLUXDB_READ_USER_PASSWORD`: Password for the read user
* `INFLUXDB_WRITE_USER`: Create a user who can write to `INFLUXDB_DB`
* `INFLUXDB_WRITE_USER_PASSWORD`: Password for the write user

### Custom initialization scripts

InfluxDB v1.x Docker containers support custom initialization scripts for testing scenarios:

Create an initialization script (`init-scripts/setup.iql`):

```sql
CREATE DATABASE sensors;
CREATE DATABASE logs;

CREATE USER "telegraf" WITH PASSWORD 'secret123';
GRANT WRITE ON "sensors" TO "telegraf";

CREATE USER "grafana" WITH PASSWORD 'secret456';
GRANT READ ON "sensors" TO "grafana";
GRANT READ ON "logs" TO "grafana";

CREATE RETENTION POLICY "one_week" ON "sensors" DURATION 1w REPLICATION 1 DEFAULT;
```

Run with initialization scripts:

```bash
docker run -p 8086:8086 \
  -v $PWD/data:/var/lib/influxdb \
  -v $PWD/init-scripts:/docker-entrypoint-initdb.d \
  influxdb:1.12.4
```

Supported script types:

* Shell scripts (`.sh`)
* InfluxDB query language files (`.iql`)

> [!Important]
> Initialization scripts only run on first startup when the data directory is empty.
> Scripts execute in alphabetical order based on filename.

## Access the InfluxDB CLI

To access the InfluxDB command line interface from within the Docker container:

```bash
docker exec -it <container-name> influx
```

Replace `<container-name>` with your InfluxDB container name or ID.

## Next steps

Once you have InfluxDB running in Docker, see the [Get started guide](/influxdb/v1/introduction/get-started/) to:

* Create databases
* Write and query data
* Learn InfluxQL basics

#### Related

* [Install InfluxDB OSS v1](/influxdb/v1/introduction/install/)
* [Get started with InfluxDB OSS v1](/influxdb/v1/introduction/get-started/)
* [Authentication and authorization in InfluxDB OSS v1](/influxdb/v1/administration/authentication_and_authorization/)
* [Write data to InfluxDB OSS v1](/influxdb/v1/guides/write_data/)
* [Query data in InfluxDB OSS v1](/influxdb/v1/guides/query_data/)
* [Configure InfluxDB OSS v1](/influxdb/v1/administration/config/)
