-
Notifications
You must be signed in to change notification settings - Fork 0
/
ducker
executable file
·43 lines (40 loc) · 1.95 KB
/
ducker
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
# /bin/bash
CM="sudo docker";CATEGORY=$1;COMMAND=$2
if [ "$CATEGORY" == "shell" ]; then $CM exec -it $2 bash; exit 0; fi
if [ "$CATEGORY" == "compose" ]; then
if [ "$COMMAND" == "shell" ]; then $CM compose run --rm app; exit 0; fi
$CM compose up --build; exit 0; fi
if [ "$CATEGORY" == "list" ]; then
echo Images:; $CM images | sed 's/^/\t/g'
echo Containers:; $CM ps -a | sed 's/^/\t/g'
exit 0; fi
if [ "$CATEGORY" == "image" ]; then
if [ "$COMMAND" == "install" ]; then $CM image pull $3; exit 0; fi
if [ "$COMMAND" == "remove" ]; then $CM image rm $3 -f; exit 0; fi
if [ "$COMMAND" == "build" ]; then $CM build -t $3 .; fi
echo 'Images:'; $CM images | sed 's/^/\t/g'
exit 0; fi
if [ "$CATEGORY" == "container" ]; then
if [ "$COMMAND" == "drop" ]; then $CM remove $3; exit 0; fi
if [ "$COMMAND" == "start" ]; then $CM start --attach $3; exit 0; fi
if [ "$COMMAND" == "stop" ]; then $CM container stop $3; exit 0; fi
if [ "$COMMAND" == "create" ]; then $CM attach $($CM run -dit $3); exit 0; fi
if [ "$COMMAND" == "reconnect" ]; then $CM attach $3; exit 0; fi
echo Containers:; $CM ps -a | sed 's/^/\t/g'
exit 0; fi
echo \
'Usage: ducker [container|image|list] <command> <arguments>
General Commands:
- list Prints out a list of installed docker images and containers
Image Commands:
- build <image name> Builds and installs a docker image from a dockerfile in the current directory
- install <image name> Downloads and installs a docker image
- remove <image name> Removes an image previously downloaded using ducker image install
- list
Container Commands:
- create <image name> Creates a new container and connects to it
- start <container name> Restarts a container
- stop <container name> Stops a container
- drop <container name> Shuts down and removes an existing container
- reconnect <container name> Connects to an existing container
- list'