summaryrefslogtreecommitdiff
path: root/plugins/docker/_docker
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/docker/_docker')
-rw-r--r--plugins/docker/_docker40
1 files changed, 35 insertions, 5 deletions
diff --git a/plugins/docker/_docker b/plugins/docker/_docker
index 28568a6e5..fd459a0ca 100644
--- a/plugins/docker/_docker
+++ b/plugins/docker/_docker
@@ -4,14 +4,24 @@
# Requires: Docker installed
# Author: Azaan (@aeonazaan)
# Updates: Bob Maerten (@bobmaerten) for Docker v0.9+
+# Paul van den Berg (@bergvandenp) for Docker v1.3+
# ----- Helper functions
# Output a selectable list of all running docker containers
__docker_containers() {
declare -a cont_cmd
- cont_cmd=($(docker ps | awk 'NR>1{print $1":[CON("$1")"$2"("$3")]"}'))
- _describe 'containers' cont_cmd
+ cont_cmd=($(docker ps | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}'))
+ if [[ 'X$cont_cmd' != 'X' ]]
+ _describe 'containers' cont_cmd
+}
+
+# Output a selectable list of all containers, even not running
+__docker_all_containers() {
+ declare -a cont_cmd
+ cont_cmd=($(docker ps -a | awk 'NR>1{print $NF":[CON("$1")"$2"("$3")]"}'))
+ if [[ 'X$cont_cmd' != 'X' ]]
+ _describe 'containers' cont_cmd
}
# output a selectable list of all docker images
@@ -56,7 +66,7 @@ __diff() {
__docker_containers
}
-__events() {
+__events() {
_arguments \
'--since=[Show previously created events and then stream.]'
}
@@ -97,10 +107,12 @@ __insert() {
__inspect() {
__docker_images
- __docker_containers
+ __docker_all_containers
}
__kill() {
+ _arguments \
+ '(-s,--signal=)'{-s,--signal=}'[KILL Signal]'
__docker_containers
}
@@ -161,7 +173,7 @@ __rm() {
'(-f,--force=)'{-f,--force=}'[Force removal of running container]' \
'(-l,--link=)'{-l,--link=}'[Remove the specified link and not the underlying container]' \
'(-v,--volumes=)'{-v,--volumes=}'[Remove the volumes associated to the container]'
- __docker_containers
+ __docker_all_containers
}
__rmi() {
@@ -215,6 +227,10 @@ __start() {
_arguments \
'(-a,--attach=)'{-a,--attach=}'[Attach container''s stdout/stderr and forward all signals to the process]' \
'(-i,--interactive=)'{-i,--interactive=}'[Attach container''s stdin]'
+ __docker_all_containers
+}
+
+__stats() {
__docker_containers
}
@@ -238,6 +254,14 @@ __wait() {
__docker_containers
}
+__exec() {
+ _arguments \
+ '(-d,--detach=)'{-d,--detach=}'[Detached mode: run command in the background]' \
+ '(-i,--interactive=)'{-i,--interactive=}'[Keep STDIN open even if not attached]' \
+ '(-t,--tty=)'{-t,--tty=}'[Allocate a pseudo-TTY]'
+ __docker_containers
+}
+
# end commands ---------
# ----------------------
@@ -271,11 +295,13 @@ _1st_arguments=(
"save":"Save an image to a tar archive"
"search":"Search for an image in the docker index"
"start":"Start a stopped container"
+ "stats":"Display a live stream of one or more containers' resource usage statistics"
"stop":"Stop a running container"
"tag":"Tag an image into a repository"
"top":"Lookup the running processes of a container"
"version":"Show the docker version information"
"wait":"Block until a container stops, then print its exit code"
+ "exec":"Run a task inside a running container"
)
_arguments '*:: :->command'
@@ -341,6 +367,8 @@ case "$words[1]" in
__save ;;
search)
__search ;;
+ stats)
+ __stats ;;
start)
__start ;;
stop)
@@ -353,4 +381,6 @@ case "$words[1]" in
__version ;;
wait)
__wait ;;
+ exec)
+ __exec ;;
esac