forked from mdouchement/dotfiles-old
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.dockerfunc
146 lines (118 loc) · 3.69 KB
/
.dockerfunc
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/bin/bash
# Bash wrappers for docker run commands
#
# Helper Functions
#
dcleanup(){
docker rm $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null
docker rmi $(docker images --filter dangling=true -q 2>/dev/null) 2>/dev/null
}
dcrmnone(){
docker images | grep '<none>' | awk '{print $3}' | xargs docker rmi 2>/dev/null
}
dcrmvolumes(){
docker volume rm $(docker volume ls -qf dangling=true 2>/dev/null) 2>/dev/null
}
dcleanupall(){
dcleanup
docker rm $(docker ps --filter status=created -q 2>/dev/null) 2>/dev/null
dcrmnone
dcrmvolumes
}
xhyve_enter(){
docker run -it --privileged --pid=host debian nsenter -t 1 -m -u -n -i sh
}
del_stopped(){
local name=$1
local state=$(docker inspect --format "{{.State.Running}}" $name 2>/dev/null)
if [[ "$state" == "false" ]]; then
docker rm $name
fi
}
relies_on(){
local containers=$@
for container in $containers; do
local 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
}
#
# Container Aliases
#
redis-server(){
docker run --restart=always --name redis -p 6379:6379 -itd redis 2>/dev/null
}
redis-cli(){
docker exec -it redis redis-cli "$@"
}
mongo(){
docker exec -it mongo mongo
}
mongo-server(){
docker run --restart=always --name mongo -p 27017:27017 -itd mongo 2>/dev/null
}
postgres-server(){
docker run --restart=always --name postgres -e POSTGRES_PASSWORD=postgres -p 5432:5432 -itd postgres 2>/dev/null
}
psql(){
docker exec -it postgres psql "$@"
}
s3-server(){
docker run --restart=always --name=s3_server -p 10001:10001 -v $HOME/tmp/s3-server/storage:/data/storage -v $HOME/tmp/s3-server/db:/data/db -itd predicsis/s3-server
}
iceweasel(){
docker run -v /tmp/dcrctn:/root/Downloads -v /tmp/.X11-unix:/tmp/.X11-unix:ro -e DISPLAY=unix$DISPLAY -it mdouchement/iceweasel
}
dockswift(){
docker run -P -p 80:80 -p 8080:8080 -p 5000:5000 -p 35357:35357 -p 8000:8000 -d -e INITIALIZE=yes -e IPADDRESS=192.168.1.59 --name swift predicsis/dockswift
sleep 40
docker exec -it swift swift post -m "Temp-URL-Key:temp_url_key" -V 2 --os-auth-url='http://127.0.0.1:5000/v2.0' --os-username='swift' --os-password='swift' --os-tenant-name='service'
}
dockerui(){
docker run --restart=always -d -p 9000:9000 --privileged -v /var/run/docker.sock:/var/run/docker.sock dockerui/dockerui
}
dnsmasq(){
docker run --restart=always --name dnsmasq -d -p 53:53/udp -p 8088:8080 -v ~/app/dnsmasq.conf:/etc/dnsmasq.conf quay.io/jpillora/dnsmasq-gui:latest
}
#geary(){
#docker run -v /tmp/dcrctn:/root/Downloads -v /tmp/.X11-unix:/tmp/.X11-unix:ro -e DISPLAY=unix$DISPLAY -itd mdouchement/geary
#}
chrome(){
del_stopped chrome
# one day remove /etc/hosts bind mount when effing
# overlay support inotify, such bullshit
docker run -d \
--cpuset-cpus 0 \
--memory 3gb \
--net host \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY \
-v $HOME/Downloads:/root/Downloads \
-v $HOME/Pictures:/root/Pictures \
-v $HOME/Torrents:/root/Torrents \
-v $HOME/.chrome:/data \
-v /etc/hosts:/etc/hosts \
--device /dev/snd \
--device /dev/dri \
--device /dev/video0 \
--name chrome \
jess/chrome:stable --user-data-dir=/data --force-device-scale-factor=1 "$@"
# exit current shell
exit 0
}
libreoffice(){
del_stopped libreoffice
docker run -d \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-e DISPLAY=unix$DISPLAY \
-v $HOME/slides:/root/slides \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
--name libreoffice \
jess/libreoffice
}