-
Notifications
You must be signed in to change notification settings - Fork 4
/
bash_profile_docker_aliases
137 lines (120 loc) · 5.4 KB
/
bash_profile_docker_aliases
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
# Docker Machine
alias dmachine='cd ~/Downloads/dmachine'
alias dm='sudo docker-machine '
alias dml='docker-machine ls '
alias devstar='docker-machine start dev'
alias denv='env | grep DOCKER'
alias dkenv='eval "$(sudo docker-machine env dev)"'
alias dmc='docker-machine create '
alias dmip='docker-machine ip '
alias dmub='docker run -d -p ubuntu /bin/bash'
alias dmstar='docker-machine start '
alias dmstop='docker-machine stop '
alias mstar='docker-machine start '
alias mstop='docker-machine stop '
# GetIP addresses
dockexecl() { docker exec -i -t $(docker ps -l -q) bash ;}
dockexec() { docker exec -i -t $@ bash ;}
alias dockip='docker inspect --format "{{ .NetworkSettings.IPAddress }}"'
alias dockipl='docker inspect --format "{{ .NetworkSettings.IPAddress }}" $(docker ps -q)'
alias dip='docker inspect --format "{{ .NetworkSettings.IPAddress }}" '
alias dipl='docker inspect $(docker ps -qq) | grep IPAddress'
# Start/Stop the containers
alias mstar1='docker-machine start $(docker-machine ls | tail -1 | awk "{print $1}")'
alias mstop1='docker-machine stop $(docker-machine ls | tail -1 | awk "{print $1}")'
alias dmk='docker-machine kill'
# Gracefully stop and delete all container
alias dra='docker rm $(docker stop $(docker ps -aq))'
# Kill and delete all containers
alias drk='docker rm $(docker kill $(docker ps -aq))'
# Inspect the last container created
alias dmin='docker-machine inspect $(docker-machine ls | tail -1 | awk "{print $1}")'
# Remove the last container created
alias dmrm='docker-machine rm $(docker-machine ls | tail -1 | awk "{print $1}")'
# Docker Network aliases
alias dnr='docker network rm'
alias dnl='docker network ls'
alias dnc='docker network create'
alias dni='docker network inspect'
alias dnia ='docker network inspect $(docker network ls -q)'
alias dnrm='docker network rm $(docker network ls -q)'
# Docker Engine aliases
alias di='docker images'
alias di5='docker images | head -n5'
# start/stop all containers
alias start='docker start $(docker ps -qa)'
alias stop='docker stop $(docker ps -qa)'
# start/stop last containers
alias startl='docker start $(docker ps -qal)'
alias stopl='docker stop $(docker ps -qal)'
alias dl='docker logs '
alias dri='docker rmi '
alias dr='docker rm -f '
alias dls='docker ps -a '
alias dlsl='docker ps -l '
alias dcount='docker ps -qa | wc -l'
alias dtop='docker stop '
alias din='docker inspect '
alias dp='docker port $(docker ps -l -q)'
alias db='docker build -t '
alias dbc='docker build -t --no-cache '
alias drl='docker rm -f `docker ps -ql`'
alias drall='docker rm -f `docker ps -qa`'
alias dexec='docker exec '
dexl() { docker exec -i -t $(docker ps -l -q) /bin/sh ;}
dex() { docker exec -i -t $@ /bin/sh ;}
alias dlog='docker logs $(docker ps -l -q)'
alias drun='docker run -i -t -name '
alias dport='docker port $(docker ps -l -q)'
# Docker inspect the last container created
alias dinl='docker inspect $(docker ps -qal)'
# Docker inspect all containers
alias dina='docker inspect $(docker ps -qa)'
# Docker service ls
alias dsl='docker service ls'
# Docker service inspect
alias dsi='docker service inspect'
# Docker service rm
alias dsrm='docker service rm '
# Docker service delete the last
alias dsrml='docker service rm $(docker service ls -q | head -n1)'
# Inspect and parse all IPs for all containers
alias dnip='docker inspect $(docker ps -qa) | grep IPA | grep [0-9]'
# Example Docker network inspect all network subnets
alias dnnet='docker network inspect $(docker network ls -q) | grep "Subnet\|Gateway"'
# Delete all containers matching the passed paramater
# Example: "delcon ubuntu" or 'anything matching in docker ps output'
delcon() { docker rm -f $(docker ps -a | grep $@ | awk '{print $1}') ;}
# Stop all containers matching the passed paramater.
stopcon() { docker stop $(docker ps -a | grep $@ | awk '{print $1}') ;}
# On demand foreground OS bash shells that delete on shell exit
alias alpinerm='docker run -it --rm alpine /bin/sh'
alias ubunturm='docker run -it --rm ubuntu'
alias debianrm='docker run -it --rm debian'
alias fedorarm='docker run -it --rm fedora'
alias centosrm='docker run -it --rm centos'
alias busyrm='docker run -it --rm busybox'
alias nethostrm='docker run -it --rm --net=host ubuntu'
# On demand foreground OS bash shells that stops on shell exit
alias alpine='docker run -it alpine /bin/sh'
alias ubuntu='docker run -it ubuntu'
alias debian='docker run -it debian'
alias fedora='docker run -it fedora'
alias busy='docker run -it busybox'
alias nethost='docker run -it --net=host ubuntu'
# On demand background OS bash shells running in daemon mode
alias alpined='docker run -itd alpine /bin/sh'
alias ubuntud='docker run -itd ubuntu'
alias debiand='docker run -itd debian'
alias fedorad='docker run -itd fedora'
alias busyd='docker run -itd busybox'
# Delete all containers matching the passed paramater
delimg() { docker rmi $(docker images | grep $@ | awk '{print $3}') ;}
# Delete all with a <none> label bad makes will orphan a 'none' img
delnone() { docker rmi $(docker images | grep none | awk '{print $3}') ;}
# Delete all images matching the arg passed after 'delimg none'
delimg() { docker rmi $(docker images | grep $@ | awk '{print $3}') ;}
# Find all orphaned files, tcp or http connections not being properly closed
alias conns="sudo lsof -a -p $(pidof docker) | wc -l"
# Same as above for unclosed threads but more generic name to pid match such as docker-dev-1.x
alias conns2="lsof -a -p $(ps -e | grep docker | awk '{print $1}' | head -n1) | wc -l"