-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathdc
executable file
·63 lines (54 loc) · 1 KB
/
dc
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
#!/usr/bin/env bash
# Borrowed from @ggerrietts
function dc_rebuild {
docker-compose build "$@" && docker-compose stop "$@" && docker-compose up -d "$@"
}
function dc_cycle {
docker-compose stop "$@" && docker-compose up -d "$@"
}
function dc_clean {
docker rm $(docker ps -a -q)
docker rmi $(docker images -q -f dangling=true)
}
function dc_nuke {
docker kill $(docker ps -q)
docker rm $(docker ps -a -q)
docker rmi $(docker images -q)
}
function dc_console {
docker-compose exec "$1" /bin/bash
}
function dc_ports {
docker ps --filter name="$1" --format "{{.Names}}: {{.Ports}}"
}
if [[ $# > 0 ]]; then
case "$1" in
clean )
dc_clean
;;
console )
shift
dc_console "$@"
;;
cycle )
shift
dc_cycle "$@"
;;
nuke )
dc_nuke
;;
ports )
shift
dc_ports "$@"
;;
rebuild )
shift
dc_rebuild "$@"
;;
*)
docker-compose "$@"
;;
esac
else
docker-compose
fi