forked from OPENDAP/hyrax-docker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdocker_handy.sh
55 lines (48 loc) · 917 Bytes
/
docker_handy.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
#!/bin/bash
# Docker Tricks
# Source this file and read it to see what's up.
# And then use the functions on the command line
#
#
# Stop all running containers
#
function dhalt() {
docker stop $(docker ps -aq);
}
#
# Remove all containers
#
function drmc(){
docker rm $(docker ps -aq);
}
#
# Remove all images
#
function drmi(){
docker rmi $(docker images -q);
}
#
# List all containers (only IDs)
#
function dlist(){
docker ps -aq;
}
#
# Interactive Login Shell
#
function dlogin(){
docker exec -ti $1 bash;
}
#
# stop, cleanup container and image, build, run, login interactive shell
#
function dscbrl() {
package=$1;
tag=`echo "${package}" | tr '[:upper:]' '[:lower:]'`
docker container stop ${tag}
docker rm $(docker ps -aq)
docker rmi ${tag}
docker build -t ${tag} ${package}
docker run --name ${tag} -d -p 8080:8080 ${tag}
docker exec -ti ${tag} bash
}