centos7 docker redis

docker run --name=redistmp -ti centos /bin/bash

yum -y install gcc tcl make

cd /home

wget http://download.redis.io/redis-stable.tar.gz

tar zxvf redis-stable.tar.gz

cd redis-stable

make MALLOC=libc

make install

mkdir /home/redis

cp redis.conf /home/redis/redis.conf

cp utils/redis_init_script /home/redis/redis_init_script  

chmod +x /home/redis/redis_init_script

vi /home/redis/redis_init_script

docker commit redistmp centos7/redis

mkdir /home/redis/6380

docker cp redistmp:/home/redis/ /home/redis/6380

docker stop redistmp

docker rm redistmp


docker run --name=redis6380 -tid -p 6380:6379 -v /home/redis/6380:/home/redis/  centos7/redis /home/redis/redis_init_script start
redis_init_script


#!/bin/sh
#
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.

REDISPORT=6379
EXEC=/usr/local/bin/redis-server
CLIEXEC=/usr/local/bin/redis-cli

PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/home/redis/redis.conf"

case "$1" in
    start)
        if [ -f $PIDFILE ]
        then
                echo "$PIDFILE exists, process is already running or crashed"
        else
                echo "Starting Redis server..."
                $EXEC $CONF
        fi
        ;;
    stop)
        if [ ! -f $PIDFILE ]
        then
                echo "$PIDFILE does not exist, process is not running"
        else
                PID=$(cat $PIDFILE)
                echo "Stopping ..."
                $CLIEXEC -p $REDISPORT shutdown
                while [ -x /proc/${PID} ]
                do
                    echo "Waiting for Redis to shutdown ..."
                    sleep 1
                done
                echo "Redis stopped"
        fi
        ;;
    *)
        echo "Please use start or stop as first argument"
        ;;
esac

 

posted @ 2016-07-07 14:21  fr5s  阅读(689)  评论(0编辑  收藏  举报