-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker.zsh
194 lines (173 loc) · 4.54 KB
/
docker.zsh
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
#!/usr/bin/zsh
#
# Helper Functions
#
dcleanup(){
docker rm $(docker ps -aq 2>/dev/null) 2>/dev/null
docker rm -v $(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
}
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
}
vpn(){
docker run -it \
--cap-add=NET_ADMIN \
--device /dev/net/tun \
--dns 1.1.1.1 \
--dns 1.0.0.1 \
-v $HOME/ownCloud/docker_data/vpn:/vpn \
--restart=always \
--name vpn \
-d dperson/openvpn-client -d -f ''
}
heroku(){
docker run -it --rm -u $(id -u):$(id -g) \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-v /etc/localtime:/etc/localtime:ro \
-v /home:/home \
-v "$PWD":"$PWD" \
-w "$PWD" \
-v /run/user/$(id -u):/run/user/$(id -u) \
johnnagro/heroku-toolbelt "$@"
}
pt(){
docker run -it --rm -u $(id -u):$(id -g) \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-v /etc/localtime:/etc/localtime:ro \
-v /home:/home \
-v "$PWD":"$PWD" \
-w "$PWD" \
-e PAPERTRAIL_API_TOKEN=$PAPERTRAIL_API_TOKEN \
-v /run/user/$(id -u):/run/user/$(id -u) \
johnnagro/papertrail "$@"
}
letsencrypt(){
docker run -it --rm \
-v /etc/localtime:/etc/localtime:ro \
-v /home/jnagro/ownCloud/env/letsencrypt:/etc/letsencrypt \
johnnagro/letsencrypt "$@"
}
1password(){
# del_stopped 1password
docker run \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $HOME/Dropbox:/root/Dropbox \
-e DISPLAY=unix$DISPLAY \
--name 1password \
johnnagro/1password
}
torproxy(){
del_stopped torproxy
docker run -d \
--restart always \
-v /etc/localtime:/etc/localtime:ro \
-p 9050:9050 \
--name torproxy \
jess/tor-proxy
}
# thunderbird(){
# del_stopped thunderbird
# relies_on torproxy
#
# docker run --rm -u $(id -u):$(id -g) -w $HOME \
# --device /dev/snd \
# --device /dev/dri \
# --net container:torproxy \
# -v /etc/passwd:/etc/passwd:ro \
# -v /etc/group:/etc/group:ro \
# -v /etc/localtime:/etc/localtime:ro \
# -v /etc/machine-id:/etc/machine-id:ro \
# -v /home:/home \
# -v /tmp/.X11-unix:/tmp/.X11-unix \
# -v /run/user/$(id -u):/run/user/$(id -u) \
# -e DISPLAY=unix$DISPLAY \
# --name thunderbird \
# johnnagro/thunderbird
# }
# atom(){
# # del_stopped atom
# docker run -u $(id -u):$(id -g) -w $HOME \
# --device /dev/snd \
# --device /dev/dri \
# -v /etc/passwd:/etc/passwd:ro \
# -v /etc/group:/etc/group:ro \
# -v /etc/localtime:/etc/localtime:ro \
# -v /home:/home \
# -v /tmp/.X11-unix:/tmp/.X11-unix \
# -v /run/user/$(id -u):/run/user/$(id -u) \
# -e DISPLAY=unix$DISPLAY \
# --name atom \
# johnnagro/atom "$@"
# }
# slack(){
# del_stopped slack
#
# docker run --rm -u $(id -u):$(id -g) -w $HOME \
# --device /dev/dri \
# --device /dev/snd \
# -v /etc/passwd:/etc/passwd:ro \
# -v /etc/group:/etc/group:ro \
# -v /etc/machine-id:/etc/machine-id:ro \
# -v /etc/localtime:/etc/localtime:ro \
# -v /home:/home \
# -v /tmp/.X11-unix:/tmp/.X11-unix \
# -v /run/user/$(id -u):/run/user/$(id -u) \
# -e DISPLAY=unix$DISPLAY \
# --name slack \
# 58bc7d634701
# }
scudcloud(){
# del_stopped scudcloud
docker run -u $(id -u):$(id -g) -w $HOME \
--device /dev/dri \
--device /dev/snd \
-v /etc/passwd:/etc/passwd:ro \
-v /etc/group:/etc/group:ro \
-v /etc/machine-id:/etc/machine-id:ro \
-v /etc/localtime:/etc/localtime:ro \
-v /home:/home \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /run/user/$(id -u):/run/user/$(id -u) \
-e DISPLAY=unix$DISPLAY \
--name scudcloud \
johnnagro/scudcloud
}
# torbrowser(){
# del_stopped torbrowser
#
# docker run --rm \
# --device /dev/snd \
# --device /dev/dri \
# -v /tmp/.X11-unix:/tmp/.X11-unix \
# -e DISPLAY=unix$DISPLAY \
# --name torbrowser \
# jess/tor-browser
# }
# torbrowser () {
# del_stopped torbrowser
# docker run --rm \
# --device /dev/snd \
# --device /dev/dri \
# -v /tmp/.X11-unix:/tmp/.X11-unix \
# -e DISPLAY=unix$DISPLAY \
# --name torbrowser \
# johnnagro/torbrowser
# }