github.com/docker/docker-ce@v17.12.1-ce-rc2+incompatible/components/cli/contrib/completion/zsh/_docker (about) 1 #compdef docker dockerd 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 --format 'table' --no-trunc $args)"$'\n'}}) 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*|Created*) ]]; 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*|Created*) ]]; 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_complete_stopped_containers() { 117 [[ $PREFIX = -* ]] && return 1 118 __docker_get_containers stopped all "$@" 119 } 120 121 __docker_complete_running_containers() { 122 [[ $PREFIX = -* ]] && return 1 123 __docker_get_containers running all "$@" 124 } 125 126 __docker_complete_containers() { 127 [[ $PREFIX = -* ]] && return 1 128 __docker_get_containers all all "$@" 129 } 130 131 __docker_complete_containers_ids() { 132 [[ $PREFIX = -* ]] && return 1 133 __docker_get_containers all ids "$@" 134 } 135 136 __docker_complete_containers_names() { 137 [[ $PREFIX = -* ]] && return 1 138 __docker_get_containers all names "$@" 139 } 140 141 __docker_complete_info_plugins() { 142 [[ $PREFIX = -* ]] && return 1 143 integer ret=1 144 emulate -L zsh 145 setopt extendedglob 146 local -a plugins 147 plugins=(${(ps: :)${(M)${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'Plugins:}%%$'\n'^ *}}:# $1: *}## $1: }) 148 _describe -t plugins "$1 plugins" plugins && ret=0 149 return ret 150 } 151 152 __docker_complete_images() { 153 [[ $PREFIX = -* ]] && return 1 154 integer ret=1 155 declare -a images 156 images=(${${${(f)${:-"$(_call_program commands docker $docker_options images)"$'\n'}}[2,-1]}/(#b)([^ ]##) ##([^ ]##) ##([^ ]##)*/${match[3]}:${(r:15:: :::)match[2]} in ${match[1]}}) 157 _describe -t docker-images "images" images && ret=0 158 __docker_complete_repositories_with_tags && ret=0 159 return ret 160 } 161 162 __docker_complete_repositories() { 163 [[ $PREFIX = -* ]] && return 1 164 integer ret=1 165 declare -a repos 166 repos=(${${${(f)${:-"$(_call_program commands docker $docker_options images)"$'\n'}}%% *}[2,-1]}) 167 repos=(${repos#<none>}) 168 _describe -t docker-repos "repositories" repos && ret=0 169 return ret 170 } 171 172 __docker_complete_repositories_with_tags() { 173 [[ $PREFIX = -* ]] && return 1 174 integer ret=1 175 declare -a repos onlyrepos matched 176 declare m 177 repos=(${${${${(f)${:-"$(_call_program commands docker $docker_options images)"$'\n'}}[2,-1]}/ ##/:::}%% *}) 178 repos=(${${repos%:::<none>}#<none>}) 179 # Check if we have a prefix-match for the current prefix. 180 onlyrepos=(${repos%::*}) 181 for m in $onlyrepos; do 182 [[ ${PREFIX##${~~m}} != ${PREFIX} ]] && { 183 # Yes, complete with tags 184 repos=(${${repos/:::/:}/:/\\:}) 185 _describe -t docker-repos-with-tags "repositories with tags" repos && ret=0 186 return ret 187 } 188 done 189 # No, only complete repositories 190 onlyrepos=(${${repos%:::*}/:/\\:}) 191 _describe -t docker-repos "repositories" onlyrepos -qS : && ret=0 192 193 return ret 194 } 195 196 __docker_search() { 197 [[ $PREFIX = -* ]] && return 1 198 local cache_policy 199 zstyle -s ":completion:${curcontext}:" cache-policy cache_policy 200 if [[ -z "$cache_policy" ]]; then 201 zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy 202 fi 203 204 local searchterm cachename 205 searchterm="${words[$CURRENT]%/}" 206 cachename=_docker-search-$searchterm 207 208 local expl 209 local -a result 210 if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \ 211 && ! _retrieve_cache ${cachename#_}; then 212 _message "Searching for ${searchterm}..." 213 result=(${${${(f)${:-"$(_call_program commands docker $docker_options search $searchterm)"$'\n'}}%% *}[2,-1]}) 214 _store_cache ${cachename#_} result 215 fi 216 _wanted dockersearch expl 'available images' compadd -a result 217 } 218 219 __docker_get_log_options() { 220 [[ $PREFIX = -* ]] && return 1 221 222 integer ret=1 223 local log_driver=${opt_args[--log-driver]:-"all"} 224 local -a common_options common_options2 awslogs_options fluentd_options gelf_options journald_options json_file_options logentries_options syslog_options splunk_options 225 226 common_options=("max-buffer-size" "mode") 227 common_options2=("env" "env-regex" "labels") 228 awslogs_options=($common_options "awslogs-create-group" "awslogs-datetime-format" "awslogs-group" "awslogs-multiline-pattern" "awslogs-region" "awslogs-stream" "tag") 229 fluentd_options=($common_options $common_options2 "fluentd-address" "fluentd-async-connect" "fluentd-buffer-limit" "fluentd-retry-wait" "fluentd-max-retries" "fluentd-sub-second-precision" "tag") 230 gcplogs_options=($common_options $common_options2 "gcp-log-cmd" "gcp-meta-id" "gcp-meta-name" "gcp-meta-zone" "gcp-project") 231 gelf_options=($common_options $common_options2 "gelf-address" "gelf-compression-level" "gelf-compression-type" "tag") 232 journald_options=($common_options $common_options2 "tag") 233 json_file_options=($common_options $common_options2 "max-file" "max-size") 234 logentries_options=($common_options $common_options2 "logentries-token" "tag") 235 syslog_options=($common_options $common_options2 "syslog-address" "syslog-facility" "syslog-format" "syslog-tls-ca-cert" "syslog-tls-cert" "syslog-tls-key" "syslog-tls-skip-verify" "tag") 236 splunk_options=($common_options $common_options2 "splunk-caname" "splunk-capath" "splunk-format" "splunk-gzip" "splunk-gzip-level" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "splunk-verify-connection" "tag") 237 238 [[ $log_driver = (awslogs|all) ]] && _describe -t awslogs-options "awslogs options" awslogs_options "$@" && ret=0 239 [[ $log_driver = (fluentd|all) ]] && _describe -t fluentd-options "fluentd options" fluentd_options "$@" && ret=0 240 [[ $log_driver = (gcplogs|all) ]] && _describe -t gcplogs-options "gcplogs options" gcplogs_options "$@" && ret=0 241 [[ $log_driver = (gelf|all) ]] && _describe -t gelf-options "gelf options" gelf_options "$@" && ret=0 242 [[ $log_driver = (journald|all) ]] && _describe -t journald-options "journald options" journald_options "$@" && ret=0 243 [[ $log_driver = (json-file|all) ]] && _describe -t json-file-options "json-file options" json_file_options "$@" && ret=0 244 [[ $log_driver = (logentries|all) ]] && _describe -t logentries-options "logentries options" logentries_options "$@" && ret=0 245 [[ $log_driver = (syslog|all) ]] && _describe -t syslog-options "syslog options" syslog_options "$@" && ret=0 246 [[ $log_driver = (splunk|all) ]] && _describe -t splunk-options "splunk options" splunk_options "$@" && ret=0 247 248 return ret 249 } 250 251 __docker_complete_log_drivers() { 252 [[ $PREFIX = -* ]] && return 1 253 integer ret=1 254 drivers=(awslogs etwlogs fluentd gcplogs gelf journald json-file none splunk syslog) 255 _describe -t log-drivers "log drivers" drivers && ret=0 256 return ret 257 } 258 259 __docker_complete_log_options() { 260 [[ $PREFIX = -* ]] && return 1 261 integer ret=1 262 263 if compset -P '*='; then 264 case "${${words[-1]%=*}#*=}" in 265 (syslog-format) 266 local opts=('rfc3164' 'rfc5424' 'rfc5424micro') 267 _describe -t syslog-format-opts "syslog format options" opts && ret=0 268 ;; 269 (mode) 270 local opts=('blocking' 'non-blocking') 271 _describe -t mode-opts "mode options" opts && ret=0 272 ;; 273 *) 274 _message 'value' && ret=0 275 ;; 276 esac 277 else 278 __docker_get_log_options -qS "=" && ret=0 279 fi 280 281 return ret 282 } 283 284 __docker_complete_detach_keys() { 285 [[ $PREFIX = -* ]] && return 1 286 integer ret=1 287 288 compset -P "*," 289 keys=(${:-{a-z}}) 290 ctrl_keys=(${:-ctrl-{{a-z},{@,'[','\\','^',']',_}}}) 291 _describe -t detach_keys "[a-z]" keys -qS "," && ret=0 292 _describe -t detach_keys-ctrl "'ctrl-' + 'a-z @ [ \\\\ ] ^ _'" ctrl_keys -qS "," && ret=0 293 } 294 295 __docker_complete_pid() { 296 [[ $PREFIX = -* ]] && return 1 297 integer ret=1 298 local -a opts vopts 299 300 opts=('host') 301 vopts=('container') 302 303 if compset -P '*:'; then 304 case "${${words[-1]%:*}#*=}" in 305 (container) 306 __docker_complete_running_containers && ret=0 307 ;; 308 *) 309 _message 'value' && ret=0 310 ;; 311 esac 312 else 313 _describe -t pid-value-opts "PID Options with value" vopts -qS ":" && ret=0 314 _describe -t pid-opts "PID Options" opts && ret=0 315 fi 316 317 return ret 318 } 319 320 __docker_complete_runtimes() { 321 [[ $PREFIX = -* ]] && return 1 322 integer ret=1 323 324 emulate -L zsh 325 setopt extendedglob 326 local -a runtimes_opts 327 runtimes_opts=(${(ps: :)${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'Runtimes: }%%$'\n'^ *}}}) 328 _describe -t runtimes-opts "runtimes options" runtimes_opts && ret=0 329 } 330 331 __docker_complete_ps_filters() { 332 [[ $PREFIX = -* ]] && return 1 333 integer ret=1 334 335 if compset -P '*='; then 336 case "${${words[-1]%=*}#*=}" in 337 (ancestor) 338 __docker_complete_images && ret=0 339 ;; 340 (before|since) 341 __docker_complete_containers && ret=0 342 ;; 343 (health) 344 health_opts=('healthy' 'none' 'starting' 'unhealthy') 345 _describe -t health-filter-opts "health filter options" health_opts && ret=0 346 ;; 347 (id) 348 __docker_complete_containers_ids && ret=0 349 ;; 350 (is-task) 351 _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0 352 ;; 353 (name) 354 __docker_complete_containers_names && ret=0 355 ;; 356 (network) 357 __docker_complete_networks && ret=0 358 ;; 359 (status) 360 status_opts=('created' 'dead' 'exited' 'paused' 'restarting' 'running' 'removing') 361 _describe -t status-filter-opts "status filter options" status_opts && ret=0 362 ;; 363 (volume) 364 __docker_complete_volumes && ret=0 365 ;; 366 *) 367 _message 'value' && ret=0 368 ;; 369 esac 370 else 371 opts=('ancestor' 'before' 'exited' 'expose' 'health' 'id' 'label' 'name' 'network' 'publish' 'since' 'status' 'volume') 372 _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 373 fi 374 375 return ret 376 } 377 378 __docker_complete_search_filters() { 379 [[ $PREFIX = -* ]] && return 1 380 integer ret=1 381 declare -a boolean_opts opts 382 383 boolean_opts=('true' 'false') 384 opts=('is-automated' 'is-official' 'stars') 385 386 if compset -P '*='; then 387 case "${${words[-1]%=*}#*=}" in 388 (is-automated|is-official) 389 _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0 390 ;; 391 *) 392 _message 'value' && ret=0 393 ;; 394 esac 395 else 396 _describe -t filter-opts "filter options" opts -qS "=" && ret=0 397 fi 398 399 return ret 400 } 401 402 __docker_complete_images_filters() { 403 [[ $PREFIX = -* ]] && return 1 404 integer ret=1 405 declare -a boolean_opts opts 406 407 boolean_opts=('true' 'false') 408 opts=('before' 'dangling' 'label' 'reference' 'since') 409 410 if compset -P '*='; then 411 case "${${words[-1]%=*}#*=}" in 412 (before|reference|since) 413 __docker_complete_images && ret=0 414 ;; 415 (dangling) 416 _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0 417 ;; 418 *) 419 _message 'value' && ret=0 420 ;; 421 esac 422 else 423 _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 424 fi 425 426 return ret 427 } 428 429 __docker_complete_events_filter() { 430 [[ $PREFIX = -* ]] && return 1 431 integer ret=1 432 declare -a opts 433 434 opts=('container' 'daemon' 'event' 'image' 'label' 'network' 'type' 'volume') 435 436 if compset -P '*='; then 437 case "${${words[-1]%=*}#*=}" in 438 (container) 439 __docker_complete_containers && ret=0 440 ;; 441 (daemon) 442 emulate -L zsh 443 setopt extendedglob 444 local -a daemon_opts 445 daemon_opts=( 446 ${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'Name: }%%$'\n'^ *}} 447 ${${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'ID: }%%$'\n'^ *}}//:/\\:} 448 ) 449 _describe -t daemon-filter-opts "daemon filter options" daemon_opts && ret=0 450 ;; 451 (event) 452 local -a event_opts 453 event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disconnect' 'exec_create' 'exec_detach' 454 'exec_start' 'export' 'health_status' 'import' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start' 455 'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update') 456 _describe -t event-filter-opts "event filter options" event_opts && ret=0 457 ;; 458 (image) 459 __docker_complete_images && ret=0 460 ;; 461 (network) 462 __docker_complete_networks && ret=0 463 ;; 464 (type) 465 local -a type_opts 466 type_opts=('container' 'daemon' 'image' 'network' 'volume') 467 _describe -t type-filter-opts "type filter options" type_opts && ret=0 468 ;; 469 (volume) 470 __docker_complete_volumes && ret=0 471 ;; 472 *) 473 _message 'value' && ret=0 474 ;; 475 esac 476 else 477 _describe -t filter-opts "filter options" opts -qS "=" && ret=0 478 fi 479 480 return ret 481 } 482 483 __docker_complete_prune_filters() { 484 [[ $PREFIX = -* ]] && return 1 485 integer ret=1 486 declare -a opts 487 488 opts=('until') 489 490 if compset -P '*='; then 491 case "${${words[-1]%=*}#*=}" in 492 *) 493 _message 'value' && ret=0 494 ;; 495 esac 496 else 497 _describe -t filter-opts "filter options" opts -qS "=" && ret=0 498 fi 499 500 return ret 501 } 502 503 # BO checkpoint 504 505 __docker_checkpoint_commands() { 506 local -a _docker_checkpoint_subcommands 507 _docker_checkpoint_subcommands=( 508 "create:Create a checkpoint from a running container" 509 "ls:List checkpoints for a container" 510 "rm:Remove a checkpoint" 511 ) 512 _describe -t docker-checkpoint-commands "docker checkpoint command" _docker_checkpoint_subcommands 513 } 514 515 __docker_checkpoint_subcommand() { 516 local -a _command_args opts_help 517 local expl help="--help" 518 integer ret=1 519 520 opts_help=("(: -)--help[Print usage]") 521 522 case "$words[1]" in 523 (create) 524 _arguments $(__docker_arguments) \ 525 $opts_help \ 526 "($help)--checkpoint-dir=[Use a custom checkpoint storage directory]:dir:_directories" \ 527 "($help)--leave-running[Leave the container running after checkpoint]" \ 528 "($help -)1:container:__docker_complete_running_containers" \ 529 "($help -)2:checkpoint: " && ret=0 530 ;; 531 (ls|list) 532 _arguments $(__docker_arguments) \ 533 $opts_help \ 534 "($help)--checkpoint-dir=[Use a custom checkpoint storage directory]:dir:_directories" \ 535 "($help -)1:container:__docker_complete_containers" && ret=0 536 ;; 537 (rm|remove) 538 _arguments $(__docker_arguments) \ 539 $opts_help \ 540 "($help)--checkpoint-dir=[Use a custom checkpoint storage directory]:dir:_directories" \ 541 "($help -)1:container:__docker_complete_containers" \ 542 "($help -)2:checkpoint: " && ret=0 543 ;; 544 (help) 545 _arguments $(__docker_arguments) ":subcommand:__docker_checkpoint_commands" && ret=0 546 ;; 547 esac 548 549 return ret 550 } 551 552 # EO checkpoint 553 554 # BO container 555 556 __docker_container_commands() { 557 local -a _docker_container_subcommands 558 _docker_container_subcommands=( 559 "attach:Attach to a running container" 560 "commit:Create a new image from a container's changes" 561 "cp:Copy files/folders between a container and the local filesystem" 562 "create:Create a new container" 563 "diff:Inspect changes on a container's filesystem" 564 "exec:Run a command in a running container" 565 "export:Export a container's filesystem as a tar archive" 566 "inspect:Display detailed information on one or more containers" 567 "kill:Kill one or more running containers" 568 "logs:Fetch the logs of a container" 569 "ls:List containers" 570 "pause:Pause all processes within one or more containers" 571 "port:List port mappings or a specific mapping for the container" 572 "prune:Remove all stopped containers" 573 "rename:Rename a container" 574 "restart:Restart one or more containers" 575 "rm:Remove one or more containers" 576 "run:Run a command in a new container" 577 "start:Start one or more stopped containers" 578 "stats:Display a live stream of container(s) resource usage statistics" 579 "stop:Stop one or more running containers" 580 "top:Display the running processes of a container" 581 "unpause:Unpause all processes within one or more containers" 582 "update:Update configuration of one or more containers" 583 "wait:Block until one or more containers stop, then print their exit codes" 584 ) 585 _describe -t docker-container-commands "docker container command" _docker_container_subcommands 586 } 587 588 __docker_container_subcommand() { 589 local -a _command_args opts_help opts_attach_exec_run_start opts_create_run opts_create_run_update 590 local expl help="--help" 591 integer ret=1 592 593 opts_attach_exec_run_start=( 594 "($help)--detach-keys=[Escape key sequence used to detach a container]:sequence:__docker_complete_detach_keys" 595 ) 596 opts_create_run=( 597 "($help -a --attach)"{-a=,--attach=}"[Attach to stdin, stdout or stderr]:device:(STDIN STDOUT STDERR)" 598 "($help)*--add-host=[Add a custom host-to-IP mapping]:host\:ip mapping: " 599 "($help)*--blkio-weight-device=[Block IO (relative device weight)]:device:Block IO weight: " 600 "($help)*--cap-add=[Add Linux capabilities]:capability: " 601 "($help)*--cap-drop=[Drop Linux capabilities]:capability: " 602 "($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: " 603 "($help)--cidfile=[Write the container ID to the file]:CID file:_files" 604 "($help)--cpus=[Number of CPUs (default 0.000)]:cpus: " 605 "($help)*--device=[Add a host device to the container]:device:_files" 606 "($help)*--device-cgroup-rule=[Add a rule to the cgroup allowed devices list]:device:cgroup: " 607 "($help)*--device-read-bps=[Limit the read rate (bytes per second) from a device]:device:IO rate: " 608 "($help)*--device-read-iops=[Limit the read rate (IO per second) from a device]:device:IO rate: " 609 "($help)*--device-write-bps=[Limit the write rate (bytes per second) to a device]:device:IO rate: " 610 "($help)*--device-write-iops=[Limit the write rate (IO per second) to a device]:device:IO rate: " 611 "($help)--disable-content-trust[Skip image verification]" 612 "($help)*--dns=[Custom DNS servers]:DNS server: " 613 "($help)*--dns-option=[Custom DNS options]:DNS option: " 614 "($help)*--dns-search=[Custom DNS search domains]:DNS domains: " 615 "($help)*"{-e=,--env=}"[Environment variables]:environment variable: " 616 "($help)--entrypoint=[Overwrite the default entrypoint of the image]:entry point: " 617 "($help)*--env-file=[Read environment variables from a file]:environment file:_files" 618 "($help)*--expose=[Expose a port from the container without publishing it]: " 619 "($help)*--group=[Set one or more supplementary user groups for the container]:group:_groups" 620 "($help -h --hostname)"{-h=,--hostname=}"[Container host name]:hostname:_hosts" 621 "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]" 622 "($help)--init[Run an init inside the container that forwards signals and reaps processes]" 623 "($help)--ip=[IPv4 address]:IPv4: " 624 "($help)--ip6=[IPv6 address]:IPv6: " 625 "($help)--ipc=[IPC namespace to use]:IPC namespace: " 626 "($help)--isolation=[Container isolation technology]:isolation:(default hyperv process)" 627 "($help)*--link=[Add link to another container]:link:->link" 628 "($help)*--link-local-ip=[Container IPv4/IPv6 link-local addresses]:IPv4/IPv6: " 629 "($help)*"{-l=,--label=}"[Container metadata]:label: " 630 "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_complete_log_drivers" 631 "($help)*--log-opt=[Log driver specific options]:log driver options:__docker_complete_log_options" 632 "($help)--mac-address=[Container MAC address]:MAC address: " 633 "($help)*--mount=[Attach a filesystem mount to the container]:mount: " 634 "($help)--name=[Container name]:name: " 635 "($help)--network=[Connect a container to a network]:network mode:(bridge none container host)" 636 "($help)*--network-alias=[Add network-scoped alias for the container]:alias: " 637 "($help)--oom-kill-disable[Disable OOM Killer]" 638 "($help)--oom-score-adj[Tune the host's OOM preferences for containers (accepts -1000 to 1000)]" 639 "($help)--pids-limit[Tune container pids limit (set -1 for unlimited)]" 640 "($help -P --publish-all)"{-P,--publish-all}"[Publish all exposed ports]" 641 "($help)*"{-p=,--publish=}"[Expose a container's port to the host]:port:_ports" 642 "($help)--pid=[PID namespace to use]:PID namespace:__docker_complete_pid" 643 "($help)--privileged[Give extended privileges to this container]" 644 "($help)--read-only[Mount the container's root filesystem as read only]" 645 "($help)*--security-opt=[Security options]:security option: " 646 "($help)*--shm-size=[Size of '/dev/shm' (format is '<number><unit>')]:shm size: " 647 "($help)--stop-signal=[Signal to kill a container]:signal:_signals" 648 "($help)--stop-timeout=[Timeout (in seconds) to stop a container]:time: " 649 "($help)*--sysctl=-[sysctl options]:sysctl: " 650 "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" 651 "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" 652 "($help)*--ulimit=[ulimit options]:ulimit: " 653 "($help)--userns=[Container user namespace]:user namespace:(host)" 654 "($help)--tmpfs[mount tmpfs]" 655 "($help)*-v[Bind mount a volume]:volume: " 656 "($help)--volume-driver=[Optional volume driver for the container]:volume driver:(local)" 657 "($help)*--volumes-from=[Mount volumes from the specified container]:volume: " 658 "($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories" 659 ) 660 opts_create_run_update=( 661 "($help)--blkio-weight=[Block IO (relative weight), between 10 and 1000]:Block IO weight:(10 100 500 1000)" 662 "($help -c --cpu-shares)"{-c=,--cpu-shares=}"[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)" 663 "($help)--cpu-period=[Limit the CPU CFS (Completely Fair Scheduler) period]:CPU period: " 664 "($help)--cpu-quota=[Limit the CPU CFS (Completely Fair Scheduler) quota]:CPU quota: " 665 "($help)--cpu-rt-period=[Limit the CPU real-time period]:CPU real-time period in microseconds: " 666 "($help)--cpu-rt-runtime=[Limit the CPU real-time runtime]:CPU real-time runtime in microseconds: " 667 "($help)--cpuset-cpus=[CPUs in which to allow execution]:CPUs: " 668 "($help)--cpuset-mems=[MEMs in which to allow execution]:MEMs: " 669 "($help)--kernel-memory=[Kernel memory limit in bytes]:Memory limit: " 670 "($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: " 671 "($help)--memory-reservation=[Memory soft limit]:Memory limit: " 672 "($help)--memory-swap=[Total memory limit with swap]:Memory limit: " 673 "($help)--restart=[Restart policy]:restart policy:(no on-failure always unless-stopped)" 674 ) 675 opts_help=("(: -)--help[Print usage]") 676 677 case "$words[1]" in 678 (attach) 679 _arguments $(__docker_arguments) \ 680 $opts_help \ 681 $opts_attach_exec_run_start \ 682 "($help)--no-stdin[Do not attach stdin]" \ 683 "($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \ 684 "($help -):containers:__docker_complete_running_containers" && ret=0 685 ;; 686 (commit) 687 _arguments $(__docker_arguments) \ 688 $opts_help \ 689 "($help -a --author)"{-a=,--author=}"[Author]:author: " \ 690 "($help)*"{-c=,--change=}"[Apply Dockerfile instruction to the created image]:Dockerfile:_files" \ 691 "($help -m --message)"{-m=,--message=}"[Commit message]:message: " \ 692 "($help -p --pause)"{-p,--pause}"[Pause container during commit]" \ 693 "($help -):container:__docker_complete_containers" \ 694 "($help -): :__docker_complete_repositories_with_tags" && ret=0 695 ;; 696 (cp) 697 local state 698 _arguments $(__docker_arguments) \ 699 $opts_help \ 700 "($help -L --follow-link)"{-L,--follow-link}"[Always follow symbol link]" \ 701 "($help -)1:container:->container" \ 702 "($help -)2:hostpath:_files" && ret=0 703 case $state in 704 (container) 705 if compset -P "*:"; then 706 _files && ret=0 707 else 708 __docker_complete_containers -qS ":" && ret=0 709 fi 710 ;; 711 esac 712 ;; 713 (create) 714 local state 715 _arguments $(__docker_arguments) \ 716 $opts_help \ 717 $opts_create_run \ 718 $opts_create_run_update \ 719 "($help -): :__docker_complete_images" \ 720 "($help -):command: _command_names -e" \ 721 "($help -)*::arguments: _normal" && ret=0 722 case $state in 723 (link) 724 if compset -P "*:"; then 725 _wanted alias expl "Alias" compadd -E "" && ret=0 726 else 727 __docker_complete_running_containers -qS ":" && ret=0 728 fi 729 ;; 730 esac 731 ;; 732 (diff) 733 _arguments $(__docker_arguments) \ 734 $opts_help \ 735 "($help -)*:containers:__docker_complete_containers" && ret=0 736 ;; 737 (exec) 738 local state 739 _arguments $(__docker_arguments) \ 740 $opts_help \ 741 $opts_attach_exec_run_start \ 742 "($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \ 743 "($help)*"{-e=,--env=}"[Set environment variables]:environment variable: " \ 744 "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]" \ 745 "($help)--privileged[Give extended Linux capabilities to the command]" \ 746 "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" \ 747 "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" \ 748 "($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories" \ 749 "($help -):containers:__docker_complete_running_containers" \ 750 "($help -)*::command:->anycommand" && ret=0 751 case $state in 752 (anycommand) 753 shift 1 words 754 (( CURRENT-- )) 755 _normal && ret=0 756 ;; 757 esac 758 ;; 759 (export) 760 _arguments $(__docker_arguments) \ 761 $opts_help \ 762 "($help -o --output)"{-o=,--output=}"[Write to a file, instead of stdout]:output file:_files" \ 763 "($help -)*:containers:__docker_complete_containers" && ret=0 764 ;; 765 (inspect) 766 _arguments $(__docker_arguments) \ 767 $opts_help \ 768 "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ 769 "($help -s --size)"{-s,--size}"[Display total file sizes]" \ 770 "($help -)*:containers:__docker_complete_containers" && ret=0 771 ;; 772 (kill) 773 _arguments $(__docker_arguments) \ 774 $opts_help \ 775 "($help -s --signal)"{-s=,--signal=}"[Signal to send]:signal:_signals" \ 776 "($help -)*:containers:__docker_complete_running_containers" && ret=0 777 ;; 778 (logs) 779 _arguments $(__docker_arguments) \ 780 $opts_help \ 781 "($help)--details[Show extra details provided to logs]" \ 782 "($help -f --follow)"{-f,--follow}"[Follow log output]" \ 783 "($help -s --since)"{-s=,--since=}"[Show logs since this timestamp]:timestamp: " \ 784 "($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \ 785 "($help)--tail=[Output the last K lines]:lines:(1 10 20 50 all)" \ 786 "($help -)*:containers:__docker_complete_containers" && ret=0 787 ;; 788 (ls|list) 789 _arguments $(__docker_arguments) \ 790 $opts_help \ 791 "($help -a --all)"{-a,--all}"[Show all containers]" \ 792 "($help)--before=[Show only container created before...]:containers:__docker_complete_containers" \ 793 "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_ps_filters" \ 794 "($help)--format=[Pretty-print containers using a Go template]:template: " \ 795 "($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \ 796 "($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \ 797 "($help)--no-trunc[Do not truncate output]" \ 798 "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ 799 "($help -s --size)"{-s,--size}"[Display total file sizes]" \ 800 "($help)--since=[Show only containers created since...]:containers:__docker_complete_containers" && ret=0 801 ;; 802 (pause|unpause) 803 _arguments $(__docker_arguments) \ 804 $opts_help \ 805 "($help -)*:containers:__docker_complete_running_containers" && ret=0 806 ;; 807 (port) 808 _arguments $(__docker_arguments) \ 809 $opts_help \ 810 "($help -)1:containers:__docker_complete_running_containers" \ 811 "($help -)2:port:_ports" && ret=0 812 ;; 813 (prune) 814 _arguments $(__docker_arguments) \ 815 $opts_help \ 816 "($help)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \ 817 "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0 818 ;; 819 (rename) 820 _arguments $(__docker_arguments) \ 821 $opts_help \ 822 "($help -):old name:__docker_complete_containers" \ 823 "($help -):new name: " && ret=0 824 ;; 825 (restart) 826 _arguments $(__docker_arguments) \ 827 $opts_help \ 828 "($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)" \ 829 "($help -)*:containers:__docker_complete_containers_ids" && ret=0 830 ;; 831 (rm) 832 local state 833 _arguments $(__docker_arguments) \ 834 $opts_help \ 835 "($help -f --force)"{-f,--force}"[Force removal]" \ 836 "($help -l --link)"{-l,--link}"[Remove the specified link and not the underlying container]" \ 837 "($help -v --volumes)"{-v,--volumes}"[Remove the volumes associated to the container]" \ 838 "($help -)*:containers:->values" && ret=0 839 case $state in 840 (values) 841 if [[ ${words[(r)-f]} == -f || ${words[(r)--force]} == --force ]]; then 842 __docker_complete_containers && ret=0 843 else 844 __docker_complete_stopped_containers && ret=0 845 fi 846 ;; 847 esac 848 ;; 849 (run) 850 local state 851 _arguments $(__docker_arguments) \ 852 $opts_help \ 853 $opts_create_run \ 854 $opts_create_run_update \ 855 $opts_attach_exec_run_start \ 856 "($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \ 857 "($help)--health-cmd=[Command to run to check health]:command: " \ 858 "($help)--health-interval=[Time between running the check]:time: " \ 859 "($help)--health-retries=[Consecutive failures needed to report unhealthy]:retries:(1 2 3 4 5)" \ 860 "($help)--health-timeout=[Maximum time to allow one check to run]:time: " \ 861 "($help)--no-healthcheck[Disable any container-specified HEALTHCHECK]" \ 862 "($help)--rm[Remove intermediate containers when it exits]" \ 863 "($help)--runtime=[Name of the runtime to be used for that container]:runtime:__docker_complete_runtimes" \ 864 "($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \ 865 "($help)--storage-opt=[Storage driver options for the container]:storage options:->storage-opt" \ 866 "($help -): :__docker_complete_images" \ 867 "($help -):command: _command_names -e" \ 868 "($help -)*::arguments: _normal" && ret=0 869 case $state in 870 (link) 871 if compset -P "*:"; then 872 _wanted alias expl "Alias" compadd -E "" && ret=0 873 else 874 __docker_complete_running_containers -qS ":" && ret=0 875 fi 876 ;; 877 (storage-opt) 878 if compset -P "*="; then 879 _message "value" && ret=0 880 else 881 opts=('size') 882 _describe -t filter-opts "storage options" opts -qS "=" && ret=0 883 fi 884 ;; 885 esac 886 ;; 887 (start) 888 _arguments $(__docker_arguments) \ 889 $opts_help \ 890 $opts_attach_exec_run_start \ 891 "($help -a --attach)"{-a,--attach}"[Attach container's stdout/stderr and forward all signals]" \ 892 "($help -i --interactive)"{-i,--interactive}"[Attach container's stding]" \ 893 "($help -)*:containers:__docker_complete_stopped_containers" && ret=0 894 ;; 895 (stats) 896 _arguments $(__docker_arguments) \ 897 $opts_help \ 898 "($help -a --all)"{-a,--all}"[Show all containers (default shows just running)]" \ 899 "($help)--format=[Pretty-print images using a Go template]:template: " \ 900 "($help)--no-stream[Disable streaming stats and only pull the first result]" \ 901 "($help)--no-trunc[Do not truncate output]" \ 902 "($help -)*:containers:__docker_complete_running_containers" && ret=0 903 ;; 904 (stop) 905 _arguments $(__docker_arguments) \ 906 $opts_help \ 907 "($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)" \ 908 "($help -)*:containers:__docker_complete_running_containers" && ret=0 909 ;; 910 (top) 911 local state 912 _arguments $(__docker_arguments) \ 913 $opts_help \ 914 "($help -)1:containers:__docker_complete_running_containers" \ 915 "($help -)*:: :->ps-arguments" && ret=0 916 case $state in 917 (ps-arguments) 918 _ps && ret=0 919 ;; 920 esac 921 ;; 922 (update) 923 local state 924 _arguments $(__docker_arguments) \ 925 $opts_help \ 926 opts_create_run_update \ 927 "($help -)*: :->values" && ret=0 928 case $state in 929 (values) 930 if [[ ${words[(r)--kernel-memory*]} = (--kernel-memory*) ]]; then 931 __docker_complete_stopped_containers && ret=0 932 else 933 __docker_complete_containers && ret=0 934 fi 935 ;; 936 esac 937 ;; 938 (wait) 939 _arguments $(__docker_arguments) \ 940 $opts_help \ 941 "($help -)*:containers:__docker_complete_running_containers" && ret=0 942 ;; 943 (help) 944 _arguments $(__docker_arguments) ":subcommand:__docker_container_commands" && ret=0 945 ;; 946 esac 947 948 return ret 949 } 950 951 # EO container 952 953 # BO image 954 955 __docker_image_commands() { 956 local -a _docker_image_subcommands 957 _docker_image_subcommands=( 958 "build:Build an image from a Dockerfile" 959 "history:Show the history of an image" 960 "import:Import the contents from a tarball to create a filesystem image" 961 "inspect:Display detailed information on one or more images" 962 "load:Load an image from a tar archive or STDIN" 963 "ls:List images" 964 "prune:Remove unused images" 965 "pull:Pull an image or a repository from a registry" 966 "push:Push an image or a repository to a registry" 967 "rm:Remove one or more images" 968 "save:Save one or more images to a tar archive (streamed to STDOUT by default)" 969 "tag:Tag an image into a repository" 970 ) 971 _describe -t docker-image-commands "docker image command" _docker_image_subcommands 972 } 973 974 __docker_image_subcommand() { 975 local -a _command_args opts_help 976 local expl help="--help" 977 integer ret=1 978 979 opts_help=("(: -)--help[Print usage]") 980 981 case "$words[1]" in 982 (build) 983 _arguments $(__docker_arguments) \ 984 $opts_help \ 985 "($help)*--add-host=[Add a custom host-to-IP mapping]:host\:ip mapping: " \ 986 "($help)*--build-arg=[Build-time variables]:<varname>=<value>: " \ 987 "($help)*--cache-from=[Images to consider as cache sources]: :__docker_complete_repositories_with_tags" \ 988 "($help -c --cpu-shares)"{-c=,--cpu-shares=}"[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)" \ 989 "($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: " \ 990 "($help)--compress[Compress the build context using gzip]" \ 991 "($help)--cpu-period=[Limit the CPU CFS (Completely Fair Scheduler) period]:CPU period: " \ 992 "($help)--cpu-quota=[Limit the CPU CFS (Completely Fair Scheduler) quota]:CPU quota: " \ 993 "($help)--cpu-rt-period=[Limit the CPU real-time period]:CPU real-time period in microseconds: " \ 994 "($help)--cpu-rt-runtime=[Limit the CPU real-time runtime]:CPU real-time runtime in microseconds: " \ 995 "($help)--cpuset-cpus=[CPUs in which to allow execution]:CPUs: " \ 996 "($help)--cpuset-mems=[MEMs in which to allow execution]:MEMs: " \ 997 "($help)--disable-content-trust[Skip image verification]" \ 998 "($help -f --file)"{-f=,--file=}"[Name of the Dockerfile]:Dockerfile:_files" \ 999 "($help)--force-rm[Always remove intermediate containers]" \ 1000 "($help)--isolation=[Container isolation technology]:isolation:(default hyperv process)" \ 1001 "($help)*--label=[Set metadata for an image]:label=value: " \ 1002 "($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: " \ 1003 "($help)--memory-swap=[Total memory limit with swap]:Memory limit: " \ 1004 "($help)--network=[Connect a container to a network]:network mode:(bridge none container host)" \ 1005 "($help)--no-cache[Do not use cache when building the image]" \ 1006 "($help)--pull[Attempt to pull a newer version of the image]" \ 1007 "($help -q --quiet)"{-q,--quiet}"[Suppress verbose build output]" \ 1008 "($help)--rm[Remove intermediate containers after a successful build]" \ 1009 "($help)*--shm-size=[Size of '/dev/shm' (format is '<number><unit>')]:shm size: " \ 1010 "($help)--squash[Squash newly built layers into a single new layer]" \ 1011 "($help -t --tag)*"{-t=,--tag=}"[Repository, name and tag for the image]: :__docker_complete_repositories_with_tags" \ 1012 "($help)*--ulimit=[ulimit options]:ulimit: " \ 1013 "($help)--userns=[Container user namespace]:user namespace:(host)" \ 1014 "($help -):path or URL:_directories" && ret=0 1015 ;; 1016 (history) 1017 _arguments $(__docker_arguments) \ 1018 $opts_help \ 1019 "($help -H --human)"{-H,--human}"[Print sizes and dates in human readable format]" \ 1020 "($help)--no-trunc[Do not truncate output]" \ 1021 "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ 1022 "($help -)*: :__docker_complete_images" && ret=0 1023 ;; 1024 (import) 1025 _arguments $(__docker_arguments) \ 1026 $opts_help \ 1027 "($help)*"{-c=,--change=}"[Apply Dockerfile instruction to the created image]:Dockerfile:_files" \ 1028 "($help -m --message)"{-m=,--message=}"[Commit message for imported image]:message: " \ 1029 "($help -):URL:(- http:// file://)" \ 1030 "($help -): :__docker_complete_repositories_with_tags" && ret=0 1031 ;; 1032 (inspect) 1033 _arguments $(__docker_arguments) \ 1034 $opts_help \ 1035 "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ 1036 "($help -)*:images:__docker_complete_images" && ret=0 1037 ;; 1038 (load) 1039 _arguments $(__docker_arguments) \ 1040 $opts_help \ 1041 "($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))(-.)\"" \ 1042 "($help -q --quiet)"{-q,--quiet}"[Suppress the load output]" && ret=0 1043 ;; 1044 (ls|list) 1045 local state 1046 _arguments $(__docker_arguments) \ 1047 $opts_help \ 1048 "($help -a --all)"{-a,--all}"[Show all images]" \ 1049 "($help)--digests[Show digests]" \ 1050 "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_images_filters" \ 1051 "($help)--format=[Pretty-print images using a Go template]:template: " \ 1052 "($help)--no-trunc[Do not truncate output]" \ 1053 "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \ 1054 "($help -): :__docker_complete_repositories" && ret=0 1055 ;; 1056 (prune) 1057 _arguments $(__docker_arguments) \ 1058 $opts_help \ 1059 "($help -a --all)"{-a,--all}"[Remove all unused images, not just dangling ones]" \ 1060 "($help)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \ 1061 "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0 1062 ;; 1063 (pull) 1064 _arguments $(__docker_arguments) \ 1065 $opts_help \ 1066 "($help -a --all-tags)"{-a,--all-tags}"[Download all tagged images]" \ 1067 "($help)--disable-content-trust[Skip image verification]" \ 1068 "($help -):name:__docker_search" && ret=0 1069 ;; 1070 (push) 1071 _arguments $(__docker_arguments) \ 1072 $opts_help \ 1073 "($help)--disable-content-trust[Skip image signing]" \ 1074 "($help -): :__docker_complete_images" && ret=0 1075 ;; 1076 (rm) 1077 _arguments $(__docker_arguments) \ 1078 $opts_help \ 1079 "($help -f --force)"{-f,--force}"[Force removal]" \ 1080 "($help)--no-prune[Do not delete untagged parents]" \ 1081 "($help -)*: :__docker_complete_images" && ret=0 1082 ;; 1083 (save) 1084 _arguments $(__docker_arguments) \ 1085 $opts_help \ 1086 "($help -o --output)"{-o=,--output=}"[Write to file]:file:_files" \ 1087 "($help -)*: :__docker_complete_images" && ret=0 1088 ;; 1089 (tag) 1090 _arguments $(__docker_arguments) \ 1091 $opts_help \ 1092 "($help -):source:__docker_complete_images"\ 1093 "($help -):destination:__docker_complete_repositories_with_tags" && ret=0 1094 ;; 1095 (help) 1096 _arguments $(__docker_arguments) ":subcommand:__docker_container_commands" && ret=0 1097 ;; 1098 esac 1099 1100 return ret 1101 } 1102 1103 # EO image 1104 1105 # BO network 1106 1107 __docker_network_complete_ls_filters() { 1108 [[ $PREFIX = -* ]] && return 1 1109 integer ret=1 1110 1111 if compset -P '*='; then 1112 case "${${words[-1]%=*}#*=}" in 1113 (driver) 1114 __docker_complete_info_plugins Network && ret=0 1115 ;; 1116 (id) 1117 __docker_complete_networks_ids && ret=0 1118 ;; 1119 (name) 1120 __docker_complete_networks_names && ret=0 1121 ;; 1122 (scope) 1123 opts=('global' 'local' 'swarm') 1124 _describe -t scope-filter-opts "Scope filter options" opts && ret=0 1125 ;; 1126 (type) 1127 opts=('builtin' 'custom') 1128 _describe -t type-filter-opts "Type filter options" opts && ret=0 1129 ;; 1130 *) 1131 _message 'value' && ret=0 1132 ;; 1133 esac 1134 else 1135 opts=('driver' 'id' 'label' 'name' 'scope' 'type') 1136 _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 1137 fi 1138 1139 return ret 1140 } 1141 1142 __docker_get_networks() { 1143 [[ $PREFIX = -* ]] && return 1 1144 integer ret=1 1145 local line s 1146 declare -a lines networks 1147 1148 type=$1; shift 1149 1150 lines=(${(f)${:-"$(_call_program commands docker $docker_options network ls)"$'\n'}}) 1151 1152 # Parse header line to find columns 1153 local i=1 j=1 k header=${lines[1]} 1154 declare -A begin end 1155 while (( j < ${#header} - 1 )); do 1156 i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) 1157 j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) 1158 k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) 1159 begin[${header[$i,$((j-1))]}]=$i 1160 end[${header[$i,$((j-1))]}]=$k 1161 done 1162 end[${header[$i,$((j-1))]}]=-1 1163 lines=(${lines[2,-1]}) 1164 1165 # Network ID 1166 if [[ $type = (ids|all) ]]; then 1167 for line in $lines; do 1168 s="${line[${begin[NETWORK ID]},${end[NETWORK ID]}]%% ##}" 1169 s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}" 1170 s="$s, ${${line[${begin[SCOPE]},${end[SCOPE]}]}%% ##}" 1171 networks=($networks $s) 1172 done 1173 fi 1174 1175 # Names 1176 if [[ $type = (names|all) ]]; then 1177 for line in $lines; do 1178 s="${line[${begin[NAME]},${end[NAME]}]%% ##}" 1179 s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}" 1180 s="$s, ${${line[${begin[SCOPE]},${end[SCOPE]}]}%% ##}" 1181 networks=($networks $s) 1182 done 1183 fi 1184 1185 _describe -t networks-list "networks" networks "$@" && ret=0 1186 return ret 1187 } 1188 1189 __docker_complete_networks() { 1190 [[ $PREFIX = -* ]] && return 1 1191 __docker_get_networks all "$@" 1192 } 1193 1194 __docker_complete_networks_ids() { 1195 [[ $PREFIX = -* ]] && return 1 1196 __docker_get_networks ids "$@" 1197 } 1198 1199 __docker_complete_networks_names() { 1200 [[ $PREFIX = -* ]] && return 1 1201 __docker_get_networks names "$@" 1202 } 1203 1204 __docker_network_commands() { 1205 local -a _docker_network_subcommands 1206 _docker_network_subcommands=( 1207 "connect:Connect a container to a network" 1208 "create:Creates a new network with a name specified by the user" 1209 "disconnect:Disconnects a container from a network" 1210 "inspect:Displays detailed information on a network" 1211 "ls:Lists all the networks created by the user" 1212 "prune:Remove all unused networks" 1213 "rm:Deletes one or more networks" 1214 ) 1215 _describe -t docker-network-commands "docker network command" _docker_network_subcommands 1216 } 1217 1218 __docker_network_subcommand() { 1219 local -a _command_args opts_help 1220 local expl help="--help" 1221 integer ret=1 1222 1223 opts_help=("(: -)--help[Print usage]") 1224 1225 case "$words[1]" in 1226 (connect) 1227 _arguments $(__docker_arguments) \ 1228 $opts_help \ 1229 "($help)*--alias=[Add network-scoped alias for the container]:alias: " \ 1230 "($help)--ip=[IPv4 address]:IPv4: " \ 1231 "($help)--ip6=[IPv6 address]:IPv6: " \ 1232 "($help)*--link=[Add a link to another container]:link:->link" \ 1233 "($help)*--link-local-ip=[Add a link-local address for the container]:IPv4/IPv6: " \ 1234 "($help -)1:network:__docker_complete_networks" \ 1235 "($help -)2:containers:__docker_complete_containers" && ret=0 1236 1237 case $state in 1238 (link) 1239 if compset -P "*:"; then 1240 _wanted alias expl "Alias" compadd -E "" && ret=0 1241 else 1242 __docker_complete_running_containers -qS ":" && ret=0 1243 fi 1244 ;; 1245 esac 1246 ;; 1247 (create) 1248 _arguments $(__docker_arguments) -A '-*' \ 1249 $opts_help \ 1250 "($help)--attachable[Enable manual container attachment]" \ 1251 "($help)*--aux-address[Auxiliary IPv4 or IPv6 addresses used by network driver]:key=IP: " \ 1252 "($help -d --driver)"{-d=,--driver=}"[Driver to manage the Network]:driver:(null host bridge overlay)" \ 1253 "($help)*--gateway=[IPv4 or IPv6 Gateway for the master subnet]:IP: " \ 1254 "($help)--internal[Restricts external access to the network]" \ 1255 "($help)*--ip-range=[Allocate container ip from a sub-range]:IP/mask: " \ 1256 "($help)--ipam-driver=[IP Address Management Driver]:driver:(default)" \ 1257 "($help)*--ipam-opt=[Custom IPAM plugin options]:opt=value: " \ 1258 "($help)--ipv6[Enable IPv6 networking]" \ 1259 "($help)*--label=[Set metadata on a network]:label=value: " \ 1260 "($help)*"{-o=,--opt=}"[Driver specific options]:opt=value: " \ 1261 "($help)*--subnet=[Subnet in CIDR format that represents a network segment]:IP/mask: " \ 1262 "($help -)1:Network Name: " && ret=0 1263 ;; 1264 (disconnect) 1265 _arguments $(__docker_arguments) \ 1266 $opts_help \ 1267 "($help -)1:network:__docker_complete_networks" \ 1268 "($help -)2:containers:__docker_complete_containers" && ret=0 1269 ;; 1270 (inspect) 1271 _arguments $(__docker_arguments) \ 1272 $opts_help \ 1273 "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ 1274 "($help)--verbose[Show detailed information]" \ 1275 "($help -)*:network:__docker_complete_networks" && ret=0 1276 ;; 1277 (ls) 1278 _arguments $(__docker_arguments) \ 1279 $opts_help \ 1280 "($help)--no-trunc[Do not truncate the output]" \ 1281 "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_network_complete_ls_filters" \ 1282 "($help)--format=[Pretty-print networks using a Go template]:template: " \ 1283 "($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0 1284 ;; 1285 (prune) 1286 _arguments $(__docker_arguments) \ 1287 $opts_help \ 1288 "($help)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \ 1289 "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0 1290 ;; 1291 (rm) 1292 _arguments $(__docker_arguments) \ 1293 $opts_help \ 1294 "($help -)*:network:__docker_complete_networks" && ret=0 1295 ;; 1296 (help) 1297 _arguments $(__docker_arguments) ":subcommand:__docker_network_commands" && ret=0 1298 ;; 1299 esac 1300 1301 return ret 1302 } 1303 1304 # EO network 1305 1306 # BO node 1307 1308 __docker_node_complete_ls_filters() { 1309 [[ $PREFIX = -* ]] && return 1 1310 integer ret=1 1311 1312 if compset -P '*='; then 1313 case "${${words[-1]%=*}#*=}" in 1314 (id) 1315 __docker_complete_nodes_ids && ret=0 1316 ;; 1317 (membership) 1318 membership_opts=('accepted' 'pending' 'rejected') 1319 _describe -t membership-opts "membership options" membership_opts && ret=0 1320 ;; 1321 (name) 1322 __docker_complete_nodes_names && ret=0 1323 ;; 1324 (role) 1325 role_opts=('manager' 'worker') 1326 _describe -t role-opts "role options" role_opts && ret=0 1327 ;; 1328 *) 1329 _message 'value' && ret=0 1330 ;; 1331 esac 1332 else 1333 opts=('id' 'label' 'membership' 'name' 'role') 1334 _describe -t filter-opts "filter options" opts -qS "=" && ret=0 1335 fi 1336 1337 return ret 1338 } 1339 1340 __docker_node_complete_ps_filters() { 1341 [[ $PREFIX = -* ]] && return 1 1342 integer ret=1 1343 1344 if compset -P '*='; then 1345 case "${${words[-1]%=*}#*=}" in 1346 (desired-state) 1347 state_opts=('accepted' 'running' 'shutdown') 1348 _describe -t state-opts "desired state options" state_opts && ret=0 1349 ;; 1350 *) 1351 _message 'value' && ret=0 1352 ;; 1353 esac 1354 else 1355 opts=('desired-state' 'id' 'label' 'name') 1356 _describe -t filter-opts "filter options" opts -qS "=" && ret=0 1357 fi 1358 1359 return ret 1360 } 1361 1362 __docker_nodes() { 1363 [[ $PREFIX = -* ]] && return 1 1364 integer ret=1 1365 local line s 1366 declare -a lines nodes args 1367 1368 type=$1; shift 1369 filter=$1; shift 1370 [[ $filter != "none" ]] && args=("-f $filter") 1371 1372 lines=(${(f)${:-"$(_call_program commands docker $docker_options node ls $args)"$'\n'}}) 1373 # Parse header line to find columns 1374 local i=1 j=1 k header=${lines[1]} 1375 declare -A begin end 1376 while (( j < ${#header} - 1 )); do 1377 i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) 1378 j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) 1379 k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) 1380 begin[${header[$i,$((j-1))]}]=$i 1381 end[${header[$i,$((j-1))]}]=$k 1382 done 1383 end[${header[$i,$((j-1))]}]=-1 1384 lines=(${lines[2,-1]}) 1385 1386 # Node ID 1387 if [[ $type = (ids|all) ]]; then 1388 for line in $lines; do 1389 s="${line[${begin[ID]},${end[ID]}]%% ##}" 1390 nodes=($nodes $s) 1391 done 1392 fi 1393 1394 # Names 1395 if [[ $type = (names|all) ]]; then 1396 for line in $lines; do 1397 s="${line[${begin[HOSTNAME]},${end[HOSTNAME]}]%% ##}" 1398 nodes=($nodes $s) 1399 done 1400 fi 1401 1402 _describe -t nodes-list "nodes" nodes "$@" && ret=0 1403 return ret 1404 } 1405 1406 __docker_complete_nodes() { 1407 [[ $PREFIX = -* ]] && return 1 1408 __docker_nodes all none "$@" 1409 } 1410 1411 __docker_complete_nodes_ids() { 1412 [[ $PREFIX = -* ]] && return 1 1413 __docker_nodes ids none "$@" 1414 } 1415 1416 __docker_complete_nodes_names() { 1417 [[ $PREFIX = -* ]] && return 1 1418 __docker_nodes names none "$@" 1419 } 1420 1421 __docker_complete_pending_nodes() { 1422 [[ $PREFIX = -* ]] && return 1 1423 __docker_nodes all "membership=pending" "$@" 1424 } 1425 1426 __docker_complete_manager_nodes() { 1427 [[ $PREFIX = -* ]] && return 1 1428 __docker_nodes all "role=manager" "$@" 1429 } 1430 1431 __docker_complete_worker_nodes() { 1432 [[ $PREFIX = -* ]] && return 1 1433 __docker_nodes all "role=worker" "$@" 1434 } 1435 1436 __docker_node_commands() { 1437 local -a _docker_node_subcommands 1438 _docker_node_subcommands=( 1439 "demote:Demote a node as manager in the swarm" 1440 "inspect:Display detailed information on one or more nodes" 1441 "ls:List nodes in the swarm" 1442 "promote:Promote a node as manager in the swarm" 1443 "rm:Remove one or more nodes from the swarm" 1444 "ps:List tasks running on one or more nodes, defaults to current node" 1445 "update:Update a node" 1446 ) 1447 _describe -t docker-node-commands "docker node command" _docker_node_subcommands 1448 } 1449 1450 __docker_node_subcommand() { 1451 local -a _command_args opts_help 1452 local expl help="--help" 1453 integer ret=1 1454 1455 opts_help=("(: -)--help[Print usage]") 1456 1457 case "$words[1]" in 1458 (rm|remove) 1459 _arguments $(__docker_arguments) \ 1460 $opts_help \ 1461 "($help -f --force)"{-f,--force}"[Force remove a node from the swarm]" \ 1462 "($help -)*:node:__docker_complete_pending_nodes" && ret=0 1463 ;; 1464 (demote) 1465 _arguments $(__docker_arguments) \ 1466 $opts_help \ 1467 "($help -)*:node:__docker_complete_manager_nodes" && ret=0 1468 ;; 1469 (inspect) 1470 _arguments $(__docker_arguments) \ 1471 $opts_help \ 1472 "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ 1473 "($help)--pretty[Print the information in a human friendly format]" \ 1474 "($help -)*:node:__docker_complete_nodes" && ret=0 1475 ;; 1476 (ls|list) 1477 _arguments $(__docker_arguments) \ 1478 $opts_help \ 1479 "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_node_complete_ls_filters" \ 1480 "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0 1481 ;; 1482 (promote) 1483 _arguments $(__docker_arguments) \ 1484 $opts_help \ 1485 "($help -)*:node:__docker_complete_worker_nodes" && ret=0 1486 ;; 1487 (ps) 1488 _arguments $(__docker_arguments) \ 1489 $opts_help \ 1490 "($help -a --all)"{-a,--all}"[Display all instances]" \ 1491 "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_node_complete_ps_filters" \ 1492 "($help)--format=[Format the output using the given go template]:template: " \ 1493 "($help)--no-resolve[Do not map IDs to Names]" \ 1494 "($help)--no-trunc[Do not truncate output]" \ 1495 "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" \ 1496 "($help -)*:node:__docker_complete_nodes" && ret=0 1497 ;; 1498 (update) 1499 _arguments $(__docker_arguments) \ 1500 $opts_help \ 1501 "($help)--availability=[Availability of the node]:availability:(active pause drain)" \ 1502 "($help)*--label-add=[Add or update a node label]:key=value: " \ 1503 "($help)*--label-rm=[Remove a node label if exists]:label: " \ 1504 "($help)--role=[Role of the node]:role:(manager worker)" \ 1505 "($help -)1:node:__docker_complete_nodes" && ret=0 1506 ;; 1507 (help) 1508 _arguments $(__docker_arguments) ":subcommand:__docker_node_commands" && ret=0 1509 ;; 1510 esac 1511 1512 return ret 1513 } 1514 1515 # EO node 1516 1517 # BO plugin 1518 1519 __docker_plugin_complete_ls_filters() { 1520 [[ $PREFIX = -* ]] && return 1 1521 integer ret=1 1522 1523 if compset -P '*='; then 1524 case "${${words[-1]%=*}#*=}" in 1525 (capability) 1526 opts=('authz' 'ipamdriver' 'logdriver' 'metricscollector' 'networkdriver' 'volumedriver') 1527 _describe -t capability-opts "capability options" opts && ret=0 1528 ;; 1529 (enabled) 1530 opts=('false' 'true') 1531 _describe -t enabled-opts "enabled options" opts && ret=0 1532 ;; 1533 *) 1534 _message 'value' && ret=0 1535 ;; 1536 esac 1537 else 1538 opts=('capability' 'enabled') 1539 _describe -t filter-opts "filter options" opts -qS "=" && ret=0 1540 fi 1541 1542 return ret 1543 } 1544 1545 __docker_plugins() { 1546 [[ $PREFIX = -* ]] && return 1 1547 integer ret=1 1548 local line s 1549 declare -a lines plugins args 1550 1551 filter=$1; shift 1552 [[ $filter != "none" ]] && args=("-f $filter") 1553 1554 lines=(${(f)${:-"$(_call_program commands docker $docker_options plugin ls $args)"$'\n'}}) 1555 1556 # Parse header line to find columns 1557 local i=1 j=1 k header=${lines[1]} 1558 declare -A begin end 1559 while (( j < ${#header} - 1 )); do 1560 i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) 1561 j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) 1562 k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) 1563 begin[${header[$i,$((j-1))]}]=$i 1564 end[${header[$i,$((j-1))]}]=$k 1565 done 1566 end[${header[$i,$((j-1))]}]=-1 1567 lines=(${lines[2,-1]}) 1568 1569 # Name 1570 for line in $lines; do 1571 s="${line[${begin[NAME]},${end[NAME]}]%% ##}" 1572 s="$s:${(l:7:: :::)${${line[${begin[TAG]},${end[TAG]}]}%% ##}}" 1573 plugins=($plugins $s) 1574 done 1575 1576 _describe -t plugins-list "plugins" plugins "$@" && ret=0 1577 return ret 1578 } 1579 1580 __docker_complete_plugins() { 1581 [[ $PREFIX = -* ]] && return 1 1582 __docker_plugins none "$@" 1583 } 1584 1585 __docker_complete_enabled_plugins() { 1586 [[ $PREFIX = -* ]] && return 1 1587 __docker_plugins enabled=true "$@" 1588 } 1589 1590 __docker_complete_disabled_plugins() { 1591 [[ $PREFIX = -* ]] && return 1 1592 __docker_plugins enabled=false "$@" 1593 } 1594 1595 __docker_plugin_commands() { 1596 local -a _docker_plugin_subcommands 1597 _docker_plugin_subcommands=( 1598 "disable:Disable a plugin" 1599 "enable:Enable a plugin" 1600 "inspect:Return low-level information about a plugin" 1601 "install:Install a plugin" 1602 "ls:List plugins" 1603 "push:Push a plugin" 1604 "rm:Remove a plugin" 1605 "set:Change settings for a plugin" 1606 "upgrade:Upgrade an existing plugin" 1607 ) 1608 _describe -t docker-plugin-commands "docker plugin command" _docker_plugin_subcommands 1609 } 1610 1611 __docker_plugin_subcommand() { 1612 local -a _command_args opts_help 1613 local expl help="--help" 1614 integer ret=1 1615 1616 opts_help=("(: -)--help[Print usage]") 1617 1618 case "$words[1]" in 1619 (disable) 1620 _arguments $(__docker_arguments) \ 1621 $opts_help \ 1622 "($help -f --force)"{-f,--force}"[Force the disable of an active plugin]" \ 1623 "($help -)1:plugin:__docker_complete_enabled_plugins" && ret=0 1624 ;; 1625 (enable) 1626 _arguments $(__docker_arguments) \ 1627 $opts_help \ 1628 "($help)--timeout=[HTTP client timeout (in seconds)]:timeout: " \ 1629 "($help -)1:plugin:__docker_complete_disabled_plugins" && ret=0 1630 ;; 1631 (inspect) 1632 _arguments $(__docker_arguments) \ 1633 $opts_help \ 1634 "($help -f --format)"{-f=,--format=}"[Format the output using the given Go template]:template: " \ 1635 "($help -)*:plugin:__docker_complete_plugins" && ret=0 1636 ;; 1637 (install) 1638 _arguments $(__docker_arguments) \ 1639 $opts_help \ 1640 "($help)--alias=[Local name for plugin]:alias: " \ 1641 "($help)--disable[Do not enable the plugin on install]" \ 1642 "($help)--disable-content-trust[Skip image verification (default true)]" \ 1643 "($help)--grant-all-permissions[Grant all permissions necessary to run the plugin]" \ 1644 "($help -)1:plugin:__docker_complete_plugins" \ 1645 "($help -)*:key=value: " && ret=0 1646 ;; 1647 (ls|list) 1648 _arguments $(__docker_arguments) \ 1649 $opts_help \ 1650 "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_plugin_complete_ls_filters" \ 1651 "($help --format)--format=[Format the output using the given Go template]:template: " \ 1652 "($help)--no-trunc[Don't truncate output]" \ 1653 "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0 1654 ;; 1655 (push) 1656 _arguments $(__docker_arguments) \ 1657 $opts_help \ 1658 "($help)--disable-content-trust[Skip image verification (default true)]" \ 1659 "($help -)1:plugin:__docker_complete_plugins" && ret=0 1660 ;; 1661 (rm|remove) 1662 _arguments $(__docker_arguments) \ 1663 $opts_help \ 1664 "($help -f --force)"{-f,--force}"[Force the removal of an active plugin]" \ 1665 "($help -)*:plugin:__docker_complete_plugins" && ret=0 1666 ;; 1667 (set) 1668 _arguments $(__docker_arguments) \ 1669 $opts_help \ 1670 "($help -)1:plugin:__docker_complete_plugins" \ 1671 "($help -)*:key=value: " && ret=0 1672 ;; 1673 (upgrade) 1674 _arguments $(__docker_arguments) \ 1675 $opts_help \ 1676 "($help)--disable-content-trust[Skip image verification (default true)]" \ 1677 "($help)--grant-all-permissions[Grant all permissions necessary to run the plugin]" \ 1678 "($help)--skip-remote-check[Do not check if specified remote plugin matches existing plugin image]" \ 1679 "($help -)1:plugin:__docker_complete_plugins" \ 1680 "($help -):remote: " && ret=0 1681 ;; 1682 (help) 1683 _arguments $(__docker_arguments) ":subcommand:__docker_plugin_commands" && ret=0 1684 ;; 1685 esac 1686 1687 return ret 1688 } 1689 1690 # EO plugin 1691 1692 # BO secret 1693 1694 __docker_secrets() { 1695 [[ $PREFIX = -* ]] && return 1 1696 integer ret=1 1697 local line s 1698 declare -a lines secrets 1699 1700 type=$1; shift 1701 1702 lines=(${(f)${:-"$(_call_program commands docker $docker_options secret ls)"$'\n'}}) 1703 1704 # Parse header line to find columns 1705 local i=1 j=1 k header=${lines[1]} 1706 declare -A begin end 1707 while (( j < ${#header} - 1 )); do 1708 i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) 1709 j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) 1710 k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) 1711 begin[${header[$i,$((j-1))]}]=$i 1712 end[${header[$i,$((j-1))]}]=$k 1713 done 1714 end[${header[$i,$((j-1))]}]=-1 1715 lines=(${lines[2,-1]}) 1716 1717 # ID 1718 if [[ $type = (ids|all) ]]; then 1719 for line in $lines; do 1720 s="${line[${begin[ID]},${end[ID]}]%% ##}" 1721 secrets=($secrets $s) 1722 done 1723 fi 1724 1725 # Names 1726 if [[ $type = (names|all) ]]; then 1727 for line in $lines; do 1728 s="${line[${begin[NAME]},${end[NAME]}]%% ##}" 1729 secrets=($secrets $s) 1730 done 1731 fi 1732 1733 _describe -t secrets-list "secrets" secrets "$@" && ret=0 1734 return ret 1735 } 1736 1737 __docker_complete_secrets() { 1738 [[ $PREFIX = -* ]] && return 1 1739 __docker_secrets all "$@" 1740 } 1741 1742 __docker_secret_commands() { 1743 local -a _docker_secret_subcommands 1744 _docker_secret_subcommands=( 1745 "create:Create a secret using stdin as content" 1746 "inspect:Display detailed information on one or more secrets" 1747 "ls:List secrets" 1748 "rm:Remove one or more secrets" 1749 ) 1750 _describe -t docker-secret-commands "docker secret command" _docker_secret_subcommands 1751 } 1752 1753 __docker_secret_subcommand() { 1754 local -a _command_args opts_help 1755 local expl help="--help" 1756 integer ret=1 1757 1758 opts_help=("(: -)--help[Print usage]") 1759 1760 case "$words[1]" in 1761 (create) 1762 _arguments $(__docker_arguments) -A '-*' \ 1763 $opts_help \ 1764 "($help)*"{-l=,--label=}"[Secret labels]:label: " \ 1765 "($help -):secret: " && ret=0 1766 ;; 1767 (inspect) 1768 _arguments $(__docker_arguments) \ 1769 $opts_help \ 1770 "($help -f --format)"{-f=,--format=}"[Format the output using the given Go template]:template: " \ 1771 "($help -)*:secret:__docker_complete_secrets" && ret=0 1772 ;; 1773 (ls|list) 1774 _arguments $(__docker_arguments) \ 1775 $opts_help \ 1776 "($help)--format=[Format the output using the given go template]:template: " \ 1777 "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0 1778 ;; 1779 (rm|remove) 1780 _arguments $(__docker_arguments) \ 1781 $opts_help \ 1782 "($help -)*:secret:__docker_complete_secrets" && ret=0 1783 ;; 1784 (help) 1785 _arguments $(__docker_arguments) ":subcommand:__docker_secret_commands" && ret=0 1786 ;; 1787 esac 1788 1789 return ret 1790 } 1791 1792 # EO secret 1793 1794 # BO service 1795 1796 __docker_service_complete_ls_filters() { 1797 [[ $PREFIX = -* ]] && return 1 1798 integer ret=1 1799 1800 if compset -P '*='; then 1801 case "${${words[-1]%=*}#*=}" in 1802 (id) 1803 __docker_complete_services_ids && ret=0 1804 ;; 1805 (mode) 1806 opts=('global' 'replicated') 1807 _describe -t mode-opts "mode options" opts && ret=0 1808 ;; 1809 (name) 1810 __docker_complete_services_names && ret=0 1811 ;; 1812 *) 1813 _message 'value' && ret=0 1814 ;; 1815 esac 1816 else 1817 opts=('id' 'label' 'mode' 'name') 1818 _describe -t filter-opts "filter options" opts -qS "=" && ret=0 1819 fi 1820 1821 return ret 1822 } 1823 1824 __docker_service_complete_ps_filters() { 1825 [[ $PREFIX = -* ]] && return 1 1826 integer ret=1 1827 1828 if compset -P '*='; then 1829 case "${${words[-1]%=*}#*=}" in 1830 (desired-state) 1831 state_opts=('accepted' 'running' 'shutdown') 1832 _describe -t state-opts "desired state options" state_opts && ret=0 1833 ;; 1834 *) 1835 _message 'value' && ret=0 1836 ;; 1837 esac 1838 else 1839 opts=('desired-state' 'id' 'label' 'name') 1840 _describe -t filter-opts "filter options" opts -qS "=" && ret=0 1841 fi 1842 1843 return ret 1844 } 1845 1846 __docker_service_complete_placement_pref() { 1847 [[ $PREFIX = -* ]] && return 1 1848 integer ret=1 1849 1850 if compset -P '*='; then 1851 case "${${words[-1]%=*}#*=}" in 1852 (spread) 1853 opts=('engine.labels' 'node.labels') 1854 _describe -t spread-opts "spread options" opts -qS "." && ret=0 1855 ;; 1856 *) 1857 _message 'value' && ret=0 1858 ;; 1859 esac 1860 else 1861 opts=('spread') 1862 _describe -t pref-opts "placement pref options" opts -qS "=" && ret=0 1863 fi 1864 1865 return ret 1866 } 1867 1868 __docker_services() { 1869 [[ $PREFIX = -* ]] && return 1 1870 integer ret=1 1871 local line s 1872 declare -a lines services 1873 1874 type=$1; shift 1875 1876 lines=(${(f)${:-"$(_call_program commands docker $docker_options service ls)"$'\n'}}) 1877 1878 # Parse header line to find columns 1879 local i=1 j=1 k header=${lines[1]} 1880 declare -A begin end 1881 while (( j < ${#header} - 1 )); do 1882 i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) 1883 j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) 1884 k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) 1885 begin[${header[$i,$((j-1))]}]=$i 1886 end[${header[$i,$((j-1))]}]=$k 1887 done 1888 end[${header[$i,$((j-1))]}]=-1 1889 lines=(${lines[2,-1]}) 1890 1891 # Service ID 1892 if [[ $type = (ids|all) ]]; then 1893 for line in $lines; do 1894 s="${line[${begin[ID]},${end[ID]}]%% ##}" 1895 s="$s:${(l:7:: :::)${${line[${begin[IMAGE]},${end[IMAGE]}]}%% ##}}" 1896 services=($services $s) 1897 done 1898 fi 1899 1900 # Names 1901 if [[ $type = (names|all) ]]; then 1902 for line in $lines; do 1903 s="${line[${begin[NAME]},${end[NAME]}]%% ##}" 1904 s="$s:${(l:7:: :::)${${line[${begin[IMAGE]},${end[IMAGE]}]}%% ##}}" 1905 services=($services $s) 1906 done 1907 fi 1908 1909 _describe -t services-list "services" services "$@" && ret=0 1910 return ret 1911 } 1912 1913 __docker_complete_services() { 1914 [[ $PREFIX = -* ]] && return 1 1915 __docker_services all "$@" 1916 } 1917 1918 __docker_complete_services_ids() { 1919 [[ $PREFIX = -* ]] && return 1 1920 __docker_services ids "$@" 1921 } 1922 1923 __docker_complete_services_names() { 1924 [[ $PREFIX = -* ]] && return 1 1925 __docker_services names "$@" 1926 } 1927 1928 __docker_service_commands() { 1929 local -a _docker_service_subcommands 1930 _docker_service_subcommands=( 1931 "create:Create a new service" 1932 "inspect:Display detailed information on one or more services" 1933 "logs:Fetch the logs of a service or task" 1934 "ls:List services" 1935 "rm:Remove one or more services" 1936 "rollback:Revert changes to a service's configuration" 1937 "scale:Scale one or multiple replicated services" 1938 "ps:List the tasks of a service" 1939 "update:Update a service" 1940 ) 1941 _describe -t docker-service-commands "docker service command" _docker_service_subcommands 1942 } 1943 1944 __docker_service_subcommand() { 1945 local -a _command_args opts_help opts_create_update 1946 local expl help="--help" 1947 integer ret=1 1948 1949 opts_help=("(: -)--help[Print usage]") 1950 opts_create_update=( 1951 "($help)*--constraint=[Placement constraints]:constraint: " 1952 "($help)--endpoint-mode=[Placement constraints]:mode:(dnsrr vip)" 1953 "($help)*"{-e=,--env=}"[Set environment variables]:env: " 1954 "($help)--health-cmd=[Command to run to check health]:command: " 1955 "($help)--health-interval=[Time between running the check]:time: " 1956 "($help)--health-retries=[Consecutive failures needed to report unhealthy]:retries:(1 2 3 4 5)" 1957 "($help)--health-timeout=[Maximum time to allow one check to run]:time: " 1958 "($help)--hostname=[Service container hostname]:hostname: " \ 1959 "($help)--isolation=[Service container isolation mode]:isolation:(default process hyperv)" \ 1960 "($help)*--label=[Service labels]:label: " 1961 "($help)--limit-cpu=[Limit CPUs]:value: " 1962 "($help)--limit-memory=[Limit Memory]:value: " 1963 "($help)--log-driver=[Logging driver for service]:logging driver:__docker_complete_log_drivers" 1964 "($help)*--log-opt=[Logging driver options]:log driver options:__docker_complete_log_options" 1965 "($help)*--mount=[Attach a filesystem mount to the service]:mount: " 1966 "($help)*--network=[Network attachments]:network: " 1967 "($help)--no-healthcheck[Disable any container-specified HEALTHCHECK]" 1968 "($help)--read-only[Mount the container's root filesystem as read only]" 1969 "($help)--replicas=[Number of tasks]:replicas: " 1970 "($help)--reserve-cpu=[Reserve CPUs]:value: " 1971 "($help)--reserve-memory=[Reserve Memory]:value: " 1972 "($help)--restart-condition=[Restart when condition is met]:mode:(any none on-failure)" 1973 "($help)--restart-delay=[Delay between restart attempts]:delay: " 1974 "($help)--restart-max-attempts=[Maximum number of restarts before giving up]:max-attempts: " 1975 "($help)--restart-window=[Window used to evaluate the restart policy]:duration: " 1976 "($help)--rollback-delay=[Delay between task rollbacks]:duration: " 1977 "($help)--rollback-failure-action=[Action on rollback failure]:action:(continue pause)" 1978 "($help)--rollback-max-failure-ratio=[Failure rate to tolerate during a rollback]:failure rate: " 1979 "($help)--rollback-monitor=[Duration after each task rollback to monitor for failure]:duration: " 1980 "($help)--rollback-parallelism=[Maximum number of tasks rolled back simultaneously]:number: " 1981 "($help)*--secret=[Specify secrets to expose to the service]:secret:__docker_complete_secrets" 1982 "($help)--stop-grace-period=[Time to wait before force killing a container]:grace period: " 1983 "($help)--stop-signal=[Signal to stop the container]:signal:_signals" 1984 "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-TTY]" 1985 "($help)--update-delay=[Delay between updates]:delay: " 1986 "($help)--update-failure-action=[Action on update failure]:mode:(continue pause rollback)" 1987 "($help)--update-max-failure-ratio=[Failure rate to tolerate during an update]:fraction: " 1988 "($help)--update-monitor=[Duration after each task update to monitor for failure]:window: " 1989 "($help)--update-parallelism=[Maximum number of tasks updated simultaneously]:number: " 1990 "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" 1991 "($help)--with-registry-auth[Send registry authentication details to swarm agents]" 1992 "($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories" 1993 ) 1994 1995 case "$words[1]" in 1996 (create) 1997 _arguments $(__docker_arguments) \ 1998 $opts_help \ 1999 $opts_create_update \ 2000 "($help)*--container-label=[Container labels]:label: " \ 2001 "($help)*--dns=[Set custom DNS servers]:DNS: " \ 2002 "($help)*--dns-option=[Set DNS options]:DNS option: " \ 2003 "($help)*--dns-search=[Set custom DNS search domains]:DNS search: " \ 2004 "($help)*--env-file=[Read environment variables from a file]:environment file:_files" \ 2005 "($help)--mode=[Service Mode]:mode:(global replicated)" \ 2006 "($help)--name=[Service name]:name: " \ 2007 "($help)*--placement-pref=[Add a placement preference]:pref:__docker_service_complete_placement_pref" \ 2008 "($help)*"{-p=,--publish=}"[Publish a port as a node port]:port: " \ 2009 "($help -): :__docker_complete_images" \ 2010 "($help -):command: _command_names -e" \ 2011 "($help -)*::arguments: _normal" && ret=0 2012 ;; 2013 (inspect) 2014 _arguments $(__docker_arguments) \ 2015 $opts_help \ 2016 "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ 2017 "($help)--pretty[Print the information in a human friendly format]" \ 2018 "($help -)*:service:__docker_complete_services" && ret=0 2019 ;; 2020 (logs) 2021 _arguments $(__docker_arguments) \ 2022 $opts_help \ 2023 "($help -f --follow)"{-f,--follow}"[Follow log output]" \ 2024 "($help)--no-resolve[Do not map IDs to Names]" \ 2025 "($help)--no-task-ids[Do not include task IDs]" \ 2026 "($help)--no-trunc[Do not truncate output]" \ 2027 "($help)--since=[Show logs since timestamp]:timestamp: " \ 2028 "($help)--tail=[Number of lines to show from the end of the logs]:lines:(1 10 20 50 all)" \ 2029 "($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \ 2030 "($help -)1:service:__docker_complete_services" && ret=0 2031 ;; 2032 (ls|list) 2033 _arguments $(__docker_arguments) \ 2034 $opts_help \ 2035 "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_service_complete_ls_filters" \ 2036 "($help)--format=[Pretty-print services using a Go template]:template: " \ 2037 "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0 2038 ;; 2039 (rm|remove) 2040 _arguments $(__docker_arguments) \ 2041 $opts_help \ 2042 "($help -)*:service:__docker_complete_services" && ret=0 2043 ;; 2044 (rollback) 2045 _arguments $(__docker_arguments) \ 2046 $opts_help \ 2047 "($help -d --detach)"{-d=false,--detach=false}"[Disable detached mode]" \ 2048 "($help -q --quiet)"{-q,--quiet}"[Suppress progress output]" \ 2049 "($help -)*:service:__docker_complete_services" && ret=0 2050 ;; 2051 (scale) 2052 _arguments $(__docker_arguments) \ 2053 $opts_help \ 2054 "($help -d --detach)"{-d=false,--detach=false}"[Disable detached mode]" \ 2055 "($help -)*:service:->values" && ret=0 2056 case $state in 2057 (values) 2058 if compset -P '*='; then 2059 _message 'replicas' && ret=0 2060 else 2061 __docker_complete_services -qS "=" 2062 fi 2063 ;; 2064 esac 2065 ;; 2066 (ps) 2067 _arguments $(__docker_arguments) \ 2068 $opts_help \ 2069 "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_service_complete_ps_filters" \ 2070 "($help)--format=[Format the output using the given go template]:template: " \ 2071 "($help)--no-resolve[Do not map IDs to Names]" \ 2072 "($help)--no-trunc[Do not truncate output]" \ 2073 "($help -q --quiet)"{-q,--quiet}"[Only display task IDs]" \ 2074 "($help -)*:service:__docker_complete_services" && ret=0 2075 ;; 2076 (update) 2077 _arguments $(__docker_arguments) \ 2078 $opts_help \ 2079 $opts_create_update \ 2080 "($help)--arg=[Service command args]:arguments: _normal" \ 2081 "($help)*--container-label-add=[Add or update container labels]:label: " \ 2082 "($help)*--container-label-rm=[Remove a container label by its key]:label: " \ 2083 "($help)*--dns-add=[Add or update custom DNS servers]:DNS: " \ 2084 "($help)*--dns-rm=[Remove custom DNS servers]:DNS: " \ 2085 "($help)*--dns-option-add=[Add or update DNS options]:DNS option: " \ 2086 "($help)*--dns-option-rm=[Remove DNS options]:DNS option: " \ 2087 "($help)*--dns-search-add=[Add or update custom DNS search domains]:DNS search: " \ 2088 "($help)*--dns-search-rm=[Remove DNS search domains]:DNS search: " \ 2089 "($help)--force[Force update]" \ 2090 "($help)*--group-add=[Add additional supplementary user groups to the container]:group:_groups" \ 2091 "($help)*--group-rm=[Remove previously added supplementary user groups from the container]:group:_groups" \ 2092 "($help)--image=[Service image tag]:image:__docker_complete_repositories" \ 2093 "($help)*--placement-pref-add=[Add a placement preference]:pref:__docker_service_complete_placement_pref" \ 2094 "($help)*--placement-pref-rm=[Remove a placement preference]:pref:__docker_service_complete_placement_pref" \ 2095 "($help)*--publish-add=[Add or update a port]:port: " \ 2096 "($help)*--publish-rm=[Remove a port(target-port mandatory)]:port: " \ 2097 "($help)--rollback[Rollback to previous specification]" \ 2098 "($help -)1:service:__docker_complete_services" && ret=0 2099 ;; 2100 (help) 2101 _arguments $(__docker_arguments) ":subcommand:__docker_service_commands" && ret=0 2102 ;; 2103 esac 2104 2105 return ret 2106 } 2107 2108 # EO service 2109 2110 # BO stack 2111 2112 __docker_stack_complete_ps_filters() { 2113 [[ $PREFIX = -* ]] && return 1 2114 integer ret=1 2115 2116 if compset -P '*='; then 2117 case "${${words[-1]%=*}#*=}" in 2118 (desired-state) 2119 state_opts=('accepted' 'running' 'shutdown') 2120 _describe -t state-opts "desired state options" state_opts && ret=0 2121 ;; 2122 *) 2123 _message 'value' && ret=0 2124 ;; 2125 esac 2126 else 2127 opts=('desired-state' 'id' 'name') 2128 _describe -t filter-opts "filter options" opts -qS "=" && ret=0 2129 fi 2130 2131 return ret 2132 } 2133 2134 __docker_stack_complete_services_filters() { 2135 [[ $PREFIX = -* ]] && return 1 2136 integer ret=1 2137 2138 if compset -P '*='; then 2139 case "${${words[-1]%=*}#*=}" in 2140 *) 2141 _message 'value' && ret=0 2142 ;; 2143 esac 2144 else 2145 opts=('id' 'label' 'name') 2146 _describe -t filter-opts "filter options" opts -qS "=" && ret=0 2147 fi 2148 2149 return ret 2150 } 2151 2152 __docker_stacks() { 2153 [[ $PREFIX = -* ]] && return 1 2154 integer ret=1 2155 local line s 2156 declare -a lines stacks 2157 2158 lines=(${(f)${:-"$(_call_program commands docker $docker_options stack ls)"$'\n'}}) 2159 2160 # Parse header line to find columns 2161 local i=1 j=1 k header=${lines[1]} 2162 declare -A begin end 2163 while (( j < ${#header} - 1 )); do 2164 i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) 2165 j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) 2166 k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) 2167 begin[${header[$i,$((j-1))]}]=$i 2168 end[${header[$i,$((j-1))]}]=$k 2169 done 2170 end[${header[$i,$((j-1))]}]=-1 2171 lines=(${lines[2,-1]}) 2172 2173 # Service NAME 2174 for line in $lines; do 2175 s="${line[${begin[NAME]},${end[NAME]}]%% ##}" 2176 stacks=($stacks $s) 2177 done 2178 2179 _describe -t stacks-list "stacks" stacks "$@" && ret=0 2180 return ret 2181 } 2182 2183 __docker_complete_stacks() { 2184 [[ $PREFIX = -* ]] && return 1 2185 __docker_stacks "$@" 2186 } 2187 2188 __docker_stack_commands() { 2189 local -a _docker_stack_subcommands 2190 _docker_stack_subcommands=( 2191 "deploy:Deploy a new stack or update an existing stack" 2192 "ls:List stacks" 2193 "ps:List the tasks in the stack" 2194 "rm:Remove the stack" 2195 "services:List the services in the stack" 2196 ) 2197 _describe -t docker-stack-commands "docker stack command" _docker_stack_subcommands 2198 } 2199 2200 __docker_stack_subcommand() { 2201 local -a _command_args opts_help 2202 local expl help="--help" 2203 integer ret=1 2204 2205 opts_help=("(: -)--help[Print usage]") 2206 2207 case "$words[1]" in 2208 (deploy|up) 2209 _arguments $(__docker_arguments) \ 2210 $opts_help \ 2211 "($help)--bundle-file=[Path to a Distributed Application Bundle file]:dab:_files -g \"*.dab\"" \ 2212 "($help -c --compose-file)"{-c=,--compose-file=}"[Path to a Compose file]:compose file:_files -g \"*.(yml|yaml)\"" \ 2213 "($help)--with-registry-auth[Send registry authentication details to Swarm agents]" \ 2214 "($help -):stack:__docker_complete_stacks" && ret=0 2215 ;; 2216 (ls|list) 2217 _arguments $(__docker_arguments) \ 2218 $opts_help && ret=0 2219 ;; 2220 (ps) 2221 _arguments $(__docker_arguments) \ 2222 $opts_help \ 2223 "($help -a --all)"{-a,--all}"[Display all tasks]" \ 2224 "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_stack_complete_ps_filters" \ 2225 "($help)--format=[Format the output using the given go template]:template: " \ 2226 "($help)--no-resolve[Do not map IDs to Names]" \ 2227 "($help)--no-trunc[Do not truncate output]" \ 2228 "($help -q --quiet)"{-q,--quiet}"[Only display task IDs]" \ 2229 "($help -):stack:__docker_complete_stacks" && ret=0 2230 ;; 2231 (rm|remove|down) 2232 _arguments $(__docker_arguments) \ 2233 $opts_help \ 2234 "($help -):stack:__docker_complete_stacks" && ret=0 2235 ;; 2236 (services) 2237 _arguments $(__docker_arguments) \ 2238 $opts_help \ 2239 "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:__docker_stack_complete_services_filters" \ 2240 "($help)--format=[Pretty-print services using a Go template]:template: " \ 2241 "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" \ 2242 "($help -):stack:__docker_complete_stacks" && ret=0 2243 ;; 2244 (help) 2245 _arguments $(__docker_arguments) ":subcommand:__docker_stack_commands" && ret=0 2246 ;; 2247 esac 2248 2249 return ret 2250 } 2251 2252 # EO stack 2253 2254 # BO swarm 2255 2256 __docker_swarm_commands() { 2257 local -a _docker_swarm_subcommands 2258 _docker_swarm_subcommands=( 2259 "init:Initialize a swarm" 2260 "join:Join a swarm as a node and/or manager" 2261 "join-token:Manage join tokens" 2262 "leave:Leave a swarm" 2263 "unlock:Unlock swarm" 2264 "unlock-key:Manage the unlock key" 2265 "update:Update the swarm" 2266 ) 2267 _describe -t docker-swarm-commands "docker swarm command" _docker_swarm_subcommands 2268 } 2269 2270 __docker_swarm_subcommand() { 2271 local -a _command_args opts_help 2272 local expl help="--help" 2273 integer ret=1 2274 2275 opts_help=("(: -)--help[Print usage]") 2276 2277 case "$words[1]" in 2278 (init) 2279 _arguments $(__docker_arguments) \ 2280 $opts_help \ 2281 "($help)--advertise-addr=[Advertised address]:ip\:port: " \ 2282 "($help)--data-path-addr=[Data path IP or interface]:ip " \ 2283 "($help)--autolock[Enable manager autolocking]" \ 2284 "($help)--availability=[Availability of the node]:availability:(active drain pause)" \ 2285 "($help)--cert-expiry=[Validity period for node certificates]:duration: " \ 2286 "($help)--dispatcher-heartbeat=[Dispatcher heartbeat period]:duration: " \ 2287 "($help)*--external-ca=[Specifications of one or more certificate signing endpoints]:endpoint: " \ 2288 "($help)--force-new-cluster[Force create a new cluster from current state]" \ 2289 "($help)--listen-addr=[Listen address]:ip\:port: " \ 2290 "($help)--max-snapshots[Number of additional Raft snapshots to retain]" \ 2291 "($help)--snapshot-interval[Number of log entries between Raft snapshots]" \ 2292 "($help)--task-history-limit=[Task history retention limit]:limit: " && ret=0 2293 ;; 2294 (join) 2295 _arguments $(__docker_arguments) -A '-*' \ 2296 $opts_help \ 2297 "($help)--advertise-addr=[Advertised address]:ip\:port: " \ 2298 "($help)--data-path-addr=[Data path IP or interface]:ip " \ 2299 "($help)--availability=[Availability of the node]:availability:(active drain pause)" \ 2300 "($help)--listen-addr=[Listen address]:ip\:port: " \ 2301 "($help)--token=[Token for entry into the swarm]:secret: " \ 2302 "($help -):host\:port: " && ret=0 2303 ;; 2304 (join-token) 2305 _arguments $(__docker_arguments) \ 2306 $opts_help \ 2307 "($help -q --quiet)"{-q,--quiet}"[Only display token]" \ 2308 "($help)--rotate[Rotate join token]" \ 2309 "($help -):role:(manager worker)" && ret=0 2310 ;; 2311 (leave) 2312 _arguments $(__docker_arguments) \ 2313 $opts_help \ 2314 "($help -f --force)"{-f,--force}"[Force this node to leave the swarm, ignoring warnings]" && ret=0 2315 ;; 2316 (unlock) 2317 _arguments $(__docker_arguments) \ 2318 $opts_help && ret=0 2319 ;; 2320 (unlock-key) 2321 _arguments $(__docker_arguments) \ 2322 $opts_help \ 2323 "($help -q --quiet)"{-q,--quiet}"[Only display token]" \ 2324 "($help)--rotate[Rotate unlock token]" && ret=0 2325 ;; 2326 (update) 2327 _arguments $(__docker_arguments) \ 2328 $opts_help \ 2329 "($help)--autolock[Enable manager autolocking]" \ 2330 "($help)--cert-expiry=[Validity period for node certificates]:duration: " \ 2331 "($help)--dispatcher-heartbeat=[Dispatcher heartbeat period]:duration: " \ 2332 "($help)*--external-ca=[Specifications of one or more certificate signing endpoints]:endpoint: " \ 2333 "($help)--max-snapshots[Number of additional Raft snapshots to retain]" \ 2334 "($help)--snapshot-interval[Number of log entries between Raft snapshots]" \ 2335 "($help)--task-history-limit=[Task history retention limit]:limit: " && ret=0 2336 ;; 2337 (help) 2338 _arguments $(__docker_arguments) ":subcommand:__docker_network_commands" && ret=0 2339 ;; 2340 esac 2341 2342 return ret 2343 } 2344 2345 # EO swarm 2346 2347 # BO system 2348 2349 __docker_system_commands() { 2350 local -a _docker_system_subcommands 2351 _docker_system_subcommands=( 2352 "df:Show docker filesystem usage" 2353 "events:Get real time events from the server" 2354 "info:Display system-wide information" 2355 "prune:Remove unused data" 2356 ) 2357 _describe -t docker-system-commands "docker system command" _docker_system_subcommands 2358 } 2359 2360 __docker_system_subcommand() { 2361 local -a _command_args opts_help 2362 local expl help="--help" 2363 integer ret=1 2364 2365 opts_help=("(: -)--help[Print usage]") 2366 2367 case "$words[1]" in 2368 (df) 2369 _arguments $(__docker_arguments) \ 2370 $opts_help \ 2371 "($help -v --verbose)"{-v,--verbose}"[Show detailed information on space usage]" && ret=0 2372 ;; 2373 (events) 2374 _arguments $(__docker_arguments) \ 2375 $opts_help \ 2376 "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_events_filter" \ 2377 "($help)--since=[Events created since this timestamp]:timestamp: " \ 2378 "($help)--until=[Events created until this timestamp]:timestamp: " \ 2379 "($help)--format=[Format the output using the given go template]:template: " && ret=0 2380 ;; 2381 (info) 2382 _arguments $(__docker_arguments) \ 2383 $opts_help \ 2384 "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0 2385 ;; 2386 (prune) 2387 _arguments $(__docker_arguments) \ 2388 $opts_help \ 2389 "($help -a --all)"{-a,--all}"[Remove all unused data, not just dangling ones]" \ 2390 "($help)*--filter=[Filter values]:filter:__docker_complete_prune_filters" \ 2391 "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" \ 2392 "($help)--volumes=[Remove all unused volumes]" && ret=0 2393 ;; 2394 (help) 2395 _arguments $(__docker_arguments) ":subcommand:__docker_volume_commands" && ret=0 2396 ;; 2397 esac 2398 2399 return ret 2400 } 2401 2402 # EO system 2403 2404 # BO volume 2405 2406 __docker_volume_complete_ls_filters() { 2407 [[ $PREFIX = -* ]] && return 1 2408 integer ret=1 2409 2410 if compset -P '*='; then 2411 case "${${words[-1]%=*}#*=}" in 2412 (dangling) 2413 dangling_opts=('true' 'false') 2414 _describe -t dangling-filter-opts "Dangling Filter Options" dangling_opts && ret=0 2415 ;; 2416 (driver) 2417 __docker_complete_info_plugins Volume && ret=0 2418 ;; 2419 (name) 2420 __docker_complete_volumes && ret=0 2421 ;; 2422 *) 2423 _message 'value' && ret=0 2424 ;; 2425 esac 2426 else 2427 opts=('dangling' 'driver' 'label' 'name') 2428 _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0 2429 fi 2430 2431 return ret 2432 } 2433 2434 __docker_complete_volumes() { 2435 [[ $PREFIX = -* ]] && return 1 2436 integer ret=1 2437 declare -a lines volumes 2438 2439 lines=(${(f)${:-"$(_call_program commands docker $docker_options volume ls)"$'\n'}}) 2440 2441 # Parse header line to find columns 2442 local i=1 j=1 k header=${lines[1]} 2443 declare -A begin end 2444 while (( j < ${#header} - 1 )); do 2445 i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 )) 2446 j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 )) 2447 k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 )) 2448 begin[${header[$i,$((j-1))]}]=$i 2449 end[${header[$i,$((j-1))]}]=$k 2450 done 2451 end[${header[$i,$((j-1))]}]=-1 2452 lines=(${lines[2,-1]}) 2453 2454 # Names 2455 local line s 2456 for line in $lines; do 2457 s="${line[${begin[VOLUME NAME]},${end[VOLUME NAME]}]%% ##}" 2458 s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}" 2459 volumes=($volumes $s) 2460 done 2461 2462 _describe -t volumes-list "volumes" volumes && ret=0 2463 return ret 2464 } 2465 2466 __docker_volume_commands() { 2467 local -a _docker_volume_subcommands 2468 _docker_volume_subcommands=( 2469 "create:Create a volume" 2470 "inspect:Display detailed information on one or more volumes" 2471 "ls:List volumes" 2472 "prune:Remove all unused volumes" 2473 "rm:Remove one or more volumes" 2474 ) 2475 _describe -t docker-volume-commands "docker volume command" _docker_volume_subcommands 2476 } 2477 2478 __docker_volume_subcommand() { 2479 local -a _command_args opts_help 2480 local expl help="--help" 2481 integer ret=1 2482 2483 opts_help=("(: -)--help[Print usage]") 2484 2485 case "$words[1]" in 2486 (create) 2487 _arguments $(__docker_arguments) -A '-*' \ 2488 $opts_help \ 2489 "($help -d --driver)"{-d=,--driver=}"[Volume driver name]:Driver name:(local)" \ 2490 "($help)*--label=[Set metadata for a volume]:label=value: " \ 2491 "($help)*"{-o=,--opt=}"[Driver specific options]:Driver option: " \ 2492 "($help -)1:Volume name: " && ret=0 2493 ;; 2494 (inspect) 2495 _arguments $(__docker_arguments) \ 2496 $opts_help \ 2497 "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ 2498 "($help -)1:volume:__docker_complete_volumes" && ret=0 2499 ;; 2500 (ls) 2501 _arguments $(__docker_arguments) \ 2502 $opts_help \ 2503 "($help)*"{-f=,--filter=}"[Provide filter values]:filter:__docker_volume_complete_ls_filters" \ 2504 "($help)--format=[Pretty-print volumes using a Go template]:template: " \ 2505 "($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0 2506 ;; 2507 (prune) 2508 _arguments $(__docker_arguments) \ 2509 $opts_help \ 2510 "($help -f --force)"{-f,--force}"[Do not prompt for confirmation]" && ret=0 2511 ;; 2512 (rm) 2513 _arguments $(__docker_arguments) \ 2514 $opts_help \ 2515 "($help -f --force)"{-f,--force}"[Force the removal of one or more volumes]" \ 2516 "($help -):volume:__docker_complete_volumes" && ret=0 2517 ;; 2518 (help) 2519 _arguments $(__docker_arguments) ":subcommand:__docker_volume_commands" && ret=0 2520 ;; 2521 esac 2522 2523 return ret 2524 } 2525 2526 # EO volume 2527 2528 __docker_caching_policy() { 2529 oldp=( "$1"(Nmh+1) ) # 1 hour 2530 (( $#oldp )) 2531 } 2532 2533 __docker_commands() { 2534 local cache_policy 2535 integer force_invalidation=0 2536 2537 zstyle -s ":completion:${curcontext}:" cache-policy cache_policy 2538 if [[ -z "$cache_policy" ]]; then 2539 zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy 2540 fi 2541 2542 if ( (( ! ${+_docker_hide_legacy_commands} )) || _cache_invalid docker_hide_legacy_commands ) \ 2543 && ! _retrieve_cache docker_hide_legacy_commands; 2544 then 2545 _docker_hide_legacy_commands="${DOCKER_HIDE_LEGACY_COMMANDS}" 2546 _store_cache docker_hide_legacy_commands _docker_hide_legacy_commands 2547 fi 2548 2549 if [[ "${_docker_hide_legacy_commands}" != "${DOCKER_HIDE_LEGACY_COMMANDS}" ]]; then 2550 force_invalidation=1 2551 _docker_hide_legacy_commands="${DOCKER_HIDE_LEGACY_COMMANDS}" 2552 _store_cache docker_hide_legacy_commands _docker_hide_legacy_commands 2553 fi 2554 2555 if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands ) \ 2556 && ! _retrieve_cache docker_subcommands || [[ ${force_invalidation} -eq 1 ]]; 2557 then 2558 local -a lines 2559 lines=(${(f)"$(_call_program commands docker 2>&1)"}) 2560 _docker_subcommands=(${${${(M)${lines[$((${lines[(i)*Commands:]} + 1)),-1]}:# *}## #}/ ##/:}) 2561 _docker_subcommands=($_docker_subcommands 'daemon:Enable daemon mode' 'help:Show help for a command') 2562 (( $#_docker_subcommands > 2 )) && _store_cache docker_subcommands _docker_subcommands 2563 fi 2564 _describe -t docker-commands "docker command" _docker_subcommands 2565 } 2566 2567 __docker_subcommand() { 2568 local -a _command_args opts_help 2569 local expl help="--help" 2570 integer ret=1 2571 2572 opts_help=("(: -)--help[Print usage]") 2573 2574 case "$words[1]" in 2575 (attach|commit|cp|create|diff|exec|export|kill|logs|pause|unpause|port|rename|restart|rm|run|start|stats|stop|top|update|wait) 2576 __docker_container_subcommand && ret=0 2577 ;; 2578 (build|history|import|load|pull|push|save|tag) 2579 __docker_image_subcommand && ret=0 2580 ;; 2581 (checkpoint) 2582 local curcontext="$curcontext" state 2583 _arguments $(__docker_arguments) \ 2584 $opts_help \ 2585 "($help -): :->command" \ 2586 "($help -)*:: :->option-or-argument" && ret=0 2587 2588 case $state in 2589 (command) 2590 __docker_checkpoint_commands && ret=0 2591 ;; 2592 (option-or-argument) 2593 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 2594 __docker_checkpoint_subcommand && ret=0 2595 ;; 2596 esac 2597 ;; 2598 (container) 2599 local curcontext="$curcontext" state 2600 _arguments $(__docker_arguments) \ 2601 $opts_help \ 2602 "($help -): :->command" \ 2603 "($help -)*:: :->option-or-argument" && ret=0 2604 2605 case $state in 2606 (command) 2607 __docker_container_commands && ret=0 2608 ;; 2609 (option-or-argument) 2610 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 2611 __docker_container_subcommand && ret=0 2612 ;; 2613 esac 2614 ;; 2615 (daemon) 2616 _arguments $(__docker_arguments) \ 2617 $opts_help \ 2618 "($help)*--add-runtime=[Register an additional OCI compatible runtime]:runtime:__docker_complete_runtimes" \ 2619 "($help)*--allow-nondistributable-artifacts=[Push nondistributable artifacts to specified registries]:registry: " \ 2620 "($help)--api-cors-header=[CORS headers in the Engine API]:CORS headers: " \ 2621 "($help)*--authorization-plugin=[Authorization plugins to load]" \ 2622 "($help -b --bridge)"{-b=,--bridge=}"[Attach containers to a network bridge]:bridge:_net_interfaces" \ 2623 "($help)--bip=[Network bridge IP]:IP address: " \ 2624 "($help)--cgroup-parent=[Parent cgroup for all containers]:cgroup: " \ 2625 "($help)--cluster-advertise=[Address or interface name to advertise]:Instance to advertise (host\:port): " \ 2626 "($help)--cluster-store=[URL of the distributed storage backend]:Cluster Store:->cluster-store" \ 2627 "($help)*--cluster-store-opt=[Cluster store options]:Cluster options:->cluster-store-options" \ 2628 "($help)--config-file=[Path to daemon configuration file]:Config File:_files" \ 2629 "($help)--containerd=[Path to containerd socket]:socket:_files -g \"*.sock\"" \ 2630 "($help)--data-root=[Root directory of persisted Docker data]:path:_directories" \ 2631 "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \ 2632 "($help)--default-gateway[Container default gateway IPv4 address]:IPv4 address: " \ 2633 "($help)--default-gateway-v6[Container default gateway IPv6 address]:IPv6 address: " \ 2634 "($help)--default-shm-size=[Default shm size for containers]:size:" \ 2635 "($help)*--default-ulimit=[Default ulimits for containers]:ulimit: " \ 2636 "($help)*--dns=[DNS server to use]:DNS: " \ 2637 "($help)*--dns-opt=[DNS options to use]:DNS option: " \ 2638 "($help)*--dns-search=[DNS search domains to use]:DNS search: " \ 2639 "($help)*--exec-opt=[Runtime execution options]:runtime execution options: " \ 2640 "($help)--exec-root=[Root directory for execution state files]:path:_directories" \ 2641 "($help)--experimental[Enable experimental features]" \ 2642 "($help)--fixed-cidr=[IPv4 subnet for fixed IPs]:IPv4 subnet: " \ 2643 "($help)--fixed-cidr-v6=[IPv6 subnet for fixed IPs]:IPv6 subnet: " \ 2644 "($help -G --group)"{-G=,--group=}"[Group for the unix socket]:group:_groups" \ 2645 "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \ 2646 "($help)--icc[Enable inter-container communication]" \ 2647 "($help)--init[Run an init inside containers to forward signals and reap processes]" \ 2648 "($help)--init-path=[Path to the docker-init binary]:docker-init binary:_files" \ 2649 "($help)*--insecure-registry=[Enable insecure registry communication]:registry: " \ 2650 "($help)--ip=[Default IP when binding container ports]" \ 2651 "($help)--ip-forward[Enable net.ipv4.ip_forward]" \ 2652 "($help)--ip-masq[Enable IP masquerading]" \ 2653 "($help)--iptables[Enable addition of iptables rules]" \ 2654 "($help)--ipv6[Enable IPv6 networking]" \ 2655 "($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \ 2656 "($help)*--label=[Key=value labels]:label: " \ 2657 "($help)--live-restore[Enable live restore of docker when containers are still running]" \ 2658 "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_complete_log_drivers" \ 2659 "($help)*--log-opt=[Default log driver options for containers]:log driver options:__docker_complete_log_options" \ 2660 "($help)--max-concurrent-downloads[Set the max concurrent downloads for each pull]" \ 2661 "($help)--max-concurrent-uploads[Set the max concurrent uploads for each push]" \ 2662 "($help)--mtu=[Network MTU]:mtu:(0 576 1420 1500 9000)" \ 2663 "($help)--oom-score-adjust=[Set the oom_score_adj for the daemon]:oom-score:(-500)" \ 2664 "($help -p --pidfile)"{-p=,--pidfile=}"[Path to use for daemon PID file]:PID file:_files" \ 2665 "($help)--raw-logs[Full timestamps without ANSI coloring]" \ 2666 "($help)*--registry-mirror=[Preferred Docker registry mirror]:registry mirror: " \ 2667 "($help)--seccomp-profile=[Path to seccomp profile]:path:_files -g \"*.json\"" \ 2668 "($help -s --storage-driver)"{-s=,--storage-driver=}"[Storage driver to use]:driver:(aufs btrfs devicemapper overlay overlay2 vfs zfs)" \ 2669 "($help)--selinux-enabled[Enable selinux support]" \ 2670 "($help)--shutdown-timeout=[Set the shutdown timeout value in seconds]:time: " \ 2671 "($help)*--storage-opt=[Storage driver options]:storage driver options: " \ 2672 "($help)--tls[Use TLS]" \ 2673 "($help)--tlscacert=[Trust certs signed only by this CA]:PEM file:_files -g \"*.(pem|crt)\"" \ 2674 "($help)--tlscert=[Path to TLS certificate file]:PEM file:_files -g \"*.(pem|crt)\"" \ 2675 "($help)--tlskey=[Path to TLS key file]:Key file:_files -g \"*.(pem|key)\"" \ 2676 "($help)--tlsverify[Use TLS and verify the remote]" \ 2677 "($help)--userns-remap=[User/Group setting for user namespaces]:user\:group:->users-groups" \ 2678 "($help)--userland-proxy[Use userland proxy for loopback traffic]" \ 2679 "($help)--userland-proxy-path=[Path to the userland proxy binary]:binary:_files" && ret=0 2680 2681 case $state in 2682 (cluster-store) 2683 if compset -P '*://'; then 2684 _message 'host:port' && ret=0 2685 else 2686 store=('consul' 'etcd' 'zk') 2687 _describe -t cluster-store "Cluster Store" store -qS "://" && ret=0 2688 fi 2689 ;; 2690 (cluster-store-options) 2691 if compset -P '*='; then 2692 _files && ret=0 2693 else 2694 opts=('discovery.heartbeat' 'discovery.ttl' 'kv.cacertfile' 'kv.certfile' 'kv.keyfile' 'kv.path') 2695 _describe -t cluster-store-opts "Cluster Store Options" opts -qS "=" && ret=0 2696 fi 2697 ;; 2698 (users-groups) 2699 if compset -P '*:'; then 2700 _groups && ret=0 2701 else 2702 _describe -t userns-default "default Docker user management" '(default)' && ret=0 2703 _users && ret=0 2704 fi 2705 ;; 2706 esac 2707 ;; 2708 (events|info) 2709 __docker_system_subcommand && ret=0 2710 ;; 2711 (image) 2712 local curcontext="$curcontext" state 2713 _arguments $(__docker_arguments) \ 2714 $opts_help \ 2715 "($help -): :->command" \ 2716 "($help -)*:: :->option-or-argument" && ret=0 2717 2718 case $state in 2719 (command) 2720 __docker_image_commands && ret=0 2721 ;; 2722 (option-or-argument) 2723 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 2724 __docker_image_subcommand && ret=0 2725 ;; 2726 esac 2727 ;; 2728 (images) 2729 words[1]='ls' 2730 __docker_image_subcommand && ret=0 2731 ;; 2732 (inspect) 2733 local state 2734 _arguments $(__docker_arguments) \ 2735 $opts_help \ 2736 "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \ 2737 "($help -s --size)"{-s,--size}"[Display total file sizes if the type is container]" \ 2738 "($help)--type=[Return JSON for specified type]:type:(container image network node plugin service volume)" \ 2739 "($help -)*: :->values" && ret=0 2740 2741 case $state in 2742 (values) 2743 if [[ ${words[(r)--type=container]} == --type=container ]]; then 2744 __docker_complete_containers && ret=0 2745 elif [[ ${words[(r)--type=image]} == --type=image ]]; then 2746 __docker_complete_images && ret=0 2747 elif [[ ${words[(r)--type=network]} == --type=network ]]; then 2748 __docker_complete_networks && ret=0 2749 elif [[ ${words[(r)--type=node]} == --type=node ]]; then 2750 __docker_complete_nodes && ret=0 2751 elif [[ ${words[(r)--type=plugin]} == --type=plugin ]]; then 2752 __docker_complete_plugins && ret=0 2753 elif [[ ${words[(r)--type=service]} == --type=secrets ]]; then 2754 __docker_complete_secrets && ret=0 2755 elif [[ ${words[(r)--type=service]} == --type=service ]]; then 2756 __docker_complete_services && ret=0 2757 elif [[ ${words[(r)--type=volume]} == --type=volume ]]; then 2758 __docker_complete_volumes && ret=0 2759 else 2760 __docker_complete_containers 2761 __docker_complete_images 2762 __docker_complete_networks 2763 __docker_complete_nodes 2764 __docker_complete_plugins 2765 __docker_complete_secrets 2766 __docker_complete_services 2767 __docker_complete_volumes && ret=0 2768 fi 2769 ;; 2770 esac 2771 ;; 2772 (login) 2773 _arguments $(__docker_arguments) -A '-*' \ 2774 $opts_help \ 2775 "($help -p --password)"{-p=,--password=}"[Password]:password: " \ 2776 "($help)--password-stdin[Read password from stdin]" \ 2777 "($help -u --user)"{-u=,--user=}"[Username]:username: " \ 2778 "($help -)1:server: " && ret=0 2779 ;; 2780 (logout) 2781 _arguments $(__docker_arguments) -A '-*' \ 2782 $opts_help \ 2783 "($help -)1:server: " && ret=0 2784 ;; 2785 (network) 2786 local curcontext="$curcontext" state 2787 _arguments $(__docker_arguments) \ 2788 $opts_help \ 2789 "($help -): :->command" \ 2790 "($help -)*:: :->option-or-argument" && ret=0 2791 2792 case $state in 2793 (command) 2794 __docker_network_commands && ret=0 2795 ;; 2796 (option-or-argument) 2797 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 2798 __docker_network_subcommand && ret=0 2799 ;; 2800 esac 2801 ;; 2802 (node) 2803 local curcontext="$curcontext" state 2804 _arguments $(__docker_arguments) \ 2805 $opts_help \ 2806 "($help -): :->command" \ 2807 "($help -)*:: :->option-or-argument" && ret=0 2808 2809 case $state in 2810 (command) 2811 __docker_node_commands && ret=0 2812 ;; 2813 (option-or-argument) 2814 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 2815 __docker_node_subcommand && ret=0 2816 ;; 2817 esac 2818 ;; 2819 (plugin) 2820 local curcontext="$curcontext" state 2821 _arguments $(__docker_arguments) \ 2822 $opts_help \ 2823 "($help -): :->command" \ 2824 "($help -)*:: :->option-or-argument" && ret=0 2825 2826 case $state in 2827 (command) 2828 __docker_plugin_commands && ret=0 2829 ;; 2830 (option-or-argument) 2831 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 2832 __docker_plugin_subcommand && ret=0 2833 ;; 2834 esac 2835 ;; 2836 (ps) 2837 words[1]='ls' 2838 __docker_container_subcommand && ret=0 2839 ;; 2840 (rmi) 2841 words[1]='rm' 2842 __docker_image_subcommand && ret=0 2843 ;; 2844 (search) 2845 _arguments $(__docker_arguments) -A '-*' \ 2846 $opts_help \ 2847 "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_search_filters" \ 2848 "($help)--limit=[Maximum returned search results]:limit:(1 5 10 25 50)" \ 2849 "($help)--no-trunc[Do not truncate output]" \ 2850 "($help -):term: " && ret=0 2851 ;; 2852 (secret) 2853 local curcontext="$curcontext" state 2854 _arguments $(__docker_arguments) \ 2855 $opts_help \ 2856 "($help -): :->command" \ 2857 "($help -)*:: :->option-or-argument" && ret=0 2858 2859 case $state in 2860 (command) 2861 __docker_secret_commands && ret=0 2862 ;; 2863 (option-or-argument) 2864 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 2865 __docker_secret_subcommand && ret=0 2866 ;; 2867 esac 2868 ;; 2869 (service) 2870 local curcontext="$curcontext" state 2871 _arguments $(__docker_arguments) \ 2872 $opts_help \ 2873 "($help -): :->command" \ 2874 "($help -)*:: :->option-or-argument" && ret=0 2875 2876 case $state in 2877 (command) 2878 __docker_service_commands && ret=0 2879 ;; 2880 (option-or-argument) 2881 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 2882 __docker_service_subcommand && ret=0 2883 ;; 2884 esac 2885 ;; 2886 (stack) 2887 local curcontext="$curcontext" state 2888 _arguments $(__docker_arguments) \ 2889 $opts_help \ 2890 "($help -): :->command" \ 2891 "($help -)*:: :->option-or-argument" && ret=0 2892 2893 case $state in 2894 (command) 2895 __docker_stack_commands && ret=0 2896 ;; 2897 (option-or-argument) 2898 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 2899 __docker_stack_subcommand && ret=0 2900 ;; 2901 esac 2902 ;; 2903 (swarm) 2904 local curcontext="$curcontext" state 2905 _arguments $(__docker_arguments) \ 2906 $opts_help \ 2907 "($help -): :->command" \ 2908 "($help -)*:: :->option-or-argument" && ret=0 2909 2910 case $state in 2911 (command) 2912 __docker_swarm_commands && ret=0 2913 ;; 2914 (option-or-argument) 2915 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 2916 __docker_swarm_subcommand && ret=0 2917 ;; 2918 esac 2919 ;; 2920 (system) 2921 local curcontext="$curcontext" state 2922 _arguments $(__docker_arguments) \ 2923 $opts_help \ 2924 "($help -): :->command" \ 2925 "($help -)*:: :->option-or-argument" && ret=0 2926 2927 case $state in 2928 (command) 2929 __docker_system_commands && ret=0 2930 ;; 2931 (option-or-argument) 2932 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 2933 __docker_system_subcommand && ret=0 2934 ;; 2935 esac 2936 ;; 2937 (version) 2938 _arguments $(__docker_arguments) \ 2939 $opts_help \ 2940 "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0 2941 ;; 2942 (volume) 2943 local curcontext="$curcontext" state 2944 _arguments $(__docker_arguments) \ 2945 $opts_help \ 2946 "($help -): :->command" \ 2947 "($help -)*:: :->option-or-argument" && ret=0 2948 2949 case $state in 2950 (command) 2951 __docker_volume_commands && ret=0 2952 ;; 2953 (option-or-argument) 2954 curcontext=${curcontext%:*:*}:docker-${words[-1]}: 2955 __docker_volume_subcommand && ret=0 2956 ;; 2957 esac 2958 ;; 2959 (help) 2960 _arguments $(__docker_arguments) ":subcommand:__docker_commands" && ret=0 2961 ;; 2962 esac 2963 2964 return ret 2965 } 2966 2967 _docker() { 2968 # Support for subservices, which allows for `compdef _docker docker-shell=_docker_containers`. 2969 # Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`. 2970 if [[ $service != docker ]]; then 2971 _call_function - _$service 2972 return 2973 fi 2974 2975 local curcontext="$curcontext" state line help="-h --help" 2976 integer ret=1 2977 typeset -A opt_args 2978 2979 _arguments $(__docker_arguments) -C \ 2980 "(: -)"{-h,--help}"[Print usage]" \ 2981 "($help)--config[Location of client config files]:path:_directories" \ 2982 "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \ 2983 "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \ 2984 "($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \ 2985 "($help)--tls[Use TLS]" \ 2986 "($help)--tlscacert=[Trust certs signed only by this CA]:PEM file:_files -g "*.(pem|crt)"" \ 2987 "($help)--tlscert=[Path to TLS certificate file]:PEM file:_files -g "*.(pem|crt)"" \ 2988 "($help)--tlskey=[Path to TLS key file]:Key file:_files -g "*.(pem|key)"" \ 2989 "($help)--tlsverify[Use TLS and verify the remote]" \ 2990 "($help)--userland-proxy[Use userland proxy for loopback traffic]" \ 2991 "($help -v --version)"{-v,--version}"[Print version information and quit]" \ 2992 "($help -): :->command" \ 2993 "($help -)*:: :->option-or-argument" && ret=0 2994 2995 local host=${opt_args[-H]}${opt_args[--host]} 2996 local config=${opt_args[--config]} 2997 local docker_options="${host:+--host $host} ${config:+--config $config}" 2998 2999 case $state in 3000 (command) 3001 __docker_commands && ret=0 3002 ;; 3003 (option-or-argument) 3004 curcontext=${curcontext%:*:*}:docker-$words[1]: 3005 __docker_subcommand && ret=0 3006 ;; 3007 esac 3008 3009 return ret 3010 } 3011 3012 _dockerd() { 3013 integer ret=1 3014 words[1]='daemon' 3015 __docker_subcommand && ret=0 3016 return ret 3017 } 3018 3019 _docker "$@" 3020 3021 # Local Variables: 3022 # mode: Shell-Script 3023 # sh-indentation: 4 3024 # indent-tabs-mode: nil 3025 # sh-basic-offset: 4 3026 # End: 3027 # vim: ft=zsh sw=4 ts=4 et