-
Notifications
You must be signed in to change notification settings - Fork 0
/
.dockerfuncs
99 lines (83 loc) · 2.35 KB
/
.dockerfuncs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env bash
# Bash wrappers for docker run commands
dcleanup(){
local containers
mapfile -t containers < <(docker ps -aq 2>/dev/null)
docker rm "${containers[@]}" 2>/dev/null
local volumes
mapfile -t volumes < <(docker ps --filter status=exited -q 2>/dev/null)
docker rm -v "${volumes[@]}" 2>/dev/null
local images
mapfile -t images < <(docker images --filter dangling=true -q 2>/dev/null)
docker rmi "${images[@]}" 2>/dev/null
}
del_stopped(){
local name=$1
local state
state=$(docker inspect --format "{{.State.Running}}" "$name" 2>/dev/null)
if [[ "$state" == "false" ]]; then
docker rm "$name"
fi
}
rmctr(){
# shellcheck disable=SC2068
docker rm -f $@ 2>/dev/null || true
}
relies_on(){
for container in "$@"; do
local state
state=$(docker inspect --format "{{.State.Running}}" "$container" 2>/dev/null)
if [[ "$state" == "false" ]] || [[ "$state" == "" ]]; then
echo "$container is not running, starting it for you."
$container
fi
done
}
dps() {
docker ps -a --format 'table {{.Names}}\t{{.Status}}\t{{.Ports}}\t{{.ID}}'
}
cockroachdb() {
del_stopped cockroachdb
docker volume create cockroach_data
docker run -d \
--restart always \
-v cockroach_data:/cockroach/cockroach-data \
-p 26257:26257 \
-p 8080:8080 \
--name cockroachdb \
cockroachdb/cockroach start-single-node --insecure
}
mongodb() {
del_stopped mongodb
docker run -d \
--restart always \
-e MONGO_INITDB_ROOT_USERNAME=root \
-e MONGO_INITDB_ROOT_PASSWORD=admin\
-v "$HOME"/.mongodb_data:/data/db \
-p 27017:27017 \
mongo
}
prometheus() {
del_stopped prometheus
docker volume create prometheus_data
docker run -d \
--restart always \
-v "$HOME"/.prometheus/prometheus.yml:/etc/prometheus/prometheus.yml \
-v prometheus_data:/prometheus \
-p 9090:9090 \
-config.file=/etc/prometheus/prometheus.yml \
-storage.local.path=/prometheus \
-storage.local.memory-chunks=10000 \
--name prometheus \
prom/prometheus
}
redis() {
del_stopped redis
docker volume create redis_data
docker run -d \
--restart always \
-v redis_data:/data \
-p 6379:6379 \
--name redis \
redis-server --save 60 --requirepass pixelA1+ --loglevel warning
}