github.com/reds/docker@v1.11.2-rc1/contrib/completion/zsh/_docker (about) 1 #compdef docker 2 # 3 # zsh completion for docker (http://docker.com) 4 # 5 # version: 0.3.0 6 # github: https://github.com/felixr/docker-zsh-completion 7 # 8 # contributors: 9 # - Felix Riedel 10 # - Steve Durrheimer 11 # - Vincent Bernat 12 # 13 # license: 14 # 15 # Copyright (c) 2013, Felix Riedel 16 # All rights reserved. 17 # 18 # Redistribution and use in source and binary forms, with or without 19 # modification, are permitted provided that the following conditions are met: 20 # * Redistributions of source code must retain the above copyright 21 # notice, this list of conditions and the following disclaimer. 22 # * Redistributions in binary form must reproduce the above copyright 23 # notice, this list of conditions and the following disclaimer in the 24 # documentation and/or other materials provided with the distribution. 25 # * Neither the name of the <organization> nor the 26 # names of its contributors may be used to endorse or promote products 27 # derived from this software without specific prior written permission. 28 # 29 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 30 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 31 # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 32 # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY 33 # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 34 # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 35 # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 36 # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 37 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 38 # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 39 # 40 41 # Short-option stacking can be enabled with: 42 # zstyle ':completion:*:*:docker:*' option-stacking yes 43 # zstyle ':completion:*:*:docker-*:*' option-stacking yes 44 __docker_arguments() { 45 if zstyle -t ":completion:${curcontext}:" option-stacking; then 46 print -- -s 47 fi 48 } 49 50 __docker_get_containers() { 51 [[ $PREFIX = -* ]] && return 1 52 integer ret=1 53 local kind type line s 54 declare -a running stopped lines args names 55 56 kind=$1; shift 57 type=$1; shift 58 [[ $kind = (stopped|all) ]] && args=($args -a) 59 60 lines=(${(f)"$(_call_program commands docker $docker_options ps --no-trunc $args)"}) 61 62 # Parse header line to find columns 63 local i=1 j=1 k header=${lines[1]} 64 declare -A begin end 65 while (( j < ${#header} - 1 )); do 66 i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) 67 j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) 68 k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) 69 begin[${header[$i,$((j-1))]}]=$i 70 end[${header[$i,$((j-1))]}]=$k 71 done 72 end[${header[$i,$((j-1))]}]=-1 # Last column, should go to the end of the line 73 lines=(${lines[2,-1]}) 74 75 # Container ID 76 if [[ $type = (ids|all) ]]; then 77 for line in $lines; do 78 s="${${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}[0,12]}" 79 s="$s:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}" 80 s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}" 81 if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then 82 stopped=($stopped $s) 83 else 84 running=($running $s) 85 fi 86 done 87 fi 88 89 # Names: we only display the one without slash. All other names 90 # are generated and may clutter the completion. However, with 91 # Swarm, all names may be prefixed by the swarm node name. 92 if [[ $type = (names|all) ]]; then 93 for line in $lines; do 94 names=(${(ps:,:)${${line[${begin[NAMES]},${end[NAMES]}]}%% *}}) 95 # First step: find a common prefix and strip it (swarm node case) 96 (( ${#${(u)names%%/*}} == 1 )) && names=${names#${names[1]%%/*}/} 97 # Second step: only keep the first name without a / 98 s=${${names:#*/*}[1]} 99 # If no name, well give up. 100 (( $#s != 0 )) || continue 101 s="$s:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}" 102 s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}" 103 if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then 104 stopped=($stopped $s) 105 else 106 running=($running $s) 107 fi 108 done 109 fi 110 111 [[ $kind = (running|all) ]] && _describe -t containers-running "running containers" running "$@" && ret=0 112 [[ $kind = (stopped|all) ]] && _describe -t containers-stopped "stopped containers" stopped "$@" && ret=0 113 return ret 114 } 115 116 __docker_stoppedcontainers() { 117 [[ $PREFIX = -* ]] && return 1 118 __docker_get_containers stopped all "$@" 119 } 120 121 __docker_runningcontainers() { 122 [[ $PREFIX = -* ]] && return 1 123 __docker_get_containers running all "$@" 124 } 125 126 __docker_containers() { 127 [[ $PREFIX = -* ]] && return 1 128 __docker_get_containers all all "$@" 129 } 130 131 __docker_containers_ids() { 132 [[ $PREFIX = -* ]] && return 1 133 __docker_get_containers all ids "$@" 134 } 135 136 __docker_containers_names() { 137 [[ $PREFIX = -* ]] && return 1 138 __docker_get_containers all names "$@" 139 } 140 141 __docker_images() { 142 [[ $PREFIX = -* ]] && return 1 143 integer ret=1 144 declare -a images 145 images=(${${${(f)"$(_call_program commands docker $docker_options images)"}[2,-1]}/(#b)([^ ]##) ##([^ ]##) ##([^ ]##)*/${match[3]}:${(r:15:: :::)match[2]} in ${match[1]}}) 146 _describe -t docker-images "images" images && ret=0 147 __docker_repositories_with_tags && ret=0 148 return ret 149 } 150 151 __docker_repositories() { 152 [[ $PREFIX = -* ]] && return 1 153 declare -a repos 154 repos=(${${${(f)"$(_call_program commands docker $docker_options images)"}%% *}[2,-1]}) 155 repos=(${repos#<none>}) 156 _describe -t docker-repos "repositories" repos 157 } 158 159 __docker_repositories_with_tags() { 160 [[ $PREFIX = -* ]] && return 1 161 integer ret=1 162 declare -a repos onlyrepos matched 163 declare m 164 repos=(${${${${(f)"$(_call_program commands docker $docker_options images)"}[2,-1]}/ ##/:::}%% *}) 165 repos=(${${repos%:::<none>}#<none>}) 166 # Check if we have a prefix-match for the current prefix. 167 onlyrepos=(${repos%::*}) 168 for m in $onlyrepos; do 169 [[ ${PREFIX##${~~m}} != ${PREFIX} ]] && { 170 # Yes, complete with tags 171 repos=(${${repos/:::/:}/:/\\:}) 172 _describe -t docker-repos-with-tags "repositories with tags" repos && ret=0 173 return ret 174 } 175 done 176 # No, only complete repositories 177 onlyrepos=(${${repos%:::*}/:/\\:}) 178 _describe -t docker-repos "repositories" onlyrepos -qS : && ret=0 179 180 return ret 181 } 182 183 __docker_search() { 184 [[ $PREFIX = -* ]] && return 1 185 local cache_policy 186 zstyle -s ":completion:${curcontext}:" cache-policy cache_policy 187 if [[ -z "$cache_policy" ]]; then 188 zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy 189 fi 190 191 local searchterm cachename 192 searchterm="${words[$CURRENT]%/}" 193 cachename=_docker-search-$searchterm 194 195 local expl 196 local -a result 197 if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \ 198 && ! _retrieve_cache ${cachename#_}; then 199 _message "Searching for ${searchterm}..." 200 result=(${${${(f)"$(_call_program commands docker $docker_options search $searchterm)"}%% *}[2,-1]}) 201 _store_cache ${cachename#_} result 202 fi 203 _wanted dockersearch expl 'available images' compadd -a result 204 } 205 206 __docker_get_log_options() { 207 [[ $PREFIX = -* ]] && return 1 208 209 integer ret=1 210 local log_driver=${opt_args[--log-driver]:-"all"} 211 local -a awslogs_options fluentd_options gelf_options journald_options json_file_options syslog_options splunk_options 212 213 awslogs_options=("awslogs-region" "awslogs-group" "awslogs-stream") 214 fluentd_options=("env" "fluentd-address" "fluentd-async-connect" "fluentd-buffer-limit" "fluentd-retry-wait" "fluentd-max-retries" "labels" "tag") 215 gcplogs_options=("env" "gcp-log-cmd" "gcp-project" "labels") 216 gelf_options=("env" "gelf-address" "gelf-compression-level" "gelf-compression-type" "labels" "tag") 217 journald_options=("env" "labels" "tag") 218 json_file_options=("env" "labels" "max-file" "max-size") 219 syslog_options=("syslog-address" "syslog-format" "syslog-tls-ca-cert" "syslog-tls-cert" "syslog-tls-key" "syslog-tls-skip-verify" "syslog-facility" "tag") 220 splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "tag") 221 222 [[ $log_driver = (awslogs|all) ]] && _describe -t awslogs-options "awslogs options" awslogs_options "$@" && ret=0 223 [[ $log_driver = (fluentd|all) ]] && _describe -t fluentd-options "fluentd options" fluentd_options "$@" && ret=0 224 [[ $log_driver = (gcplogs|all) ]] && _describe -t gcplogs-options "gcplogs options" gcplogs_options "$@" && ret=0 225 [[ $log_driver = (gelf|all) ]] && _describe -t gelf-options "gelf options" gelf_options "$@" && ret=0 226 [[ $log_driver = (journald|all) ]] && _describe -t journald-options "journald options" journald_options "$@" && ret=0 227 [[ $log_driver = (json-file|all) ]] && _describe -t json-file-options "json-file options" json_file_options "$@" && ret=0 228 [[ $log_driver = (syslog|all) ]] && _describe -t syslog-options "syslog options" syslog_options "$@" && ret=0 229 [[ $log_driver = (splunk|all) ]] && _describe -t splunk-options "splunk options" splunk_options "$@" && ret=0 230 231 return ret 232 } 233 234 __docker_log_options() { 235 [[ $PREFIX = -* ]] && return 1 236 integer ret=1 237 238 if compset -P '*='; then 239 case "${${words[-1]%=*}#*=}" in 240 (syslog-format) 241 syslog_format_opts=('rfc3164' 'rfc5424') 242 _describe -t syslog-format-opts "Syslog format Options" syslog_format_opts && ret=0 243 ;; 244 *) 245 _message 'value' && ret=0 246 ;; 247 esac 248 else 249 __docker_get_log_options -qS "=" && ret=0 250 fi 251 252 return ret 253 } 254 255 __docker_complete_detach_keys() { 256 [[ $PREFIX = -* ]] && return 1 257 integer ret=1 258 259 compset -P "*," 260 keys=(${:-{a-z}}) 261 ctrl_keys=(${:-ctrl-{{a-z},{@,'[','\\','^',']',_}}}) 262 _describe -t detach_keys "[a-z]" keys -qS "," && ret=0 263 _describe -t detach_keys-ctrl "'ctrl-' + 'a-z @ [ \\\\ ] ^ _'" ctrl_keys -qS "," && ret=0 264 } 265 266 __docker_complete_ps_filters() { 267 [[ $PREFIX = -* ]] && return 1 268 integer ret=1 269 270 if compset -P '*='; then 271 case "${${words[-1]%=*}#*=}" in 272 (ancestor) 273 __docker_images && ret=0 274 ;; 275 (before|since) 276 __docker_containers && ret=0 277 ;; 278 (id) 279 __docker_containers_ids && ret=0 280 ;; 281 (name) 282 __docker_containers_names && ret=0 283 ;; 284 (status) 285 status_opts=('created' 'dead' 'exited' 'paused' 'restarting' 'running') 286 _describe -t status-filter-opts "Status Filter Options" status_opts && ret=0 287 ;; 288 (volume) 289 __docker_volumes && ret=0 290 ;; 291 *) 292 _message 'value' && ret=0 293 ;; 294 esac 295 else 296 opts=('ancestor' 'before' 'exited' 'id' 'label' 'name' 'since' 'status' 'volume') 297 _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 298 fi 299 300 return ret 301 } 302 303 __docker_networks() { 304 [[ $PREFIX = -* ]] && return 1 305 integer ret=1 306 declare -a lines networks 307 308 lines=(${(f)"$(_call_program commands docker $docker_options network ls)"}) 309 310 # Parse header line to find columns 311 local i=1 j=1 k header=${lines[1]} 312 declare -A begin end 313 while (( j < ${#header} - 1 )); do 314 i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) 315 j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) 316 k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) 317 begin[${header[$i,$((j-1))]}]=$i 318 end[${header[$i,$((j-1))]}]=$k 319 done 320 end[${header[$i,$((j-1))]}]=-1 321 lines=(${lines[2,-1]}) 322 323 # Network ID 324 local line s 325 for line in $lines; do 326 s="${line[${begin[NETWORK ID]},${end[NETWORK ID]}]%% ##}" 327 s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}" 328 networks=($networks $s) 329 done 330 331 # Names 332 for line in $lines; do 333 s="${line[${begin[NAME]},${end[NAME]}]%% ##}" 334 s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}" 335 networks=($networks $s) 336 done 337 338 _describe -t networks-list "networks" networks && ret=0 339 return ret 340 } 341 342 __docker_network_commands() { 343 local -a _docker_network_subcommands 344 _docker_network_subcommands=( 345 "connect:onnects a container to a network" 346 "create:Creates a new network with a name specified by the user" 347 "disconnect:Disconnects a container from a network" 348 "inspect:Displays detailed information on a network" 349 "ls:Lists all the networks created by the user" 350 "rm:Deletes one or more networks" 351 ) 352 _describe -t docker-network-commands "docker network command" _docker_network_subcommands 353 } 354 355 __docker_network_subcommand() { 356 local -a _command_args opts_help 357 local expl help="--help" 358 integer ret=1 359 360 opts_help=("(: -)--help[Print usage]") 361 362 case "$words[1]" in 363 (connect) 364 _arguments $(__docker_arguments) \ 365 $opts_help \ 366 "($help)*--alias=[Add network-scoped alias for the container]:alias: " \ 367 "($help)--ip=[Container IPv4 address]:IPv4: " \ 368 "($help)--ip6=[Container IPv6 address]:IPv6: " \ 369 "($help)*--link=[Add a link to another container]:link:->link" \ 370 "($help -)1:network:__docker_networks" \ 371 "($help -)2:containers:__docker_containers" && ret=0 372 373 case $state in 374 (link) 375 if compset -P "*:"; then 376 _wanted alias expl "Alias" compadd -E "" && ret=0 377 else 378 __docker_runningcontainers -qS ":" && ret=0 379 fi 380 ;; 381 esac 382 ;; 383 (create) 384 _arguments $(__docker_arguments) -A '-*' \ 385 $opts_help \ 386 "($help)*--aux-address[Auxiliary IPv4 or IPv6 addresses used by network driver]:key=IP: " \ 387 "($help -d --driver)"{-d=,--driver=}"[Driver to manage the Network]:driver:(null host bridge overlay)" \ 388 "($help)*--gateway=[IPv4 or IPv6 Gateway for the master subnet]:IP: " \ 389 "($help)--internal[Restricts external access to the network]" \ 390 "($help)*--ip-range=[Allocate container ip from a sub-range]:IP/mask: " \ 391 "($help)--ipam-driver=[IP Address Management Driver]:driver:(default)" \ 392 "($help)*--ipam-opt=[Custom IPAM plugin options]:opt=value: " \ 393 "($help)--ipv6[Enable IPv6 networking]" \ 394 "($help)*--label=[Set metadata on a network]:label=value: " \ 395 "($help)*"{-o=,--opt=}"[Driver specific options]:opt=value: " \ 396 "($help)*--subnet=[Subnet in CIDR format that represents a network segment]:IP/mask: " \ 397 "($help -)1:Network Name: " && ret=0 398 ;; 399 (disconnect) 400 _arguments $(__docker_arguments) \ 401 $opts_help \ 402 "($help -)1:network:__docker_networks" \ 403 "($help -)2:containers:__docker_containers" && ret=0 404 ;; 405 (inspect) 406 _arguments $(__docker_arguments) \ 407 $opts_help \ 408 "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ 409 "($help -)*:network:__docker_networks" && ret=0 410 ;; 411 (ls) 412 _arguments $(__docker_arguments) \ 413 $opts_help \ 414 "($help)--no-trunc[Do not truncate the output]" \ 415 "($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0 416 ;; 417 (rm) 418 _arguments $(__docker_arguments) \ 419 $opts_help \ 420 "($help -)*:network:__docker_networks" && ret=0 421 ;; 422 (help) 423 _arguments $(__docker_arguments) ":subcommand:__docker_network_commands" && ret=0 424 ;; 425 esac 426 427 return ret 428 } 429 430 __docker_volumes() { 431 [[ $PREFIX = -* ]] && return 1 432 integer ret=1 433 declare -a lines volumes 434 435 lines=(${(f)"$(_call_program commands docker $docker_options volume ls)"}) 436 437 # Parse header line to find columns 438 local i=1 j=1 k header=${lines[1]} 439 declare -A begin end 440 while (( j < ${#header} - 1 )); do 441 i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) 442 j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) 443 k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) 444 begin[${header[$i,$((j-1))]}]=$i 445 end[${header[$i,$((j-1))]}]=$k 446 done 447 end[${header[$i,$((j-1))]}]=-1 448 lines=(${lines[2,-1]}) 449 450 # Names 451 local line s 452 for line in $lines; do 453 s="${line[${begin[VOLUME NAME]},${end[VOLUME NAME]}]%% ##}" 454 s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}" 455 volumes=($volumes $s) 456 done 457 458 _describe -t volumes-list "volumes" volumes && ret=0 459 return ret 460 } 461 462 __docker_volume_commands() { 463 local -a _docker_volume_subcommands 464 _docker_volume_subcommands=( 465 "create:Create a volume" 466 "inspect:Return low-level information on a volume" 467 "ls:List volumes" 468 "rm:Remove a volume" 469 ) 470 _describe -t docker-volume-commands "docker volume command" _docker_volume_subcommands 471 } 472 473 __docker_volume_subcommand() { 474 local -a _command_args opts_help 475 local expl help="--help" 476 integer ret=1 477 478 opts_help=("(: -)--help[Print usage]") 479 480 case "$words[1]" in 481 (create) 482 _arguments $(__docker_arguments) \ 483 $opts_help \ 484 "($help -d --driver)"{-d=,--driver=}"[Volume driver name]:Driver name:(local)" \ 485 "($help)*--label=[Set metadata for a volume]:label=value: " \ 486 "($help)--name=[Volume name]" \ 487 "($help)*"{-o=,--opt=}"[Driver specific options]:Driver option: " && ret=0 488 ;; 489 (inspect) 490 _arguments $(__docker_arguments) \ 491 $opts_help \ 492 "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ 493 "($help -)1:volume:__docker_volumes" && ret=0 494 ;; 495 (ls) 496 _arguments $(__docker_arguments) \ 497 $opts_help \ 498 "($help)*"{-f=,--filter=}"[Provide filter values (i.e. 'dangling=true')]:filter: " \ 499 "($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0 500 ;; 501 (rm) 502 _arguments $(__docker_arguments) \ 503 $opts_help \ 504 "($help -):volume:__docker_volumes" && ret=0 505 ;; 506 (help) 507 _arguments $(__docker_arguments) ":subcommand:__docker_volume_commands" && ret=0 508 ;; 509 esac 510 511 return ret 512 } 513 514 __docker_caching_policy() { 515 oldp=( "$1"(Nmh+1) ) # 1 hour 516 (( $#oldp )) 517 } 518 519 __docker_commands() { 520 local cache_policy 521 522 zstyle -s ":completion:${curcontext}:" cache-policy cache_policy 523 if [[ -z "$cache_policy" ]]; then 524 zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy 525 fi 526 527 if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands) \ 528 && ! _retrieve_cache docker_subcommands; 529 then 530 local -a lines 531 lines=(${(f)"$(_call_program commands docker 2>&1)"}) 532 _docker_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:}) 533 _docker_subcommands=($_docker_subcommands 'daemon:Enable daemon mode' 'help:Show help for a command') 534 (( $#_docker_subcommands > 2 )) && _store_cache docker_subcommands _docker_subcommands 535 fi 536 _describe -t docker-commands "docker command" _docker_subcommands 537 } 538 539 __docker_subcommand() { 540 local -a _command_args opts_help opts_build_create_run opts_build_create_run_update opts_create_run opts_create_run_update 541 local expl help="--help" 542 integer ret=1 543 544 opts_help=("(: -)--help[Print usage]") 545 opts_build_create_run=( 546 "($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: " 547 "($help)--isolation=[Container isolation technology]:isolation:(default hyperv process)" 548 "($help)*--shm-size=[Size of '/dev/shm' (format is '<number><unit>')]:shm size: " 549 "($help)*--ulimit=[ulimit options]:ulimit: " 550 "($help)--userns=[Container user namespace]:user namespace:(host)" 551 ) 552 opts_build_create_run_update=( 553 "($help)--cpu-shares=[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)" 554 "($help)--cpu-period=[Limit the CPU CFS (Completely Fair Scheduler) period]:CPU period: " 555 "($help)--cpu-quota=[Limit the CPU CFS (Completely Fair Scheduler) quota]:CPU quota: " 556 "($help)--cpuset-cpus=[CPUs in which to allow execution]:CPUs: " 557 "($help)--cpuset-mems=[MEMs in which to allow execution]:MEMs: " 558 "($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: " 559 "($help)--memory-swap=[Total memory limit with swap]:Memory limit: " 560 ) 561 opts_create_run=( 562 "($help -a --attach)"{-a=,--attach=}"[Attach to stdin, stdout or stderr]:device:(STDIN STDOUT STDERR)" 563 "($help)*--add-host=[Add a custom host-to-IP mapping]:host\:ip mapping: " 564 "($help)*--blkio-weight-device=[Block IO (relative device weight)]:device:Block IO weight: " 565 "($help)*--cap-add=[Add Linux capabilities]:capability: " 566 "($help)*--cap-drop=[Drop Linux capabilities]:capability: " 567 "($help)--cidfile=[Write the container ID to the file]:CID file:_files" 568 "($help)*--device=[Add a host device to the container]:device:_files" 569 "($help)*--device-read-bps=[Limit the read rate (bytes per second) from a device]:device:IO rate: " 570 "($help)*--device-read-iops=[Limit the read rate (IO per second) from a device]:device:IO rate: " 571 "($help)*--device-write-bps=[Limit the write rate (bytes per second) to a device]:device:IO rate: " 572 "($help)*--device-write-iops=[Limit the write rate (IO per second) to a device]:device:IO rate: " 573 "($help)*--dns=[Custom DNS servers]:DNS server: " 574 "($help)*--dns-opt=[Custom DNS options]:DNS option: " 575 "($help)*--dns-search=[Custom DNS search domains]:DNS domains: " 576 "($help)*"{-e=,--env=}"[Environment variables]:environment variable: " 577 "($help)--entrypoint=[Overwrite the default entrypoint of the image]:entry point: " 578 "($help)*--env-file=[Read environment variables from a file]:environment file:_files" 579 "($help)*--expose=[Expose a port from the container without publishing it]: " 580 "($help)*--group-add=[Add additional groups to run as]:group:_groups" 581 "($help -h --hostname)"{-h=,--hostname=}"[Container host name]:hostname:_hosts" 582 "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]" 583 "($help)--ip=[Container IPv4 address]:IPv4: " 584 "($help)--ip6=[Container IPv6 address]:IPv6: " 585 "($help)--ipc=[IPC namespace to use]:IPC namespace: " 586 "($help)*--link=[Add link to another container]:link:->link" 587 "($help)*"{-l=,--label=}"[Container metadata]:label: " 588 "($help)--log-driver=[Default driver for container logs]:Logging driver:(awslogs etwlogs fluentd gcplogs gelf journald json-file none splunk syslog)" 589 "($help)*--log-opt=[Log driver specific options]:log driver options:__docker_log_options" 590 "($help)--mac-address=[Container MAC address]:MAC address: " 591 "($help)--name=[Container name]:name: " 592 "($help)--net=[Connect a container to a network]:network mode:(bridge none container host)" 593 "($help)*--net-alias=[Add network-scoped alias for the container]:alias: " 594 "($help)--oom-kill-disable[Disable OOM Killer]" 595 "($help)--oom-score-adj[Tune the host's OOM preferences for containers (accepts -1000 to 1000)]" 596 "($help)--pids-limit[Tune container pids limit (set -1 for unlimited)]" 597 "($help -P --publish-all)"{-P,--publish-all}"[Publish all exposed ports]" 598 "($help)*"{-p=,--publish=}"[Expose a container's port to the host]:port:_ports" 599 "($help)--pid=[PID namespace to use]:PID: " 600 "($help)--privileged[Give extended privileges to this container]" 601 "($help)--read-only[Mount the container's root filesystem as read only]" 602 "($help)*--security-opt=[Security options]:security option: " 603 "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" 604 "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" 605 "($help)--tmpfs[mount tmpfs]" 606 "($help)*-v[Bind mount a volume]:volume: " 607 "($help)--volume-driver=[Optional volume driver for the container]:volume driver:(local)" 608 "($help)*--volumes-from=[Mount volumes from the specified container]:volume: " 609 "($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories" 610 ) 611 opts_create_run_update=( 612 "($help)--blkio-weight=[Block IO (relative weight), between 10 and 1000]:Block IO weight:(10 100 500 1000)" 613 "($help)--kernel-memory=[Kernel memory limit in bytes]:Memory limit: " 614 "($help)--memory-reservation=[Memory soft limit]:Memory limit: " 615 "($help)--restart=[Restart policy]:restart policy:(no on-failure always unless-stopped)" 616 ) 617 opts_attach_exec_run_start=( 618 "($help)--detach-keys=[Escape key sequence used to detach a container]:sequence:__docker_complete_detach_keys" 619 ) 620 621 case "$words[1]" in 622 (attach) 623 _arguments $(__docker_arguments) \ 624 $opts_help \ 625 $opts_attach_exec_run_start \ 626 "($help)--no-stdin[Do not attach stdin]" \ 627 "($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \ 628 "($help -):containers:__docker_runningcontainers" && ret=0 629 ;; 630 (build) 631 _arguments $(__docker_arguments) \ 632 $opts_help \ 633 $opts_build_create_run \ 634 $opts_build_create_run_update \ 635 "($help)*--build-arg[Build-time variables]:<varname>=<value>: " \ 636 "($help -f --file)"{-f=,--file=}"[Name of the Dockerfile]:Dockerfile:_files" \ 637 "($help)--force-rm[Always remove intermediate containers]" \ 638 "($help)*--label=[Set metadata for an image]:label=value: " \ 639 "($help)--no-cache[Do not use cache when building the image]" \ 640 "($help)--pull[Attempt to pull a newer version of the image]" \ 641 "($help -q --quiet)"{-q,--quiet}"[Suppress verbose build output]" \ 642 "($help)--rm[Remove intermediate containers after a successful build]" \ 643 "($help -t --tag)*"{-t=,--tag=}"[Repository, name and tag for the image]: :__docker_repositories_with_tags" \ 644 "($help -):path or URL:_directories" && ret=0 645 ;; 646 (commit) 647 _arguments $(__docker_arguments) \ 648 $opts_help \ 649 "($help -a --author)"{-a=,--author=}"[Author]:author: " \ 650 "($help)*"{-c=,--change=}"[Apply Dockerfile instruction to the created image]:Dockerfile:_files" \ 651 "($help -m --message)"{-m=,--message=}"[Commit message]:message: " \ 652 "($help -p --pause)"{-p,--pause}"[Pause container during commit]" \ 653 "($help -):container:__docker_containers" \ 654 "($help -): :__docker_repositories_with_tags" && ret=0 655 ;; 656 (cp) 657 _arguments $(__docker_arguments) \ 658 $opts_help \ 659 "($help -L --follow-link)"{-L,--follow-link}"[Always follow symbol link]" \ 660 "($help -)1:container:->container" \ 661 "($help -)2:hostpath:_files" && ret=0 662 case $state in 663 (container) 664 if compset -P "*:"; then 665 _files && ret=0 666 else 667 __docker_containers -qS ":" && ret=0 668 fi 669 ;; 670 esac 671 ;; 672 (create) 673 _arguments $(__docker_arguments) \ 674 $opts_help \ 675 $opts_build_create_run \ 676 $opts_build_create_run_update \ 677 $opts_create_run \ 678 $opts_create_run_update \ 679 "($help -): :__docker_images" \ 680 "($help -):command: _command_names -e" \ 681 "($help -)*::arguments: _normal" && ret=0 682 683 case $state in 684 (link) 685 if compset -P "*:"; then 686 _wanted alias expl "Alias" compadd -E "" && ret=0 687 else 688 __docker_runningcontainers -qS ":" && ret=0 689 fi 690 ;; 691 esac 692 693 ;; 694 (daemon) 695 _arguments $(__docker_arguments) \ 696 $opts_help \ 697 "($help)--api-cors-header=[CORS headers in the remote API]:CORS headers: " \ 698 "($help)*--authorization-plugin=[Authorization plugins to load]" \ 699 "($help -b --bridge)"{-b=,--bridge=}"[Attach containers to a network bridge]:bridge:_net_interfaces" \ 700 "($help)--bip=[Network bridge IP]:IP address: " \ 701 "($help)--cgroup-parent=[Parent cgroup for all containers]:cgroup: " \ 702 "($help)--containerd=[Path to containerd socket]:socket:_files -g \"*.sock\"" \ 703 "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \ 704 "($help)--default-gateway[Container default gateway IPv4 address]:IPv4 address: " \ 705 "($help)--default-gateway-v6[Container default gateway IPv6 address]:IPv6 address: " \ 706 "($help)--cluster-store=[URL of the distributed storage backend]:Cluster Store:->cluster-store" \ 707 "($help)--cluster-advertise=[Address of the daemon instance to advertise]:Instance to advertise (host\:port): " \ 708 "($help)*--cluster-store-opt=[Cluster options]:Cluster options:->cluster-store-options" \ 709 "($help)*--dns=[DNS server to use]:DNS: " \ 710 "($help)*--dns-search=[DNS search domains to use]:DNS search: " \ 711 "($help)*--dns-opt=[DNS options to use]:DNS option: " \ 712 "($help)*--default-ulimit=[Default ulimit settings for containers]:ulimit: " \ 713 "($help)--disable-legacy-registry[Do not contact legacy registries]" \ 714 "($help)*--exec-opt=[Runtime execution options]:runtime execution options: " \ 715 "($help)--exec-root=[Root directory for execution state files]:path:_directories" \ 716 "($help)--fixed-cidr=[IPv4 subnet for fixed IPs]:IPv4 subnet: " \ 717 "($help)--fixed-cidr-v6=[IPv6 subnet for fixed IPs]:IPv6 subnet: " \ 718 "($help -G --group)"{-G=,--group=}"[Group for the unix socket]:group:_groups" \ 719 "($help -g --graph)"{-g=,--graph=}"[Root of the Docker runtime]:path:_directories" \ 720 "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \ 721 "($help)--icc[Enable inter-container communication]" \ 722 "($help)*--insecure-registry=[Enable insecure registry communication]:registry: " \ 723 "($help)--ip=[Default IP when binding container ports]" \ 724 "($help)--ip-forward[Enable net.ipv4.ip_forward]" \ 725 "($help)--ip-masq[Enable IP masquerading]" \ 726 "($help)--iptables[Enable addition of iptables rules]" \ 727 "($help)--ipv6[Enable IPv6 networking]" \ 728 "($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \ 729 "($help)*--label=[Key=value labels]:label: " \ 730 "($help)--log-driver=[Default driver for container logs]:Logging driver:(awslogs etwlogs fluentd gcplogs gelf journald json-file none splunk syslog)" \ 731 "($help)*--log-opt=[Log driver specific options]:log driver options:__docker_log_options" \ 732 "($help)--mtu=[Network MTU]:mtu:(0 576 1420 1500 9000)" \ 733 "($help -p --pidfile)"{-p=,--pidfile=}"[Path to use for daemon PID file]:PID file:_files" \ 734 "($help)--raw-logs[Full timestamps without ANSI coloring]" \ 735 "($help)*--registry-mirror=[Preferred Docker registry mirror]:registry mirror: " \ 736 "($help -s --storage-driver)"{-s=,--storage-driver=}"[Storage driver to use]:driver:(aufs devicemapper btrfs zfs overlay)" \ 737 "($help)--selinux-enabled[Enable selinux support]" \ 738 "($help)*--storage-opt=[Storage driver options]:storage driver options: " \ 739 "($help)--tls[Use TLS]" \ 740 "($help)--tlscacert=[Trust certs signed only by this CA]:PEM file:_files -g \"*.(pem|crt)\"" \ 741 "($help)--tlscert=[Path to TLS certificate file]:PEM file:_files -g \"*.(pem|crt)\"" \ 742 "($help)--tlskey=[Path to TLS key file]:Key file:_files -g \"*.(pem|key)\"" \ 743 "($help)--tlsverify[Use TLS and verify the remote]" \ 744 "($help)--userns-remap=[User/Group setting for user namespaces]:user\:group:->users-groups" \ 745 "($help)--userland-proxy[Use userland proxy for loopback traffic]" && ret=0 746 747 case $state in 748 (cluster-store) 749 if compset -P '*://'; then 750 _message 'host:port' && ret=0 751 else 752 store=('consul' 'etcd' 'zk') 753 _describe -t cluster-store "Cluster Store" store -qS "://" && ret=0 754 fi 755 ;; 756 (cluster-store-options) 757 if compset -P '*='; then 758 _files && ret=0 759 else 760 opts=('discovery.heartbeat' 'discovery.ttl' 'kv.cacertfile' 'kv.certfile' 'kv.keyfile' 'kv.path') 761 _describe -t cluster-store-opts "Cluster Store Options" opts -qS "=" && ret=0 762 fi 763 ;; 764 (users-groups) 765 if compset -P '*:'; then 766 _groups && ret=0 767 else 768 _describe -t userns-default "default Docker user management" '(default)' && ret=0 769 _users && ret=0 770 fi 771 ;; 772 esac 773 ;; 774 (diff) 775 _arguments $(__docker_arguments) \ 776 $opts_help \ 777 "($help -)*:containers:__docker_containers" && ret=0 778 ;; 779 (events) 780 _arguments $(__docker_arguments) \ 781 $opts_help \ 782 "($help)*"{-f=,--filter=}"[Filter values]:filter: " \ 783 "($help)--since=[Events created since this timestamp]:timestamp: " \ 784 "($help)--until=[Events created until this timestamp]:timestamp: " && ret=0 785 ;; 786 (exec) 787 local state 788 _arguments $(__docker_arguments) \ 789 $opts_help \ 790 $opts_attach_exec_run_start \ 791 "($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \ 792 "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]" \ 793 "($help)--privileged[Give extended Linux capabilities to the command]" \ 794 "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" \ 795 "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" \ 796 "($help -):containers:__docker_runningcontainers" \ 797 "($help -)*::command:->anycommand" && ret=0 798 799 case $state in 800 (anycommand) 801 shift 1 words 802 (( CURRENT-- )) 803 _normal && ret=0 804 ;; 805 esac 806 ;; 807 (export) 808 _arguments $(__docker_arguments) \ 809 $opts_help \ 810 "($help -o --output)"{-o=,--output=}"[Write to a file, instead of stdout]:output file:_files" \ 811 "($help -)*:containers:__docker_containers" && ret=0 812 ;; 813 (history) 814 _arguments $(__docker_arguments) \ 815 $opts_help \ 816 "($help -H --human)"{-H,--human}"[Print sizes and dates in human readable format]" \ 817 "($help)--no-trunc[Do not truncate output]" \ 818 "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ 819 "($help -)*: :__docker_images" && ret=0 820 ;; 821 (images) 822 _arguments $(__docker_arguments) \ 823 $opts_help \ 824 "($help -a --all)"{-a,--all}"[Show all images]" \ 825 "($help)--digests[Show digests]" \ 826 "($help)*"{-f=,--filter=}"[Filter values]:filter: " \ 827 "($help)--format[Pretty-print containers using a Go template]:format: " \ 828 "($help)--no-trunc[Do not truncate output]" \ 829 "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ 830 "($help -): :__docker_repositories" && ret=0 831 ;; 832 (import) 833 _arguments $(__docker_arguments) \ 834 $opts_help \ 835 "($help)*"{-c=,--change=}"[Apply Dockerfile instruction to the created image]:Dockerfile:_files" \ 836 "($help -m --message)"{-m=,--message=}"[Commit message for imported image]:message: " \ 837 "($help -):URL:(- http:// file://)" \ 838 "($help -): :__docker_repositories_with_tags" && ret=0 839 ;; 840 (info|version) 841 _arguments $(__docker_arguments) \ 842 $opts_help && ret=0 843 ;; 844 (inspect) 845 local state 846 _arguments $(__docker_arguments) \ 847 $opts_help \ 848 "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ 849 "($help -s --size)"{-s,--size}"[Display total file sizes if the type is container]" \ 850 "($help)--type=[Return JSON for specified type]:type:(image container)" \ 851 "($help -)*: :->values" && ret=0 852 853 case $state in 854 (values) 855 if [[ ${words[(r)--type=container]} == --type=container ]]; then 856 __docker_containers && ret=0 857 elif [[ ${words[(r)--type=image]} == --type=image ]]; then 858 __docker_images && ret=0 859 else 860 __docker_images && __docker_containers && ret=0 861 fi 862 ;; 863 esac 864 ;; 865 (kill) 866 _arguments $(__docker_arguments) \ 867 $opts_help \ 868 "($help -s --signal)"{-s=,--signal=}"[Signal to send]:signal:_signals" \ 869 "($help -)*:containers:__docker_runningcontainers" && ret=0 870 ;; 871 (load) 872 _arguments $(__docker_arguments) \ 873 $opts_help \ 874 "($help -i --input)"{-i=,--input=}"[Read from tar archive file]:archive file:_files -g \"*.((tar|TAR)(.gz|.GZ|.Z|.bz2|.lzma|.xz|)|(tbz|tgz|txz))(-.)\"" \ 875 "($help -q --quiet)"{-q,--quiet}"[Suppress the load output]" && ret=0 876 ;; 877 (login) 878 _arguments $(__docker_arguments) \ 879 $opts_help \ 880 "($help -p --password)"{-p=,--password=}"[Password]:password: " \ 881 "($help -u --user)"{-u=,--user=}"[Username]:username: " \ 882 "($help -)1:server: " && ret=0 883 ;; 884 (logout) 885 _arguments $(__docker_arguments) \ 886 $opts_help \ 887 "($help -)1:server: " && ret=0 888 ;; 889 (logs) 890 _arguments $(__docker_arguments) \ 891 $opts_help \ 892 "($help -f --follow)"{-f,--follow}"[Follow log output]" \ 893 "($help -s --since)"{-s=,--since=}"[Show logs since this timestamp]:timestamp: " \ 894 "($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \ 895 "($help)--tail=[Output the last K lines]:lines:(1 10 20 50 all)" \ 896 "($help -)*:containers:__docker_containers" && ret=0 897 ;; 898 (network) 899 local curcontext="$curcontext" state 900 _arguments $(__docker_arguments) \ 901 $opts_help \ 902 "($help -): :->command" \ 903 "($help -)*:: :->option-or-argument" && ret=0 904 905 case $state in 906 (command) 907 __docker_network_commands && ret=0 908 ;; 909 (option-or-argument) 910 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 911 __docker_network_subcommand && ret=0 912 ;; 913 esac 914 ;; 915 (pause|unpause) 916 _arguments $(__docker_arguments) \ 917 $opts_help \ 918 "($help -)*:containers:__docker_runningcontainers" && ret=0 919 ;; 920 (port) 921 _arguments $(__docker_arguments) \ 922 $opts_help \ 923 "($help -)1:containers:__docker_runningcontainers" \ 924 "($help -)2:port:_ports" && ret=0 925 ;; 926 (ps) 927 _arguments $(__docker_arguments) \ 928 $opts_help \ 929 "($help -a --all)"{-a,--all}"[Show all containers]" \ 930 "($help)--before=[Show only container created before...]:containers:__docker_containers" \ 931 "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \ 932 "($help)--format[Pretty-print containers using a Go template]:format: " \ 933 "($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \ 934 "($help)-n[Show n last created containers, include non-running one]:n:(1 5 10 25 50)" \ 935 "($help)--no-trunc[Do not truncate output]" \ 936 "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ 937 "($help -s --size)"{-s,--size}"[Display total file sizes]" \ 938 "($help)--since=[Show only containers created since...]:containers:__docker_containers" && ret=0 939 940 case $state in 941 (filter-options) 942 __docker_complete_ps_filters && ret=0 943 ;; 944 esac 945 ;; 946 (pull) 947 _arguments $(__docker_arguments) \ 948 $opts_help \ 949 "($help -a --all-tags)"{-a,--all-tags}"[Download all tagged images]" \ 950 "($help)--disable-content-trust[Skip image verification]" \ 951 "($help -):name:__docker_search" && ret=0 952 ;; 953 (push) 954 _arguments $(__docker_arguments) \ 955 $opts_help \ 956 "($help)--disable-content-trust[Skip image signing]" \ 957 "($help -): :__docker_images" && ret=0 958 ;; 959 (rename) 960 _arguments $(__docker_arguments) \ 961 $opts_help \ 962 "($help -):old name:__docker_containers" \ 963 "($help -):new name: " && ret=0 964 ;; 965 (restart|stop) 966 _arguments $(__docker_arguments) \ 967 $opts_help \ 968 "($help -t --time)"{-t=,--time=}"[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)" \ 969 "($help -)*:containers:__docker_runningcontainers" && ret=0 970 ;; 971 (rm) 972 _arguments $(__docker_arguments) \ 973 $opts_help \ 974 "($help -f --force)"{-f,--force}"[Force removal]" \ 975 "($help -l --link)"{-l,--link}"[Remove the specified link and not the underlying container]" \ 976 "($help -v --volumes)"{-v,--volumes}"[Remove the volumes associated to the container]" \ 977 "($help -)*:containers:__docker_stoppedcontainers" && ret=0 978 ;; 979 (rmi) 980 _arguments $(__docker_arguments) \ 981 $opts_help \ 982 "($help -f --force)"{-f,--force}"[Force removal]" \ 983 "($help)--no-prune[Do not delete untagged parents]" \ 984 "($help -)*: :__docker_images" && ret=0 985 ;; 986 (run) 987 _arguments $(__docker_arguments) \ 988 $opts_help \ 989 $opts_build_create_run \ 990 $opts_build_create_run_update \ 991 $opts_create_run \ 992 $opts_create_run_update \ 993 $opts_attach_exec_run_start \ 994 "($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \ 995 "($help)--rm[Remove intermediate containers when it exits]" \ 996 "($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \ 997 "($help)--stop-signal=[Signal to kill a container]:signal:_signals" \ 998 "($help -): :__docker_images" \ 999 "($help -):command: _command_names -e" \ 1000 "($help -)*::arguments: _normal" && ret=0 1001 1002 case $state in 1003 (link) 1004 if compset -P "*:"; then 1005 _wanted alias expl "Alias" compadd -E "" && ret=0 1006 else 1007 __docker_runningcontainers -qS ":" && ret=0 1008 fi 1009 ;; 1010 esac 1011 1012 ;; 1013 (save) 1014 _arguments $(__docker_arguments) \ 1015 $opts_help \ 1016 "($help -o --output)"{-o=,--output=}"[Write to file]:file:_files" \ 1017 "($help -)*: :__docker_images" && ret=0 1018 ;; 1019 (search) 1020 _arguments $(__docker_arguments) \ 1021 $opts_help \ 1022 "($help)--automated[Only show automated builds]" \ 1023 "($help)--no-trunc[Do not truncate output]" \ 1024 "($help -s --stars)"{-s=,--stars=}"[Only display with at least X stars]:stars:(0 10 100 1000)" \ 1025 "($help -):term: " && ret=0 1026 ;; 1027 (start) 1028 _arguments $(__docker_arguments) \ 1029 $opts_help \ 1030 $opts_attach_exec_run_start \ 1031 "($help -a --attach)"{-a,--attach}"[Attach container's stdout/stderr and forward all signals]" \ 1032 "($help -i --interactive)"{-i,--interactive}"[Attach container's stding]" \ 1033 "($help -)*:containers:__docker_stoppedcontainers" && ret=0 1034 ;; 1035 (stats) 1036 _arguments $(__docker_arguments) \ 1037 $opts_help \ 1038 "($help -a --all)"{-a,--all}"[Show all containers (default shows just running)]" \ 1039 "($help)--no-stream[Disable streaming stats and only pull the first result]" \ 1040 "($help -)*:containers:__docker_runningcontainers" && ret=0 1041 ;; 1042 (tag) 1043 _arguments $(__docker_arguments) \ 1044 $opts_help \ 1045 "($help -):source:__docker_images"\ 1046 "($help -):destination:__docker_repositories_with_tags" && ret=0 1047 ;; 1048 (top) 1049 _arguments $(__docker_arguments) \ 1050 $opts_help \ 1051 "($help -)1:containers:__docker_runningcontainers" \ 1052 "($help -)*:: :->ps-arguments" && ret=0 1053 case $state in 1054 (ps-arguments) 1055 _ps && ret=0 1056 ;; 1057 esac 1058 1059 ;; 1060 (update) 1061 _arguments $(__docker_arguments) \ 1062 $opts_help \ 1063 $opts_create_run_update \ 1064 $opts_build_create_run_update \ 1065 "($help -)*: :->values" && ret=0 1066 1067 case $state in 1068 (values) 1069 if [[ ${words[(r)--kernel-memory*]} = (--kernel-memory*) ]]; then 1070 __docker_stoppedcontainers && ret=0 1071 else 1072 __docker_containers && ret=0 1073 fi 1074 ;; 1075 esac 1076 ;; 1077 (volume) 1078 local curcontext="$curcontext" state 1079 _arguments $(__docker_arguments) \ 1080 $opts_help \ 1081 "($help -): :->command" \ 1082 "($help -)*:: :->option-or-argument" && ret=0 1083 1084 case $state in 1085 (command) 1086 __docker_volume_commands && ret=0 1087 ;; 1088 (option-or-argument) 1089 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 1090 __docker_volume_subcommand && ret=0 1091 ;; 1092 esac 1093 ;; 1094 (wait) 1095 _arguments $(__docker_arguments) \ 1096 $opts_help \ 1097 "($help -)*:containers:__docker_runningcontainers" && ret=0 1098 ;; 1099 (help) 1100 _arguments $(__docker_arguments) ":subcommand:__docker_commands" && ret=0 1101 ;; 1102 esac 1103 1104 return ret 1105 } 1106 1107 _docker() { 1108 # Support for subservices, which allows for `compdef _docker docker-shell=_docker_containers`. 1109 # Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`. 1110 if [[ $service != docker ]]; then 1111 _call_function - _$service 1112 return 1113 fi 1114 1115 local curcontext="$curcontext" state line help="-h --help" 1116 integer ret=1 1117 typeset -A opt_args 1118 1119 _arguments $(__docker_arguments) -C \ 1120 "(: -)"{-h,--help}"[Print usage]" \ 1121 "($help)--config[Location of client config files]:path:_directories" \ 1122 "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \ 1123 "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \ 1124 "($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \ 1125 "($help)--tls[Use TLS]" \ 1126 "($help)--tlscacert=[Trust certs signed only by this CA]:PEM file:_files -g "*.(pem|crt)"" \ 1127 "($help)--tlscert=[Path to TLS certificate file]:PEM file:_files -g "*.(pem|crt)"" \ 1128 "($help)--tlskey=[Path to TLS key file]:Key file:_files -g "*.(pem|key)"" \ 1129 "($help)--tlsverify[Use TLS and verify the remote]" \ 1130 "($help)--userland-proxy[Use userland proxy for loopback traffic]" \ 1131 "($help -v --version)"{-v,--version}"[Print version information and quit]" \ 1132 "($help -): :->command" \ 1133 "($help -)*:: :->option-or-argument" && ret=0 1134 1135 local host=${opt_args[-H]}${opt_args[--host]} 1136 local config=${opt_args[--config]} 1137 local docker_options="${host:+--host $host} ${config:+--config $config}" 1138 1139 case $state in 1140 (command) 1141 __docker_commands && ret=0 1142 ;; 1143 (option-or-argument) 1144 curcontext=${curcontext%:*:*}:docker-$words[1]: 1145 __docker_subcommand && ret=0 1146 ;; 1147 esac 1148 1149 return ret 1150 } 1151 1152 _docker "$@" 1153 1154 # Local Variables: 1155 # mode: Shell-Script 1156 # sh-indentation: 4 1157 # indent-tabs-mode: nil 1158 # sh-basic-offset: 4 1159 # End: 1160 # vim: ft=zsh sw=4 ts=4 et