-
Notifications
You must be signed in to change notification settings - Fork 1
/
do
44 lines (40 loc) · 808 Bytes
/
do
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
#!/usr/bin/env bash
PATH="$PATH:/usr/local/bin"
TYPE="$1"
COMMAND="$2"
MACHINE="$3"
ID="$4"
date
echo "Type: $TYPE"
echo "Command: $COMMAND"
echo "Machine: $MACHINE"
echo "ID: $ID"
if [ "$TYPE" = "machine" -a "$COMMAND" = "ip" ];
then
docker-machine ip "$MACHINE" | pbcopy
exit $?
fi
if [ "$TYPE" = "machine" ]
then
docker-machine "$COMMAND" "$MACHINE"
exit $?
fi
if [ "$TYPE" = "container" ]
then
if [ "$COMMAND" = "remove" ]; then
ENV=$(docker-machine env --shell sh "$MACHINE")
eval "$ENV"
docker rm -f $(docker ps -aq)
exit $?
elif [ "$COMMAND" = "prune" ]; then
ENV=$(docker-machine env --shell sh "$MACHINE")
eval "$ENV"
docker system prune -a -f
exit $?
else
ENV=$(docker-machine env --shell sh "$MACHINE")
eval "$ENV"
docker "$COMMAND" "$ID"
exit $?
fi
fi