Last active
March 1, 2016 10:56
-
-
Save YannRobert/3aa307a5e5d510d58e23 to your computer and use it in GitHub Desktop.
initialisation of volumes for graphite container hopsoft/graphite-statsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
set -x | |
LOG_DIR=$HOME/graphite-volumes/var-log | |
DATA_DIR=$HOME/graphite-volumes/graphite-storage | |
VOLUMES_INIT_CONTAINER_NAME=graphite-volumes-init | |
#rm -rf $LOG_DIR | |
#rm -rf $DATA_DIR | |
# this will fail if one of the volume directories already exists, this prevents you from accidentally deleting your existing data | |
mkdir $LOG_DIR | |
mkdir $DATA_DIR | |
#sudo restorecon -Rv /$HOME/graphite-volumes | |
#sudo chcon -Rt svirt_sandbox_file_t $LOG_DIR | |
#sudo chcon -Rt svirt_sandbox_file_t $DATA_DIR | |
docker rm -f $VOLUMES_INIT_CONTAINER_NAME || true | |
docker pull hopsoft/graphite-statsd | |
docker run -d \ | |
--name $VOLUMES_INIT_CONTAINER_NAME \ | |
hopsoft/graphite-statsd | |
sleep 2 | |
docker logs $VOLUMES_INIT_CONTAINER_NAME | |
docker cp $VOLUMES_INIT_CONTAINER_NAME:/opt/graphite/storage $DATA_DIR | |
mv $DATA_DIR/storage/* $DATA_DIR | |
rmdir $DATA_DIR/storage | |
docker cp $VOLUMES_INIT_CONTAINER_NAME:/var/log $LOG_DIR | |
mv $LOG_DIR/log/* $LOG_DIR | |
rmdir $LOG_DIR/log | |
docker rm -f $VOLUMES_INIT_CONTAINER_NAME | |
echo "Content of storage directory" | |
ls -alFtr $DATA_DIR | |
echo "Content of log directory" | |
ls -alFtr $LOG_DIR | |
echo "Success" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
set -x | |
LOG_DIR=$HOME/graphite-volumes/var-log | |
DATA_DIR=$HOME/graphite-volumes/graphite-storage | |
CONTAINER_NAME=graphite | |
docker pull hopsoft/graphite-statsd | |
docker rm -f $CONTAINER_NAME || true | |
find $DATA_DIR -name "*.pid" | xargs --no-run-if-empty rm | |
docker run -d \ | |
--name $CONTAINER_NAME \ | |
-v /etc/localtime:/etc/localtime \ | |
-v $DATA_DIR:/opt/graphite/storage \ | |
-v $LOG_DIR:/var/log \ | |
-p 80:80 \ | |
-p 2003:2003 \ | |
-p 8125:8125/udp \ | |
hopsoft/graphite-statsd | |
sleep 2 | |
docker logs $CONTAINER_NAME | |
sleep 1 | |
curl --fail http://localhost | |
echo "Success" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You missed one hard-coded container name: https://gist.github.com/janpapenbrock/09b415bcb7da50c8d2de/revisions