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