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