-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_docker_functions
124 lines (98 loc) · 2.6 KB
/
_docker_functions
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
#!/bin/bash
# docker stuff - https://hackernoon.com/handy-docker-aliases-4bd85089a3b8h
dkln() {
docker logs -f `docker ps | grep $1 | awk '{print $1}'`
}
dkp() {
if [ ! -f .dockerignore ]; then
echo "Warning, .dockerignore file is missing."
read -p "Proceed anyway?"
fi
if [ ! -f package.json ]; then
echo "Warning, package.json file is missing."
read -p "Are you in the right directory?"
fi
VERSION=`cat package.json | jq .version | sed 's/\"//g'`
NAME=`cat package.json | jq .name | sed 's/\"//g'`
LABEL="$1/$NAME:$VERSION"
docker build --build-arg NPM_TOKEN=${NPM_TOKEN} -t $LABEL .
read -p "Press enter to publish"
docker push $LABEL
}
dkpnc() {
if [ ! -f .dockerignore ]; then
echo "Warning, .dockerignore file is missing."
read -p "Proceed anyway?"
fi
if [ ! -f package.json ]; then
echo "Warning, package.json file is missing."
read -p "Are you in the right directory?"
fi
VERSION=`cat package.json | jq .version | sed 's/\"//g'`
NAME=`cat package.json | jq .name | sed 's/\"//g'`
LABEL="$1/$NAME:$VERSION"
docker build --build-arg NPM_TOKEN=${NPM_TOKEN} --no-cache=true -t $LABEL .
read -p "Press enter to publish"
docker push $LABEL
}
dkpl() {
if [ ! -f .dockerignore ]; then
echo "Warning, .dockerignore file is missing."
read -p "Proceed anyway?"
fi
if [ ! -f package.json ]; then
echo "Warning, package.json file is missing."
read -p "Are you in the right directory?"
fi
VERSION=`cat package.json | jq .version | sed 's/\"//g'`
NAME=`cat package.json | jq .name | sed 's/\"//g'`
LATEST="$1/$NAME:latest"
docker build --build-arg NPM_TOKEN=${NPM_TOKEN} --no-cache=true -t $LATEST .
read -p "Press enter to publish"
docker push $LATEST
}
dkclean() {
docker rm $(docker ps --all -q -f status=exited)
docker volume rm $(docker volume ls -qf dangling=true)
}
dkprune() {
docker system prune -af
}
dktop() {
docker stats --format "table {{.Container}}\t{{.Name}}\t{{.CPUPerc}} {{.MemPerc}}\t{{.NetIO}}\t{{.BlockIO}}"
}
dkstats() {
if [ $# -eq 0 ]
then docker stats --no-stream;
else docker stats --no-stream | grep $1;
fi
}
dke() {
docker exec -it $1 /bin/sh
}
dkexe() {
docker exec -it $1 $2
}
dkreboot() {
osascript -e 'quit app "Docker"'
countdown 2
open -a Docker
echo "Restarting Docker engine"
countdown 120
}
dkstate() {
docker inspect $1 | jq .[0].State
}
dksb() {
docker service scale $1=0
sleep 2
docker service scale $1=$2
}
mongo() {
mongoLabel=`docker ps | grep mongo | awk '{print $NF}'`
docker exec -it $mongoLabel mongo "$@"
}
redis() {
redisLabel=`docker ps | grep redis | awk '{print $NF}'`
docker exec -it $redisLabel redis-cli
}