Skip to content

Instantly share code, notes, and snippets.

@szukalski
Last active February 2, 2017 20:07
Show Gist options
  • Save szukalski/30ce32b8d30aa1d09bc760b3c9350d89 to your computer and use it in GitHub Desktop.
Save szukalski/30ce32b8d30aa1d09bc760b3c9350d89 to your computer and use it in GitHub Desktop.
docker: influxdb_install
#!/bin/bash
# Run this as root
PERSISTENT_DATA_DIR=/srv/docker
GITHUB_USER=szukalski
GITHUB_REPO=docker-influxdb
IMAGE=influxdb
CONTAINER=influxdb
# Pull the GITHUB repo
cd $PERSISTENT_DATA_DIR
git clone [email protected]:$GITHUB_USER/$GITHUB_REPO
# Create persistent volume list (if any)
VOLUMES=""
if [ -f $PERSISTENT_DATA_DIR/$GITHUB_REPO/docker_volume_list ]
then
while read VOL
do
VOLUMES+="-v $PERSISTENT_DATA_DIR/$GITHUB_REPO$VOL:$VOL "
done < $PERSISTENT_DATA_DIR/$GITHUB_REPO/docker_volume_list
fi
# The databases to create by default
declare -a databases=("servers" "virtualhosts" "network")
# Pull the image
docker pull $IMAGE
# Run the image
docker run -d \
-p 8086:8086 \
$VOLUMES\
--restart always \
--name $CONTAINER \
$IMAGE
sleep 10
# Create databases
for db in "${databases[@]}"
do
curl -G http://localhost:8086/query --data-urlencode "q=CREATE DATABASE $db"
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment