-
Notifications
You must be signed in to change notification settings - Fork 5
/
functions
25 lines (21 loc) · 874 Bytes
/
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
function dock() {
# Point docker client and docker-machine to the given node
eval "$(docker-machine env $@)"
}
# Remove all containers as well as clear out dangling images
function cleardock() {
docker rm -f $(docker ps -aq) 2> /dev/null
docker rmi $(docker images --filter "dangling=true" -q) 2> /dev/null
}
# Return public IP of a running container
function dockip() {
docker inspect $(docker ps -f name=$@ -q) | grep IP\" | cut -d '"' -f 4
}
# Kill all running instances of given image with partial match
function dockrm() {
docker rm -f $(docker ps | awk '{print $1,$2}' | grep $@ | awk '{print $1}')
}
# List running instances of a given image with partial match, showing none if no match
function dockpsi() {
docker ps --filter id=nonexisting $(docker ps | awk '{print $1,$2}' | grep $@ | awk '{print $1}' | xargs -I{} echo --filter id={} | xargs)
}