-
Notifications
You must be signed in to change notification settings - Fork 0
/
aliases.sh
68 lines (55 loc) · 1.48 KB
/
aliases.sh
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
# Author: Fatih Mert Doğancan
# Github: github@fatihmert
# WWW: https://fatihmert.dev
# Repo: https://github.com/fatihmert/Docker-Quick-CLI-Commands
## Basics
alias d.rm='docker rm -f'
alias d.rmi='docker rmi'
## Lists
alias d.vols='docker volume ls'
alias d.logs='docker logs'
alias d.psa='docker ps --format "table {{.Status}}\t{{.ID}}\t{{.Names}}\t{{.Image}}"'
## Execution
alias d.exec='docker exec -it'
d.bash(){
d.exec $1 /bin/bash
}
d.sh(){
# d.sh $(d.id go_api)
d.exec $1 /bin/sh
}
## Compose
alias dc.up='docker compose up'
alias dc.upd='docker compose up -d'
alias dc.upb='docker compose up --build'
alias dc.s='docker compose stop'
alias dc.d='docker compose down'
alias dc.r='docker compose restart'
## Others
d.kill(){
if [ "$1" = "all" ]; then
docker container kill $(docker ps -q)
else
docker container kill $1
fi
}
# Find containerId from container image/name
# Ex: d.id go_api
d.id(){
docker ps --format "table {{.ID}}\t{{.Names}}\t{{.Image}}" | grep $1 | awk '{print $1;}'
}
## Miscellaneous
# d.nginx [restart|reload|stop|start] <id>
d.nginx(){
if [ "$1" = "restart" ]; then
d.exec $2 nginx -s restart
elif [ "$1" = "reload" ]; then
d.exec $2 nginx -s reload
elif [ "$1" = "start" ]; then
d.exec $2 nginx -s start
elif [ "$1" = "stop" ]; then
d.exec $2 nginx -s stop
else
echo "[UNKOWN] >$1 not found. Allow NGINX commands; restart, reload, start, stop"
fi
}