Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM google/golang

RUN apt-get update && \
DEBIAN_FRONTEND=noninteractive apt-get install -yq --no-install-recommends libreadline-gplv2-dev

WORKDIR /gopath/src/influx-cli
ADD . /gopath/src/influx-cli/
RUN go get influx-cli

CMD []
ENTRYPOINT ["/gopath/bin/influx-cli"]
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,3 +138,37 @@ ANY command above can be subject to:
> <filename> : redirect the output into a file

```

docker
------

If you don't have a golang environment available, you can also use influx-cli
from a docker container:

```
$ docker build -t dieterbe/influx-cli .

$ docker run --rm -ti dieterbe/influx-cli
```

Once the `dieterbe/influx-cli` container has been built, you can also use the
`docker-influx-cli.sh` script to run influx-cli through docker.

By default, `docker-influx-cli.sh` will use InfluxDB configuration from
`~/.influxrc` config file, but you can provide your own InfluxDB config file to
the script.

Here are some usage examples:
```
# enter influx-cli prompt with default config file
$ ./docker-influx-cli.sh

# enter influx-cli prompt with custom my.influxrc config file
$ ./docker-influx-cli.sh my.influxrc

# run a single query
$ echo "select * from /pattern/ limit 10" | ./docker-influx-cli.sh

# drop all series that match a request
$ echo "list series /pattern/" | ./docker-influx-cli.sh | sed 's/.*/drop series "&"/' | ./docker-influx-cli.sh
```
21 changes: 21 additions & 0 deletions docker-influx-cli.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash

DOCKER_OPTIONS="--rm -i"
CFG="${1:-$HOME/.influxrc}"
CFGPATH=$(readlink -f "$CFG")

if [ -f "$CFGPATH" ]
then
# add volume to influx-cli config file
DOCKER_OPTIONS="$DOCKER_OPTIONS -v $CFGPATH:/root/.influxrc"
else
>&2 echo "Cannot find influx-cli config file: $CFGPATH"
fi

if [[ -t 0 ]]
then
# stdin is coming from the terminal
DOCKER_OPTIONS="$DOCKER_OPTIONS -t"
fi

docker run $DOCKER_OPTIONS dieterbe/influx-cli