-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdocker.zsh
71 lines (64 loc) · 1.59 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
if [ "$(uname)" = "Linux" ]; then
alias dockerr="sudo docker"
else
alias dockerr="docker"
fi
# use images
alias db="dockerr build"
alias dr="dockerr run --rm"
alias dri="dockerr run -it"
# list
alias di="dockerr images | grep -Fv 'rancher/'"
alias dps="dockerr ps -a | grep -Fve 'rancher/' -e 'k8s_'"
# rm
alias rmc="dockerr rm"
alias rmca='dockerr rm $(dockerr ps -q -a) >/dev/null 2>&1; true'
alias rmi="rmca; dockerr rmi"
function rmia() {
rmca
dockerr images | grep -F '<none>' | awk '{ print $3 }' | tr '\n' ' ' | xargs dockerr rmi -f
}
alias rma="rmia" # rm all
alias dk="dockerr kill"
dex() {
dockerr exec -it $1 bash
# -u 0 for root access
}
dep() {
local CONTAINER_ID=$1; shift
dockerr exec -it $CONTAINER_ID psql $@
}
# docker-compose
function dc() {
dockerr compose --ansi always $@ | grep -v rabbitmq-1
}
alias dcb="dockerr compose build"
alias dcup="dockerr compose up"
alias dcdown="dockerr compose down"
alias dcre="dockerr compose restart"
alias dcs="yq '.services | keys' docker-compose.yml"
alias k="kubectl"
# get
alias kp="k get pods"
alias pods="k get pods"
alias kpw="k get pods -o wide"
alias kd="k get deployments"
alias depl="k get deployments"
alias ks="k get services"
alias serv="k get services"
alias kall="k get all"
alias kn="k get namespace | grep -Fve kube-public -e kube-system -e kube-node-lease"
alias kcm="k get configmap"
alias ki="k get ingresses"
alias kpv="k get pv"
alias kpvc="k get pvc"
# debugging
alias kl="k logs"
alias kdes="k describe"
kx() {
k exec -it $1 -- bin/bash
}
# apply config
alias ka="k apply -f"
alias kr="k delete -f"
alias krm="k delete -f"