github.com/brahmaroutu/docker@v1.2.1-0.20160809185609-eb28dde01f16/contrib/completion/bash/docker (about)

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