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