github.com/fabiokung/docker@v0.11.2-0.20170222101415-4534dcd49497/contrib/completion/bash/docker (about) 1 #!/usr/bin/env 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_CONTAINER_IDS 24 # DOCKER_COMPLETION_SHOW_NETWORK_IDS 25 # DOCKER_COMPLETION_SHOW_NODE_IDS 26 # DOCKER_COMPLETION_SHOW_PLUGIN_IDS 27 # DOCKER_COMPLETION_SHOW_SECRET_IDS 28 # DOCKER_COMPLETION_SHOW_SERVICE_IDS 29 # "no" - Show names only (default) 30 # "yes" - Show names and ids 31 # 32 # You can tailor completion for the "events", "history", "inspect", "run", 33 # "rmi" and "save" commands by settings the following environment 34 # variables: 35 # 36 # DOCKER_COMPLETION_SHOW_IMAGE_IDS 37 # "none" - Show names only (default) 38 # "non-intermediate" - Show names and ids, but omit intermediate image IDs 39 # "all" - Show names and ids, including intermediate image IDs 40 # 41 # DOCKER_COMPLETION_SHOW_TAGS 42 # "yes" - include tags in completion options (default) 43 # "no" - don't include tags in completion options 44 45 # 46 # Note: 47 # Currently, the completions will not work if the docker daemon is not 48 # bound to the default communication port/socket 49 # If the docker daemon is using a unix socket for communication your user 50 # must have access to the socket for the completions to function correctly 51 # 52 # Note for developers: 53 # Please arrange options sorted alphabetically by long name with the short 54 # options immediately following their corresponding long form. 55 # This order should be applied to lists, alternatives and code blocks. 56 57 __docker_previous_extglob_setting=$(shopt -p extglob) 58 shopt -s extglob 59 60 __docker_q() { 61 docker ${host:+-H "$host"} ${config:+--config "$config"} 2>/dev/null "$@" 62 } 63 64 # __docker_containers returns a list of containers. Additional options to 65 # `docker ps` may be specified in order to filter the list, e.g. 66 # `__docker_containers --filter status=running` 67 # By default, only names are returned. 68 # Set DOCKER_COMPLETION_SHOW_CONTAINER_IDS=yes to also complete IDs. 69 # An optional first option `--id|--name` may be used to limit the 70 # output to the IDs or names of matching items. This setting takes 71 # precedence over the environment setting. 72 __docker_containers() { 73 local format 74 if [ "$1" = "--id" ] ; then 75 format='{{.ID}}' 76 shift 77 elif [ "$1" = "--name" ] ; then 78 format='{{.Names}}' 79 shift 80 elif [ "${DOCKER_COMPLETION_SHOW_CONTAINER_IDS}" = yes ] ; then 81 format='{{.ID}} {{.Names}}' 82 else 83 format='{{.Names}}' 84 fi 85 __docker_q ps --format "$format" "$@" 86 } 87 88 # __docker_complete_containers applies completion of containers based on the current 89 # value of `$cur` or the value of the optional first option `--cur`, if given. 90 # Additional filters may be appended, see `__docker_containers`. 91 __docker_complete_containers() { 92 local current="$cur" 93 if [ "$1" = "--cur" ] ; then 94 current="$2" 95 shift 2 96 fi 97 COMPREPLY=( $(compgen -W "$(__docker_containers "$@")" -- "$current") ) 98 } 99 100 __docker_complete_containers_all() { 101 __docker_complete_containers "$@" --all 102 } 103 104 __docker_complete_containers_running() { 105 __docker_complete_containers "$@" --filter status=running 106 } 107 108 __docker_complete_containers_stopped() { 109 __docker_complete_containers "$@" --filter status=exited 110 } 111 112 __docker_complete_containers_unpauseable() { 113 __docker_complete_containers "$@" --filter status=paused 114 } 115 116 __docker_complete_container_names() { 117 local containers=( $(__docker_q ps -aq --no-trunc) ) 118 local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") ) 119 names=( "${names[@]#/}" ) # trim off the leading "/" from the container names 120 COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") ) 121 } 122 123 __docker_complete_container_ids() { 124 local containers=( $(__docker_q ps -aq) ) 125 COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") ) 126 } 127 128 __docker_images() { 129 local images_args="" 130 131 case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in 132 all) 133 images_args="--no-trunc -a" 134 ;; 135 non-intermediate) 136 images_args="--no-trunc" 137 ;; 138 esac 139 140 local repo_print_command 141 if [ "${DOCKER_COMPLETION_SHOW_TAGS:-yes}" = "yes" ]; then 142 repo_print_command='print $1; print $1":"$2' 143 else 144 repo_print_command='print $1' 145 fi 146 147 local awk_script 148 case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in 149 all|non-intermediate) 150 awk_script='NR>1 { print $3; if ($1 != "<none>") { '"$repo_print_command"' } }' 151 ;; 152 none|*) 153 awk_script='NR>1 && $1 != "<none>" { '"$repo_print_command"' }' 154 ;; 155 esac 156 157 __docker_q images $images_args | awk "$awk_script" | grep -v '<none>$' 158 } 159 160 __docker_complete_images() { 161 COMPREPLY=( $(compgen -W "$(__docker_images)" -- "$cur") ) 162 __ltrim_colon_completions "$cur" 163 } 164 165 __docker_complete_image_repos() { 166 local repos="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1 }')" 167 COMPREPLY=( $(compgen -W "$repos" -- "$cur") ) 168 } 169 170 __docker_complete_image_repos_and_tags() { 171 local reposAndTags="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1; print $1":"$2 }')" 172 COMPREPLY=( $(compgen -W "$reposAndTags" -- "$cur") ) 173 __ltrim_colon_completions "$cur" 174 } 175 176 # __docker_networks returns a list of all networks. Additional options to 177 # `docker network ls` may be specified in order to filter the list, e.g. 178 # `__docker_networks --filter type=custom` 179 # By default, only names are returned. 180 # Set DOCKER_COMPLETION_SHOW_NETWORK_IDS=yes to also complete IDs. 181 # An optional first option `--id|--name` may be used to limit the 182 # output to the IDs or names of matching items. This setting takes 183 # precedence over the environment setting. 184 __docker_networks() { 185 local format 186 if [ "$1" = "--id" ] ; then 187 format='{{.ID}}' 188 shift 189 elif [ "$1" = "--name" ] ; then 190 format='{{.Name}}' 191 shift 192 elif [ "${DOCKER_COMPLETION_SHOW_NETWORK_IDS}" = yes ] ; then 193 format='{{.ID}} {{.Name}}' 194 else 195 format='{{.Name}}' 196 fi 197 __docker_q network ls --format "$format" "$@" 198 } 199 200 # __docker_complete_networks applies completion of networks based on the current 201 # value of `$cur` or the value of the optional first option `--cur`, if given. 202 # Additional filters may be appended, see `__docker_networks`. 203 __docker_complete_networks() { 204 local current="$cur" 205 if [ "$1" = "--cur" ] ; then 206 current="$2" 207 shift 2 208 fi 209 COMPREPLY=( $(compgen -W "$(__docker_networks "$@")" -- "$current") ) 210 } 211 212 __docker_complete_containers_in_network() { 213 local containers=$(__docker_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1") 214 COMPREPLY=( $(compgen -W "$containers" -- "$cur") ) 215 } 216 217 # __docker_volumes returns a list of all volumes. Additional options to 218 # `docker volume ls` may be specified in order to filter the list, e.g. 219 # `__docker_volumes --filter dangling=true` 220 # Because volumes do not have IDs, this function does not distinguish between 221 # IDs and names. 222 __docker_volumes() { 223 __docker_q volume ls -q "$@" 224 } 225 226 # __docker_complete_volumes applies completion of volumes based on the current 227 # value of `$cur` or the value of the optional first option `--cur`, if given. 228 # Additional filters may be appended, see `__docker_volumes`. 229 __docker_complete_volumes() { 230 local current="$cur" 231 if [ "$1" = "--cur" ] ; then 232 current="$2" 233 shift 2 234 fi 235 COMPREPLY=( $(compgen -W "$(__docker_volumes "$@")" -- "$current") ) 236 } 237 238 # __docker_plugins_bundled returns a list of all plugins of a given type. 239 # The type has to be specified with the mandatory option `--type`. 240 # Valid types are: Network, Volume, Authorization. 241 # Completions may be added or removed with `--add` and `--remove` 242 # This function only deals with plugins that come bundled with Docker. 243 # For plugins managed by `docker plugin`, see `__docker_plugins_installed`. 244 __docker_plugins_bundled() { 245 local type add=() remove=() 246 while true ; do 247 case "$1" in 248 --type) 249 type="$2" 250 shift 2 251 ;; 252 --add) 253 add+=("$2") 254 shift 2 255 ;; 256 --remove) 257 remove+=("$2") 258 shift 2 259 ;; 260 *) 261 break 262 ;; 263 esac 264 done 265 266 local plugins=($(__docker_q info --format "{{range \$i, \$p := .Plugins.$type}}{{.}} {{end}}")) 267 for del in "${remove[@]}" ; do 268 plugins=(${plugins[@]/$del/}) 269 done 270 echo "${plugins[@]} ${add[@]}" 271 } 272 273 # __docker_complete_plugins_bundled applies completion of plugins based on the current 274 # value of `$cur` or the value of the optional first option `--cur`, if given. 275 # The plugin type has to be specified with the next option `--type`. 276 # This function only deals with plugins that come bundled with Docker. 277 # For completion of plugins managed by `docker plugin`, see 278 # `__docker_complete_plugins_installed`. 279 __docker_complete_plugins_bundled() { 280 local current="$cur" 281 if [ "$1" = "--cur" ] ; then 282 current="$2" 283 shift 2 284 fi 285 COMPREPLY=( $(compgen -W "$(__docker_plugins_bundled "$@")" -- "$current") ) 286 } 287 288 # __docker_plugins_installed returns a list of all plugins that were installed with 289 # the Docker plugin API. 290 # By default, only names are returned. 291 # Set DOCKER_COMPLETION_SHOW_PLUGIN_IDS=yes to also complete IDs. 292 # Additional options to `docker plugin ls` may be specified in order to filter the list, 293 # e.g. `__docker_plugins_installed --filter enabled=true` 294 # For built-in pugins, see `__docker_plugins_bundled`. 295 __docker_plugins_installed() { 296 local format 297 if [ "$DOCKER_COMPLETION_SHOW_PLUGIN_IDS" = yes ] ; then 298 format='{{.ID}} {{.Name}}' 299 else 300 format='{{.Name}}' 301 fi 302 __docker_q plugin ls --format "$format" "$@" 303 } 304 305 # __docker_complete_plugins_installed applies completion of plugins that were installed 306 # with the Docker plugin API, based on the current value of `$cur` or the value of 307 # the optional first option `--cur`, if given. 308 # Additional filters may be appended, see `__docker_plugins_installed`. 309 # For completion of built-in pugins, see `__docker_complete_plugins_bundled`. 310 __docker_complete_plugins_installed() { 311 local current="$cur" 312 if [ "$1" = "--cur" ] ; then 313 current="$2" 314 shift 2 315 fi 316 COMPREPLY=( $(compgen -W "$(__docker_plugins_installed "$@")" -- "$current") ) 317 } 318 319 __docker_runtimes() { 320 __docker_q info | sed -n 's/^Runtimes: \(.*\)/\1/p' 321 } 322 323 __docker_complete_runtimes() { 324 COMPREPLY=( $(compgen -W "$(__docker_runtimes)" -- "$cur") ) 325 } 326 327 # __docker_secrets returns a list of all secrets. 328 # By default, only names of secrets are returned. 329 # Set DOCKER_COMPLETION_SHOW_SECRET_IDS=yes to also complete IDs of secrets. 330 __docker_secrets() { 331 local fields='$2' # default: name only 332 [ "${DOCKER_COMPLETION_SHOW_SECRET_IDS}" = yes ] && fields='$1,$2' # ID and name 333 334 __docker_q secret ls | awk "NR>1 {print $fields}" 335 } 336 337 # __docker_complete_secrets applies completion of secrets based on the current value 338 # of `$cur`. 339 __docker_complete_secrets() { 340 COMPREPLY=( $(compgen -W "$(__docker_secrets)" -- "$cur") ) 341 } 342 343 # __docker_stacks returns a list of all stacks. 344 __docker_stacks() { 345 __docker_q stack ls | awk 'NR>1 {print $1}' 346 } 347 348 # __docker_complete_stacks applies completion of stacks based on the current value 349 # of `$cur` or the value of the optional first option `--cur`, if given. 350 __docker_complete_stacks() { 351 local current="$cur" 352 if [ "$1" = "--cur" ] ; then 353 current="$2" 354 shift 2 355 fi 356 COMPREPLY=( $(compgen -W "$(__docker_stacks "$@")" -- "$current") ) 357 } 358 359 # __docker_nodes returns a list of all nodes. Additional options to 360 # `docker node ls` may be specified in order to filter the list, e.g. 361 # `__docker_nodes --filter role=manager` 362 # By default, only node names are returned. 363 # Set DOCKER_COMPLETION_SHOW_NODE_IDS=yes to also complete node IDs. 364 # An optional first option `--id|--name` may be used to limit the 365 # output to the IDs or names of matching items. This setting takes 366 # precedence over the environment setting. 367 # Completions may be added with `--add`, e.g. `--add self`. 368 __docker_nodes() { 369 local add=() 370 local fields='$2' # default: node name only 371 [ "${DOCKER_COMPLETION_SHOW_NODE_IDS}" = yes ] && fields='$1,$2' # ID and name 372 373 while true ; do 374 case "$1" in 375 --id) 376 fields='$1' # IDs only 377 shift 378 ;; 379 --name) 380 fields='$2' # names only 381 shift 382 ;; 383 --add) 384 add+=("$2") 385 shift 2 386 ;; 387 *) 388 break 389 ;; 390 esac 391 done 392 393 echo $(__docker_q node ls "$@" | tr -d '*' | awk "NR>1 {print $fields}") "${add[@]}" 394 } 395 396 # __docker_complete_nodes applies completion of nodes based on the current 397 # value of `$cur` or the value of the optional first option `--cur`, if given. 398 # Additional filters may be appended, see `__docker_nodes`. 399 __docker_complete_nodes() { 400 local current="$cur" 401 if [ "$1" = "--cur" ] ; then 402 current="$2" 403 shift 2 404 fi 405 COMPREPLY=( $(compgen -W "$(__docker_nodes "$@")" -- "$current") ) 406 } 407 408 __docker_complete_nodes_plus_self() { 409 __docker_complete_nodes --add self "$@" 410 } 411 412 # __docker_services returns a list of all services. Additional options to 413 # `docker service ls` may be specified in order to filter the list, e.g. 414 # `__docker_services --filter name=xxx` 415 # By default, only node names are returned. 416 # Set DOCKER_COMPLETION_SHOW_SERVICE_IDS=yes to also complete IDs. 417 # An optional first option `--id|--name` may be used to limit the 418 # output to the IDs or names of matching items. This setting takes 419 # precedence over the environment setting. 420 __docker_services() { 421 local fields='$2' # default: service name only 422 [ "${DOCKER_COMPLETION_SHOW_SERVICE_IDS}" = yes ] && fields='$1,$2' # ID & name 423 424 if [ "$1" = "--id" ] ; then 425 fields='$1' # IDs only 426 shift 427 elif [ "$1" = "--name" ] ; then 428 fields='$2' # names only 429 shift 430 fi 431 __docker_q service ls "$@" | awk "NR>1 {print $fields}" 432 } 433 434 # __docker_complete_services applies completion of services based on the current 435 # value of `$cur` or the value of the optional first option `--cur`, if given. 436 # Additional filters may be appended, see `__docker_services`. 437 __docker_complete_services() { 438 local current="$cur" 439 if [ "$1" = "--cur" ] ; then 440 current="$2" 441 shift 2 442 fi 443 COMPREPLY=( $(compgen -W "$(__docker_services "$@")" -- "$current") ) 444 } 445 446 # __docker_append_to_completions appends the word passed as an argument to every 447 # word in `$COMPREPLY`. 448 # Normally you do this with `compgen -S` while generating the completions. 449 # This function allows you to append a suffix later. It allows you to use 450 # the __docker_complete_XXX functions in cases where you need a suffix. 451 __docker_append_to_completions() { 452 COMPREPLY=( ${COMPREPLY[@]/%/"$1"} ) 453 } 454 455 # __docker_daemon_is_experimental tests whether the currently configured Docker 456 # daemon runs in experimental mode. If so, the function exits with 0 (true). 457 # Otherwise, or if the result cannot be determined, the exit value is 1 (false). 458 __docker_daemon_is_experimental() { 459 [ "$(__docker_q version -f '{{.Server.Experimental}}')" = "true" ] 460 } 461 462 # __docker_daemon_os_is tests whether the currently configured Docker daemon runs 463 # on the operating system passed in as the first argument. 464 # It does so by querying the daemon for its OS. The result is cached for the duration 465 # of one invocation of bash completion so that this function can be used to test for 466 # several different operating systems without additional costs. 467 # Known operating systems: linux, windows. 468 __docker_daemon_os_is() { 469 local expected_os="$1" 470 local actual_os=${daemon_os=$(__docker_q version -f '{{.Server.Os}}')} 471 [ "$actual_os" = "$expected_os" ] 472 } 473 474 # __docker_pos_first_nonflag finds the position of the first word that is neither 475 # option nor an option's argument. If there are options that require arguments, 476 # you should pass a glob describing those options, e.g. "--option1|-o|--option2" 477 # Use this function to restrict completions to exact positions after the argument list. 478 __docker_pos_first_nonflag() { 479 local argument_flags=$1 480 481 local counter=$((${subcommand_pos:-${command_pos}} + 1)) 482 while [ $counter -le $cword ]; do 483 if [ -n "$argument_flags" ] && eval "case '${words[$counter]}' in $argument_flags) true ;; *) false ;; esac"; then 484 (( counter++ )) 485 # eat "=" in case of --option=arg syntax 486 [ "${words[$counter]}" = "=" ] && (( counter++ )) 487 else 488 case "${words[$counter]}" in 489 -*) 490 ;; 491 *) 492 break 493 ;; 494 esac 495 fi 496 497 # Bash splits words at "=", retaining "=" as a word, examples: 498 # "--debug=false" => 3 words, "--log-opt syslog-facility=daemon" => 4 words 499 while [ "${words[$counter + 1]}" = "=" ] ; do 500 counter=$(( counter + 2)) 501 done 502 503 (( counter++ )) 504 done 505 506 echo $counter 507 } 508 509 # __docker_map_key_of_current_option returns `key` if we are currently completing the 510 # value of a map option (`key=value`) which matches the extglob given as an argument. 511 # This function is needed for key-specific completions. 512 __docker_map_key_of_current_option() { 513 local glob="$1" 514 515 local key glob_pos 516 if [ "$cur" = "=" ] ; then # key= case 517 key="$prev" 518 glob_pos=$((cword - 2)) 519 elif [[ $cur == *=* ]] ; then # key=value case (OSX) 520 key=${cur%=*} 521 glob_pos=$((cword - 1)) 522 elif [ "$prev" = "=" ] ; then 523 key=${words[$cword - 2]} # key=value case 524 glob_pos=$((cword - 3)) 525 else 526 return 527 fi 528 529 [ "${words[$glob_pos]}" = "=" ] && ((glob_pos--)) # --option=key=value syntax 530 531 [[ ${words[$glob_pos]} == @($glob) ]] && echo "$key" 532 } 533 534 # __docker_value_of_option returns the value of the first option matching `option_glob`. 535 # Valid values for `option_glob` are option names like `--log-level` and globs like 536 # `--log-level|-l` 537 # Only positions between the command and the current word are considered. 538 __docker_value_of_option() { 539 local option_extglob=$(__docker_to_extglob "$1") 540 541 local counter=$((command_pos + 1)) 542 while [ $counter -lt $cword ]; do 543 case ${words[$counter]} in 544 $option_extglob ) 545 echo ${words[$counter + 1]} 546 break 547 ;; 548 esac 549 (( counter++ )) 550 done 551 } 552 553 # __docker_to_alternatives transforms a multiline list of strings into a single line 554 # string with the words separated by `|`. 555 # This is used to prepare arguments to __docker_pos_first_nonflag(). 556 __docker_to_alternatives() { 557 local parts=( $1 ) 558 local IFS='|' 559 echo "${parts[*]}" 560 } 561 562 # __docker_to_extglob transforms a multiline list of options into an extglob pattern 563 # suitable for use in case statements. 564 __docker_to_extglob() { 565 local extglob=$( __docker_to_alternatives "$1" ) 566 echo "@($extglob)" 567 } 568 569 # __docker_subcommands processes subcommands 570 # Locates the first occurrence of any of the subcommands contained in the 571 # first argument. In case of a match, calls the corresponding completion 572 # function and returns 0. 573 # If no match is found, 1 is returned. The calling function can then 574 # continue processing its completion. 575 # 576 # TODO if the preceding command has options that accept arguments and an 577 # argument is equal ot one of the subcommands, this is falsely detected as 578 # a match. 579 __docker_subcommands() { 580 local subcommands="$1" 581 582 local counter=$(($command_pos + 1)) 583 while [ $counter -lt $cword ]; do 584 case "${words[$counter]}" in 585 $(__docker_to_extglob "$subcommands") ) 586 subcommand_pos=$counter 587 local subcommand=${words[$counter]} 588 local completions_func=_docker_${command}_${subcommand} 589 declare -F $completions_func >/dev/null && $completions_func 590 return 0 591 ;; 592 esac 593 (( counter++ )) 594 done 595 return 1 596 } 597 598 # __docker_nospace suppresses trailing whitespace 599 __docker_nospace() { 600 # compopt is not available in ancient bash versions 601 type compopt &>/dev/null && compopt -o nospace 602 } 603 604 __docker_complete_resolved_hostname() { 605 command -v host >/dev/null 2>&1 || return 606 COMPREPLY=( $(host 2>/dev/null "${cur%:}" | awk '/has address/ {print $4}') ) 607 } 608 609 __docker_local_interfaces() { 610 command -v ip >/dev/null 2>&1 || return 611 ip addr show scope global 2>/dev/null | sed -n 's| \+inet \([0-9.]\+\).* \([^ ]\+\)|\1 \2|p' 612 } 613 614 __docker_complete_local_interfaces() { 615 local additional_interface 616 if [ "$1" = "--add" ] ; then 617 additional_interface="$2" 618 fi 619 620 COMPREPLY=( $( compgen -W "$(__docker_local_interfaces) $additional_interface" -- "$cur" ) ) 621 } 622 623 # __docker_complete_capabilities_addable completes Linux capabilities which are 624 # not granted by default and may be added. 625 # see https://docs.docker.com/engine/reference/run/#/runtime-privilege-and-linux-capabilities 626 __docker_complete_capabilities_addable() { 627 COMPREPLY=( $( compgen -W " 628 ALL 629 AUDIT_CONTROL 630 BLOCK_SUSPEND 631 DAC_READ_SEARCH 632 IPC_LOCK 633 IPC_OWNER 634 LEASE 635 LINUX_IMMUTABLE 636 MAC_ADMIN 637 MAC_OVERRIDE 638 NET_ADMIN 639 NET_BROADCAST 640 SYS_ADMIN 641 SYS_BOOT 642 SYSLOG 643 SYS_MODULE 644 SYS_NICE 645 SYS_PACCT 646 SYS_PTRACE 647 SYS_RAWIO 648 SYS_RESOURCE 649 SYS_TIME 650 SYS_TTY_CONFIG 651 WAKE_ALARM 652 " -- "$cur" ) ) 653 } 654 655 # __docker_complete_capabilities_droppable completes Linux capability options which are 656 # allowed by default and can be dropped. 657 # see https://docs.docker.com/engine/reference/run/#/runtime-privilege-and-linux-capabilities 658 __docker_complete_capabilities_droppable() { 659 COMPREPLY=( $( compgen -W " 660 ALL 661 AUDIT_WRITE 662 CHOWN 663 DAC_OVERRIDE 664 FOWNER 665 FSETID 666 KILL 667 MKNOD 668 NET_BIND_SERVICE 669 NET_RAW 670 SETFCAP 671 SETGID 672 SETPCAP 673 SETUID 674 SYS_CHROOT 675 " -- "$cur" ) ) 676 } 677 678 __docker_complete_detach-keys() { 679 case "$prev" in 680 --detach-keys) 681 case "$cur" in 682 *,) 683 COMPREPLY=( $( compgen -W "${cur}ctrl-" -- "$cur" ) ) 684 ;; 685 *) 686 COMPREPLY=( $( compgen -W "ctrl-" -- "$cur" ) ) 687 ;; 688 esac 689 690 __docker_nospace 691 return 692 ;; 693 esac 694 return 1 695 } 696 697 __docker_complete_isolation() { 698 COMPREPLY=( $( compgen -W "default hyperv process" -- "$cur" ) ) 699 } 700 701 __docker_complete_log_drivers() { 702 COMPREPLY=( $( compgen -W " 703 awslogs 704 etwlogs 705 fluentd 706 gcplogs 707 gelf 708 journald 709 json-file 710 logentries 711 none 712 splunk 713 syslog 714 " -- "$cur" ) ) 715 } 716 717 __docker_complete_log_options() { 718 # see repository docker/docker.github.io/engine/admin/logging/ 719 local common_options="max-buffer-size mode" 720 721 local awslogs_options="$common_options awslogs-region awslogs-group awslogs-stream awslogs-create-group" 722 local fluentd_options="$common_options env fluentd-address fluentd-async-connect fluentd-buffer-limit fluentd-retry-wait fluentd-max-retries labels tag" 723 local gcplogs_options="$common_options env gcp-log-cmd gcp-project labels" 724 local gelf_options="$common_options env gelf-address gelf-compression-level gelf-compression-type labels tag" 725 local journald_options="$common_options env labels tag" 726 local json_file_options="$common_options env labels max-file max-size" 727 local logentries_options="$common_options logentries-token" 728 local syslog_options="$common_options env labels syslog-address syslog-facility syslog-format syslog-tls-ca-cert syslog-tls-cert syslog-tls-key syslog-tls-skip-verify tag" 729 local splunk_options="$common_options env labels splunk-caname splunk-capath splunk-format splunk-gzip splunk-gzip-level splunk-index splunk-insecureskipverify splunk-source splunk-sourcetype splunk-token splunk-url splunk-verify-connection tag" 730 731 local all_options="$fluentd_options $gcplogs_options $gelf_options $journald_options $logentries_options $json_file_options $syslog_options $splunk_options" 732 733 case $(__docker_value_of_option --log-driver) in 734 '') 735 COMPREPLY=( $( compgen -W "$all_options" -S = -- "$cur" ) ) 736 ;; 737 awslogs) 738 COMPREPLY=( $( compgen -W "$awslogs_options" -S = -- "$cur" ) ) 739 ;; 740 fluentd) 741 COMPREPLY=( $( compgen -W "$fluentd_options" -S = -- "$cur" ) ) 742 ;; 743 gcplogs) 744 COMPREPLY=( $( compgen -W "$gcplogs_options" -S = -- "$cur" ) ) 745 ;; 746 gelf) 747 COMPREPLY=( $( compgen -W "$gelf_options" -S = -- "$cur" ) ) 748 ;; 749 journald) 750 COMPREPLY=( $( compgen -W "$journald_options" -S = -- "$cur" ) ) 751 ;; 752 json-file) 753 COMPREPLY=( $( compgen -W "$json_file_options" -S = -- "$cur" ) ) 754 ;; 755 logentries) 756 COMPREPLY=( $( compgen -W "$logentries_options" -S = -- "$cur" ) ) 757 ;; 758 syslog) 759 COMPREPLY=( $( compgen -W "$syslog_options" -S = -- "$cur" ) ) 760 ;; 761 splunk) 762 COMPREPLY=( $( compgen -W "$splunk_options" -S = -- "$cur" ) ) 763 ;; 764 *) 765 return 766 ;; 767 esac 768 769 __docker_nospace 770 } 771 772 __docker_complete_log_driver_options() { 773 local key=$(__docker_map_key_of_current_option '--log-opt') 774 case "$key" in 775 fluentd-async-connect) 776 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 777 return 778 ;; 779 gelf-address) 780 COMPREPLY=( $( compgen -W "udp" -S "://" -- "${cur##*=}" ) ) 781 __docker_nospace 782 return 783 ;; 784 gelf-compression-level) 785 COMPREPLY=( $( compgen -W "1 2 3 4 5 6 7 8 9" -- "${cur##*=}" ) ) 786 return 787 ;; 788 gelf-compression-type) 789 COMPREPLY=( $( compgen -W "gzip none zlib" -- "${cur##*=}" ) ) 790 return 791 ;; 792 mode) 793 COMPREPLY=( $( compgen -W "blocking non-blocking" -- "${cur##*=}" ) ) 794 return 795 ;; 796 syslog-address) 797 COMPREPLY=( $( compgen -W "tcp:// tcp+tls:// udp:// unix://" -- "${cur##*=}" ) ) 798 __docker_nospace 799 __ltrim_colon_completions "${cur}" 800 return 801 ;; 802 syslog-facility) 803 COMPREPLY=( $( compgen -W " 804 auth 805 authpriv 806 cron 807 daemon 808 ftp 809 kern 810 local0 811 local1 812 local2 813 local3 814 local4 815 local5 816 local6 817 local7 818 lpr 819 mail 820 news 821 syslog 822 user 823 uucp 824 " -- "${cur##*=}" ) ) 825 return 826 ;; 827 syslog-format) 828 COMPREPLY=( $( compgen -W "rfc3164 rfc5424 rfc5424micro" -- "${cur##*=}" ) ) 829 return 830 ;; 831 syslog-tls-ca-cert|syslog-tls-cert|syslog-tls-key) 832 _filedir 833 return 834 ;; 835 syslog-tls-skip-verify) 836 COMPREPLY=( $( compgen -W "true" -- "${cur##*=}" ) ) 837 return 838 ;; 839 splunk-url) 840 COMPREPLY=( $( compgen -W "http:// https://" -- "${cur##*=}" ) ) 841 __docker_nospace 842 __ltrim_colon_completions "${cur}" 843 return 844 ;; 845 splunk-gzip|splunk-insecureskipverify|splunk-verify-connection) 846 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 847 return 848 ;; 849 splunk-format) 850 COMPREPLY=( $( compgen -W "inline json raw" -- "${cur##*=}" ) ) 851 return 852 ;; 853 esac 854 return 1 855 } 856 857 __docker_complete_log_levels() { 858 COMPREPLY=( $( compgen -W "debug info warn error fatal" -- "$cur" ) ) 859 } 860 861 __docker_complete_restart() { 862 case "$prev" in 863 --restart) 864 case "$cur" in 865 on-failure:*) 866 ;; 867 *) 868 COMPREPLY=( $( compgen -W "always no on-failure on-failure: unless-stopped" -- "$cur") ) 869 ;; 870 esac 871 return 872 ;; 873 esac 874 return 1 875 } 876 877 # __docker_complete_signals returns a subset of the available signals that is most likely 878 # relevant in the context of docker containers 879 __docker_complete_signals() { 880 local signals=( 881 SIGCONT 882 SIGHUP 883 SIGINT 884 SIGKILL 885 SIGQUIT 886 SIGSTOP 887 SIGTERM 888 SIGUSR1 889 SIGUSR2 890 ) 891 COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo $cur | tr '[:lower:]' '[:upper:]')" ) ) 892 } 893 894 __docker_complete_user_group() { 895 if [[ $cur == *:* ]] ; then 896 COMPREPLY=( $(compgen -g -- "${cur#*:}") ) 897 else 898 COMPREPLY=( $(compgen -u -S : -- "$cur") ) 899 __docker_nospace 900 fi 901 } 902 903 _docker_docker() { 904 # global options that may appear after the docker command 905 local boolean_options=" 906 $global_boolean_options 907 --help 908 --version -v 909 " 910 911 case "$prev" in 912 --config) 913 _filedir -d 914 return 915 ;; 916 --log-level|-l) 917 __docker_complete_log_levels 918 return 919 ;; 920 $(__docker_to_extglob "$global_options_with_args") ) 921 return 922 ;; 923 esac 924 925 case "$cur" in 926 -*) 927 COMPREPLY=( $( compgen -W "$boolean_options $global_options_with_args" -- "$cur" ) ) 928 ;; 929 *) 930 local counter=$( __docker_pos_first_nonflag "$(__docker_to_extglob "$global_options_with_args")" ) 931 if [ $cword -eq $counter ]; then 932 __docker_daemon_is_experimental && commands+=(${experimental_commands[*]}) 933 COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) ) 934 fi 935 ;; 936 esac 937 } 938 939 _docker_attach() { 940 _docker_container_attach 941 } 942 943 _docker_build() { 944 _docker_image_build 945 } 946 947 948 _docker_checkpoint() { 949 local subcommands=" 950 create 951 ls 952 rm 953 " 954 local aliases=" 955 list 956 remove 957 " 958 __docker_subcommands "$subcommands $aliases" && return 959 960 case "$cur" in 961 -*) 962 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 963 ;; 964 *) 965 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 966 ;; 967 esac 968 } 969 970 _docker_checkpoint_create() { 971 case "$prev" in 972 --checkpoint-dir) 973 _filedir -d 974 return 975 ;; 976 esac 977 978 case "$cur" in 979 -*) 980 COMPREPLY=( $( compgen -W "--checkpoint-dir --help --leave-running" -- "$cur" ) ) 981 ;; 982 *) 983 local counter=$(__docker_pos_first_nonflag '--checkpoint-dir') 984 if [ $cword -eq $counter ]; then 985 __docker_complete_containers_running 986 fi 987 ;; 988 esac 989 } 990 991 _docker_checkpoint_ls() { 992 case "$prev" in 993 --checkpoint-dir) 994 _filedir -d 995 return 996 ;; 997 esac 998 999 case "$cur" in 1000 -*) 1001 COMPREPLY=( $( compgen -W "--checkpoint-dir --help" -- "$cur" ) ) 1002 ;; 1003 *) 1004 local counter=$(__docker_pos_first_nonflag '--checkpoint-dir') 1005 if [ $cword -eq $counter ]; then 1006 __docker_complete_containers_all 1007 fi 1008 ;; 1009 esac 1010 } 1011 1012 _docker_checkpoint_rm() { 1013 case "$prev" in 1014 --checkpoint-dir) 1015 _filedir -d 1016 return 1017 ;; 1018 esac 1019 1020 case "$cur" in 1021 -*) 1022 COMPREPLY=( $( compgen -W "--checkpoint-dir --help" -- "$cur" ) ) 1023 ;; 1024 *) 1025 local counter=$(__docker_pos_first_nonflag '--checkpoint-dir') 1026 if [ $cword -eq $counter ]; then 1027 __docker_complete_containers_all 1028 elif [ $cword -eq $(($counter + 1)) ]; then 1029 COMPREPLY=( $( compgen -W "$(__docker_q checkpoint ls "$prev" | sed 1d)" -- "$cur" ) ) 1030 fi 1031 ;; 1032 esac 1033 } 1034 1035 1036 _docker_container() { 1037 local subcommands=" 1038 attach 1039 commit 1040 cp 1041 create 1042 diff 1043 exec 1044 export 1045 inspect 1046 kill 1047 logs 1048 ls 1049 pause 1050 port 1051 prune 1052 rename 1053 restart 1054 rm 1055 run 1056 start 1057 stats 1058 stop 1059 top 1060 unpause 1061 update 1062 wait 1063 " 1064 local aliases=" 1065 list 1066 ps 1067 " 1068 __docker_subcommands "$subcommands $aliases" && return 1069 1070 case "$cur" in 1071 -*) 1072 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1073 ;; 1074 *) 1075 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 1076 ;; 1077 esac 1078 } 1079 1080 _docker_container_attach() { 1081 __docker_complete_detach-keys && return 1082 1083 case "$cur" in 1084 -*) 1085 COMPREPLY=( $( compgen -W "--detach-keys --help --no-stdin --sig-proxy=false" -- "$cur" ) ) 1086 ;; 1087 *) 1088 local counter=$(__docker_pos_first_nonflag '--detach-keys') 1089 if [ $cword -eq $counter ]; then 1090 __docker_complete_containers_running 1091 fi 1092 ;; 1093 esac 1094 } 1095 1096 _docker_container_commit() { 1097 case "$prev" in 1098 --author|-a|--change|-c|--message|-m) 1099 return 1100 ;; 1101 esac 1102 1103 case "$cur" in 1104 -*) 1105 COMPREPLY=( $( compgen -W "--author -a --change -c --help --message -m --pause=false -p=false" -- "$cur" ) ) 1106 ;; 1107 *) 1108 local counter=$(__docker_pos_first_nonflag '--author|-a|--change|-c|--message|-m') 1109 1110 if [ $cword -eq $counter ]; then 1111 __docker_complete_containers_all 1112 return 1113 fi 1114 (( counter++ )) 1115 1116 if [ $cword -eq $counter ]; then 1117 __docker_complete_image_repos_and_tags 1118 return 1119 fi 1120 ;; 1121 esac 1122 } 1123 1124 _docker_container_cp() { 1125 case "$cur" in 1126 -*) 1127 COMPREPLY=( $( compgen -W "--follow-link -L --help" -- "$cur" ) ) 1128 ;; 1129 *) 1130 local counter=$(__docker_pos_first_nonflag) 1131 if [ $cword -eq $counter ]; then 1132 case "$cur" in 1133 *:) 1134 return 1135 ;; 1136 *) 1137 # combined container and filename completion 1138 _filedir 1139 local files=( ${COMPREPLY[@]} ) 1140 1141 __docker_complete_containers_all 1142 COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) 1143 local containers=( ${COMPREPLY[@]} ) 1144 1145 COMPREPLY=( $( compgen -W "${files[*]} ${containers[*]}" -- "$cur" ) ) 1146 if [[ "$COMPREPLY" == *: ]]; then 1147 __docker_nospace 1148 fi 1149 return 1150 ;; 1151 esac 1152 fi 1153 (( counter++ )) 1154 1155 if [ $cword -eq $counter ]; then 1156 if [ -e "$prev" ]; then 1157 __docker_complete_containers_all 1158 COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) 1159 __docker_nospace 1160 else 1161 _filedir 1162 fi 1163 return 1164 fi 1165 ;; 1166 esac 1167 } 1168 1169 _docker_container_create() { 1170 _docker_container_run_and_create 1171 } 1172 1173 _docker_container_diff() { 1174 case "$cur" in 1175 -*) 1176 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1177 ;; 1178 *) 1179 local counter=$(__docker_pos_first_nonflag) 1180 if [ $cword -eq $counter ]; then 1181 __docker_complete_containers_all 1182 fi 1183 ;; 1184 esac 1185 } 1186 1187 _docker_container_exec() { 1188 __docker_complete_detach-keys && return 1189 1190 case "$prev" in 1191 --env|-e) 1192 # we do not append a "=" here because "-e VARNAME" is legal systax, too 1193 COMPREPLY=( $( compgen -e -- "$cur" ) ) 1194 __docker_nospace 1195 return 1196 ;; 1197 --user|-u) 1198 __docker_complete_user_group 1199 return 1200 ;; 1201 esac 1202 1203 case "$cur" in 1204 -*) 1205 COMPREPLY=( $( compgen -W "--detach -d --detach-keys --env -e --help --interactive -i --privileged -t --tty -u --user" -- "$cur" ) ) 1206 ;; 1207 *) 1208 __docker_complete_containers_running 1209 ;; 1210 esac 1211 } 1212 1213 _docker_container_export() { 1214 case "$prev" in 1215 --output|-o) 1216 _filedir 1217 return 1218 ;; 1219 esac 1220 1221 case "$cur" in 1222 -*) 1223 COMPREPLY=( $( compgen -W "--help --output -o" -- "$cur" ) ) 1224 ;; 1225 *) 1226 local counter=$(__docker_pos_first_nonflag) 1227 if [ $cword -eq $counter ]; then 1228 __docker_complete_containers_all 1229 fi 1230 ;; 1231 esac 1232 } 1233 1234 _docker_container_inspect() { 1235 _docker_inspect --type container 1236 } 1237 1238 _docker_container_kill() { 1239 case "$prev" in 1240 --signal|-s) 1241 __docker_complete_signals 1242 return 1243 ;; 1244 esac 1245 1246 case "$cur" in 1247 -*) 1248 COMPREPLY=( $( compgen -W "--help --signal -s" -- "$cur" ) ) 1249 ;; 1250 *) 1251 __docker_complete_containers_running 1252 ;; 1253 esac 1254 } 1255 1256 _docker_container_logs() { 1257 case "$prev" in 1258 --since|--tail) 1259 return 1260 ;; 1261 esac 1262 1263 case "$cur" in 1264 -*) 1265 COMPREPLY=( $( compgen -W "--details --follow -f --help --since --tail --timestamps -t" -- "$cur" ) ) 1266 ;; 1267 *) 1268 local counter=$(__docker_pos_first_nonflag '--since|--tail') 1269 if [ $cword -eq $counter ]; then 1270 __docker_complete_containers_all 1271 fi 1272 ;; 1273 esac 1274 } 1275 1276 _docker_container_list() { 1277 _docker_container_ls 1278 } 1279 1280 _docker_container_ls() { 1281 local key=$(__docker_map_key_of_current_option '--filter|-f') 1282 case "$key" in 1283 ancestor) 1284 cur="${cur##*=}" 1285 __docker_complete_images 1286 return 1287 ;; 1288 before) 1289 __docker_complete_containers_all --cur "${cur##*=}" 1290 return 1291 ;; 1292 expose|publish) 1293 return 1294 ;; 1295 id) 1296 __docker_complete_containers_all --cur "${cur##*=}" --id 1297 return 1298 ;; 1299 health) 1300 COMPREPLY=( $( compgen -W "healthy starting none unhealthy" -- "${cur##*=}" ) ) 1301 return 1302 ;; 1303 is-task) 1304 COMPREPLY=( $( compgen -W "true false" -- "${cur##*=}" ) ) 1305 return 1306 ;; 1307 name) 1308 __docker_complete_containers_all --cur "${cur##*=}" --name 1309 return 1310 ;; 1311 network) 1312 __docker_complete_networks --cur "${cur##*=}" 1313 return 1314 ;; 1315 since) 1316 __docker_complete_containers_all --cur "${cur##*=}" 1317 return 1318 ;; 1319 status) 1320 COMPREPLY=( $( compgen -W "created dead exited paused restarting running removing" -- "${cur##*=}" ) ) 1321 return 1322 ;; 1323 volume) 1324 __docker_complete_volumes --cur "${cur##*=}" 1325 return 1326 ;; 1327 esac 1328 1329 case "$prev" in 1330 --filter|-f) 1331 COMPREPLY=( $( compgen -S = -W "ancestor before exited expose health id is-task label name network publish since status volume" -- "$cur" ) ) 1332 __docker_nospace 1333 return 1334 ;; 1335 --format|--last|-n) 1336 return 1337 ;; 1338 esac 1339 1340 case "$cur" in 1341 -*) 1342 COMPREPLY=( $( compgen -W "--all -a --filter -f --format --help --last -n --latest -l --no-trunc --quiet -q --size -s" -- "$cur" ) ) 1343 ;; 1344 esac 1345 } 1346 1347 _docker_container_pause() { 1348 case "$cur" in 1349 -*) 1350 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1351 ;; 1352 *) 1353 __docker_complete_containers_running 1354 ;; 1355 esac 1356 } 1357 1358 _docker_container_port() { 1359 case "$cur" in 1360 -*) 1361 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1362 ;; 1363 *) 1364 local counter=$(__docker_pos_first_nonflag) 1365 if [ $cword -eq $counter ]; then 1366 __docker_complete_containers_all 1367 fi 1368 ;; 1369 esac 1370 } 1371 1372 _docker_container_prune() { 1373 case "$prev" in 1374 --filter) 1375 COMPREPLY=( $( compgen -W "until" -S = -- "$cur" ) ) 1376 __docker_nospace 1377 return 1378 ;; 1379 esac 1380 1381 case "$cur" in 1382 -*) 1383 COMPREPLY=( $( compgen -W "--force -f --filter --help" -- "$cur" ) ) 1384 ;; 1385 esac 1386 } 1387 1388 _docker_container_ps() { 1389 _docker_container_ls 1390 } 1391 1392 _docker_container_rename() { 1393 case "$cur" in 1394 -*) 1395 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1396 ;; 1397 *) 1398 local counter=$(__docker_pos_first_nonflag) 1399 if [ $cword -eq $counter ]; then 1400 __docker_complete_containers_all 1401 fi 1402 ;; 1403 esac 1404 } 1405 1406 _docker_container_restart() { 1407 case "$prev" in 1408 --time|-t) 1409 return 1410 ;; 1411 esac 1412 1413 case "$cur" in 1414 -*) 1415 COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) ) 1416 ;; 1417 *) 1418 __docker_complete_containers_all 1419 ;; 1420 esac 1421 } 1422 1423 _docker_container_rm() { 1424 case "$cur" in 1425 -*) 1426 COMPREPLY=( $( compgen -W "--force -f --help --link -l --volumes -v" -- "$cur" ) ) 1427 ;; 1428 *) 1429 for arg in "${COMP_WORDS[@]}"; do 1430 case "$arg" in 1431 --force|-f) 1432 __docker_complete_containers_all 1433 return 1434 ;; 1435 esac 1436 done 1437 __docker_complete_containers_stopped 1438 ;; 1439 esac 1440 } 1441 1442 _docker_container_run() { 1443 _docker_container_run_and_create 1444 } 1445 1446 # _docker_container_run_and_create is the combined completion for `_docker_container_run` 1447 # and `_docker_container_create` 1448 _docker_container_run_and_create() { 1449 local options_with_args=" 1450 --add-host 1451 --attach -a 1452 --blkio-weight 1453 --blkio-weight-device 1454 --cap-add 1455 --cap-drop 1456 --cgroup-parent 1457 --cidfile 1458 --cpu-period 1459 --cpu-quota 1460 --cpu-rt-period 1461 --cpu-rt-runtime 1462 --cpuset-cpus 1463 --cpus 1464 --cpuset-mems 1465 --cpu-shares -c 1466 --device 1467 --device-cgroup-rule 1468 --device-read-bps 1469 --device-read-iops 1470 --device-write-bps 1471 --device-write-iops 1472 --dns 1473 --dns-option 1474 --dns-search 1475 --entrypoint 1476 --env -e 1477 --env-file 1478 --expose 1479 --group-add 1480 --hostname -h 1481 --init-path 1482 --ip 1483 --ip6 1484 --ipc 1485 --kernel-memory 1486 --label-file 1487 --label -l 1488 --link 1489 --link-local-ip 1490 --log-driver 1491 --log-opt 1492 --mac-address 1493 --memory -m 1494 --memory-swap 1495 --memory-swappiness 1496 --memory-reservation 1497 --name 1498 --network 1499 --network-alias 1500 --oom-score-adj 1501 --pid 1502 --pids-limit 1503 --publish -p 1504 --restart 1505 --runtime 1506 --security-opt 1507 --shm-size 1508 --stop-signal 1509 --stop-timeout 1510 --storage-opt 1511 --tmpfs 1512 --sysctl 1513 --ulimit 1514 --user -u 1515 --userns 1516 --uts 1517 --volume-driver 1518 --volumes-from 1519 --volume -v 1520 --workdir -w 1521 " 1522 __docker_daemon_os_is windows && options_with_args+=" 1523 --cpu-count 1524 --cpu-percent 1525 --credentialspec 1526 --io-maxbandwidth 1527 --io-maxiops 1528 --isolation 1529 " 1530 1531 local boolean_options=" 1532 --disable-content-trust=false 1533 --help 1534 --init 1535 --interactive -i 1536 --oom-kill-disable 1537 --privileged 1538 --publish-all -P 1539 --read-only 1540 --tty -t 1541 " 1542 1543 if [ "$command" = "run" -o "$subcommand" = "run" ] ; then 1544 options_with_args="$options_with_args 1545 --detach-keys 1546 --health-cmd 1547 --health-interval 1548 --health-retries 1549 --health-timeout 1550 " 1551 boolean_options="$boolean_options 1552 --detach -d 1553 --no-healthcheck 1554 --rm 1555 --sig-proxy=false 1556 " 1557 __docker_complete_detach-keys && return 1558 fi 1559 1560 local all_options="$options_with_args $boolean_options" 1561 1562 1563 __docker_complete_log_driver_options && return 1564 __docker_complete_restart && return 1565 1566 local key=$(__docker_map_key_of_current_option '--security-opt') 1567 case "$key" in 1568 label) 1569 [[ $cur == *: ]] && return 1570 COMPREPLY=( $( compgen -W "user: role: type: level: disable" -- "${cur##*=}") ) 1571 if [ "${COMPREPLY[*]}" != "disable" ] ; then 1572 __docker_nospace 1573 fi 1574 return 1575 ;; 1576 seccomp) 1577 local cur=${cur##*=} 1578 _filedir 1579 COMPREPLY+=( $( compgen -W "unconfined" -- "$cur" ) ) 1580 return 1581 ;; 1582 esac 1583 1584 case "$prev" in 1585 --add-host) 1586 case "$cur" in 1587 *:) 1588 __docker_complete_resolved_hostname 1589 return 1590 ;; 1591 esac 1592 ;; 1593 --attach|-a) 1594 COMPREPLY=( $( compgen -W 'stdin stdout stderr' -- "$cur" ) ) 1595 return 1596 ;; 1597 --cap-add) 1598 __docker_complete_capabilities_addable 1599 return 1600 ;; 1601 --cap-drop) 1602 __docker_complete_capabilities_droppable 1603 return 1604 ;; 1605 --cidfile|--env-file|--init-path|--label-file) 1606 _filedir 1607 return 1608 ;; 1609 --device|--tmpfs|--volume|-v) 1610 case "$cur" in 1611 *:*) 1612 # TODO somehow do _filedir for stuff inside the image, if it's already specified (which is also somewhat difficult to determine) 1613 ;; 1614 '') 1615 COMPREPLY=( $( compgen -W '/' -- "$cur" ) ) 1616 __docker_nospace 1617 ;; 1618 /*) 1619 _filedir 1620 __docker_nospace 1621 ;; 1622 esac 1623 return 1624 ;; 1625 --env|-e) 1626 # we do not append a "=" here because "-e VARNAME" is legal systax, too 1627 COMPREPLY=( $( compgen -e -- "$cur" ) ) 1628 __docker_nospace 1629 return 1630 ;; 1631 --ipc) 1632 case "$cur" in 1633 *:*) 1634 cur="${cur#*:}" 1635 __docker_complete_containers_running 1636 ;; 1637 *) 1638 COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) ) 1639 if [ "$COMPREPLY" = "container:" ]; then 1640 __docker_nospace 1641 fi 1642 ;; 1643 esac 1644 return 1645 ;; 1646 --isolation) 1647 if __docker_daemon_os_is windows ; then 1648 __docker_complete_isolation 1649 return 1650 fi 1651 ;; 1652 --link) 1653 case "$cur" in 1654 *:*) 1655 ;; 1656 *) 1657 __docker_complete_containers_running 1658 COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) 1659 __docker_nospace 1660 ;; 1661 esac 1662 return 1663 ;; 1664 --log-driver) 1665 __docker_complete_log_drivers 1666 return 1667 ;; 1668 --log-opt) 1669 __docker_complete_log_options 1670 return 1671 ;; 1672 --network) 1673 case "$cur" in 1674 container:*) 1675 __docker_complete_containers_all --cur "${cur#*:}" 1676 ;; 1677 *) 1678 COMPREPLY=( $( compgen -W "$(__docker_plugins_bundled --type Network) $(__docker_networks) container:" -- "$cur") ) 1679 if [ "${COMPREPLY[*]}" = "container:" ] ; then 1680 __docker_nospace 1681 fi 1682 ;; 1683 esac 1684 return 1685 ;; 1686 --pid) 1687 case "$cur" in 1688 *:*) 1689 __docker_complete_containers_running --cur "${cur#*:}" 1690 ;; 1691 *) 1692 COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) ) 1693 if [ "$COMPREPLY" = "container:" ]; then 1694 __docker_nospace 1695 fi 1696 ;; 1697 esac 1698 return 1699 ;; 1700 --runtime) 1701 __docker_complete_runtimes 1702 return 1703 ;; 1704 --security-opt) 1705 COMPREPLY=( $( compgen -W "apparmor= label= no-new-privileges seccomp=" -- "$cur") ) 1706 if [ "${COMPREPLY[*]}" != "no-new-privileges" ] ; then 1707 __docker_nospace 1708 fi 1709 return 1710 ;; 1711 --storage-opt) 1712 COMPREPLY=( $( compgen -W "size" -S = -- "$cur") ) 1713 __docker_nospace 1714 return 1715 ;; 1716 --user|-u) 1717 __docker_complete_user_group 1718 return 1719 ;; 1720 --userns) 1721 COMPREPLY=( $( compgen -W "host" -- "$cur" ) ) 1722 return 1723 ;; 1724 --volume-driver) 1725 __docker_complete_plugins_bundled --type Volume 1726 return 1727 ;; 1728 --volumes-from) 1729 __docker_complete_containers_all 1730 return 1731 ;; 1732 $(__docker_to_extglob "$options_with_args") ) 1733 return 1734 ;; 1735 esac 1736 1737 case "$cur" in 1738 -*) 1739 COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) 1740 ;; 1741 *) 1742 local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) ) 1743 if [ $cword -eq $counter ]; then 1744 __docker_complete_images 1745 fi 1746 ;; 1747 esac 1748 } 1749 1750 _docker_container_start() { 1751 __docker_complete_detach-keys && return 1752 1753 case "$prev" in 1754 --checkpoint) 1755 if [ __docker_daemon_is_experimental ] ; then 1756 return 1757 fi 1758 ;; 1759 --checkpoint-dir) 1760 if [ __docker_daemon_is_experimental ] ; then 1761 _filedir -d 1762 return 1763 fi 1764 ;; 1765 esac 1766 1767 case "$cur" in 1768 -*) 1769 local options="--attach -a --detach-keys --help --interactive -i" 1770 __docker_daemon_is_experimental && options+=" --checkpoint --checkpoint-dir" 1771 COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) 1772 ;; 1773 *) 1774 __docker_complete_containers_stopped 1775 ;; 1776 esac 1777 } 1778 1779 _docker_container_stats() { 1780 case "$prev" in 1781 --format) 1782 return 1783 ;; 1784 esac 1785 1786 case "$cur" in 1787 -*) 1788 COMPREPLY=( $( compgen -W "--all -a --format --help --no-stream" -- "$cur" ) ) 1789 ;; 1790 *) 1791 __docker_complete_containers_running 1792 ;; 1793 esac 1794 } 1795 1796 _docker_container_stop() { 1797 case "$prev" in 1798 --time|-t) 1799 return 1800 ;; 1801 esac 1802 1803 case "$cur" in 1804 -*) 1805 COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) ) 1806 ;; 1807 *) 1808 __docker_complete_containers_running 1809 ;; 1810 esac 1811 } 1812 1813 _docker_container_top() { 1814 case "$cur" in 1815 -*) 1816 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1817 ;; 1818 *) 1819 local counter=$(__docker_pos_first_nonflag) 1820 if [ $cword -eq $counter ]; then 1821 __docker_complete_containers_running 1822 fi 1823 ;; 1824 esac 1825 } 1826 1827 _docker_container_unpause() { 1828 case "$cur" in 1829 -*) 1830 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1831 ;; 1832 *) 1833 local counter=$(__docker_pos_first_nonflag) 1834 if [ $cword -eq $counter ]; then 1835 __docker_complete_containers_unpauseable 1836 fi 1837 ;; 1838 esac 1839 } 1840 1841 _docker_container_update() { 1842 local options_with_args=" 1843 --blkio-weight 1844 --cpu-period 1845 --cpu-quota 1846 --cpu-rt-period 1847 --cpu-rt-runtime 1848 --cpuset-cpus 1849 --cpuset-mems 1850 --cpu-shares -c 1851 --kernel-memory 1852 --memory -m 1853 --memory-reservation 1854 --memory-swap 1855 --restart 1856 " 1857 1858 local boolean_options=" 1859 --help 1860 " 1861 1862 local all_options="$options_with_args $boolean_options" 1863 1864 __docker_complete_restart && return 1865 1866 case "$prev" in 1867 $(__docker_to_extglob "$options_with_args") ) 1868 return 1869 ;; 1870 esac 1871 1872 case "$cur" in 1873 -*) 1874 COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) 1875 ;; 1876 *) 1877 __docker_complete_containers_all 1878 ;; 1879 esac 1880 } 1881 1882 _docker_container_wait() { 1883 case "$cur" in 1884 -*) 1885 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 1886 ;; 1887 *) 1888 __docker_complete_containers_all 1889 ;; 1890 esac 1891 } 1892 1893 1894 _docker_commit() { 1895 _docker_container_commit 1896 } 1897 1898 _docker_cp() { 1899 _docker_container_cp 1900 } 1901 1902 _docker_create() { 1903 _docker_container_create 1904 } 1905 1906 _docker_daemon() { 1907 local boolean_options=" 1908 $global_boolean_options 1909 --disable-legacy-registry 1910 --experimental 1911 --help 1912 --icc=false 1913 --init 1914 --ip-forward=false 1915 --ip-masq=false 1916 --iptables=false 1917 --ipv6 1918 --live-restore 1919 --raw-logs 1920 --selinux-enabled 1921 --userland-proxy=false 1922 " 1923 local options_with_args=" 1924 $global_options_with_args 1925 --add-runtime 1926 --api-cors-header 1927 --authorization-plugin 1928 --bip 1929 --bridge -b 1930 --cgroup-parent 1931 --cluster-advertise 1932 --cluster-store 1933 --cluster-store-opt 1934 --config-file 1935 --containerd 1936 --default-gateway 1937 --default-gateway-v6 1938 --default-shm-size 1939 --default-ulimit 1940 --dns 1941 --dns-search 1942 --dns-opt 1943 --exec-opt 1944 --exec-root 1945 --fixed-cidr 1946 --fixed-cidr-v6 1947 --graph -g 1948 --group -G 1949 --init-path 1950 --insecure-registry 1951 --ip 1952 --label 1953 --log-driver 1954 --log-opt 1955 --max-concurrent-downloads 1956 --max-concurrent-uploads 1957 --mtu 1958 --oom-score-adjust 1959 --pidfile -p 1960 --registry-mirror 1961 --seccomp-profile 1962 --shutdown-timeout 1963 --storage-driver -s 1964 --storage-opt 1965 --userland-proxy-path 1966 --userns-remap 1967 " 1968 1969 __docker_complete_log_driver_options && return 1970 1971 key=$(__docker_map_key_of_current_option '--cluster-store-opt') 1972 case "$key" in 1973 kv.*file) 1974 cur=${cur##*=} 1975 _filedir 1976 return 1977 ;; 1978 esac 1979 1980 local key=$(__docker_map_key_of_current_option '--storage-opt') 1981 case "$key" in 1982 dm.blkdiscard|dm.override_udev_sync_check|dm.use_deferred_removal|dm.use_deferred_deletion) 1983 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 1984 return 1985 ;; 1986 dm.fs) 1987 COMPREPLY=( $( compgen -W "ext4 xfs" -- "${cur##*=}" ) ) 1988 return 1989 ;; 1990 dm.thinpooldev) 1991 cur=${cur##*=} 1992 _filedir 1993 return 1994 ;; 1995 esac 1996 1997 case "$prev" in 1998 --authorization-plugin) 1999 __docker_complete_plugins_bundled --type Authorization 2000 return 2001 ;; 2002 --cluster-store) 2003 COMPREPLY=( $( compgen -W "consul etcd zk" -S "://" -- "$cur" ) ) 2004 __docker_nospace 2005 return 2006 ;; 2007 --cluster-store-opt) 2008 COMPREPLY=( $( compgen -W "discovery.heartbeat discovery.ttl kv.cacertfile kv.certfile kv.keyfile kv.path" -S = -- "$cur" ) ) 2009 __docker_nospace 2010 return 2011 ;; 2012 --config-file|--containerd|--init-path|--pidfile|-p|--tlscacert|--tlscert|--tlskey|--userland-proxy-path) 2013 _filedir 2014 return 2015 ;; 2016 --exec-root|--graph|-g) 2017 _filedir -d 2018 return 2019 ;; 2020 --log-driver) 2021 __docker_complete_log_drivers 2022 return 2023 ;; 2024 --storage-driver|-s) 2025 COMPREPLY=( $( compgen -W "aufs btrfs devicemapper overlay overlay2 vfs zfs" -- "$(echo $cur | tr '[:upper:]' '[:lower:]')" ) ) 2026 return 2027 ;; 2028 --storage-opt) 2029 local btrfs_options="btrfs.min_space" 2030 local devicemapper_options=" 2031 dm.basesize 2032 dm.blkdiscard 2033 dm.blocksize 2034 dm.fs 2035 dm.loopdatasize 2036 dm.loopmetadatasize 2037 dm.min_free_space 2038 dm.mkfsarg 2039 dm.mountopt 2040 dm.override_udev_sync_check 2041 dm.thinpooldev 2042 dm.use_deferred_deletion 2043 dm.use_deferred_removal 2044 " 2045 local zfs_options="zfs.fsname" 2046 2047 case $(__docker_value_of_option '--storage-driver|-s') in 2048 '') 2049 COMPREPLY=( $( compgen -W "$btrfs_options $devicemapper_options $zfs_options" -S = -- "$cur" ) ) 2050 ;; 2051 btrfs) 2052 COMPREPLY=( $( compgen -W "$btrfs_options" -S = -- "$cur" ) ) 2053 ;; 2054 devicemapper) 2055 COMPREPLY=( $( compgen -W "$devicemapper_options" -S = -- "$cur" ) ) 2056 ;; 2057 zfs) 2058 COMPREPLY=( $( compgen -W "$zfs_options" -S = -- "$cur" ) ) 2059 ;; 2060 *) 2061 return 2062 ;; 2063 esac 2064 __docker_nospace 2065 return 2066 ;; 2067 --log-level|-l) 2068 __docker_complete_log_levels 2069 return 2070 ;; 2071 --log-opt) 2072 __docker_complete_log_options 2073 return 2074 ;; 2075 --seccomp-profile) 2076 _filedir json 2077 return 2078 ;; 2079 --userns-remap) 2080 __docker_complete_user_group 2081 return 2082 ;; 2083 $(__docker_to_extglob "$options_with_args") ) 2084 return 2085 ;; 2086 esac 2087 2088 case "$cur" in 2089 -*) 2090 COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) 2091 ;; 2092 esac 2093 } 2094 2095 _docker_deploy() { 2096 __docker_daemon_is_experimental && _docker_stack_deploy 2097 } 2098 2099 _docker_diff() { 2100 _docker_container_diff 2101 } 2102 2103 _docker_events() { 2104 _docker_system_events 2105 } 2106 2107 _docker_exec() { 2108 _docker_container_exec 2109 } 2110 2111 _docker_export() { 2112 _docker_container_export 2113 } 2114 2115 _docker_help() { 2116 local counter=$(__docker_pos_first_nonflag) 2117 if [ $cword -eq $counter ]; then 2118 COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) ) 2119 fi 2120 } 2121 2122 _docker_history() { 2123 _docker_image_history 2124 } 2125 2126 2127 _docker_image() { 2128 local subcommands=" 2129 build 2130 history 2131 import 2132 inspect 2133 load 2134 ls 2135 prune 2136 pull 2137 push 2138 rm 2139 save 2140 tag 2141 " 2142 local aliases=" 2143 images 2144 list 2145 remove 2146 rmi 2147 " 2148 __docker_subcommands "$subcommands $aliases" && return 2149 2150 case "$cur" in 2151 -*) 2152 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2153 ;; 2154 *) 2155 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 2156 ;; 2157 esac 2158 } 2159 2160 _docker_image_build() { 2161 local options_with_args=" 2162 --build-arg 2163 --cache-from 2164 --cgroup-parent 2165 --cpuset-cpus 2166 --cpuset-mems 2167 --cpu-shares -c 2168 --cpu-period 2169 --cpu-quota 2170 --file -f 2171 --label 2172 --memory -m 2173 --memory-swap 2174 --network 2175 --shm-size 2176 --tag -t 2177 --ulimit 2178 " 2179 __docker_daemon_os_is windows && options_with_args+=" 2180 --isolation 2181 " 2182 2183 local boolean_options=" 2184 --compress 2185 --disable-content-trust=false 2186 --force-rm 2187 --help 2188 --no-cache 2189 --pull 2190 --quiet -q 2191 --rm 2192 " 2193 __docker_daemon_is_experimental && boolean_options+="--squash" 2194 2195 local all_options="$options_with_args $boolean_options" 2196 2197 case "$prev" in 2198 --build-arg) 2199 COMPREPLY=( $( compgen -e -- "$cur" ) ) 2200 __docker_nospace 2201 return 2202 ;; 2203 --cache-from) 2204 __docker_complete_image_repos_and_tags 2205 return 2206 ;; 2207 --file|-f) 2208 _filedir 2209 return 2210 ;; 2211 --isolation) 2212 if __docker_daemon_os_is windows ; then 2213 __docker_complete_isolation 2214 return 2215 fi 2216 ;; 2217 --network) 2218 case "$cur" in 2219 container:*) 2220 __docker_complete_containers_all --cur "${cur#*:}" 2221 ;; 2222 *) 2223 COMPREPLY=( $( compgen -W "$(__docker_plugins --type Network) $(__docker_networks) container:" -- "$cur") ) 2224 if [ "${COMPREPLY[*]}" = "container:" ] ; then 2225 __docker_nospace 2226 fi 2227 ;; 2228 esac 2229 return 2230 ;; 2231 --tag|-t) 2232 __docker_complete_image_repos_and_tags 2233 return 2234 ;; 2235 $(__docker_to_extglob "$options_with_args") ) 2236 return 2237 ;; 2238 esac 2239 2240 case "$cur" in 2241 -*) 2242 COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) ) 2243 ;; 2244 *) 2245 local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) ) 2246 if [ $cword -eq $counter ]; then 2247 _filedir -d 2248 fi 2249 ;; 2250 esac 2251 } 2252 2253 _docker_image_history() { 2254 case "$cur" in 2255 -*) 2256 COMPREPLY=( $( compgen -W "--help --human=false -H=false --no-trunc --quiet -q" -- "$cur" ) ) 2257 ;; 2258 *) 2259 local counter=$(__docker_pos_first_nonflag) 2260 if [ $cword -eq $counter ]; then 2261 __docker_complete_images 2262 fi 2263 ;; 2264 esac 2265 } 2266 2267 _docker_image_images() { 2268 _docker_image_ls 2269 } 2270 2271 _docker_image_import() { 2272 case "$prev" in 2273 --change|-c|--message|-m) 2274 return 2275 ;; 2276 esac 2277 2278 case "$cur" in 2279 -*) 2280 COMPREPLY=( $( compgen -W "--change -c --help --message -m" -- "$cur" ) ) 2281 ;; 2282 *) 2283 local counter=$(__docker_pos_first_nonflag '--change|-c|--message|-m') 2284 if [ $cword -eq $counter ]; then 2285 return 2286 fi 2287 (( counter++ )) 2288 2289 if [ $cword -eq $counter ]; then 2290 __docker_complete_image_repos_and_tags 2291 return 2292 fi 2293 ;; 2294 esac 2295 } 2296 2297 _docker_image_inspect() { 2298 _docker_inspect --type image 2299 } 2300 2301 _docker_image_load() { 2302 case "$prev" in 2303 --input|-i) 2304 _filedir 2305 return 2306 ;; 2307 esac 2308 2309 case "$cur" in 2310 -*) 2311 COMPREPLY=( $( compgen -W "--help --input -i --quiet -q" -- "$cur" ) ) 2312 ;; 2313 esac 2314 } 2315 2316 _docker_image_list() { 2317 _docker_image_ls 2318 } 2319 2320 _docker_image_ls() { 2321 local key=$(__docker_map_key_of_current_option '--filter|-f') 2322 case "$key" in 2323 before|since|reference) 2324 cur="${cur##*=}" 2325 __docker_complete_images 2326 return 2327 ;; 2328 dangling) 2329 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 2330 return 2331 ;; 2332 label) 2333 return 2334 ;; 2335 esac 2336 2337 case "$prev" in 2338 --filter|-f) 2339 COMPREPLY=( $( compgen -S = -W "before dangling label reference since" -- "$cur" ) ) 2340 __docker_nospace 2341 return 2342 ;; 2343 --format) 2344 return 2345 ;; 2346 esac 2347 2348 case "$cur" in 2349 -*) 2350 COMPREPLY=( $( compgen -W "--all -a --digests --filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) ) 2351 ;; 2352 =) 2353 return 2354 ;; 2355 *) 2356 __docker_complete_image_repos 2357 ;; 2358 esac 2359 } 2360 2361 _docker_image_prune() { 2362 case "$prev" in 2363 --filter) 2364 COMPREPLY=( $( compgen -W "until" -S = -- "$cur" ) ) 2365 __docker_nospace 2366 return 2367 ;; 2368 esac 2369 2370 case "$cur" in 2371 -*) 2372 COMPREPLY=( $( compgen -W "--all -a --force -f --filter --help" -- "$cur" ) ) 2373 ;; 2374 esac 2375 } 2376 2377 _docker_image_pull() { 2378 case "$cur" in 2379 -*) 2380 COMPREPLY=( $( compgen -W "--all-tags -a --disable-content-trust=false --help" -- "$cur" ) ) 2381 ;; 2382 *) 2383 local counter=$(__docker_pos_first_nonflag) 2384 if [ $cword -eq $counter ]; then 2385 for arg in "${COMP_WORDS[@]}"; do 2386 case "$arg" in 2387 --all-tags|-a) 2388 __docker_complete_image_repos 2389 return 2390 ;; 2391 esac 2392 done 2393 __docker_complete_image_repos_and_tags 2394 fi 2395 ;; 2396 esac 2397 } 2398 2399 _docker_image_push() { 2400 case "$cur" in 2401 -*) 2402 COMPREPLY=( $( compgen -W "--disable-content-trust=false --help" -- "$cur" ) ) 2403 ;; 2404 *) 2405 local counter=$(__docker_pos_first_nonflag) 2406 if [ $cword -eq $counter ]; then 2407 __docker_complete_image_repos_and_tags 2408 fi 2409 ;; 2410 esac 2411 } 2412 2413 _docker_image_remove() { 2414 _docker_image_rm 2415 } 2416 2417 _docker_image_rm() { 2418 case "$cur" in 2419 -*) 2420 COMPREPLY=( $( compgen -W "--force -f --help --no-prune" -- "$cur" ) ) 2421 ;; 2422 *) 2423 __docker_complete_images 2424 ;; 2425 esac 2426 } 2427 2428 _docker_image_rmi() { 2429 _docker_image_rm 2430 } 2431 2432 _docker_image_save() { 2433 case "$prev" in 2434 --output|-o) 2435 _filedir 2436 return 2437 ;; 2438 esac 2439 2440 case "$cur" in 2441 -*) 2442 COMPREPLY=( $( compgen -W "--help --output -o" -- "$cur" ) ) 2443 ;; 2444 *) 2445 __docker_complete_images 2446 ;; 2447 esac 2448 } 2449 2450 _docker_image_tag() { 2451 case "$cur" in 2452 -*) 2453 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2454 ;; 2455 *) 2456 local counter=$(__docker_pos_first_nonflag) 2457 2458 if [ $cword -eq $counter ]; then 2459 __docker_complete_image_repos_and_tags 2460 return 2461 fi 2462 (( counter++ )) 2463 2464 if [ $cword -eq $counter ]; then 2465 __docker_complete_image_repos_and_tags 2466 return 2467 fi 2468 ;; 2469 esac 2470 } 2471 2472 2473 _docker_images() { 2474 _docker_image_ls 2475 } 2476 2477 _docker_import() { 2478 _docker_image_import 2479 } 2480 2481 _docker_info() { 2482 _docker_system_info 2483 } 2484 2485 _docker_inspect() { 2486 local preselected_type 2487 local type 2488 2489 if [ "$1" = "--type" ] ; then 2490 preselected_type=yes 2491 type="$2" 2492 else 2493 type=$(__docker_value_of_option --type) 2494 fi 2495 2496 case "$prev" in 2497 --format|-f) 2498 return 2499 ;; 2500 --type) 2501 if [ -z "$preselected_type" ] ; then 2502 COMPREPLY=( $( compgen -W "container image network node plugin service volume" -- "$cur" ) ) 2503 return 2504 fi 2505 ;; 2506 esac 2507 2508 case "$cur" in 2509 -*) 2510 local options="--format -f --help --size -s" 2511 if [ -z "$preselected_type" ] ; then 2512 options+=" --type" 2513 fi 2514 COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) 2515 ;; 2516 *) 2517 case "$type" in 2518 '') 2519 COMPREPLY=( $( compgen -W " 2520 $(__docker_containers --all) 2521 $(__docker_images) 2522 $(__docker_networks) 2523 $(__docker_nodes) 2524 $(__docker_plugins_installed) 2525 $(__docker_services) 2526 $(__docker_volumes) 2527 " -- "$cur" ) ) 2528 ;; 2529 container) 2530 __docker_complete_containers_all 2531 ;; 2532 image) 2533 __docker_complete_images 2534 ;; 2535 network) 2536 __docker_complete_networks 2537 ;; 2538 node) 2539 __docker_complete_nodes 2540 ;; 2541 plugin) 2542 __docker_complete_plugins_installed 2543 ;; 2544 service) 2545 __docker_complete_services 2546 ;; 2547 volume) 2548 __docker_complete_volumes 2549 ;; 2550 esac 2551 esac 2552 } 2553 2554 _docker_kill() { 2555 _docker_container_kill 2556 } 2557 2558 _docker_load() { 2559 _docker_image_load 2560 } 2561 2562 _docker_login() { 2563 case "$prev" in 2564 --password|-p|--username|-u) 2565 return 2566 ;; 2567 esac 2568 2569 case "$cur" in 2570 -*) 2571 COMPREPLY=( $( compgen -W "--help --password -p --username -u" -- "$cur" ) ) 2572 ;; 2573 esac 2574 } 2575 2576 _docker_logout() { 2577 case "$cur" in 2578 -*) 2579 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2580 ;; 2581 esac 2582 } 2583 2584 _docker_logs() { 2585 _docker_container_logs 2586 } 2587 2588 _docker_network_connect() { 2589 local options_with_args=" 2590 --alias 2591 --ip 2592 --ip6 2593 --link 2594 --link-local-ip 2595 " 2596 2597 local boolean_options=" 2598 --help 2599 " 2600 2601 case "$prev" in 2602 --link) 2603 case "$cur" in 2604 *:*) 2605 ;; 2606 *) 2607 __docker_complete_containers_running 2608 COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) ) 2609 __docker_nospace 2610 ;; 2611 esac 2612 return 2613 ;; 2614 $(__docker_to_extglob "$options_with_args") ) 2615 return 2616 ;; 2617 esac 2618 2619 case "$cur" in 2620 -*) 2621 COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) 2622 ;; 2623 *) 2624 local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) ) 2625 if [ $cword -eq $counter ]; then 2626 __docker_complete_networks 2627 elif [ $cword -eq $(($counter + 1)) ]; then 2628 __docker_complete_containers_all 2629 fi 2630 ;; 2631 esac 2632 } 2633 2634 _docker_network_create() { 2635 case "$prev" in 2636 --aux-address|--gateway|--internal|--ip-range|--ipam-opt|--ipv6|--opt|-o|--subnet) 2637 return 2638 ;; 2639 --ipam-driver) 2640 COMPREPLY=( $( compgen -W "default" -- "$cur" ) ) 2641 return 2642 ;; 2643 --driver|-d) 2644 # remove drivers that allow one instance only, add drivers missing in `docker info` 2645 __docker_complete_plugins_bundled --type Network --remove host --remove null --add macvlan 2646 return 2647 ;; 2648 --label) 2649 return 2650 ;; 2651 esac 2652 2653 case "$cur" in 2654 -*) 2655 COMPREPLY=( $( compgen -W "--attachable --aux-address --driver -d --gateway --help --internal --ip-range --ipam-driver --ipam-opt --ipv6 --label --opt -o --subnet" -- "$cur" ) ) 2656 ;; 2657 esac 2658 } 2659 2660 _docker_network_disconnect() { 2661 case "$cur" in 2662 -*) 2663 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2664 ;; 2665 *) 2666 local counter=$(__docker_pos_first_nonflag) 2667 if [ $cword -eq $counter ]; then 2668 __docker_complete_networks 2669 elif [ $cword -eq $(($counter + 1)) ]; then 2670 __docker_complete_containers_in_network "$prev" 2671 fi 2672 ;; 2673 esac 2674 } 2675 2676 _docker_network_inspect() { 2677 case "$prev" in 2678 --format|-f) 2679 return 2680 ;; 2681 esac 2682 2683 case "$cur" in 2684 -*) 2685 COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) 2686 ;; 2687 *) 2688 __docker_complete_networks 2689 esac 2690 } 2691 2692 _docker_network_ls() { 2693 local key=$(__docker_map_key_of_current_option '--filter|-f') 2694 case "$key" in 2695 driver) 2696 __docker_complete_plugins_bundled --cur "${cur##*=}" --type Network --add macvlan 2697 return 2698 ;; 2699 id) 2700 __docker_complete_networks --cur "${cur##*=}" --id 2701 return 2702 ;; 2703 name) 2704 __docker_complete_networks --cur "${cur##*=}" --name 2705 return 2706 ;; 2707 type) 2708 COMPREPLY=( $( compgen -W "builtin custom" -- "${cur##*=}" ) ) 2709 return 2710 ;; 2711 esac 2712 2713 case "$prev" in 2714 --filter|-f) 2715 COMPREPLY=( $( compgen -S = -W "driver id label name type" -- "$cur" ) ) 2716 __docker_nospace 2717 return 2718 ;; 2719 --format) 2720 return 2721 ;; 2722 esac 2723 2724 case "$cur" in 2725 -*) 2726 COMPREPLY=( $( compgen -W "--filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) ) 2727 ;; 2728 esac 2729 } 2730 2731 _docker_network_prune() { 2732 case "$prev" in 2733 --filter) 2734 COMPREPLY=( $( compgen -W "until" -S = -- "$cur" ) ) 2735 __docker_nospace 2736 return 2737 ;; 2738 esac 2739 2740 case "$cur" in 2741 -*) 2742 COMPREPLY=( $( compgen -W "--force -f --filter --help" -- "$cur" ) ) 2743 ;; 2744 esac 2745 } 2746 2747 _docker_network_rm() { 2748 case "$cur" in 2749 -*) 2750 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2751 ;; 2752 *) 2753 __docker_complete_networks --filter type=custom 2754 esac 2755 } 2756 2757 _docker_network() { 2758 local subcommands=" 2759 connect 2760 create 2761 disconnect 2762 inspect 2763 ls 2764 prune 2765 rm 2766 " 2767 __docker_subcommands "$subcommands" && return 2768 2769 case "$cur" in 2770 -*) 2771 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2772 ;; 2773 *) 2774 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 2775 ;; 2776 esac 2777 } 2778 2779 _docker_service() { 2780 local subcommands=" 2781 create 2782 inspect 2783 ls list 2784 rm remove 2785 scale 2786 ps 2787 update 2788 " 2789 __docker_daemon_is_experimental && subcommands+="logs" 2790 2791 __docker_subcommands "$subcommands" && return 2792 2793 case "$cur" in 2794 -*) 2795 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2796 ;; 2797 *) 2798 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 2799 ;; 2800 esac 2801 } 2802 2803 _docker_service_create() { 2804 _docker_service_update_and_create 2805 } 2806 2807 _docker_service_inspect() { 2808 case "$prev" in 2809 --format|-f) 2810 return 2811 ;; 2812 esac 2813 2814 case "$cur" in 2815 -*) 2816 COMPREPLY=( $( compgen -W "--format -f --help --pretty" -- "$cur" ) ) 2817 ;; 2818 *) 2819 __docker_complete_services 2820 esac 2821 } 2822 2823 _docker_service_logs() { 2824 case "$prev" in 2825 --since|--tail) 2826 return 2827 ;; 2828 esac 2829 2830 case "$cur" in 2831 -*) 2832 COMPREPLY=( $( compgen -W "--details --follow -f --help --no-resolve --since --tail --timestamps -t" -- "$cur" ) ) 2833 ;; 2834 *) 2835 local counter=$(__docker_pos_first_nonflag '--since|--tail') 2836 if [ $cword -eq $counter ]; then 2837 __docker_complete_services 2838 fi 2839 ;; 2840 esac 2841 } 2842 2843 _docker_service_list() { 2844 _docker_service_ls 2845 } 2846 2847 _docker_service_ls() { 2848 local key=$(__docker_map_key_of_current_option '--filter|-f') 2849 case "$key" in 2850 id) 2851 __docker_complete_services --cur "${cur##*=}" --id 2852 return 2853 ;; 2854 name) 2855 __docker_complete_services --cur "${cur##*=}" --name 2856 return 2857 ;; 2858 esac 2859 2860 case "$prev" in 2861 --filter|-f) 2862 COMPREPLY=( $( compgen -W "id label name" -S = -- "$cur" ) ) 2863 __docker_nospace 2864 return 2865 ;; 2866 --format) 2867 return 2868 ;; 2869 esac 2870 2871 case "$cur" in 2872 -*) 2873 COMPREPLY=( $( compgen -W "--filter -f --format --help --quiet -q" -- "$cur" ) ) 2874 ;; 2875 esac 2876 } 2877 2878 _docker_service_remove() { 2879 _docker_service_rm 2880 } 2881 2882 _docker_service_rm() { 2883 case "$cur" in 2884 -*) 2885 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2886 ;; 2887 *) 2888 __docker_complete_services 2889 esac 2890 } 2891 2892 _docker_service_scale() { 2893 case "$cur" in 2894 -*) 2895 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 2896 ;; 2897 *) 2898 __docker_complete_services 2899 __docker_append_to_completions "=" 2900 __docker_nospace 2901 ;; 2902 esac 2903 } 2904 2905 _docker_service_ps() { 2906 local key=$(__docker_map_key_of_current_option '--filter|-f') 2907 case "$key" in 2908 desired-state) 2909 COMPREPLY=( $( compgen -W "accepted running" -- "${cur##*=}" ) ) 2910 return 2911 ;; 2912 name) 2913 __docker_complete_services --cur "${cur##*=}" --name 2914 return 2915 ;; 2916 node) 2917 __docker_complete_nodes_plus_self --cur "${cur##*=}" 2918 return 2919 ;; 2920 esac 2921 2922 case "$prev" in 2923 --filter|-f) 2924 COMPREPLY=( $( compgen -W "desired-state id name node" -S = -- "$cur" ) ) 2925 __docker_nospace 2926 return 2927 ;; 2928 esac 2929 2930 case "$cur" in 2931 -*) 2932 COMPREPLY=( $( compgen -W "--filter -f --help --no-resolve --no-trunc --quiet -q" -- "$cur" ) ) 2933 ;; 2934 *) 2935 __docker_complete_services 2936 ;; 2937 esac 2938 } 2939 2940 _docker_service_update() { 2941 _docker_service_update_and_create 2942 } 2943 2944 # _docker_service_update_and_create is the combined completion for `docker service create` 2945 # and `docker service update` 2946 _docker_service_update_and_create() { 2947 local $subcommand="${words[$subcommand_pos]}" 2948 2949 local options_with_args=" 2950 --constraint 2951 --endpoint-mode 2952 --env -e 2953 --force 2954 --health-cmd 2955 --health-interval 2956 --health-retries 2957 --health-timeout 2958 --hostname 2959 --label -l 2960 --limit-cpu 2961 --limit-memory 2962 --log-driver 2963 --log-opt 2964 --mount 2965 --network 2966 --no-healthcheck 2967 --replicas 2968 --reserve-cpu 2969 --reserve-memory 2970 --restart-condition 2971 --restart-delay 2972 --restart-max-attempts 2973 --restart-window 2974 --rollback 2975 --stop-grace-period 2976 --update-delay 2977 --update-failure-action 2978 --update-max-failure-ratio 2979 --update-monitor 2980 --update-parallelism 2981 --user -u 2982 --workdir -w 2983 " 2984 2985 local boolean_options=" 2986 --help 2987 --read-only 2988 --tty -t 2989 --with-registry-auth 2990 " 2991 2992 __docker_complete_log_driver_options && return 2993 2994 if [ "$subcommand" = "create" ] ; then 2995 options_with_args="$options_with_args 2996 --container-label 2997 --dns 2998 --dns-option 2999 --dns-search 3000 --env-file 3001 --group 3002 --host 3003 --mode 3004 --name 3005 --publish -p 3006 --secret 3007 " 3008 3009 case "$prev" in 3010 --env-file) 3011 _filedir 3012 return 3013 ;; 3014 --group) 3015 COMPREPLY=( $(compgen -g -- "$cur") ) 3016 return 3017 ;; 3018 --host) 3019 case "$cur" in 3020 *:) 3021 __docker_complete_resolved_hostname 3022 return 3023 ;; 3024 esac 3025 ;; 3026 --mode) 3027 COMPREPLY=( $( compgen -W "global replicated" -- "$cur" ) ) 3028 return 3029 ;; 3030 --secret) 3031 __docker_complete_secrets 3032 return 3033 ;; 3034 esac 3035 fi 3036 if [ "$subcommand" = "update" ] ; then 3037 options_with_args="$options_with_args 3038 --arg 3039 --container-label-add 3040 --container-label-rm 3041 --dns-add 3042 --dns-option-add 3043 --dns-option-rm 3044 --dns-rm 3045 --dns-search-add 3046 --dns-search-rm 3047 --group-add 3048 --group-rm 3049 --host-add 3050 --host-rm 3051 --image 3052 --publish-add 3053 --publish-rm 3054 --secret-add 3055 --secret-rm 3056 " 3057 3058 case "$prev" in 3059 --group-add|--group-rm) 3060 COMPREPLY=( $(compgen -g -- "$cur") ) 3061 return 3062 ;; 3063 --host-add|--host-rm) 3064 case "$cur" in 3065 *:) 3066 __docker_complete_resolved_hostname 3067 return 3068 ;; 3069 esac 3070 ;; 3071 --image) 3072 __docker_complete_image_repos_and_tags 3073 return 3074 ;; 3075 --secret-add|--secret-rm) 3076 __docker_complete_secrets 3077 return 3078 ;; 3079 esac 3080 fi 3081 3082 case "$prev" in 3083 --endpoint-mode) 3084 COMPREPLY=( $( compgen -W "dnsrr vip" -- "$cur" ) ) 3085 return 3086 ;; 3087 --env|-e) 3088 # we do not append a "=" here because "-e VARNAME" is legal systax, too 3089 COMPREPLY=( $( compgen -e -- "$cur" ) ) 3090 __docker_nospace 3091 return 3092 ;; 3093 --log-driver) 3094 __docker_complete_log_drivers 3095 return 3096 ;; 3097 --log-opt) 3098 __docker_complete_log_options 3099 return 3100 ;; 3101 --network) 3102 __docker_complete_networks 3103 return 3104 ;; 3105 --restart-condition) 3106 COMPREPLY=( $( compgen -W "any none on-failure" -- "$cur" ) ) 3107 return 3108 ;; 3109 --user|-u) 3110 __docker_complete_user_group 3111 return 3112 ;; 3113 $(__docker_to_extglob "$options_with_args") ) 3114 return 3115 ;; 3116 esac 3117 3118 case "$cur" in 3119 -*) 3120 COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) ) 3121 ;; 3122 *) 3123 local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) ) 3124 if [ "$subcommand" = "update" ] ; then 3125 if [ $cword -eq $counter ]; then 3126 __docker_complete_services 3127 fi 3128 else 3129 if [ $cword -eq $counter ]; then 3130 __docker_complete_images 3131 fi 3132 fi 3133 ;; 3134 esac 3135 } 3136 3137 _docker_swarm() { 3138 local subcommands=" 3139 init 3140 join 3141 join-token 3142 leave 3143 unlock 3144 unlock-key 3145 update 3146 " 3147 __docker_subcommands "$subcommands" && return 3148 3149 case "$cur" in 3150 -*) 3151 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3152 ;; 3153 *) 3154 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 3155 ;; 3156 esac 3157 } 3158 3159 _docker_swarm_init() { 3160 case "$prev" in 3161 --advertise-addr) 3162 if [[ $cur == *: ]] ; then 3163 COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) ) 3164 else 3165 __docker_complete_local_interfaces 3166 __docker_nospace 3167 fi 3168 return 3169 ;; 3170 --availability) 3171 COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) ) 3172 return 3173 ;; 3174 --cert-expiry|--dispatcher-heartbeat|--external-ca|--max-snapshots|--snapshot-interval|--task-history-limit) 3175 return 3176 ;; 3177 --listen-addr) 3178 if [[ $cur == *: ]] ; then 3179 COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) ) 3180 else 3181 __docker_complete_local_interfaces --add 0.0.0.0 3182 __docker_nospace 3183 fi 3184 return 3185 ;; 3186 esac 3187 3188 case "$cur" in 3189 -*) 3190 COMPREPLY=( $( compgen -W "--advertise-addr --autolock --availability --cert-expiry --dispatcher-heartbeat --external-ca --force-new-cluster --help --listen-addr --max-snapshots --snapshot-interval --task-history-limit" -- "$cur" ) ) 3191 ;; 3192 esac 3193 } 3194 3195 _docker_swarm_join() { 3196 case "$prev" in 3197 --advertise-addr) 3198 if [[ $cur == *: ]] ; then 3199 COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) ) 3200 else 3201 __docker_complete_local_interfaces 3202 __docker_nospace 3203 fi 3204 return 3205 ;; 3206 --listen-addr) 3207 if [[ $cur == *: ]] ; then 3208 COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) ) 3209 else 3210 __docker_complete_local_interfaces --add 0.0.0.0 3211 __docker_nospace 3212 fi 3213 return 3214 ;; 3215 --availability) 3216 COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) ) 3217 return 3218 ;; 3219 --token) 3220 return 3221 ;; 3222 esac 3223 3224 case "$cur" in 3225 -*) 3226 COMPREPLY=( $( compgen -W "--advertise-addr --availability --help --listen-addr --token" -- "$cur" ) ) 3227 ;; 3228 *:) 3229 COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) ) 3230 ;; 3231 esac 3232 } 3233 3234 _docker_swarm_join-token() { 3235 case "$cur" in 3236 -*) 3237 COMPREPLY=( $( compgen -W "--help --quiet -q --rotate" -- "$cur" ) ) 3238 ;; 3239 *) 3240 local counter=$( __docker_pos_first_nonflag ) 3241 if [ $cword -eq $counter ]; then 3242 COMPREPLY=( $( compgen -W "manager worker" -- "$cur" ) ) 3243 fi 3244 ;; 3245 esac 3246 } 3247 3248 _docker_swarm_leave() { 3249 case "$cur" in 3250 -*) 3251 COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) 3252 ;; 3253 esac 3254 } 3255 3256 _docker_swarm_unlock() { 3257 case "$cur" in 3258 -*) 3259 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3260 ;; 3261 esac 3262 } 3263 3264 _docker_swarm_unlock-key() { 3265 case "$cur" in 3266 -*) 3267 COMPREPLY=( $( compgen -W "--help --quiet -q --rotate" -- "$cur" ) ) 3268 ;; 3269 esac 3270 } 3271 3272 _docker_swarm_update() { 3273 case "$prev" in 3274 --cert-expiry|--dispatcher-heartbeat|--external-ca|--max-snapshots|--snapshot-interval|--task-history-limit) 3275 return 3276 ;; 3277 esac 3278 3279 case "$cur" in 3280 -*) 3281 COMPREPLY=( $( compgen -W "--autolock --cert-expiry --dispatcher-heartbeat --external-ca --help --max-snapshots --snapshot-interval --task-history-limit" -- "$cur" ) ) 3282 ;; 3283 esac 3284 } 3285 3286 _docker_node() { 3287 local subcommands=" 3288 demote 3289 inspect 3290 ls list 3291 promote 3292 rm remove 3293 ps 3294 update 3295 " 3296 __docker_subcommands "$subcommands" && return 3297 3298 case "$cur" in 3299 -*) 3300 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3301 ;; 3302 *) 3303 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 3304 ;; 3305 esac 3306 } 3307 3308 _docker_node_demote() { 3309 case "$cur" in 3310 -*) 3311 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3312 ;; 3313 *) 3314 __docker_complete_nodes --filter role=manager 3315 esac 3316 } 3317 3318 _docker_node_inspect() { 3319 case "$prev" in 3320 --format|-f) 3321 return 3322 ;; 3323 esac 3324 3325 case "$cur" in 3326 -*) 3327 COMPREPLY=( $( compgen -W "--format -f --help --pretty" -- "$cur" ) ) 3328 ;; 3329 *) 3330 __docker_complete_nodes_plus_self 3331 esac 3332 } 3333 3334 _docker_node_list() { 3335 _docker_node_ls 3336 } 3337 3338 _docker_node_ls() { 3339 local key=$(__docker_map_key_of_current_option '--filter|-f') 3340 case "$key" in 3341 id) 3342 __docker_complete_nodes --cur "${cur##*=}" --id 3343 return 3344 ;; 3345 name) 3346 __docker_complete_nodes --cur "${cur##*=}" --name 3347 return 3348 ;; 3349 esac 3350 3351 case "$prev" in 3352 --filter|-f) 3353 COMPREPLY=( $( compgen -W "id label name" -S = -- "$cur" ) ) 3354 __docker_nospace 3355 return 3356 ;; 3357 esac 3358 3359 case "$cur" in 3360 -*) 3361 COMPREPLY=( $( compgen -W "--filter -f --help --quiet -q" -- "$cur" ) ) 3362 ;; 3363 esac 3364 } 3365 3366 _docker_node_promote() { 3367 case "$cur" in 3368 -*) 3369 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3370 ;; 3371 *) 3372 __docker_complete_nodes --filter role=worker 3373 esac 3374 } 3375 3376 _docker_node_remove() { 3377 _docker_node_rm 3378 } 3379 3380 _docker_node_rm() { 3381 case "$cur" in 3382 -*) 3383 COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) 3384 ;; 3385 *) 3386 __docker_complete_nodes 3387 esac 3388 } 3389 3390 _docker_node_ps() { 3391 local key=$(__docker_map_key_of_current_option '--filter|-f') 3392 case "$key" in 3393 desired-state) 3394 COMPREPLY=( $( compgen -W "accepted running" -- "${cur##*=}" ) ) 3395 return 3396 ;; 3397 name) 3398 __docker_complete_services --cur "${cur##*=}" --name 3399 return 3400 ;; 3401 esac 3402 3403 case "$prev" in 3404 --filter|-f) 3405 COMPREPLY=( $( compgen -W "desired-state id label name" -S = -- "$cur" ) ) 3406 __docker_nospace 3407 return 3408 ;; 3409 esac 3410 3411 case "$cur" in 3412 -*) 3413 COMPREPLY=( $( compgen -W "--filter -f --help --no-resolve --no-trunc" -- "$cur" ) ) 3414 ;; 3415 *) 3416 __docker_complete_nodes_plus_self 3417 ;; 3418 esac 3419 } 3420 3421 _docker_node_update() { 3422 case "$prev" in 3423 --availability) 3424 COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) ) 3425 return 3426 ;; 3427 --role) 3428 COMPREPLY=( $( compgen -W "manager worker" -- "$cur" ) ) 3429 return 3430 ;; 3431 --label-add|--label-rm) 3432 return 3433 ;; 3434 esac 3435 3436 case "$cur" in 3437 -*) 3438 COMPREPLY=( $( compgen -W "--availability --help --label-add --label-rm --role" -- "$cur" ) ) 3439 ;; 3440 *) 3441 __docker_complete_nodes 3442 esac 3443 } 3444 3445 _docker_pause() { 3446 _docker_container_pause 3447 } 3448 3449 _docker_plugin() { 3450 local subcommands=" 3451 create 3452 disable 3453 enable 3454 inspect 3455 install 3456 ls 3457 push 3458 rm 3459 set 3460 upgrade 3461 " 3462 local aliases=" 3463 list 3464 remove 3465 " 3466 __docker_subcommands "$subcommands $aliases" && return 3467 3468 case "$cur" in 3469 -*) 3470 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3471 ;; 3472 *) 3473 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 3474 ;; 3475 esac 3476 } 3477 3478 _docker_plugin_create() { 3479 case "$cur" in 3480 -*) 3481 COMPREPLY=( $( compgen -W "--compress --help" -- "$cur" ) ) 3482 ;; 3483 *) 3484 local counter=$(__docker_pos_first_nonflag) 3485 if [ $cword -eq $counter ]; then 3486 # reponame 3487 return 3488 elif [ $cword -eq $((counter + 1)) ]; then 3489 _filedir -d 3490 fi 3491 ;; 3492 esac 3493 } 3494 3495 _docker_plugin_disable() { 3496 case "$cur" in 3497 -*) 3498 COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) 3499 ;; 3500 *) 3501 local counter=$(__docker_pos_first_nonflag) 3502 if [ $cword -eq $counter ]; then 3503 __docker_complete_plugins_installed --filter enabled=true 3504 fi 3505 ;; 3506 esac 3507 } 3508 3509 _docker_plugin_enable() { 3510 case "$prev" in 3511 --timeout) 3512 return 3513 ;; 3514 esac 3515 3516 case "$cur" in 3517 -*) 3518 COMPREPLY=( $( compgen -W "--help --timeout" -- "$cur" ) ) 3519 ;; 3520 *) 3521 local counter=$(__docker_pos_first_nonflag '--timeout') 3522 if [ $cword -eq $counter ]; then 3523 __docker_complete_plugins_installed --filter enabled=false 3524 fi 3525 ;; 3526 esac 3527 } 3528 3529 _docker_plugin_inspect() { 3530 case "$prev" in 3531 --format|f) 3532 return 3533 ;; 3534 esac 3535 3536 case "$cur" in 3537 -*) 3538 COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) 3539 ;; 3540 *) 3541 __docker_complete_plugins_installed 3542 ;; 3543 esac 3544 } 3545 3546 _docker_plugin_install() { 3547 case "$prev" in 3548 --alias) 3549 return 3550 ;; 3551 esac 3552 3553 case "$cur" in 3554 -*) 3555 COMPREPLY=( $( compgen -W "--alias --disable --disable-content-trust=false --grant-all-permissions --help" -- "$cur" ) ) 3556 ;; 3557 esac 3558 } 3559 3560 _docker_plugin_list() { 3561 _docker_plugin_ls 3562 } 3563 3564 _docker_plugin_ls() { 3565 local key=$(__docker_map_key_of_current_option '--filter|-f') 3566 case "$key" in 3567 capability) 3568 COMPREPLY=( $( compgen -W "authz ipamdriver networkdriver volumedriver" -- "${cur##*=}" ) ) 3569 return 3570 ;; 3571 enabled) 3572 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 3573 return 3574 ;; 3575 esac 3576 3577 case "$prev" in 3578 --filter|-f) 3579 COMPREPLY=( $( compgen -S = -W "capability enabled" -- "$cur" ) ) 3580 __docker_nospace 3581 return 3582 ;; 3583 --format) 3584 return 3585 ;; 3586 esac 3587 3588 case "$cur" in 3589 -*) 3590 COMPREPLY=( $( compgen -W "--filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) ) 3591 ;; 3592 esac 3593 } 3594 3595 _docker_plugin_push() { 3596 case "$cur" in 3597 -*) 3598 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3599 ;; 3600 *) 3601 local counter=$(__docker_pos_first_nonflag) 3602 if [ $cword -eq $counter ]; then 3603 __docker_complete_plugins_installed 3604 fi 3605 ;; 3606 esac 3607 } 3608 3609 _docker_plugin_remove() { 3610 _docker_plugin_rm 3611 } 3612 3613 _docker_plugin_rm() { 3614 case "$cur" in 3615 -*) 3616 COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) 3617 ;; 3618 *) 3619 __docker_complete_plugins_installed 3620 ;; 3621 esac 3622 } 3623 3624 _docker_plugin_set() { 3625 case "$cur" in 3626 -*) 3627 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3628 ;; 3629 *) 3630 local counter=$(__docker_pos_first_nonflag) 3631 if [ $cword -eq $counter ]; then 3632 __docker_complete_plugins_installed 3633 fi 3634 ;; 3635 esac 3636 } 3637 3638 _docker_plugin_upgrade() { 3639 case "$cur" in 3640 -*) 3641 COMPREPLY=( $( compgen -W "--disable-content-trust --grant-all-permissions --help --skip-remote-check" -- "$cur" ) ) 3642 ;; 3643 *) 3644 local counter=$(__docker_pos_first_nonflag) 3645 if [ $cword -eq $counter ]; then 3646 __docker_complete_plugins_installed 3647 __ltrim_colon_completions "$cur" 3648 elif [ $cword -eq $((counter + 1)) ]; then 3649 local plugin_images="$(__docker_plugins_installed)" 3650 COMPREPLY=( $(compgen -S : -W "${plugin_images%:*}" -- "$cur") ) 3651 __docker_nospace 3652 fi 3653 ;; 3654 esac 3655 } 3656 3657 3658 _docker_port() { 3659 _docker_container_port 3660 } 3661 3662 _docker_ps() { 3663 _docker_container_ls 3664 } 3665 3666 _docker_pull() { 3667 _docker_image_pull 3668 } 3669 3670 _docker_push() { 3671 _docker_image_push 3672 } 3673 3674 _docker_rename() { 3675 _docker_container_rename 3676 } 3677 3678 _docker_restart() { 3679 _docker_container_restart 3680 } 3681 3682 _docker_rm() { 3683 _docker_container_rm 3684 } 3685 3686 _docker_rmi() { 3687 _docker_image_rm 3688 } 3689 3690 _docker_run() { 3691 _docker_container_run 3692 } 3693 3694 _docker_save() { 3695 _docker_image_save 3696 } 3697 3698 3699 _docker_secret() { 3700 local subcommands=" 3701 create 3702 inspect 3703 ls 3704 rm 3705 " 3706 local aliases=" 3707 list 3708 remove 3709 " 3710 __docker_subcommands "$subcommands $aliases" && return 3711 3712 case "$cur" in 3713 -*) 3714 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3715 ;; 3716 *) 3717 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 3718 ;; 3719 esac 3720 } 3721 3722 _docker_secret_create() { 3723 case "$prev" in 3724 --label|-l) 3725 return 3726 ;; 3727 esac 3728 3729 case "$cur" in 3730 -*) 3731 COMPREPLY=( $( compgen -W "--help --label -l" -- "$cur" ) ) 3732 ;; 3733 esac 3734 } 3735 3736 _docker_secret_inspect() { 3737 case "$prev" in 3738 --format|-f) 3739 return 3740 ;; 3741 esac 3742 3743 case "$cur" in 3744 -*) 3745 COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) 3746 ;; 3747 *) 3748 __docker_complete_secrets 3749 ;; 3750 esac 3751 } 3752 3753 _docker_secret_list() { 3754 _docker_secret_ls 3755 } 3756 3757 _docker_secret_ls() { 3758 case "$cur" in 3759 -*) 3760 COMPREPLY=( $( compgen -W "--help --quiet -q" -- "$cur" ) ) 3761 ;; 3762 esac 3763 } 3764 3765 _docker_secret_remove() { 3766 case "$cur" in 3767 -*) 3768 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3769 ;; 3770 *) 3771 __docker_complete_secrets 3772 ;; 3773 esac 3774 } 3775 3776 _docker_secret_rm() { 3777 _docker_secret_remove 3778 } 3779 3780 3781 3782 _docker_search() { 3783 local key=$(__docker_map_key_of_current_option '--filter|-f') 3784 case "$key" in 3785 is-automated) 3786 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 3787 return 3788 ;; 3789 is-official) 3790 COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) ) 3791 return 3792 ;; 3793 esac 3794 3795 case "$prev" in 3796 --filter|-f) 3797 COMPREPLY=( $( compgen -S = -W "is-automated is-official stars" -- "$cur" ) ) 3798 __docker_nospace 3799 return 3800 ;; 3801 --limit) 3802 return 3803 ;; 3804 esac 3805 3806 case "$cur" in 3807 -*) 3808 COMPREPLY=( $( compgen -W "--filter --help --limit --no-trunc" -- "$cur" ) ) 3809 ;; 3810 esac 3811 } 3812 3813 3814 _docker_stack() { 3815 local subcommands=" 3816 deploy 3817 ls 3818 ps 3819 rm 3820 services 3821 " 3822 local aliases=" 3823 down 3824 list 3825 remove 3826 up 3827 " 3828 __docker_subcommands "$subcommands $aliases" && return 3829 3830 case "$cur" in 3831 -*) 3832 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3833 ;; 3834 *) 3835 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 3836 ;; 3837 esac 3838 } 3839 3840 _docker_stack_deploy() { 3841 case "$prev" in 3842 --bundle-file) 3843 if __docker_daemon_is_experimental ; then 3844 _filedir dab 3845 return 3846 fi 3847 ;; 3848 --compose-file|-c) 3849 _filedir yml 3850 return 3851 ;; 3852 esac 3853 3854 case "$cur" in 3855 -*) 3856 local options="--compose-file -c --help --with-registry-auth" 3857 __docker_daemon_is_experimental && options+=" --bundle-file" 3858 COMPREPLY=( $( compgen -W "$options" -- "$cur" ) ) 3859 ;; 3860 esac 3861 } 3862 3863 _docker_stack_down() { 3864 _docker_stack_rm 3865 } 3866 3867 _docker_stack_list() { 3868 _docker_stack_ls 3869 } 3870 3871 _docker_stack_ls() { 3872 case "$cur" in 3873 -*) 3874 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3875 ;; 3876 esac 3877 } 3878 3879 _docker_stack_ps() { 3880 local key=$(__docker_map_key_of_current_option '--filter|-f') 3881 case "$key" in 3882 desired-state) 3883 COMPREPLY=( $( compgen -W "accepted running" -- "${cur##*=}" ) ) 3884 return 3885 ;; 3886 id) 3887 __docker_complete_stacks --cur "${cur##*=}" --id 3888 return 3889 ;; 3890 name) 3891 __docker_complete_stacks --cur "${cur##*=}" --name 3892 return 3893 ;; 3894 esac 3895 3896 case "$prev" in 3897 --filter|-f) 3898 COMPREPLY=( $( compgen -S = -W "id name desired-state" -- "$cur" ) ) 3899 __docker_nospace 3900 return 3901 ;; 3902 esac 3903 3904 case "$cur" in 3905 -*) 3906 COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve --no-trunc" -- "$cur" ) ) 3907 ;; 3908 *) 3909 local counter=$(__docker_pos_first_nonflag '--filter|-f') 3910 if [ $cword -eq $counter ]; then 3911 __docker_complete_stacks 3912 fi 3913 ;; 3914 esac 3915 } 3916 3917 _docker_stack_remove() { 3918 _docker_stack_rm 3919 } 3920 3921 _docker_stack_rm() { 3922 case "$cur" in 3923 -*) 3924 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 3925 ;; 3926 *) 3927 local counter=$(__docker_pos_first_nonflag) 3928 if [ $cword -eq $counter ]; then 3929 __docker_complete_stacks 3930 fi 3931 ;; 3932 esac 3933 } 3934 3935 _docker_stack_services() { 3936 local key=$(__docker_map_key_of_current_option '--filter|-f') 3937 case "$key" in 3938 id) 3939 __docker_complete_services --cur "${cur##*=}" --id 3940 return 3941 ;; 3942 label) 3943 return 3944 ;; 3945 name) 3946 __docker_complete_services --cur "${cur##*=}" --name 3947 return 3948 ;; 3949 esac 3950 3951 case "$prev" in 3952 --filter|-f) 3953 COMPREPLY=( $( compgen -S = -W "id label name" -- "$cur" ) ) 3954 __docker_nospace 3955 return 3956 ;; 3957 --format) 3958 return 3959 ;; 3960 esac 3961 3962 case "$cur" in 3963 -*) 3964 COMPREPLY=( $( compgen -W "--filter -f --format --help --quiet -q" -- "$cur" ) ) 3965 ;; 3966 *) 3967 local counter=$(__docker_pos_first_nonflag '--filter|-f|--format') 3968 if [ $cword -eq $counter ]; then 3969 __docker_complete_stacks 3970 fi 3971 ;; 3972 esac 3973 } 3974 3975 _docker_stack_up() { 3976 _docker_stack_deploy 3977 } 3978 3979 3980 _docker_start() { 3981 _docker_container_start 3982 } 3983 3984 _docker_stats() { 3985 _docker_container_stats 3986 } 3987 3988 _docker_stop() { 3989 _docker_container_stop 3990 } 3991 3992 3993 _docker_system() { 3994 local subcommands=" 3995 df 3996 events 3997 info 3998 prune 3999 " 4000 __docker_subcommands "$subcommands $aliases" && return 4001 4002 case "$cur" in 4003 -*) 4004 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 4005 ;; 4006 *) 4007 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 4008 ;; 4009 esac 4010 } 4011 4012 _docker_system_df() { 4013 case "$cur" in 4014 -*) 4015 COMPREPLY=( $( compgen -W "--help --verbose -v" -- "$cur" ) ) 4016 ;; 4017 esac 4018 } 4019 4020 _docker_system_events() { 4021 local key=$(__docker_map_key_of_current_option '-f|--filter') 4022 case "$key" in 4023 container) 4024 __docker_complete_containers_all --cur "${cur##*=}" 4025 return 4026 ;; 4027 daemon) 4028 local name=$(__docker_q info | sed -n 's/^\(ID\|Name\): //p') 4029 COMPREPLY=( $( compgen -W "$name" -- "${cur##*=}" ) ) 4030 return 4031 ;; 4032 event) 4033 COMPREPLY=( $( compgen -W " 4034 attach 4035 commit 4036 connect 4037 copy 4038 create 4039 delete 4040 destroy 4041 detach 4042 die 4043 disconnect 4044 exec_create 4045 exec_detach 4046 exec_start 4047 export 4048 health_status 4049 import 4050 kill 4051 load 4052 mount 4053 oom 4054 pause 4055 pull 4056 push 4057 reload 4058 rename 4059 resize 4060 restart 4061 save 4062 start 4063 stop 4064 tag 4065 top 4066 unmount 4067 unpause 4068 untag 4069 update 4070 " -- "${cur##*=}" ) ) 4071 return 4072 ;; 4073 image) 4074 cur="${cur##*=}" 4075 __docker_complete_images 4076 return 4077 ;; 4078 network) 4079 __docker_complete_networks --cur "${cur##*=}" 4080 return 4081 ;; 4082 type) 4083 COMPREPLY=( $( compgen -W "container daemon image network volume" -- "${cur##*=}" ) ) 4084 return 4085 ;; 4086 volume) 4087 __docker_complete_volumes --cur "${cur##*=}" 4088 return 4089 ;; 4090 esac 4091 4092 case "$prev" in 4093 --filter|-f) 4094 COMPREPLY=( $( compgen -S = -W "container daemon event image label network type volume" -- "$cur" ) ) 4095 __docker_nospace 4096 return 4097 ;; 4098 --since|--until) 4099 return 4100 ;; 4101 esac 4102 4103 case "$cur" in 4104 -*) 4105 COMPREPLY=( $( compgen -W "--filter -f --help --since --until --format" -- "$cur" ) ) 4106 ;; 4107 esac 4108 } 4109 4110 _docker_system_info() { 4111 case "$prev" in 4112 --format|-f) 4113 return 4114 ;; 4115 esac 4116 4117 case "$cur" in 4118 -*) 4119 COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) 4120 ;; 4121 esac 4122 } 4123 4124 _docker_system_prune() { 4125 case "$prev" in 4126 --filter) 4127 COMPREPLY=( $( compgen -W "until" -S = -- "$cur" ) ) 4128 __docker_nospace 4129 return 4130 ;; 4131 esac 4132 4133 case "$cur" in 4134 -*) 4135 COMPREPLY=( $( compgen -W "--all -a --force -f --filter --help" -- "$cur" ) ) 4136 ;; 4137 esac 4138 } 4139 4140 4141 _docker_tag() { 4142 _docker_image_tag 4143 } 4144 4145 _docker_unpause() { 4146 _docker_container_unpause 4147 } 4148 4149 _docker_update() { 4150 _docker_container_update 4151 } 4152 4153 _docker_top() { 4154 _docker_container_top 4155 } 4156 4157 _docker_version() { 4158 case "$prev" in 4159 --format|-f) 4160 return 4161 ;; 4162 esac 4163 4164 case "$cur" in 4165 -*) 4166 COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) 4167 ;; 4168 esac 4169 } 4170 4171 _docker_volume_create() { 4172 case "$prev" in 4173 --driver|-d) 4174 __docker_complete_plugins_bundled --type Volume 4175 return 4176 ;; 4177 --label|--opt|-o) 4178 return 4179 ;; 4180 esac 4181 4182 case "$cur" in 4183 -*) 4184 COMPREPLY=( $( compgen -W "--driver -d --help --label --opt -o" -- "$cur" ) ) 4185 ;; 4186 esac 4187 } 4188 4189 _docker_volume_inspect() { 4190 case "$prev" in 4191 --format|-f) 4192 return 4193 ;; 4194 esac 4195 4196 case "$cur" in 4197 -*) 4198 COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) ) 4199 ;; 4200 *) 4201 __docker_complete_volumes 4202 ;; 4203 esac 4204 } 4205 4206 _docker_volume_ls() { 4207 local key=$(__docker_map_key_of_current_option '--filter|-f') 4208 case "$key" in 4209 dangling) 4210 COMPREPLY=( $( compgen -W "true false" -- "${cur##*=}" ) ) 4211 return 4212 ;; 4213 driver) 4214 __docker_complete_plugins_bundled --cur "${cur##*=}" --type Volume 4215 return 4216 ;; 4217 name) 4218 __docker_complete_volumes --cur "${cur##*=}" 4219 return 4220 ;; 4221 esac 4222 4223 case "$prev" in 4224 --filter|-f) 4225 COMPREPLY=( $( compgen -S = -W "dangling driver label name" -- "$cur" ) ) 4226 __docker_nospace 4227 return 4228 ;; 4229 --format) 4230 return 4231 ;; 4232 esac 4233 4234 case "$cur" in 4235 -*) 4236 COMPREPLY=( $( compgen -W "--filter -f --format --help --quiet -q" -- "$cur" ) ) 4237 ;; 4238 esac 4239 } 4240 4241 _docker_volume_prune() { 4242 case "$cur" in 4243 -*) 4244 COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) 4245 ;; 4246 esac 4247 } 4248 4249 _docker_volume_rm() { 4250 case "$cur" in 4251 -*) 4252 COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) ) 4253 ;; 4254 *) 4255 __docker_complete_volumes 4256 ;; 4257 esac 4258 } 4259 4260 _docker_volume() { 4261 local subcommands=" 4262 create 4263 inspect 4264 ls 4265 prune 4266 rm 4267 " 4268 __docker_subcommands "$subcommands" && return 4269 4270 case "$cur" in 4271 -*) 4272 COMPREPLY=( $( compgen -W "--help" -- "$cur" ) ) 4273 ;; 4274 *) 4275 COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) ) 4276 ;; 4277 esac 4278 } 4279 4280 _docker_wait() { 4281 _docker_container_wait 4282 } 4283 4284 _docker() { 4285 local previous_extglob_setting=$(shopt -p extglob) 4286 shopt -s extglob 4287 4288 local management_commands=( 4289 container 4290 image 4291 network 4292 node 4293 plugin 4294 secret 4295 service 4296 stack 4297 system 4298 volume 4299 ) 4300 4301 local top_level_commands=( 4302 build 4303 login 4304 logout 4305 run 4306 search 4307 version 4308 ) 4309 4310 local legacy_commands=( 4311 commit 4312 cp 4313 create 4314 diff 4315 events 4316 exec 4317 export 4318 history 4319 images 4320 import 4321 info 4322 inspect 4323 kill 4324 load 4325 logs 4326 pause 4327 port 4328 ps 4329 pull 4330 push 4331 rename 4332 restart 4333 rm 4334 rmi 4335 save 4336 start 4337 stats 4338 stop 4339 swarm 4340 tag 4341 top 4342 unpause 4343 update 4344 wait 4345 ) 4346 4347 local experimental_commands=( 4348 checkpoint 4349 deploy 4350 ) 4351 4352 local commands=(${management_commands[*]} ${top_level_commands[*]}) 4353 [ -z "$DOCKER_HIDE_LEGACY_COMMANDS" ] && commands+=(${legacy_commands[*]}) 4354 4355 # These options are valid as global options for all client commands 4356 # and valid as command options for `docker daemon` 4357 local global_boolean_options=" 4358 --debug -D 4359 --tls 4360 --tlsverify 4361 " 4362 local global_options_with_args=" 4363 --config 4364 --host -H 4365 --log-level -l 4366 --tlscacert 4367 --tlscert 4368 --tlskey 4369 " 4370 4371 local host config daemon_os 4372 4373 COMPREPLY=() 4374 local cur prev words cword 4375 _get_comp_words_by_ref -n : cur prev words cword 4376 4377 local command='docker' command_pos=0 subcommand_pos 4378 local counter=1 4379 while [ $counter -lt $cword ]; do 4380 case "${words[$counter]}" in 4381 # save host so that completion can use custom daemon 4382 --host|-H) 4383 (( counter++ )) 4384 host="${words[$counter]}" 4385 ;; 4386 # save config so that completion can use custom configuration directories 4387 --config) 4388 (( counter++ )) 4389 config="${words[$counter]}" 4390 ;; 4391 $(__docker_to_extglob "$global_options_with_args") ) 4392 (( counter++ )) 4393 ;; 4394 -*) 4395 ;; 4396 =) 4397 (( counter++ )) 4398 ;; 4399 *) 4400 command="${words[$counter]}" 4401 command_pos=$counter 4402 break 4403 ;; 4404 esac 4405 (( counter++ )) 4406 done 4407 4408 local binary="${words[0]}" 4409 if [[ $binary == ?(*/)dockerd ]] ; then 4410 # for the dockerd binary, we reuse completion of `docker daemon`. 4411 # dockerd does not have subcommands and global options. 4412 command=daemon 4413 command_pos=0 4414 fi 4415 4416 local completions_func=_docker_${command} 4417 declare -F $completions_func >/dev/null && $completions_func 4418 4419 eval "$previous_extglob_setting" 4420 return 0 4421 } 4422 4423 eval "$__docker_previous_extglob_setting" 4424 unset __docker_previous_extglob_setting 4425 4426 complete -F _docker docker dockerd