github.com/noxiouz/docker@v0.7.3-0.20160629055221-3d231c78e8c5/contrib/completion/bash/docker (about) 1 #!/bin/bash 2 # 3 # bash completion file for core docker commands 4 # 5 # This script provides completion of: 6 # - commands and their options 7 # - container ids and names 8 # - image repos and tags 9 # - filepaths 10 # 11 # To enable the completions either: 12 # - place this file in /etc/bash_completion.d 13 # or 14 # - copy this file to e.g. ~/.docker-completion.sh and add the line 15 # below to your .bashrc after bash completion features are loaded 16 # . ~/.docker-completion.sh 17 # 18 # Configuration: 19 # 20 # For several commands, the amount of completions can be configured by 21 # setting environment variables. 22 # 23 # DOCKER_COMPLETION_SHOW_NETWORK_IDS 24 # "no" - Show names only (default) 25 # "yes" - Show names and ids 26 # 27 # You can tailor completion for the "events", "history", "inspect", "run", 28 # "rmi" and "save" commands by settings the following environment 29 # variables: 30 # 31 # DOCKER_COMPLETION_SHOW_IMAGE_IDS 32 # "none" - Show names only (default) 33 # "non-intermediate" - Show names and ids, but omit intermediate image IDs 34 # "all" - Show names and ids, including intermediate image IDs 35 # 36 # DOCKER_COMPLETION_SHOW_TAGS 37 # "yes" - include tags in completion options (default) 38 # "no" - don't include tags in completion options 39 40 # 41 # Note: 42 # Currently, the completions will not work if the docker daemon is not 43 # bound to the default communication port/socket 44 # If the docker daemon is using a unix socket for communication your user 45 # must have access to the socket for the completions to function correctly 46 # 47 # Note for developers: 48 # Please arrange options sorted alphabetically by long name with the short 49 # options immediately following their corresponding long form. 50 # This order should be applied to lists, alternatives and code blocks. 51 52 __docker_previous_extglob_setting=$(shopt -p extglob) 53 shopt -s extglob 54 55 __docker_q() { 56 docker ${host:+-H "$host"} ${config:+--config "$config"} 2>/dev/null "$@" 57 } 58 59 __docker_complete_containers_all() { 60 local IFS=$'\n' 61 local containers=( $(__docker_q ps -aq --no-trunc) ) 62 if [ "$1" ]; then 63 containers=( $(__docker_q inspect --format "{{if $1}}{{.Id}}{{end}}" "${containers[@]}") ) 64 fi 65 local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") ) 66 names=( "${names[@]#/}" ) # trim off the leading "/" from the container names 67 unset IFS 68 COMPREPLY=( $(compgen -W "${names[*]} ${containers[*]}" -- "$cur") ) 69 } 70 71 __docker_complete_containers_running() { 72 __docker_complete_containers_all '.State.Running' 73 } 74 75 __docker_complete_containers_stopped() { 76 __docker_complete_containers_all 'not .State.Running' 77 } 78 79 __docker_complete_containers_pauseable() { 80 __docker_complete_containers_all 'and .State.Running (not .State.Paused)' 81 } 82 83 __docker_complete_containers_unpauseable() { 84 __docker_complete_containers_all '.State.Paused' 85 } 86 87 __docker_complete_container_names() { 88 local containers=( $(__docker_q ps -aq --no-trunc) ) 89 local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") ) 90 names=( "${names[@]#/}" ) # trim off the leading "/" from the container names 91 COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") ) 92 } 93 94 __docker_complete_container_ids() { 95 local containers=( $(__docker_q ps -aq) ) 96 COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") ) 97 } 98 99 __docker_complete_images() { 100 local images_args="" 101 102 case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in 103 all) 104 images_args="--no-trunc -a" 105 ;; 106 non-intermediate) 107 images_args="--no-trunc" 108 ;; 109 esac 110 111 local repo_print_command 112 if [ "${DOCKER_COMPLETION_SHOW_TAGS:-yes}" = "yes" ]; then 113 repo_print_command='print $1; print $1":"$2' 114 else 115 repo_print_command='print $1' 116 fi 117 118 local awk_script 119 case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in 120 all|non-intermediate) 121 awk_script='NR>1 { print $3; if ($1 != "<none>") { '"$repo_print_command"' } }' 122 ;; 123 none|*) 124 awk_script='NR>1 && $1 != "<none>" { '"$repo_print_command"' }' 125 ;; 126 esac 127 128 local images=$(__docker_q images $images_args | awk "$awk_script") 129 COMPREPLY=( $(compgen -W "$images" -- "$cur") ) 130 __ltrim_colon_completions "$cur" 131 } 132 133 __docker_complete_image_repos() { 134 local repos="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1 }')" 135 COMPREPLY=( $(compgen -W "$repos" -- "$cur") ) 136 } 137 138 __docker_complete_image_repos_and_tags() { 139 local reposAndTags="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1; print $1":"$2 }')" 140 COMPREPLY=( $(compgen -W "$reposAndTags" -- "$cur") ) 141 __ltrim_colon_completions "$cur" 142 } 143 144 __docker_complete_containers_and_images() { 145 __docker_complete_containers_all 146 local containers=( "${COMPREPLY[@]}" ) 147 __docker_complete_images 148 COMPREPLY+=( "${containers[@]}" ) 149 } 150 151 # Returns the names and optionally IDs of networks. 152 # The selection can be narrowed by an optional filter parameter, e.g. 'type=custom' 153 __docker_networks() { 154 local filter="$1" 155 # By default, only network names are completed. 156 # Set DOCKER_COMPLETION_SHOW_NETWORK_IDS=yes to also complete network IDs. 157 local fields='$2' 158 [ "${DOCKER_COMPLETION_SHOW_NETWORK_IDS}" = yes ] && fields='$1,$2' 159 __docker_q network ls --no-trunc ${filter:+-f "$filter"} | awk "NR>1 {print $fields}" 160 #__docker_q network ls --no-trunc | awk "NR>1 {print $fields}" 161 } 162 163 __docker_complete_networks() { 164 COMPREPLY=( $(compgen -W "$(__docker_networks $@)" -- "$cur") ) 165 } 166 167 __docker_complete_network_ids() { 168 COMPREPLY=( $(compgen -W "$(__docker_q network ls -q --no-trunc)" -- "$cur") ) 169 } 170 171 __docker_complete_network_names() { 172 COMPREPLY=( $(compgen -W "$(__docker_q network ls | awk 'NR>1 {print $2}')" -- "$cur") ) 173 } 174 175 __docker_complete_containers_in_network() { 176 local containers=$(__docker_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1") 177 COMPREPLY=( $(compgen -W "$containers" -- "$cur") ) 178 } 179 180 __docker_complete_volumes() { 181 COMPREPLY=( $(compgen -W "$(__docker_q volume ls -q)" -- "$cur") ) 182 } 183 184 __docker_plugins() { 185 __docker_q info | sed -n "/^Plugins/,/^[^ ]/s/ $1: //p" 186 } 187 188 __docker_complete_plugins() { 189 COMPREPLY=( $(compgen -W "$(__docker_plugins $1)" -- "$cur") ) 190 } 191 192 __docker_runtimes() { 193 __docker_q info | sed -n 's/^Runtimes: \(.*\)/\1/p' 194 } 195 196 __docker_complete_runtimes() { 197 COMPREPLY=( $(compgen -W "$(__docker_runtimes)" -- "$cur") ) 198 } 199 200 __docker_nodes() { 201 local fields='$1,$2' # node names & IDs 202 __docker_q node ls | sed -e 's/\*//g' | awk "NR>1 {print $fields}" 203 } 204 205 __docker_complete_nodes() { 206 COMPREPLY=( $(compgen -W "$(__docker_nodes $1)" -- "$cur") ) 207 } 208 209 __docker_complete_nodes_plus_self() { 210 COMPREPLY=( $(compgen -W "$(__docker_nodes $1) self" -- "$cur") ) 211 } 212 213 __docker_pending_nodes() { 214 local fields='$1' # node ID 215 __docker_q node ls --filter membership=pending | awk "NR>1 {print $fields}" 216 } 217 218 __docker_complete_pending_nodes() { 219 COMPREPLY=( $(compgen -W "$(__docker_pending_nodes $1)" -- "$cur") ) 220 } 221 222 __docker_manager_nodes() { 223 local fields='$1,$2' # node names & IDs 224 __docker_q node ls --filter role=manager | awk "NR>1 {print $fields}" 225 } 226 227 __docker_complete_manager_nodes() { 228 COMPREPLY=( $(compgen -W "$(__docker_manager_nodes $1)" -- "$cur") ) 229 } 230 231 __docker_worker_nodes() { 232 local fields='$1,$2' # node names & IDs 233 __docker_q node ls --filter role=worker | awk "NR>1 {print $fields}" 234 } 235 236 __docker_complete_worker_nodes() { 237 COMPREPLY=( $(compgen -W "$(__docker_worker_nodes $1)" -- "$cur") ) 238 } 239 240 __docker_services() { 241 local fields='$1,$2' # service names & IDs 242 __docker_q service ls | awk "NR>1 {print $fields}" 243 } 244 245 __docker_complete_services() { 246 COMPREPLY=( $(compgen -W "$(__docker_services $1)" -- "$cur") ) 247 } 248 249 # Finds the position of the first word that is neither option nor an option's argument. 250 # If there are options that require arguments, you should pass a glob describing those 251 # options, e.g. "--option1|-o|--option2" 252 # Use this function to restrict completions to exact positions after the argument list. 253 __docker_pos_first_nonflag() { 254 local argument_flags=$1 255 256 local counter=$((${subcommand_pos:-${command_pos}} + 1)) 257 while [ $counter -le $cword ]; do 258 if [ -n "$argument_flags" ] && eval "case '${words[$counter]}' in $argument_flags) true ;; *) false ;; esac"; then 259 (( counter++ )) 260 # eat "=" in case of --option=arg syntax 261 [ "${words[$counter]}" = "=" ] && (( counter++ )) 262 else 263 case "${words[$counter]}" in 264 -*) 265 ;; 266 *) 267 break 268 ;; 269 esac 270 fi 271 272 # Bash splits words at "=", retaining "=" as a word, examples: 273 # "--debug=false" => 3 words, "--log-opt syslog-facility=daemon" => 4 words 274 while [ "${words[$counter + 1]}" = "=" ] ; do 275 counter=$(( counter + 2)) 276 done 277 278 (( counter++ )) 279 done 280 281 echo $counter 282 } 283 284 # If we are currently completing the value of a map option (key=value) 285 # which matches the extglob given as an argument, returns key. 286 # This function is needed for key-specific completions. 287 __docker_map_key_of_current_option() { 288 local glob="$1" 289 290 local key glob_pos 291 if [ "$cur" = "=" ] ; then # key= case 292 key="$prev" 293 glob_pos=$((cword - 2)) 294 elif [[ $cur == *=* ]] ; then # key=value case (OSX) 295 key=${cur%=*} 296 glob_pos=$((cword - 1)) 297 elif [ "$prev" = "=" ] ; then 298 key=${words[$cword - 2]} # key=value case 299 glob_pos=$((cword - 3)) 300 else 301 return 302 fi 303 304 [ "${words[$glob_pos]}" = "=" ] && ((glob_pos--)) # --option=key=value syntax 305 306 [[ ${words[$glob_pos]} == @($glob) ]] && echo "$key" 307 } 308 309 # Returns the value of the first option matching option_glob. 310 # Valid values for option_glob are option names like '--log-level' and 311 # globs like '--log-level|-l' 312 # Only positions between the command and the current word are considered. 313 __docker_value_of_option() { 314 local option_extglob=$(__docker_to_extglob "$1") 315 316 local counter=$((command_pos + 1)) 317 while [ $counter -lt $cword ]; do 318 case ${words[$counter]} in 319 $option_extglob ) 320 echo ${words[$counter + 1]} 321 break 322 ;; 323 esac 324 (( counter++ )) 325 done 326 } 327 328 # Transforms a multiline list of strings into a single line string 329 # with the words separated by "|". 330 # This is used to prepare arguments to __docker_pos_first_nonflag(). 331 __docker_to_alternatives() { 332 local parts=( $1 ) 333 local IFS='|' 334 echo "${parts[*]}" 335 } 336 337 # Transforms a multiline list of options into an extglob pattern 338 # suitable for use in case statements. 339 __docker_to_extglob() { 340 local extglob=$( __docker_to_alternatives "$1" ) 341 echo "@($extglob)" 342 } 343 344 # Subcommand processing. 345 # Locates the first occurrence of any of the subcommands contained in the 346 # first argument. In case of a match, calls the corresponding completion 347 # function and returns 0. 348 # If no match is found, 1 is returned. The calling function can then 349 # continue processing its completion. 350 # 351 # TODO if the preceding command has options that accept arguments and an 352 # argument is equal ot one of the subcommands, this is falsely detected as 353 # a match. 354 __docker_subcommands() { 355 local subcommands="$1" 356 357 local counter=$(($command_pos + 1)) 358 while [ $counter -lt $cword ]; do 359 case "${words[$counter]}" in 360 $(__docker_to_extglob "$subcommands") ) 361 subcommand_pos=$counter 362 local subcommand=${words[$counter]} 363 local completions_func=_docker_${command}_${subcommand} 364 declare -F $completions_func >/dev/null && $completions_func 365 return 0 366 ;; 367 esac 368 (( counter++ )) 369 done 370 return 1 371 } 372 373 # suppress trailing whitespace 374 __docker_nospace() { 375 # compopt is not available in ancient bash versions 376 type compopt &>/dev/null && compopt -o nospace 377 } 378 379 __docker_complete_resolved_hostname() { 380 command -v host >/dev/null 2>&1 || return 381 COMPREPLY=( $(host 2>/dev/null "${cur%:}" | awk '/has address/ {print $4}') ) 382 } 383 384 __docker_complete_capabilities() { 385 # The list of capabilities is defined in types.go, ALL was added manually. 386 COMPREPLY=( $( compgen -W " 387 ALL 388 AUDIT_CONTROL 389 AUDIT_WRITE 390 AUDIT_READ 391 BLOCK_SUSPEND 392 CHOWN 393 DAC_OVERRIDE 394 DAC_READ_SEARCH 395 FOWNER 396 FSETID 397 IPC_LOCK 398 IPC_OWNER 399 KILL 400 LEASE 401 LINUX_IMMUTABLE 402 MAC_ADMIN 403 MAC_OVERRIDE 404 MKNOD 405 NET_ADMIN 406 NET_BIND_SERVICE 407 NET_BROADCAST 408 NET_RAW 409 SETFCAP 410 SETGID 411 SETPCAP 412 SETUID 413 SYS_ADMIN 414 SYS_BOOT 415 SYS_CHROOT 416 SYSLOG 417 SYS_MODULE 418 SYS_NICE 419 SYS_PACCT 420 SYS_PTRACE 421 SYS_RAWIO 422 SYS_RESOURCE 423 SYS_TIME 424 SYS_TTY_CONFIG 425 WAKE_ALARM 426 " -- "$cur" ) ) 427 } 428 429 __docker_complete_detach-keys() { 430 case "$prev" in 431 --detach-keys) 432 case "$cur" in 433 *,) 434 COMPREPLY=( $( compgen -W "${cur}ctrl-" -- "$cur" ) ) 435 ;; 436 *) 437 COMPREPLY=( $( compgen -W "ctrl-" -- "$cur" ) ) 438 ;; 439 esac 440 441 __docker_nospace 442 return 443 ;; 444 esac 445 return 1 446 } 447 448 __docker_complete_isolation() { 449 COMPREPLY=( $( compgen -W "default hyperv process" -- "$cur" ) ) 450 } 451 452 __docker_complete_log_drivers() { 453 COMPREPLY=( $( compgen -W " 454 awslogs 455 etwlogs 456 fluentd 457 gcplogs 458 gelf 459 journald 460 json-file 461 none 462 splunk 463 syslog 464 " -- "$cur" ) ) 465 } 466 467 __docker_complete_log_options() { 468 # see docs/reference/logging/index.md 469 local awslogs_options="awslogs-region awslogs-group awslogs-stream" 470 local fluentd_options="env fluentd-address fluentd-async-connect fluentd-buffer-limit fluentd-retry-wait fluentd-max-retries labels tag" 471 local gcplogs_options="env gcp-log-cmd gcp-project labels" 472 local gelf_options="env gelf-address gelf-compression-level gelf-compression-type labels tag" 473 local journald_options="env labels tag" 474 local json_file_options="env labels max-file max-size" 475 local syslog_options="syslog-address syslog-format syslog-tls-ca-cert syslog-tls-cert syslog-tls-key syslog-tls-skip-verify syslog-facility tag" 476 local splunk_options="env labels splunk-caname splunk-capath splunk-index splunk-insecureskipverify splunk-source splunk-sourcetype splunk-token splunk-url tag" 477 478 local all_options="$fluentd_options $gcplogs_options $gelf_options $journald_options $json_file_options $syslog_options $splunk_options" 479 480 case $(__docker_value_of_option --log-driver) in 481 '') 482 COMPREPLY=( $( compgen -W "$all_options" -S = -- "$cur" ) ) 483 ;; 484 awslogs) 485 COMPREPLY=( $( compgen -W "$awslogs_options" -S = -- "$cur" ) ) 486 ;; 487 fluentd) 488 COMPREPLY=( $( compgen -W "$fluentd_options" -S = -- "$cur" ) ) 489 ;; 490 gcplogs) 491 COMPREPLY=( $( compgen -W "$gcplogs_options" -S = -- "$cur" ) ) 492 ;; 493 gelf) 494 COMPREPLY=( $( compgen -W "$gelf_options" -S = -- "$cur" ) ) 495 ;; 496 journald) 497 COMPREPLY=( $( compgen -W "$journald_options" -S = -- "$cur" ) ) 498 ;; 499 json-file) 500 COMPREPLY=( $( compgen -W "$json_file_options" -S = -- "$cur" ) ) 501 ;; 502 syslog) 503 COMPREPLY=( $( compgen -W "$syslog_options" -S = -- "$cur" ) ) 504 ;; 505 splunk) 506 COMPREPLY=( $( compgen -W "$splunk_options" -S = -- "$cur" ) ) 507 ;; 508 *) 509 return 510 ;; 511 esac 512 513 __docker_nospace 514 } 515 516 __docker_complete_log_driver_options() { 517 local key=$(__docker_map_key_of_current_option '--log-opt') 518 case "$key" in 519 fluentd-async-connect) 520 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 521 return 522 ;; 523 gelf-address) 524 COMPREPLY=( $( compgen -W "udp" -S "://" -- "${cur##*=}" ) ) 525 __docker_nospace 526 return 527 ;; 528 gelf-compression-level) 529 COMPREPLY=( $( compgen -W "1 2 3 4 5 6 7 8 9" -- "${cur##*=}" ) ) 530 return 531 ;; 532 gelf-compression-type) 533 COMPREPLY=( $( compgen -W "gzip none zlib" -- "${cur##*=}" ) ) 534 return 535 ;; 536 syslog-address) 537 COMPREPLY=( $( compgen -W "tcp:// tcp+tls:// udp:// unix://" -- "${cur##*=}" ) ) 538 __docker_nospace 539 __ltrim_colon_completions "${cur}" 540 return 541 ;; 542 syslog-facility) 543 COMPREPLY=( $( compgen -W " 544 auth 545 authpriv 546 cron 547 daemon 548 ftp 549 kern 550 local0 551 local1 552 local2 553 local3 554 local4 555 local5 556 local6 557 local7 558 lpr 559 mail 560 news 561 syslog 562 user 563 uucp 564 " -- "${cur##*=}" ) ) 565 return 566 ;; 567 syslog-format) 568 COMPREPLY=( $( compgen -W "rfc3164 rfc5424 rfc5424micro" -- "${cur##*=}" ) ) 569 return 570 ;; 571 syslog-tls-ca-cert|syslog-tls-cert|syslog-tls-key) 572 _filedir 573 return 574 ;; 575 syslog-tls-skip-verify) 576 COMPREPLY=( $( compgen -W "true" -- "${cur##*=}" ) ) 577 return 578 ;; 579 splunk-url) 580 COMPREPLY=( $( compgen -W "http:// https://" -- "${cur##*=}" ) ) 581 __docker_nospace 582 __ltrim_colon_completions "${cur}" 583 return 584 ;; 585 splunk-insecureskipverify) 586 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 587 return 588 ;; 589 esac 590 return 1 591 } 592 593 __docker_complete_log_levels() { 594 COMPREPLY=( $( compgen -W "debug info warn error fatal" -- "$cur" ) ) 595 } 596 597 __docker_complete_restart() { 598 case "$prev" in 599 --restart) 600 case "$cur" in 601 on-failure:*) 602 ;; 603 *) 604 COMPREPLY=( $( compgen -W "always no on-failure on-failure: unless-stopped" -- "$cur") ) 605 ;; 606 esac 607 return 608 ;; 609 esac 610 return 1 611 } 612 613 # a selection of the available signals that is most likely of interest in the 614 # context of docker containers. 615 __docker_complete_signals() { 616 local signals=( 617 SIGCONT 618 SIGHUP 619 SIGINT 620 SIGKILL 621 SIGQUIT 622 SIGSTOP 623 SIGTERM 624 SIGUSR1 625 SIGUSR2 626 ) 627 COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo $cur | tr '[:lower:]' '[:upper:]')" ) ) 628 } 629 630 __docker_complete_user_group() { 631 if [[ $cur == *:* ]] ; then 632 COMPREPLY=( $(compgen -g -- "${cur#*:}") ) 633 else 634 COMPREPLY=( $(compgen -u -S : -- "$cur") ) 635 __docker_nospace 636 fi 637 } 638 639 # global options that may appear after the docker command 640 _docker_docker() { 641 local boolean_options=" 642 $global_boolean_options 643 --help 644 --version -v 645 " 646 647 case "$prev" in 648 --config) 649 _filedir -d 650 return 651 ;; 652 --log-level|-l) 653 __docker_complete_log_levels 654 return 655 ;; 656 $(__docker_to_extglob "$global_options_with_args") ) 657 return 658 ;; 659 esac 660 661 case "$cur" in 662 -*) 663 COMPREPLY=( $( compgen -W "$boolean_options $global_options_with_args" -- "$cur" ) ) 664 ;; 665 *) 666 local counter=$( __docker_pos_first_nonflag "$(__docker_to_extglob "$global_options_with_args")" ) 667 if [ $cword -eq $counter ]; then 668 COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) ) 669 fi 670 ;; 671 esac 672 } 673 674 _docker_attach() { 675 __docker_complete_detach-keys && return 676 677 case "$cur" in 678 -*) 679 COMPREPLY=( $( compgen -W "--detach-keys --help --no-stdin --sig-proxy=false" -- "$cur" ) ) 680 ;; 681 *) 682 local counter=$(__docker_pos_first_nonflag '--detach-keys') 683 if [ $cword -eq $counter ]; then 684 __docker_complete_containers_running 685 fi 686 ;; 687 esac 688 } 689 690 _docker_build() { 691 local options_with_args=" 692 --build-arg 693 --cgroup-parent 694 --cpuset-cpus 695 --cpuset-mems 696 --cpu-shares -c 697 --cpu-period 698 --cpu-quota 699 --file -f 700 --isolation 701 --label 702 --memory -m 703 --memory-swap 704 --shm-size 705 --tag -t 706 --ulimit 707 " 708 709 local boolean_options=" 710 --disable-content-trust=false 711 --force-rm 712 --help 713 --no-cache 714 --pull 715 --quiet -q 716 --rm 717 " 718 719 local all_options="$options_with_args $boolean_options" 720 721 case "$prev" in 722 --build-arg) 723 COMPREPLY=( $( compgen -e -- "$cur" ) ) 724 __docker_nospace 725 return 726 ;; 727 --file|-f) 728 _filedir 729 return 730 ;; 731 --isolation) 732 __docker_complete_isolation 733 return 734 ;; 735 --tag|-t) 736 __docker_complete_image_repos_and_tags 737 return 738 ;; 739 $(__docker_to_extglob "$options_with_args") ) 740 return 741 ;; 742 esac 743 744 case "$cur" in 745 -*) 746 COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) 747 ;; 748 *) 749 local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) ) 750 if [ $cword -eq $counter ]; then 751 _filedir -d 752 fi 753 ;; 754 esac 755 } 756 757 _docker_commit() { 758 case "$prev" in 759 --author|-a|--change|-c|--message|-m) 760 return 761 ;; 762 esac 763 764 case "$cur" in 765 -*) 766 COMPREPLY=( $( compgen -W "--author -a --change -c --help --message -m --pause=false -p=false" -- "$cur" ) ) 767 ;; 768 *) 769 local counter=$(__docker_pos_first_nonflag '--author|-a|--change|-c|--message|-m') 770 771 if [ $cword -eq $counter ]; then 772 __docker_complete_containers_all 773 return 774 fi 775 (( counter++ )) 776 777 if [ $cword -eq $counter ]; then 778 __docker_complete_image_repos_and_tags 779 return 780 fi 781 ;; 782 esac 783 } 784 785 _docker_cp() { 786 case "$cur" in 787 -*) 788 COMPREPLY=( $( compgen -W "--follow-link -L --help" -- "$cur" ) ) 789 ;; 790 *) 791 local counter=$(__docker_pos_first_nonflag) 792 if [ $cword -eq $counter ]; then 793 case "$cur" in 794 *:) 795 return 796 ;; 797 *) 798 # combined container and filename completion 799 _filedir 800 local files=( ${COMPREPLY[@]} ) 801 802 __docker_complete_containers_all 803 COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) 804 local containers=( ${COMPREPLY[@]} ) 805 806 COMPREPLY=( $( compgen -W "${files[*]} ${containers[*]}" -- "$cur" ) ) 807 if [[ "$COMPREPLY" == *: ]]; then 808 __docker_nospace 809 fi 810 return 811 ;; 812 esac 813 fi 814 (( counter++ )) 815 816 if [ $cword -eq $counter ]; then 817 if [ -e "$prev" ]; then 818 __docker_complete_containers_all 819 COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) 820 __docker_nospace 821 else 822 _filedir 823 fi 824 return 825 fi 826 ;; 827 esac 828 } 829 830 _docker_create() { 831 _docker_run 832 } 833 834 _docker_daemon() { 835 local boolean_options=" 836 $global_boolean_options 837 --disable-legacy-registry 838 --help 839 --icc=false 840 --ip-forward=false 841 --ip-masq=false 842 --iptables=false 843 --ipv6 844 --live-restore 845 --raw-logs 846 --selinux-enabled 847 --userland-proxy=false 848 " 849 local options_with_args=" 850 $global_options_with_args 851 --add-runtime 852 --api-cors-header 853 --authorization-plugin 854 --bip 855 --bridge -b 856 --cgroup-parent 857 --cluster-advertise 858 --cluster-store 859 --cluster-store-opt 860 --config-file 861 --containerd 862 --default-gateway 863 --default-gateway-v6 864 --default-ulimit 865 --dns 866 --dns-search 867 --dns-opt 868 --exec-opt 869 --exec-root 870 --fixed-cidr 871 --fixed-cidr-v6 872 --graph -g 873 --group -G 874 --insecure-registry 875 --ip 876 --label 877 --log-driver 878 --log-opt 879 --max-concurrent-downloads 880 --max-concurrent-uploads 881 --mtu 882 --pidfile -p 883 --registry-mirror 884 --storage-driver -s 885 --storage-opt 886 --userns-remap 887 " 888 889 __docker_complete_log_driver_options && return 890 891 key=$(__docker_map_key_of_current_option '--cluster-store-opt') 892 case "$key" in 893 kv.*file) 894 cur=${cur##*=} 895 _filedir 896 return 897 ;; 898 esac 899 900 local key=$(__docker_map_key_of_current_option '--storage-opt') 901 case "$key" in 902 dm.blkdiscard|dm.override_udev_sync_check|dm.use_deferred_removal|dm.use_deferred_deletion) 903 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 904 return 905 ;; 906 dm.fs) 907 COMPREPLY=( $( compgen -W "ext4 xfs" -- "${cur##*=}" ) ) 908 return 909 ;; 910 dm.thinpooldev) 911 cur=${cur##*=} 912 _filedir 913 return 914 ;; 915 esac 916 917 case "$prev" in 918 --authorization-plugin) 919 __docker_complete_plugins Authorization 920 return 921 ;; 922 --cluster-store) 923 COMPREPLY=( $( compgen -W "consul etcd zk" -S "://" -- "$cur" ) ) 924 __docker_nospace 925 return 926 ;; 927 --cluster-store-opt) 928 COMPREPLY=( $( compgen -W "discovery.heartbeat discovery.ttl kv.cacertfile kv.certfile kv.keyfile kv.path" -S = -- "$cur" ) ) 929 __docker_nospace 930 return 931 ;; 932 --exec-root|--graph|-g) 933 _filedir -d 934 return 935 ;; 936 --log-driver) 937 __docker_complete_log_drivers 938 return 939 ;; 940 --config-file|--containerd|--pidfile|-p|--tlscacert|--tlscert|--tlskey) 941 _filedir 942 return 943 ;; 944 --storage-driver|-s) 945 COMPREPLY=( $( compgen -W "aufs btrfs devicemapper overlay overlay2 vfs zfs" -- "$(echo $cur | tr '[:upper:]' '[:lower:]')" ) ) 946 return 947 ;; 948 --storage-opt) 949 local btrfs_options="btrfs.min_space" 950 local devicemapper_options=" 951 dm.basesize 952 dm.blkdiscard 953 dm.blocksize 954 dm.fs 955 dm.loopdatasize 956 dm.loopmetadatasize 957 dm.min_free_space 958 dm.mkfsarg 959 dm.mountopt 960 dm.override_udev_sync_check 961 dm.thinpooldev 962 dm.use_deferred_deletion 963 dm.use_deferred_removal 964 " 965 local zfs_options="zfs.fsname" 966 967 case $(__docker_value_of_option '--storage-driver|-s') in 968 '') 969 COMPREPLY=( $( compgen -W "$btrfs_options $devicemapper_options $zfs_options" -S = -- "$cur" ) ) 970 ;; 971 btrfs) 972 COMPREPLY=( $( compgen -W "$btrfs_options" -S = -- "$cur" ) ) 973 ;; 974 devicemapper) 975 COMPREPLY=( $( compgen -W "$devicemapper_options" -S = -- "$cur" ) ) 976 ;; 977 zfs) 978 COMPREPLY=( $( compgen -W "$zfs_options" -S = -- "$cur" ) ) 979 ;; 980 *) 981 return 982 ;; 983 esac 984 __docker_nospace 985 return 986 ;; 987 --log-level|-l) 988 __docker_complete_log_levels 989 return 990 ;; 991 --log-opt) 992 __docker_complete_log_options 993 return 994 ;; 995 --userns-remap) 996 __docker_complete_user_group 997 return 998 ;; 999 $(__docker_to_extglob "$options_with_args") ) 1000 return 1001 ;; 1002 esac 1003 1004 case "$cur" in 1005 -*) 1006 COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) 1007 ;; 1008 esac 1009 } 1010 1011 _docker_diff() { 1012 case "$cur" in 1013 -*) 1014 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1015 ;; 1016 *) 1017 local counter=$(__docker_pos_first_nonflag) 1018 if [ $cword -eq $counter ]; then 1019 __docker_complete_containers_all 1020 fi 1021 ;; 1022 esac 1023 } 1024 1025 _docker_events() { 1026 local key=$(__docker_map_key_of_current_option '-f|--filter') 1027 case "$key" in 1028 container) 1029 cur="${cur##*=}" 1030 __docker_complete_containers_all 1031 return 1032 ;; 1033 daemon) 1034 local name=$(__docker_q info | sed -n 's/^\(ID\|Name\): //p') 1035 COMPREPLY=( $( compgen -W "$name" -- "${cur##*=}" ) ) 1036 return 1037 ;; 1038 event) 1039 COMPREPLY=( $( compgen -W " 1040 attach 1041 commit 1042 connect 1043 copy 1044 create 1045 delete 1046 destroy 1047 detach 1048 die 1049 disconnect 1050 exec_create 1051 exec_detach 1052 exec_start 1053 export 1054 import 1055 kill 1056 load 1057 mount 1058 oom 1059 pause 1060 pull 1061 push 1062 reload 1063 rename 1064 resize 1065 restart 1066 save 1067 start 1068 stop 1069 tag 1070 top 1071 unmount 1072 unpause 1073 untag 1074 update 1075 " -- "${cur##*=}" ) ) 1076 return 1077 ;; 1078 image) 1079 cur="${cur##*=}" 1080 __docker_complete_images 1081 return 1082 ;; 1083 network) 1084 cur="${cur##*=}" 1085 __docker_complete_networks 1086 return 1087 ;; 1088 type) 1089 COMPREPLY=( $( compgen -W "container daemon image network volume" -- "${cur##*=}" ) ) 1090 return 1091 ;; 1092 volume) 1093 cur="${cur##*=}" 1094 __docker_complete_volumes 1095 return 1096 ;; 1097 esac 1098 1099 case "$prev" in 1100 --filter|-f) 1101 COMPREPLY=( $( compgen -S = -W "container daemon event image label network type volume" -- "$cur" ) ) 1102 __docker_nospace 1103 return 1104 ;; 1105 --since|--until) 1106 return 1107 ;; 1108 esac 1109 1110 case "$cur" in 1111 -*) 1112 COMPREPLY=( $( compgen -W "--filter -f --help --since --until" -- "$cur" ) ) 1113 ;; 1114 esac 1115 } 1116 1117 _docker_exec() { 1118 __docker_complete_detach-keys && return 1119 1120 case "$prev" in 1121 --user|-u) 1122 __docker_complete_user_group 1123 return 1124 ;; 1125 esac 1126 1127 case "$cur" in 1128 -*) 1129 COMPREPLY=( $( compgen -W "--detach -d --detach-keys --help --interactive -i --privileged -t --tty -u --user" -- "$cur" ) ) 1130 ;; 1131 *) 1132 __docker_complete_containers_running 1133 ;; 1134 esac 1135 } 1136 1137 _docker_export() { 1138 case "$cur" in 1139 -*) 1140 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1141 ;; 1142 *) 1143 local counter=$(__docker_pos_first_nonflag) 1144 if [ $cword -eq $counter ]; then 1145 __docker_complete_containers_all 1146 fi 1147 ;; 1148 esac 1149 } 1150 1151 _docker_help() { 1152 local counter=$(__docker_pos_first_nonflag) 1153 if [ $cword -eq $counter ]; then 1154 COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) ) 1155 fi 1156 } 1157 1158 _docker_history() { 1159 case "$cur" in 1160 -*) 1161 COMPREPLY=( $( compgen -W "--help --human=false -H=false --no-trunc --quiet -q" -- "$cur" ) ) 1162 ;; 1163 *) 1164 local counter=$(__docker_pos_first_nonflag) 1165 if [ $cword -eq $counter ]; then 1166 __docker_complete_images 1167 fi 1168 ;; 1169 esac 1170 } 1171 1172 _docker_images() { 1173 local key=$(__docker_map_key_of_current_option '--filter|-f') 1174 case "$key" in 1175 before) 1176 cur="${cur##*=}" 1177 __docker_complete_images 1178 return 1179 ;; 1180 dangling) 1181 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 1182 return 1183 ;; 1184 label) 1185 return 1186 ;; 1187 since) 1188 cur="${cur##*=}" 1189 __docker_complete_images 1190 return 1191 ;; 1192 esac 1193 1194 case "$prev" in 1195 --filter|-f) 1196 COMPREPLY=( $( compgen -S = -W "before dangling label since" -- "$cur" ) ) 1197 __docker_nospace 1198 return 1199 ;; 1200 --format) 1201 return 1202 ;; 1203 esac 1204 1205 case "$cur" in 1206 -*) 1207 COMPREPLY=( $( compgen -W "--all -a --digests --filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) ) 1208 ;; 1209 =) 1210 return 1211 ;; 1212 *) 1213 __docker_complete_image_repos 1214 ;; 1215 esac 1216 } 1217 1218 _docker_import() { 1219 case "$prev" in 1220 --change|-c|--message|-m) 1221 return 1222 ;; 1223 esac 1224 1225 case "$cur" in 1226 -*) 1227 COMPREPLY=( $( compgen -W "--change -c --help --message -m" -- "$cur" ) ) 1228 ;; 1229 *) 1230 local counter=$(__docker_pos_first_nonflag '--change|-c|--message|-m') 1231 if [ $cword -eq $counter ]; then 1232 return 1233 fi 1234 (( counter++ )) 1235 1236 if [ $cword -eq $counter ]; then 1237 __docker_complete_image_repos_and_tags 1238 return 1239 fi 1240 ;; 1241 esac 1242 } 1243 1244 _docker_info() { 1245 case "$cur" in 1246 -*) 1247 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1248 ;; 1249 esac 1250 } 1251 1252 _docker_inspect() { 1253 case "$prev" in 1254 --format|-f) 1255 return 1256 ;; 1257 --type) 1258 COMPREPLY=( $( compgen -W "image container" -- "$cur" ) ) 1259 return 1260 ;; 1261 1262 esac 1263 1264 case "$cur" in 1265 -*) 1266 COMPREPLY=( $( compgen -W "--format -f --help --size -s --type" -- "$cur" ) ) 1267 ;; 1268 *) 1269 case $(__docker_value_of_option --type) in 1270 '') 1271 __docker_complete_containers_and_images 1272 ;; 1273 container) 1274 __docker_complete_containers_all 1275 ;; 1276 image) 1277 __docker_complete_images 1278 ;; 1279 esac 1280 esac 1281 } 1282 1283 _docker_kill() { 1284 case "$prev" in 1285 --signal|-s) 1286 __docker_complete_signals 1287 return 1288 ;; 1289 esac 1290 1291 case "$cur" in 1292 -*) 1293 COMPREPLY=( $( compgen -W "--help --signal -s" -- "$cur" ) ) 1294 ;; 1295 *) 1296 __docker_complete_containers_running 1297 ;; 1298 esac 1299 } 1300 1301 _docker_load() { 1302 case "$prev" in 1303 --input|-i) 1304 _filedir 1305 return 1306 ;; 1307 esac 1308 1309 case "$cur" in 1310 -*) 1311 COMPREPLY=( $( compgen -W "--help --input -i --quiet -q" -- "$cur" ) ) 1312 ;; 1313 esac 1314 } 1315 1316 _docker_login() { 1317 case "$prev" in 1318 --password|-p|--username|-u) 1319 return 1320 ;; 1321 esac 1322 1323 case "$cur" in 1324 -*) 1325 COMPREPLY=( $( compgen -W "--help --password -p --username -u" -- "$cur" ) ) 1326 ;; 1327 esac 1328 } 1329 1330 _docker_logout() { 1331 case "$cur" in 1332 -*) 1333 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1334 ;; 1335 esac 1336 } 1337 1338 _docker_logs() { 1339 case "$prev" in 1340 --since|--tail) 1341 return 1342 ;; 1343 esac 1344 1345 case "$cur" in 1346 -*) 1347 COMPREPLY=( $( compgen -W "--details --follow -f --help --since --tail --timestamps -t" -- "$cur" ) ) 1348 ;; 1349 *) 1350 local counter=$(__docker_pos_first_nonflag '--tail') 1351 if [ $cword -eq $counter ]; then 1352 __docker_complete_containers_all 1353 fi 1354 ;; 1355 esac 1356 } 1357 1358 _docker_network_connect() { 1359 local options_with_args=" 1360 --alias 1361 --ip 1362 --ip6 1363 --link 1364 --link-local-ip 1365 " 1366 1367 local boolean_options=" 1368 --help 1369 " 1370 1371 case "$prev" in 1372 --link) 1373 case "$cur" in 1374 *:*) 1375 ;; 1376 *) 1377 __docker_complete_containers_running 1378 COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) 1379 __docker_nospace 1380 ;; 1381 esac 1382 return 1383 ;; 1384 $(__docker_to_extglob "$options_with_args") ) 1385 return 1386 ;; 1387 esac 1388 1389 case "$cur" in 1390 -*) 1391 COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) 1392 ;; 1393 *) 1394 local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) ) 1395 if [ $cword -eq $counter ]; then 1396 __docker_complete_networks 1397 elif [ $cword -eq $(($counter + 1)) ]; then 1398 __docker_complete_containers_all 1399 fi 1400 ;; 1401 esac 1402 } 1403 1404 _docker_network_create() { 1405 case "$prev" in 1406 --aux-address|--gateway|--internal|--ip-range|--ipam-opt|--ipv6|--opt|-o|--subnet) 1407 return 1408 ;; 1409 --ipam-driver) 1410 COMPREPLY=( $( compgen -W "default" -- "$cur" ) ) 1411 return 1412 ;; 1413 --driver|-d) 1414 local plugins=" $(__docker_plugins Network) " 1415 # remove drivers that allow one instance only 1416 plugins=${plugins/ host / } 1417 plugins=${plugins/ null / } 1418 COMPREPLY=( $(compgen -W "$plugins" -- "$cur") ) 1419 return 1420 ;; 1421 --label) 1422 return 1423 ;; 1424 esac 1425 1426 case "$cur" in 1427 -*) 1428 COMPREPLY=( $( compgen -W "--aux-address --driver -d --gateway --help --internal --ip-range --ipam-driver --ipam-opt --ipv6 --label --opt -o --subnet" -- "$cur" ) ) 1429 ;; 1430 esac 1431 } 1432 1433 _docker_network_disconnect() { 1434 case "$cur" in 1435 -*) 1436 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1437 ;; 1438 *) 1439 local counter=$(__docker_pos_first_nonflag) 1440 if [ $cword -eq $counter ]; then 1441 __docker_complete_networks 1442 elif [ $cword -eq $(($counter + 1)) ]; then 1443 __docker_complete_containers_in_network "$prev" 1444 fi 1445 ;; 1446 esac 1447 } 1448 1449 _docker_network_inspect() { 1450 case "$prev" in 1451 --format|-f) 1452 return 1453 ;; 1454 esac 1455 1456 case "$cur" in 1457 -*) 1458 COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) 1459 ;; 1460 *) 1461 __docker_complete_networks 1462 esac 1463 } 1464 1465 _docker_network_ls() { 1466 local key=$(__docker_map_key_of_current_option '--filter|-f') 1467 case "$key" in 1468 driver) 1469 local plugins=" $(__docker_plugins Network) " 1470 COMPREPLY=( $(compgen -W "$plugins" -- "${cur##*=}") ) 1471 return 1472 ;; 1473 id) 1474 cur="${cur##*=}" 1475 __docker_complete_network_ids 1476 return 1477 ;; 1478 name) 1479 cur="${cur##*=}" 1480 __docker_complete_network_names 1481 return 1482 ;; 1483 type) 1484 COMPREPLY=( $( compgen -W "builtin custom" -- "${cur##*=}" ) ) 1485 return 1486 ;; 1487 esac 1488 1489 case "$prev" in 1490 --filter|-f) 1491 COMPREPLY=( $( compgen -S = -W "driver id label name type" -- "$cur" ) ) 1492 __docker_nospace 1493 return 1494 ;; 1495 esac 1496 1497 case "$cur" in 1498 -*) 1499 COMPREPLY=( $( compgen -W "--filter -f --help --no-trunc --quiet -q" -- "$cur" ) ) 1500 ;; 1501 esac 1502 } 1503 1504 _docker_network_rm() { 1505 case "$cur" in 1506 -*) 1507 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1508 ;; 1509 *) 1510 __docker_complete_networks type=custom 1511 esac 1512 } 1513 1514 _docker_network() { 1515 local subcommands=" 1516 connect 1517 create 1518 disconnect 1519 inspect 1520 ls 1521 rm 1522 " 1523 __docker_subcommands "$subcommands" && return 1524 1525 case "$cur" in 1526 -*) 1527 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1528 ;; 1529 *) 1530 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 1531 ;; 1532 esac 1533 } 1534 1535 _docker_service() { 1536 local subcommands=" 1537 create 1538 inspect 1539 ls list 1540 rm remove 1541 scale 1542 tasks 1543 update 1544 " 1545 __docker_subcommands "$subcommands" && return 1546 1547 case "$cur" in 1548 -*) 1549 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1550 ;; 1551 *) 1552 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 1553 ;; 1554 esac 1555 } 1556 1557 _docker_service_create() { 1558 _docker_service_update 1559 } 1560 1561 _docker_service_inspect() { 1562 case "$prev" in 1563 --format|-f) 1564 return 1565 ;; 1566 esac 1567 1568 case "$cur" in 1569 -*) 1570 COMPREPLY=( $( compgen -W "--format -f --help --pretty -p" -- "$cur" ) ) 1571 ;; 1572 *) 1573 __docker_complete_services 1574 esac 1575 } 1576 1577 _docker_service_list() { 1578 _docker_service_ls 1579 } 1580 1581 _docker_service_ls() { 1582 case "$prev" in 1583 --format|-f) 1584 return 1585 ;; 1586 esac 1587 1588 case "$cur" in 1589 -*) 1590 COMPREPLY=( $( compgen -W "-f --filter --help --quiet -q" -- "$cur" ) ) 1591 ;; 1592 esac 1593 } 1594 1595 _docker_service_remove() { 1596 _docker_service_rm 1597 } 1598 1599 _docker_service_rm() { 1600 case "$cur" in 1601 -*) 1602 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1603 ;; 1604 *) 1605 __docker_complete_services 1606 esac 1607 } 1608 1609 _docker_service_scale() { 1610 case "$cur" in 1611 -*) 1612 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1613 ;; 1614 *) 1615 COMPREPLY=( $(compgen -S "=" -W "$(__docker_services $1)" -- "$cur") ) 1616 __docker_nospace 1617 ;; 1618 esac 1619 } 1620 1621 _docker_service_tasks() { 1622 case "$prev" in 1623 --format|-f) 1624 return 1625 ;; 1626 esac 1627 1628 case "$cur" in 1629 -*) 1630 COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve -n" -- "$cur" ) ) 1631 ;; 1632 *) 1633 __docker_complete_services 1634 esac 1635 } 1636 1637 _docker_service_update() { 1638 local $subcommand="${words[$subcommand_pos]}" 1639 1640 local options_with_args=" 1641 --constraint 1642 --endpoint-mode 1643 --env -e 1644 --label -l 1645 --limit-cpu 1646 --limit-memory 1647 --mode 1648 --mount -m 1649 --name 1650 --network 1651 --publish -p 1652 --replicas 1653 --reserve-cpu 1654 --reserve-memory 1655 --restart-condition 1656 --restart-delay 1657 --restart-max-attempts 1658 --restart-window 1659 --stop-grace-period 1660 --update-delay 1661 --update-parallelism 1662 --user -u 1663 --workdir -w 1664 " 1665 1666 local boolean_options=" 1667 --help 1668 " 1669 1670 if [ "$subcommand" = "update" ] ; then 1671 options_with_args="$options_with_args 1672 --arg 1673 --command 1674 --image 1675 " 1676 1677 case "$prev" in 1678 --image) 1679 __docker_complete_image_repos_and_tags 1680 return 1681 ;; 1682 esac 1683 fi 1684 1685 case "$prev" in 1686 --endpoint-mode) 1687 COMPREPLY=( $( compgen -W "DNSRR VIP" -- "$cur" ) ) 1688 return 1689 ;; 1690 --env|-e) 1691 COMPREPLY=( $( compgen -e -S = -- "$cur" ) ) 1692 __docker_nospace 1693 return 1694 ;; 1695 --mode) 1696 COMPREPLY=( $( compgen -W "global replicated" -- "$cur" ) ) 1697 return 1698 ;; 1699 --network) 1700 __docker_complete_networks 1701 return 1702 ;; 1703 --restart-condition) 1704 COMPREPLY=( $( compgen -W "any none on_failure" -- "$cur" ) ) 1705 return 1706 ;; 1707 --user|-u) 1708 __docker_complete_user_group 1709 return 1710 ;; 1711 $(__docker_to_extglob "$options_with_args") ) 1712 return 1713 ;; 1714 esac 1715 1716 case "$cur" in 1717 -*) 1718 COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) 1719 ;; 1720 *) 1721 if [ "$subcommand" = "update" ] ; then 1722 __docker_complete_services 1723 fi 1724 esac 1725 } 1726 1727 _docker_swarm() { 1728 local subcommands=" 1729 init 1730 inspect 1731 join 1732 leave 1733 update 1734 " 1735 __docker_subcommands "$subcommands" && return 1736 1737 case "$cur" in 1738 -*) 1739 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1740 ;; 1741 *) 1742 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 1743 ;; 1744 esac 1745 } 1746 1747 _docker_swarm_init() { 1748 case "$prev" in 1749 --auto-accept) 1750 COMPREPLY=( $( compgen -W "manager none worker" -- "$cur" ) ) 1751 return 1752 ;; 1753 --listen-addr|--secret) 1754 return 1755 ;; 1756 esac 1757 1758 case "$cur" in 1759 -*) 1760 COMPREPLY=( $( compgen -W "--auto-accept --force-new-cluster --help --listen-addr --secret" -- "$cur" ) ) 1761 ;; 1762 esac 1763 } 1764 1765 _docker_swarm_inspect() { 1766 case "$prev" in 1767 --format|-f) 1768 return 1769 ;; 1770 esac 1771 1772 case "$cur" in 1773 -*) 1774 COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) 1775 ;; 1776 esac 1777 } 1778 1779 _docker_swarm_join() { 1780 case "$prev" in 1781 --ca-hash|--listen-addr|--secret) 1782 return 1783 ;; 1784 esac 1785 1786 case "$cur" in 1787 -*) 1788 COMPREPLY=( $( compgen -W "--ca-hash --help --listen-addr --manager --secret" -- "$cur" ) ) 1789 ;; 1790 esac 1791 } 1792 1793 _docker_swarm_leave() { 1794 case "$cur" in 1795 -*) 1796 COMPREPLY=( $( compgen -W "--force --help" -- "$cur" ) ) 1797 ;; 1798 esac 1799 } 1800 1801 _docker_swarm_update() { 1802 case "$prev" in 1803 --auto-accept) 1804 COMPREPLY=( $( compgen -W "manager none worker" -- "$cur" ) ) 1805 return 1806 ;; 1807 --cert-expiry|--dispatcher-heartbeat|--secret|--task-history-limit) 1808 return 1809 ;; 1810 esac 1811 1812 case "$cur" in 1813 -*) 1814 COMPREPLY=( $( compgen -W "--auto-accept --cert-expiry --dispatcher-heartbeat --help --secret --task-history-limit" -- "$cur" ) ) 1815 ;; 1816 esac 1817 } 1818 1819 _docker_node() { 1820 local subcommands=" 1821 accept 1822 demote 1823 inspect 1824 ls list 1825 promote 1826 rm remove 1827 tasks 1828 update 1829 " 1830 __docker_subcommands "$subcommands" && return 1831 1832 case "$cur" in 1833 -*) 1834 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1835 ;; 1836 *) 1837 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 1838 ;; 1839 esac 1840 } 1841 1842 _docker_node_accept() { 1843 case "$cur" in 1844 -*) 1845 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1846 ;; 1847 *) 1848 __docker_complete_pending_nodes 1849 esac 1850 } 1851 1852 _docker_node_demote() { 1853 case "$cur" in 1854 -*) 1855 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1856 ;; 1857 *) 1858 __docker_complete_manager_nodes 1859 esac 1860 } 1861 1862 _docker_node_inspect() { 1863 case "$prev" in 1864 --format|-f) 1865 return 1866 ;; 1867 esac 1868 1869 case "$cur" in 1870 -*) 1871 COMPREPLY=( $( compgen -W "--format -f --help --pretty -p" -- "$cur" ) ) 1872 ;; 1873 *) 1874 __docker_complete_nodes 1875 esac 1876 } 1877 1878 _docker_node_list() { 1879 _docker_node_ls 1880 } 1881 1882 _docker_node_ls() { 1883 case "$prev" in 1884 --filter|-f) 1885 return 1886 ;; 1887 esac 1888 1889 case "$cur" in 1890 -*) 1891 COMPREPLY=( $( compgen -W "--filter -f --help --quiet -q" -- "$cur" ) ) 1892 ;; 1893 esac 1894 } 1895 1896 _docker_node_promote() { 1897 case "$cur" in 1898 -*) 1899 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1900 ;; 1901 *) 1902 __docker_complete_worker_nodes 1903 esac 1904 } 1905 1906 _docker_node_remove() { 1907 _docker_node_rm 1908 } 1909 1910 _docker_node_rm() { 1911 case "$cur" in 1912 -*) 1913 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1914 ;; 1915 *) 1916 __docker_complete_nodes 1917 esac 1918 } 1919 1920 _docker_node_tasks() { 1921 case "$prev" in 1922 --filter|-f) 1923 return 1924 ;; 1925 esac 1926 1927 case "$cur" in 1928 -*) 1929 COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve -n" -- "$cur" ) ) 1930 ;; 1931 *) 1932 __docker_complete_nodes_plus_self 1933 esac 1934 } 1935 1936 _docker_node_update() { 1937 case "$prev" in 1938 --availability) 1939 COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) ) 1940 return 1941 ;; 1942 --membership) 1943 COMPREPLY=( $( compgen -W "accepted rejected" -- "$cur" ) ) 1944 return 1945 ;; 1946 --role) 1947 COMPREPLY=( $( compgen -W "manager worker" -- "$cur" ) ) 1948 return 1949 ;; 1950 esac 1951 1952 case "$cur" in 1953 -*) 1954 COMPREPLY=( $( compgen -W "--availability --help --membership --role" -- "$cur" ) ) 1955 ;; 1956 *) 1957 __docker_complete_nodes 1958 esac 1959 } 1960 1961 _docker_pause() { 1962 case "$cur" in 1963 -*) 1964 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1965 ;; 1966 *) 1967 local counter=$(__docker_pos_first_nonflag) 1968 if [ $cword -eq $counter ]; then 1969 __docker_complete_containers_pauseable 1970 fi 1971 ;; 1972 esac 1973 } 1974 1975 _docker_port() { 1976 case "$cur" in 1977 -*) 1978 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1979 ;; 1980 *) 1981 local counter=$(__docker_pos_first_nonflag) 1982 if [ $cword -eq $counter ]; then 1983 __docker_complete_containers_all 1984 fi 1985 ;; 1986 esac 1987 } 1988 1989 _docker_ps() { 1990 local key=$(__docker_map_key_of_current_option '--filter|-f') 1991 case "$key" in 1992 ancestor) 1993 cur="${cur##*=}" 1994 __docker_complete_images 1995 return 1996 ;; 1997 before) 1998 cur="${cur##*=}" 1999 __docker_complete_containers_all 2000 return 2001 ;; 2002 id) 2003 cur="${cur##*=}" 2004 __docker_complete_container_ids 2005 return 2006 ;; 2007 name) 2008 cur="${cur##*=}" 2009 __docker_complete_container_names 2010 return 2011 ;; 2012 network) 2013 cur="${cur##*=}" 2014 __docker_complete_networks 2015 return 2016 ;; 2017 since) 2018 cur="${cur##*=}" 2019 __docker_complete_containers_all 2020 return 2021 ;; 2022 status) 2023 COMPREPLY=( $( compgen -W "created dead exited paused restarting running" -- "${cur##*=}" ) ) 2024 return 2025 ;; 2026 volume) 2027 cur="${cur##*=}" 2028 __docker_complete_volumes 2029 return 2030 ;; 2031 esac 2032 2033 case "$prev" in 2034 --filter|-f) 2035 COMPREPLY=( $( compgen -S = -W "ancestor before exited id label name network since status volume" -- "$cur" ) ) 2036 __docker_nospace 2037 return 2038 ;; 2039 --format|-n) 2040 return 2041 ;; 2042 esac 2043 2044 case "$cur" in 2045 -*) 2046 COMPREPLY=( $( compgen -W "--all -a --filter -f --format --help --latest -l -n --no-trunc --quiet -q --size -s" -- "$cur" ) ) 2047 ;; 2048 esac 2049 } 2050 2051 _docker_pull() { 2052 case "$cur" in 2053 -*) 2054 COMPREPLY=( $( compgen -W "--all-tags -a --disable-content-trust=false --help" -- "$cur" ) ) 2055 ;; 2056 *) 2057 local counter=$(__docker_pos_first_nonflag) 2058 if [ $cword -eq $counter ]; then 2059 for arg in "${COMP_WORDS[@]}"; do 2060 case "$arg" in 2061 --all-tags|-a) 2062 __docker_complete_image_repos 2063 return 2064 ;; 2065 esac 2066 done 2067 __docker_complete_image_repos_and_tags 2068 fi 2069 ;; 2070 esac 2071 } 2072 2073 _docker_push() { 2074 case "$cur" in 2075 -*) 2076 COMPREPLY=( $( compgen -W "--disable-content-trust=false --help" -- "$cur" ) ) 2077 ;; 2078 *) 2079 local counter=$(__docker_pos_first_nonflag) 2080 if [ $cword -eq $counter ]; then 2081 __docker_complete_image_repos_and_tags 2082 fi 2083 ;; 2084 esac 2085 } 2086 2087 _docker_rename() { 2088 case "$cur" in 2089 -*) 2090 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2091 ;; 2092 *) 2093 local counter=$(__docker_pos_first_nonflag) 2094 if [ $cword -eq $counter ]; then 2095 __docker_complete_containers_all 2096 fi 2097 ;; 2098 esac 2099 } 2100 2101 _docker_restart() { 2102 case "$prev" in 2103 --time|-t) 2104 return 2105 ;; 2106 esac 2107 2108 case "$cur" in 2109 -*) 2110 COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) ) 2111 ;; 2112 *) 2113 __docker_complete_containers_all 2114 ;; 2115 esac 2116 } 2117 2118 _docker_rm() { 2119 case "$cur" in 2120 -*) 2121 COMPREPLY=( $( compgen -W "--force -f --help --link -l --volumes -v" -- "$cur" ) ) 2122 ;; 2123 *) 2124 for arg in "${COMP_WORDS[@]}"; do 2125 case "$arg" in 2126 --force|-f) 2127 __docker_complete_containers_all 2128 return 2129 ;; 2130 esac 2131 done 2132 __docker_complete_containers_stopped 2133 ;; 2134 esac 2135 } 2136 2137 _docker_rmi() { 2138 case "$cur" in 2139 -*) 2140 COMPREPLY=( $( compgen -W "--force -f --help --no-prune" -- "$cur" ) ) 2141 ;; 2142 *) 2143 __docker_complete_images 2144 ;; 2145 esac 2146 } 2147 2148 _docker_run() { 2149 local options_with_args=" 2150 --add-host 2151 --attach -a 2152 --blkio-weight 2153 --blkio-weight-device 2154 --cap-add 2155 --cap-drop 2156 --cgroup-parent 2157 --cidfile 2158 --cpu-period 2159 --cpu-quota 2160 --cpuset-cpus 2161 --cpuset-mems 2162 --cpu-shares -c 2163 --device 2164 --device-read-bps 2165 --device-read-iops 2166 --device-write-bps 2167 --device-write-iops 2168 --dns 2169 --dns-opt 2170 --dns-search 2171 --entrypoint 2172 --env -e 2173 --env-file 2174 --expose 2175 --group-add 2176 --hostname -h 2177 --ip 2178 --ip6 2179 --ipc 2180 --isolation 2181 --kernel-memory 2182 --label-file 2183 --label -l 2184 --link 2185 --link-local-ip 2186 --log-driver 2187 --log-opt 2188 --mac-address 2189 --memory -m 2190 --memory-swap 2191 --memory-swappiness 2192 --memory-reservation 2193 --name 2194 --net 2195 --net-alias 2196 --oom-score-adj 2197 --pid 2198 --pids-limit 2199 --publish -p 2200 --restart 2201 --runtime 2202 --security-opt 2203 --shm-size 2204 --stop-signal 2205 --storage-opt 2206 --tmpfs 2207 --sysctl 2208 --ulimit 2209 --user -u 2210 --userns 2211 --uts 2212 --volume-driver 2213 --volumes-from 2214 --volume -v 2215 --workdir -w 2216 " 2217 2218 local boolean_options=" 2219 --disable-content-trust=false 2220 --help 2221 --interactive -i 2222 --oom-kill-disable 2223 --privileged 2224 --publish-all -P 2225 --read-only 2226 --tty -t 2227 " 2228 2229 if [ "$command" = "run" ] ; then 2230 options_with_args="$options_with_args 2231 --detach-keys 2232 --health-cmd 2233 --health-interval 2234 --health-retries 2235 --health-timeout 2236 " 2237 boolean_options="$boolean_options 2238 --detach -d 2239 --no-healthcheck 2240 --rm 2241 --sig-proxy=false 2242 " 2243 __docker_complete_detach-keys && return 2244 fi 2245 2246 local all_options="$options_with_args $boolean_options" 2247 2248 2249 __docker_complete_log_driver_options && return 2250 __docker_complete_restart && return 2251 2252 local key=$(__docker_map_key_of_current_option '--security-opt') 2253 case "$key" in 2254 label) 2255 [[ $cur == *: ]] && return 2256 COMPREPLY=( $( compgen -W "user: role: type: level: disable" -- "${cur##*=}") ) 2257 if [ "${COMPREPLY[*]}" != "disable" ] ; then 2258 __docker_nospace 2259 fi 2260 return 2261 ;; 2262 seccomp) 2263 local cur=${cur##*=} 2264 _filedir 2265 COMPREPLY+=( $( compgen -W "unconfined" -- "$cur" ) ) 2266 return 2267 ;; 2268 esac 2269 2270 case "$prev" in 2271 --add-host) 2272 case "$cur" in 2273 *:) 2274 __docker_complete_resolved_hostname 2275 return 2276 ;; 2277 esac 2278 ;; 2279 --attach|-a) 2280 COMPREPLY=( $( compgen -W 'stdin stdout stderr' -- "$cur" ) ) 2281 return 2282 ;; 2283 --cap-add|--cap-drop) 2284 __docker_complete_capabilities 2285 return 2286 ;; 2287 --cidfile|--env-file|--label-file) 2288 _filedir 2289 return 2290 ;; 2291 --device|--tmpfs|--volume|-v) 2292 case "$cur" in 2293 *:*) 2294 # TODO somehow do _filedir for stuff inside the image, if it's already specified (which is also somewhat difficult to determine) 2295 ;; 2296 '') 2297 COMPREPLY=( $( compgen -W '/' -- "$cur" ) ) 2298 __docker_nospace 2299 ;; 2300 /*) 2301 _filedir 2302 __docker_nospace 2303 ;; 2304 esac 2305 return 2306 ;; 2307 --env|-e) 2308 COMPREPLY=( $( compgen -e -- "$cur" ) ) 2309 __docker_nospace 2310 return 2311 ;; 2312 --ipc) 2313 case "$cur" in 2314 *:*) 2315 cur="${cur#*:}" 2316 __docker_complete_containers_running 2317 ;; 2318 *) 2319 COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) ) 2320 if [ "$COMPREPLY" = "container:" ]; then 2321 __docker_nospace 2322 fi 2323 ;; 2324 esac 2325 return 2326 ;; 2327 --isolation) 2328 __docker_complete_isolation 2329 return 2330 ;; 2331 --link) 2332 case "$cur" in 2333 *:*) 2334 ;; 2335 *) 2336 __docker_complete_containers_running 2337 COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) 2338 __docker_nospace 2339 ;; 2340 esac 2341 return 2342 ;; 2343 --log-driver) 2344 __docker_complete_log_drivers 2345 return 2346 ;; 2347 --log-opt) 2348 __docker_complete_log_options 2349 return 2350 ;; 2351 --net) 2352 case "$cur" in 2353 container:*) 2354 local cur=${cur#*:} 2355 __docker_complete_containers_all 2356 ;; 2357 *) 2358 COMPREPLY=( $( compgen -W "$(__docker_plugins Network) $(__docker_networks) container:" -- "$cur") ) 2359 if [ "${COMPREPLY[*]}" = "container:" ] ; then 2360 __docker_nospace 2361 fi 2362 ;; 2363 esac 2364 return 2365 ;; 2366 --pid) 2367 case "$cur" in 2368 *:*) 2369 cur="${cur#*:}" 2370 __docker_complete_containers_running 2371 ;; 2372 *) 2373 COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) ) 2374 if [ "$COMPREPLY" = "container:" ]; then 2375 __docker_nospace 2376 fi 2377 ;; 2378 esac 2379 return 2380 ;; 2381 --runtime) 2382 __docker_complete_runtimes 2383 return 2384 ;; 2385 --security-opt) 2386 COMPREPLY=( $( compgen -W "apparmor= label= no-new-privileges seccomp=" -- "$cur") ) 2387 if [ "${COMPREPLY[*]}" != "no-new-privileges" ] ; then 2388 __docker_nospace 2389 fi 2390 return 2391 ;; 2392 --storage-opt) 2393 COMPREPLY=( $( compgen -W "size" -S = -- "$cur") ) 2394 __docker_nospace 2395 return 2396 ;; 2397 --user|-u) 2398 __docker_complete_user_group 2399 return 2400 ;; 2401 --userns) 2402 COMPREPLY=( $( compgen -W "host" -- "$cur" ) ) 2403 return 2404 ;; 2405 --volume-driver) 2406 __docker_complete_plugins Volume 2407 return 2408 ;; 2409 --volumes-from) 2410 __docker_complete_containers_all 2411 return 2412 ;; 2413 $(__docker_to_extglob "$options_with_args") ) 2414 return 2415 ;; 2416 esac 2417 2418 case "$cur" in 2419 -*) 2420 COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) 2421 ;; 2422 *) 2423 local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) ) 2424 if [ $cword -eq $counter ]; then 2425 __docker_complete_images 2426 fi 2427 ;; 2428 esac 2429 } 2430 2431 _docker_save() { 2432 case "$prev" in 2433 --output|-o) 2434 _filedir 2435 return 2436 ;; 2437 esac 2438 2439 case "$cur" in 2440 -*) 2441 COMPREPLY=( $( compgen -W "--help --output -o" -- "$cur" ) ) 2442 ;; 2443 *) 2444 __docker_complete_images 2445 ;; 2446 esac 2447 } 2448 2449 _docker_search() { 2450 local key=$(__docker_map_key_of_current_option '--filter|-f') 2451 case "$key" in 2452 is-automated) 2453 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 2454 return 2455 ;; 2456 is-official) 2457 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 2458 return 2459 ;; 2460 esac 2461 2462 case "$prev" in 2463 --filter|-f) 2464 COMPREPLY=( $( compgen -S = -W "is-automated is-official stars" -- "$cur" ) ) 2465 __docker_nospace 2466 return 2467 ;; 2468 --limit) 2469 return 2470 ;; 2471 esac 2472 2473 case "$cur" in 2474 -*) 2475 COMPREPLY=( $( compgen -W "--filter --help --limit --no-trunc" -- "$cur" ) ) 2476 ;; 2477 esac 2478 } 2479 2480 _docker_start() { 2481 __docker_complete_detach-keys && return 2482 2483 case "$cur" in 2484 -*) 2485 COMPREPLY=( $( compgen -W "--attach -a --detach-keys --help --interactive -i" -- "$cur" ) ) 2486 ;; 2487 *) 2488 __docker_complete_containers_stopped 2489 ;; 2490 esac 2491 } 2492 2493 _docker_stats() { 2494 case "$cur" in 2495 -*) 2496 COMPREPLY=( $( compgen -W "--all -a --help --no-stream" -- "$cur" ) ) 2497 ;; 2498 *) 2499 __docker_complete_containers_running 2500 ;; 2501 esac 2502 } 2503 2504 _docker_stop() { 2505 case "$prev" in 2506 --time|-t) 2507 return 2508 ;; 2509 esac 2510 2511 case "$cur" in 2512 -*) 2513 COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) ) 2514 ;; 2515 *) 2516 __docker_complete_containers_running 2517 ;; 2518 esac 2519 } 2520 2521 _docker_tag() { 2522 case "$cur" in 2523 -*) 2524 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2525 ;; 2526 *) 2527 local counter=$(__docker_pos_first_nonflag) 2528 2529 if [ $cword -eq $counter ]; then 2530 __docker_complete_image_repos_and_tags 2531 return 2532 fi 2533 (( counter++ )) 2534 2535 if [ $cword -eq $counter ]; then 2536 __docker_complete_image_repos_and_tags 2537 return 2538 fi 2539 ;; 2540 esac 2541 } 2542 2543 _docker_unpause() { 2544 case "$cur" in 2545 -*) 2546 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2547 ;; 2548 *) 2549 local counter=$(__docker_pos_first_nonflag) 2550 if [ $cword -eq $counter ]; then 2551 __docker_complete_containers_unpauseable 2552 fi 2553 ;; 2554 esac 2555 } 2556 2557 _docker_update() { 2558 local options_with_args=" 2559 --blkio-weight 2560 --cpu-period 2561 --cpu-quota 2562 --cpuset-cpus 2563 --cpuset-mems 2564 --cpu-shares -c 2565 --kernel-memory 2566 --memory -m 2567 --memory-reservation 2568 --memory-swap 2569 --restart 2570 " 2571 2572 local boolean_options=" 2573 --help 2574 " 2575 2576 local all_options="$options_with_args $boolean_options" 2577 2578 __docker_complete_restart && return 2579 2580 case "$prev" in 2581 $(__docker_to_extglob "$options_with_args") ) 2582 return 2583 ;; 2584 esac 2585 2586 case "$cur" in 2587 -*) 2588 COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) 2589 ;; 2590 *) 2591 __docker_complete_containers_all 2592 ;; 2593 esac 2594 } 2595 2596 _docker_top() { 2597 case "$cur" in 2598 -*) 2599 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2600 ;; 2601 *) 2602 local counter=$(__docker_pos_first_nonflag) 2603 if [ $cword -eq $counter ]; then 2604 __docker_complete_containers_running 2605 fi 2606 ;; 2607 esac 2608 } 2609 2610 _docker_version() { 2611 case "$cur" in 2612 -*) 2613 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2614 ;; 2615 esac 2616 } 2617 2618 _docker_volume_create() { 2619 case "$prev" in 2620 --driver|-d) 2621 __docker_complete_plugins Volume 2622 return 2623 ;; 2624 --label|--name|--opt|-o) 2625 return 2626 ;; 2627 esac 2628 2629 case "$cur" in 2630 -*) 2631 COMPREPLY=( $( compgen -W "--driver -d --help --label --name --opt -o" -- "$cur" ) ) 2632 ;; 2633 esac 2634 } 2635 2636 _docker_volume_inspect() { 2637 case "$prev" in 2638 --format|-f) 2639 return 2640 ;; 2641 esac 2642 2643 case "$cur" in 2644 -*) 2645 COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) 2646 ;; 2647 *) 2648 __docker_complete_volumes 2649 ;; 2650 esac 2651 } 2652 2653 _docker_volume_ls() { 2654 local key=$(__docker_map_key_of_current_option '--filter|-f') 2655 case "$key" in 2656 dangling) 2657 COMPREPLY=( $( compgen -W "true false" -- "${cur##*=}" ) ) 2658 return 2659 ;; 2660 driver) 2661 cur=${cur##*=} 2662 __docker_complete_plugins Volume 2663 return 2664 ;; 2665 name) 2666 cur=${cur##*=} 2667 __docker_complete_volumes 2668 return 2669 ;; 2670 esac 2671 2672 case "$prev" in 2673 --filter|-f) 2674 COMPREPLY=( $( compgen -S = -W "dangling driver name" -- "$cur" ) ) 2675 __docker_nospace 2676 return 2677 ;; 2678 esac 2679 2680 case "$cur" in 2681 -*) 2682 COMPREPLY=( $( compgen -W "--filter -f --help --quiet -q" -- "$cur" ) ) 2683 ;; 2684 esac 2685 } 2686 2687 _docker_volume_rm() { 2688 case "$cur" in 2689 -*) 2690 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2691 ;; 2692 *) 2693 __docker_complete_volumes 2694 ;; 2695 esac 2696 } 2697 2698 _docker_volume() { 2699 local subcommands=" 2700 create 2701 inspect 2702 ls 2703 rm 2704 " 2705 __docker_subcommands "$subcommands" && return 2706 2707 case "$cur" in 2708 -*) 2709 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2710 ;; 2711 *) 2712 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 2713 ;; 2714 esac 2715 } 2716 2717 _docker_wait() { 2718 case "$cur" in 2719 -*) 2720 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2721 ;; 2722 *) 2723 __docker_complete_containers_all 2724 ;; 2725 esac 2726 } 2727 2728 _docker() { 2729 local previous_extglob_setting=$(shopt -p extglob) 2730 shopt -s extglob 2731 2732 local commands=( 2733 attach 2734 build 2735 commit 2736 cp 2737 create 2738 daemon 2739 diff 2740 events 2741 exec 2742 export 2743 history 2744 images 2745 import 2746 info 2747 inspect 2748 kill 2749 load 2750 login 2751 logout 2752 logs 2753 network 2754 node 2755 pause 2756 port 2757 ps 2758 pull 2759 push 2760 rename 2761 restart 2762 rm 2763 rmi 2764 run 2765 save 2766 search 2767 service 2768 start 2769 stats 2770 stop 2771 swarm 2772 tag 2773 top 2774 unpause 2775 update 2776 version 2777 volume 2778 wait 2779 ) 2780 2781 # These options are valid as global options for all client commands 2782 # and valid as command options for `docker daemon` 2783 local global_boolean_options=" 2784 --debug -D 2785 --tls 2786 --tlsverify 2787 " 2788 local global_options_with_args=" 2789 --config 2790 --host -H 2791 --log-level -l 2792 --tlscacert 2793 --tlscert 2794 --tlskey 2795 " 2796 2797 local host config 2798 2799 COMPREPLY=() 2800 local cur prev words cword 2801 _get_comp_words_by_ref -n : cur prev words cword 2802 2803 local command='docker' command_pos=0 subcommand_pos 2804 local counter=1 2805 while [ $counter -lt $cword ]; do 2806 case "${words[$counter]}" in 2807 # save host so that completion can use custom daemon 2808 --host|-H) 2809 (( counter++ )) 2810 host="${words[$counter]}" 2811 ;; 2812 # save config so that completion can use custom configuration directories 2813 --config) 2814 (( counter++ )) 2815 config="${words[$counter]}" 2816 ;; 2817 $(__docker_to_extglob "$global_options_with_args") ) 2818 (( counter++ )) 2819 ;; 2820 -*) 2821 ;; 2822 =) 2823 (( counter++ )) 2824 ;; 2825 *) 2826 command="${words[$counter]}" 2827 command_pos=$counter 2828 break 2829 ;; 2830 esac 2831 (( counter++ )) 2832 done 2833 2834 local binary="${words[0]}" 2835 if [[ $binary == ?(*/)dockerd ]] ; then 2836 # for the dockerd binary, we reuse completion of `docker daemon`. 2837 # dockerd does not have subcommands and global options. 2838 command=daemon 2839 command_pos=0 2840 fi 2841 2842 local completions_func=_docker_${command} 2843 declare -F $completions_func >/dev/null && $completions_func 2844 2845 eval "$previous_extglob_setting" 2846 return 0 2847 } 2848 2849 eval "$__docker_previous_extglob_setting" 2850 unset __docker_previous_extglob_setting 2851 2852 complete -F _docker docker dockerd