Wednesday, March 23, 2016

Working with Docker

hi all,

Horay!! I have dockerized my graphite engine. Basically, I crafted a docker image, called centos6.6-graphite-web-base. Then, I extended a couple of paths such that a couple of containers can write onto the same share paths and files. Now, I can spawn out a couple of carbon instances, listening on a specific port numbers with no mercy at all. Its just work! Docker rock!!!!!

I used the supervisor http://supervisord.org/, to launch the processes. It is neat. 

CONTAINER_NAME="GRAPHITE1"
CONTAINER_PORT="80"
if docker ps | grep -q $CONTAINER_NAME
then
        echo "Container is created: $CONTAINER_NAME"
else
        echo -n "Creating container: $CONTAINER_NAME - "
        docker run -d --restart=on-failure:3 \
                -it \
                --memory-swap=-1 \
                --name $CONTAINER_NAME \
                --hostname $CONTAINER_NAME \
                -p $CONTAINER_PORT:$CONTAINER_PORT \
                -v $WHISPER_STORAGE_PATH:/opt/graphite/storage/whisper \
                -v $HTTPD_CONF_PATH:/etc/httpd/conf/httpd.conf:rw \
                hiuy/centos6.6-graphite-web-base:0.0 \
                /usr/local/bin/svscan /etc/my_services
        echo ""
fi

CONTAINER_NAME="CARBON1"
CONTAINER_PORT="56260"
if docker ps | grep -q $CONTAINER_NAME
then
        echo "Container is created: $CONTAINER_NAME"
else
        echo -n "Creating container: $CONTAINER_NAME - "
        docker run -d --restart=on-failure:3 \
                -it \
                --memory-swap=-1 \
                --name $CONTAINER_NAME \
                --hostname $CONTAINER_NAME \
                --env port=$CONTAINER_PORT \
                -p $CONTAINER_PORT:$CONTAINER_PORT \
                -v $WHISPER_CONF_PATH:/opt/graphite/conf/storage-schemas.conf:ro \
                -v $WHISPER_STORAGE_PATH:/opt/graphite/storage/whisper \
                hiuy/centos6.6-carbon-base:0.0 \
                /usr/local/bin/svscan /etc/my_services

fi

No comments: