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