-
Notifications
You must be signed in to change notification settings - Fork 1
/
.dockerfunc
69 lines (62 loc) · 1.58 KB
/
.dockerfunc
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
#!/bin/bash
export DOCKER_REPO_PREFIX=denhamparry
dcleanup(){
local containers
mapfile -t containers < <(docker ps -aq 2>/dev/null)
docker rm "${containers[@]}" 2>/dev/null
local volumes
mapfile -t volumes < <(docker ps --filter status=exited -q 2>/dev/null)
docker rm -v "${volumes[@]}" 2>/dev/null
local images
mapfile -t images < <(docker images --filter dangling=true -q 2>/dev/null)
docker rmi "${images[@]}" 2>/dev/null
}
del_stopped(){
local name=$1
local state
state=$(docker inspect --format "{{.State.Running}}" "$name" 2>/dev/null)
if [[ "$state" == "false" ]]; then
docker rm "$name"
fi
}
rmctr(){
# shellcheck disable=SC2068
docker rm -f $@ 2>/dev/null || true
}
relies_on(){
for container in "$@"; do
local state
state=$(docker inspect --format "{{.State.Running}}" "$container" 2>/dev/null)
if [[ "$state" == "false" ]] || [[ "$state" == "" ]]; then
echo "$container is not running, starting it for you."
$container
fi
done
}
terraform(){
docker run -it --rm \
-v "${HOME}:${HOME}:ro" \
-v "$(pwd):/usr/src/repo" \
-v /tmp:/tmp \
--workdir /usr/src/repo \
--log-driver none \
-e GOOGLE_APPLICATION_CREDENTIALS \
-e SSH_AUTH_SOCK \
${DOCKER_REPO_PREFIX}/terraform "$@"
}
aws(){
docker run --rm -it \
-v "${HOME}/.aws/:${HOME}/.aws/:rw" \
amazon/aws-cli "$@"
}
# terragrunt(){
# docker run -it --rm \
# -v "${HOME}:${HOME}:ro" \
# -v "$(pwd):/apps" \
# -v /tmp:/tmp \
# --workdir /apps \
# --log-driver none \
# -e GOOGLE_APPLICATION_CREDENTIALS \
# -e SSH_AUTH_SOCK \
# ${DOCKER_REPO_PREFIX}/terragrunt:v0.23.30 "$@"
# }