Created
March 1, 2018 20:31
-
-
Save rafaelhenrique/70bfb2cd271fe2041647ee0624fb2617 to your computer and use it in GitHub Desktop.
Create redis docker container
This file contains hidden or 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/bash | |
PORT=$(echo $PORT) | |
NAME=$(echo $NAME) | |
VOLUME=$(echo $VOLUME) | |
DATE=$(date +"%d%m%Y-%H%M%S") | |
VERSION="latest" | |
SO=$(uname) | |
if [ "$PARAM" == '-h' ]; then | |
echo "environment: PORT, NAME, VOLUME" | |
exit 0 | |
fi | |
if [ -z $PORT ]; then | |
PORT=6379 | |
fi | |
if [ -z $NAME ]; then | |
NAME=redis | |
fi | |
if [ -z $VOLUME ]; then | |
VOLUME="$(pwd)/docker-volumes/data_redis.$NAME.$DATE" | |
fi | |
echo "Overview:" | |
echo "PORT: $PORT" | |
echo "NAME: $NAME" | |
echo "VOLUME: $VOLUME" | |
echo "confirm? (y/n)" | |
read CONFIRMATION | |
if [ "$CONFIRMATION" != "y" ]; then | |
echo "Bye!" | |
exit 0 | |
fi | |
mkdir -p $VOLUME | |
docker pull redis:${VERSION} | |
docker run -t -i -p $PORT:$PORT --name $NAME -v $VOLUME:/data redis:${VERSION} redis-server --appendonly yes | |
if [ $? -ne 0 ]; then | |
docker start $NAME | |
CONTAINER_ID=$(docker ps -a -f name=$NAME --format "{{.ID}}") | |
docker logs -f $CONTAINER_ID | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment