-
Notifications
You must be signed in to change notification settings - Fork 2
/
dockerfunctions
37 lines (32 loc) · 940 Bytes
/
dockerfunctions
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
#!/bin/bash
#
# function helpers for docker commands
# Set our registry based on location
function registry_fp() {
export REGISTRY=registry.forkedprocess.com
docker login -u jmosco registry.forkedprocess.com
}
# Get a containers PID
function container_pid() {
docker inspect --format '{{ .State.Pid }}' "$1"
}
# Clean up images that are tagged <none>:<none>
# dangling images and needs to be pruned
function clean_dangling() {
docker rmi "$(docker images -f "dangling=true" -q)"
}
# Create our utility container
# check if the image is local and exists, otherwise
# build it then run the container
function utility() {
docker run -it --rm \
-v "${HOME}/.ssh:/home/jmosco/.ssh" \
-v "${HOME}/.kube:/home/jmosco/.kube" \
--name utility \
${REGISTRY}/jmosco-utility:1.0 /bin/bash
}
function dclean() {
local containers
containers=( $(docker ps -aq 2>/dev/null) )
docker rm "${containers[@]}" 2>/dev/null
}