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