Pull the latest version of influxdb official image :
docker pull influxdbOr pull specific version of influxdb official image :
docker pull influxdb:<version>Create a directory for influxdb data volume and change directory to it:
mkdir ~/influxtest && cd ~/influxtestRun influxdb container:
docker run --name influxtest -d -p 8086:8086 \
-v $PWD:/var/lib/influxdb \
influxdbFor run with custom config file :
First generate default configuration file :
docker run --rm influxdb influxd config > influxdb.confIf you want to enable user authentication on http, enable auth-enabled option in config file:
[http]
...
auth-enabled = true
...Then create an admin user :
docker run --rm --link=influxtest -it influxdb influx -host influxtest -execute "CREATE USER myname WITH PASSWORD '123456' WITH ALL PRIVILEGES"Then run the container:
docker run --name influxtest -d -p 8086:8086 \
-v $PWD:/var/lib/influxdb \
-v $PWD/influxdb.conf:/etc/influxdb/influxdb.conf:ro \
influxdb -config /etc/influxdb/influxdb.confRun influxdb cli client in another container linked to influxtest container:
docker run --rm --link=influxtest -it influxdb influx -host influxtestIf you enable user authentication, authenticate your user first:
authCreate a new database:
CREATE DATABASE <dbname>Show list of databases:
SHOW DATABASESUse a database:
USE <dbname>
Run the ps to get ID:
$ docker ps -a | grep influxtest
The return will be something like:
8ba1158110db quay.io/influxdb/influxdb:v2.0.2 "/entrypoint.sh infl…" 3 minutes ago Exited (0) 2 minutes ago influxtest
Remove the container passing the found ID:
$ docker rm 8ba1158110db
8ba1158110db
Run the ps again to check if the container was removed:
$ docker ps -a | grep influxtest