forked from somatorio/docker-desktop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dockerscript
executable file
·481 lines (419 loc) · 10.3 KB
/
dockerscript
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
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
#!/bin/bash
#
#######
# Highly based on https://github.com/jessfraz/dotfiles/blob/master/.dockerfunc
#######
check_network() {
if ! docker network inspect $1 > /dev/null 2>&1; then
docker network create $1
fi
}
clean_exited() {
docker rm $(docker ps -qf status=exited)
}
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
}
stop_all() {
docker stop $(docker ps -q)
}
############
ansible() {
docker run -it --rm \
--entrypoint /usr/bin/ansible \
-v $(pwd):/code \
-v $HOME/.ssh:/root/.ssh \
-w /code \
dgmorales/ansible "$@"
}
ansible-playbook() {
docker run -it --rm \
-v $(pwd):/code \
-v $HOME/.ssh:/root/.ssh \
-w /code \
dgmorales/ansible "$@"
}
ansible-shell() {
docker run -it --rm \
--entrypoint /bin/bash \
-v $(pwd):/code \
-v $HOME/.ssh:/root/.ssh \
-w /code \
dgmorales/ansible "$@"
}
audacity() {
del_stopped audacity
docker run -d \
--device /dev/snd \
--name audacity \
-e DISPLAY \
-e PULSE_SERVER=pulseaudio \
-v /tmp/.X11-unix:/tmp/.X11-unix/ \
-v $HOME:/root/$(whoami) \
-v $HOME/.audacity:/root/.audacity-data \
jess/audacity
}
atom() {
del_stopped atom
if [ "$1" ]
then
local=$(cd $(dirname "$@");pwd)
MOUNT="-v $local:/workdir/"
fi
docker run -d \
--name atom \
-e DISPLAY \
-u 0:0 \
-v $HOME/.atom:/root/.atom \
-v $HOME:/root/$(whoami)/ \
-v /dev/shm:/dev/shm \
-v /tmp/.X11-unix/:/tmp/.X11-unix/ \
$MOUNT \
jamesnetherton/docker-atom-editor $(if [ "$1" ]; then echo "atom -f /workdir/$(basename "$@")";fi)
}
chrome(){
del_stopped chrome
relies_on pulseaudio
docker run -d \
--cpuset-cpus 0 \
--device /dev/snd \
--device /dev/dri \
--device /dev/video0 \
--memory 1gb \
--name chrome \
--net desktop \
--net pulseaudio \
--group-add audio \
--group-add video \
--security-opt seccomp:$HOME/docker-desktop/configs/chrome/seccomp/chrome.json \
-e DBUS_SESSION_BUS_ADDRESS \
-e DISPLAY \
-e PULSE_SERVER=pulseaudio \
-v /dev/shm:/dev/shm \
-v /etc/localtime:/etc/localtime:ro \
-v /run/user/$(id -u):/run/user/$(id -u) \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /var/run/dbus:/var/run/dbus \
-v $HOME/Downloads:/home/chrome/Downloads \
-v $HOME/Pictures:/home/chrome/Pictures \
-v $HOME/Torrents:/home/chrome/Torrents \
-v $HOME/.chrome:/home/chrome/.config/google-chrome \
jess/chrome $@
}
deluge() {
del_stopped deluge
docker run -d \
--name deluge \
--net host \
-e DISPLAY \
-p 58846:58846 \
-p 58946:58946 \
-v /tmp/.X11-unix/:/tmp/.X11-unix/ \
-v $HOME/.config/deluge:/root/.config/deluge \
-v $HOME/Downloads/:/root/Downloads \
-v $HOME/Torrents/:/root/Torrents \
somatorio/deluge-gtk
}
emulationstation() {
docker run -it --rm \
--device /dev/input \
--device /dev/snd \
-e DBUS_SESSION_BUS_ADDRESS \
-e DISPLAY \
-v /run/user/$(id -u):/run/user/$(id -u) \
-v /tmp/.X11-unix/:/tmp/.X11-unix/ \
-v /var/run/dbus:/var/run/dbus \
-v /var/run/docker.sock:/var/run/docker.sock \
-v $HOME/.emulationstation:/root/.emulationstation \
-v $HOME/roms:/root/roms \
somatorio/emulationstation $@
}
firefox() {
del_stopped firefox
docker run -d \
--cpuset-cpus 0 \
--device /dev/snd \
--device /dev/dri \
--memory 1gb \
--name firefox \
--net desktop \
-e DISPLAY \
-v /etc/localtime:/etc/localtime:ro \
-v /dev/shm:/dev/shm \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $HOME/.firefox/cache:/root/.cache/mozilla \
-v $HOME/.firefox/mozilla:/root/.mozilla \
-v $HOME/.firefox/laspass:/root/.lastpass \
-v $HOME/Downloads:/root/Downloads \
jess/firefox "$@"
}
gimp() {
del_stopped gimp
docker container run -d \
--name gimp \
-e DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix/ \
-v /home/$(whoami):/root/$(whoami) \
jess/gimp
}
hugo() {
docker run --rm -it \
-v $(pwd):/src \
jojomi/hugo hugo $@
}
inkscape() {
del_stopped inkscape
docker container run -d \
--name inkscape \
-e DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix/ \
-v /home/$(whoami):/root/$(whoami) \
jess/inkscape
}
minecraft() {
#I know that "--net host" is evil, but if you want to play lan hosted games, you'll need it
docker run --rm \
-e DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix/ \
--device /dev/snd/ \
--net host \
-v $HOME/.minecraft:/root/.minecraft \
somatorio/minecraft-launcher
}
mysql-workbench() {
del_stopped mysql-workbench
docker run -d \
--name mysql-workbench \
-e DISPLAY \
-v $HOME/.mysql-workbench:/root/.mysql/workbench \
-v /tmp/.X11-unix/:/tmp/.X11-unix/ \
jdecool/mysql-workbench
}
obs(){
del_stopped obs
relies_on pulseaudio
docker run -d \
--device /dev/video0 \
--device /dev/snd/ \
--name obs \
--net pulseaudio \
-e DISPLAY \
-e PULSE_SERVER=pulseaudio \
-e QT_DEVICE_PIXEL_RATIO \
-v /tmp/.X11-unix/:/tmp/.X11-unix/ \
-v $HOME:/root/$(whoami) \
-v $HOME/.obs:/root/.config/obs-studio \
somatorio/obs-studio
}
packettracer() {
docker run -it --rm \
-e DISPLAY=unix$DISPLAY \
-v /tmp/.X11-unix/:/tmp/.X11-unix/ \
-v $HOME/pt:/root/pt \
somatorio/packet-tracer
}
plex() {
del_stopped plex
docker run -d \
--name plex \
--net=host \
-e TZ="America/Sao_Paulo" \
-v $HOME/.plex/config:/config \
-v $HOME/.plex/temp:/transcode \
-v $HOME/.plex/data:/data \
-v $HOME:/$(whoami) \
plexinc/pms-docker
}
pulseaudio(){
del_stopped pulseaudio
check_network pulseaudio
docker run -d \
--device /dev/snd \
--group-add audio \
--name pulseaudio \
--net pulseaudio \
-p 4713:4713 \
-u pulseaudio:92 \
-v /etc/localtime:/etc/localtime:ro \
-v /var/run/dbus/system_bus_socket:/var/run/dbus/system_bus_socket \
jess/pulseaudio
}
pulseaudio-set-hdmi(){
docker exec pulseaudio /usr/bin/pactl load-module module-alsa-sink device=hw:0,3
docker exec pulseaudio /usr/bin/pacmd set-default-sink 1
}
remmina(){
del_stopped remmina
check_network desktop
docker run -d \
--name remmina \
--net desktop \
-e DISPLAY \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $HOME/.remmina:/root/.remmina \
jess/remmina "$@"
}
steam(){
del_stopped steam
relies_on pulseaudio
docker run -d \
--device /dev/dri \
--name steam \
--net pulseaudio \
-e DBUS_SESSION_BUS_ADDRESS \
-e DISPLAY=unix$DISPLAY \
-e PULSE_SERVER=pulseaudio \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/machine-id:/etc/machine-id:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v /var/run/dbus:/var/run/dbus \
-v $HOME/.steam:/home/steam \
tianon/steam $@
}
skype() {
del_stopped skype
docker container run -d \
--device /dev/snd \
--device /dev/video0 \
--name skype \
-e DISPLAY \
-v /tmp/.X11-unix:/tmp/.X11-unix \
jess/skype
}
skype2() {
del_stopped skype
relies_on pulseaudio
docker run -d \
--device /dev/video0 \
--group-add video \
--group-add audio \
--name skype \
--net pulseaudio \
--security-opt seccomp:unconfined \
-e "DISPLAY=unix${DISPLAY}" \
-e PULSE_SERVER=pulseaudio \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
jess/skype
}
telegram() {
del_stopped telegram
docker run -d -it --name telegram \
--cpuset-cpus 1 \
--device /dev/snd \
-e DISPLAY \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $HOME/.TelegramDesktop:/root/.local/share/TelegramDesktop/ \
-v $HOME/Downloads:/root/Downloads \
-v $HOME/Pictures:/root/Pictures \
xorilog/telegram
}
unrar() {
local=$(cd $(dirname $1);pwd)
docker run --rm -it \
-u $(id -u):$(id -g) \
-v $local:/work \
senk/unrar e $(basename $1)
}
unzip() {
local=$(cd $(dirname $1);pwd)
docker run --rm -it \
-u $(id -u):$(id -g) \
-v $local:/root/zip \
-w /root/zip \
alpine:3.4 unzip $(basename $1)
}
vlc(){
del_stopped vlc
relies_on pulseaudio
docker run -d \
--device /dev/dri \
--name vlc \
--net pulseaudio \
--group-add audio \
--group-add video \
-e DISPLAY=unix$DISPLAY \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
-e QT_DEVICE_PIXEL_RATIO \
-e PULSE_SERVER=pulseaudio \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $HOME:/home/vlc/$(whoami) \
jess/vlc
}
xchat() {
del_stopped xchat
docker run -d \
--name xchat \
-e DISPLAY \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $HOME/.xchat:/home/xchat/config \
jamesnetherton/xchat
}
xchat-clone() {
del_stopped xchat
docker run -d \
--name xchat \
-e DISPLAY \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
jamesnetherton/xchat
}
x11-alpine() {
docker run --rm -it \
-e DISPLAY \
-v /etc/localtime:/etc/localtime:ro \
-v /etc/machine-id:/etc/machine-id \
-v /var/run/dbus:/var/run/dbus \
-v /tmp/.X11-unix:/tmp/.X11-unix \
alpine:3.4 sh
}
xfce4-screenshooter() {
del_stopped xfce4-screenshooter
docker run -d \
--name xfce4-screenshooter \
-e DISPLAY \
-v /etc/localtime:/etc/localtime:ro \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $HOME/Pictures:/root/Pictures \
somatorio/xfce4-screenshooter $@
}
wine() {
docker run --rm -it \
--device /dev/snd/ \
--device /dev/dri \
-e DISPLAY \
-e GDK_SCALE \
-e GDK_DPI_SCALE \
-e QT_DEVICE_PIXEL_RATIO \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v $(pwd):/workdir \
-v $HOME/.config/wine:/root/.wine \
-w /workdir \
somatorio/wine wine "$@"
}
if [ $1 ]; then
cmd=$1
shift
$cmd $@
fi