Last active
March 14, 2016 12:04
-
-
Save rafaelhenrique/435432b4c681b8843a55 to your computer and use it in GitHub Desktop.
Create/Manage base/simple Docker containers
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/bash | |
DOCKERIMAGE=$1 | |
if [ -z "$DOCKERIMAGE" ]; then | |
echo 'Paramether $1 not found.' | |
echo "Syntax: $0 DOCKERIMAGE" | |
exit 1 | |
fi | |
docker ps -a | docker ps -a | awk '$2 ~ /'$DOCKERIMAGE'/ { print }' | |
if [ "$?" -ne 0 ]; then | |
echo "Images dont match with your input. Bye." | |
exit 0 | |
fi | |
echo "Remove listed images? [y/N]" | |
read RESP | |
if [ "$RESP" == "y" -o "$RESP" == "Y" ]; then | |
docker rm $(docker ps -a | docker ps -a | awk '$2 ~ /'$DOCKERIMAGE'/ { print }') | |
docker rmi -f $(docker images | awk '$1 ~ /'$DOCKERIMAGE'/ {print}') | |
echo "Removed. Bye." | |
else | |
echo "Bye." | |
fi |
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/bash | |
DATADIR="$HOME/mysql_data" | |
mkdir $DATADIR | |
echo "DATADIR is $DATADIR" | |
docker pull mysql | |
docker run -t -i -p 3306:3306 -e MYSQL_ROOT_PASSWORD=YOUR_ROOT_DATABASE_PASSWORD -v "$DATADIR":/var/lib/mysql mysql mysqld |
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/bash | |
PORT=6379 | |
DATADIR="$HOME/redis_data" | |
mkdir $DATADIR | |
echo "DATADIR is $DATADIR" | |
sysctl vm.overcommit_memory=1 | |
echo 512 > /proc/sys/net/core/somaxconn | |
echo never > /sys/kernel/mm/transparent_hugepage/enabled | |
docker pull redis | |
docker run -t -i -p "$PORT":"$PORT" -v "$DATADIR":/data redis redis-server --appendonly yes |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment