-
-
Save fudanchii/4b09ed4f7739d584862308e62048ecc4 to your computer and use it in GitHub Desktop.
docker related scripts
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
#!/usr/bin/env bash | |
set -e | |
# change this to your seeds directory | |
base=$HOME/repo/quipper/seeds | |
startall() { | |
postgres.sh | |
mongodb.sh | |
memcached.sh | |
redis.sh | |
} | |
stopall() { | |
postgres.sh stop | |
mongodb.sh stop | |
memcached.sh stop | |
redis.sh stop | |
} | |
dockerstatus() { | |
docker ps --format "{{.ID}}\t{{ printf \"%-24s\" .Image}}\t{{ printf \"%.32s\" .Names}}\t{{.Status}}" | |
} | |
case $1 in | |
"start") | |
cd $base | |
startall | |
cd - | |
;; | |
"stop") | |
stopall | |
;; | |
*) | |
dockerstatus | |
;; | |
esac |
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
#! /usr/bin/env bash | |
name=$USER-memcached | |
if [[ $1 == "stop" ]]; then | |
docker stop $name | |
exit 0 | |
fi | |
case $1 in | |
"stop") | |
docker stop $name | |
exit 0 | |
;; | |
"status") | |
docker ps -f name=$name --format "{{.ID}}\t{{.Image}}\t{{ printf \"%.32s\" .Names}}\t{{.Status}}" | |
exit 0 | |
;; | |
"clean") | |
sudo rm -r $localbinddir | |
exit $? | |
;; | |
esac | |
docker run --rm -d -it \ | |
--name $name \ | |
-p 11211:11211 \ | |
memcached:1.5-alpine |
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 | |
name=$USER-mongodb | |
localbinddir="$HOME/tmp/$(basename $PWD)/mongo" | |
mongodata=/data/db | |
if [[ $1 == "stop" ]]; then | |
docker stop $name | |
exit 0 | |
fi | |
case $1 in | |
"stop") | |
docker stop $name | |
exit 0 | |
;; | |
"status") | |
docker ps -f name=$name --format "{{.ID}}\t{{.Image}}\t{{ printf \"%.32s\" .Names}}\t{{.Status}}" | |
exit 0 | |
;; | |
"clean") | |
sudo rm -r $localbinddir | |
exit $? | |
;; | |
esac | |
# postgres will be proxied via localhost port 5432 | |
docker run -it --rm --privileged -d \ | |
--name $name \ | |
-p 27017:27017 \ | |
-v $localbinddir:$mongodata \ | |
mongo:3.2.11 |
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 | |
username=${DB_USERNAME:=$USER} | |
password=${DB_PASSWORD:=""} | |
pgdata=/var/lib/postgresql/data/pgdata | |
name=$USER-postgres | |
localbinddir="$HOME/tmp/$(basename $PWD)/pgdata" | |
if [[ $1 == "stop" ]]; then | |
docker stop $name | |
exit 0 | |
fi | |
case $1 in | |
"stop") | |
docker stop $name | |
exit 0 | |
;; | |
"status") | |
docker ps -f name=$name --format "{{.ID}}\t{{.Image}}\t{{ printf \"%.32s\" .Names}}\t{{.Status}}" | |
exit 0 | |
;; | |
"clean") | |
sudo rm -r $localbinddir | |
exit $? | |
;; | |
esac | |
# postgres will be proxied via localhost port 5432 | |
docker run -it --rm --privileged -d \ | |
--name $name \ | |
-p 5432:5432 \ | |
-v $localbinddir:$pgdata \ | |
-e POSTGRES_USER=$username \ | |
-e POSTGRES_PASSWORD=$password \ | |
-e PGDATA=$pgdata \ | |
-v /run/postgresql:/var/run/postgresql \ | |
postgres:10.1-alpine |
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
#! /usr/bin/env bash | |
name=$USER-redis | |
if [[ $1 == "stop" ]]; then | |
docker stop $name | |
exit 0 | |
fi | |
case $1 in | |
"stop") | |
docker stop $name | |
exit 0 | |
;; | |
"status") | |
docker ps -f name=$name --format "{{.ID}}\t{{.Image}}\t{{ printf \"%.32s\" .Names}}\t{{.Status}}" | |
exit 0 | |
;; | |
"clean") | |
sudo rm -r $localbinddir | |
exit $? | |
;; | |
esac | |
docker run --rm -d -it \ | |
--name $name \ | |
-p 6379:6379 \ | |
redis:3-alpine |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment