docker 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665
  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. # You can tailor completion for the "events", "history", "inspect", "run",
  21. # "rmi" and "save" commands by settings the following environment
  22. # variables:
  23. #
  24. # DOCKER_COMPLETION_SHOW_IMAGE_IDS
  25. # "none" - Show names only (default)
  26. # "non-intermediate" - Show names and ids, but omit intermediate image IDs
  27. # "all" - Show names and ids, including intermediate image IDs
  28. #
  29. # DOCKER_COMPLETION_SHOW_TAGS
  30. # "yes" - include tags in completion options (default)
  31. # "no" - don't include tags in completion options
  32. #
  33. # Note:
  34. # Currently, the completions will not work if the docker daemon is not
  35. # bound to the default communication port/socket
  36. # If the docker daemon is using a unix socket for communication your user
  37. # must have access to the socket for the completions to function correctly
  38. #
  39. # Note for developers:
  40. # Please arrange options sorted alphabetically by long name with the short
  41. # options immediately following their corresponding long form.
  42. # This order should be applied to lists, alternatives and code blocks.
  43. __docker_q() {
  44. docker ${host:+-H "$host"} ${config:+--config "$config"} 2>/dev/null "$@"
  45. }
  46. __docker_containers_all() {
  47. local IFS=$'\n'
  48. local containers=( $(__docker_q ps -aq --no-trunc) )
  49. if [ "$1" ]; then
  50. containers=( $(__docker_q inspect --format "{{if $1}}{{.Id}}{{end}}" "${containers[@]}") )
  51. fi
  52. local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") )
  53. names=( "${names[@]#/}" ) # trim off the leading "/" from the container names
  54. unset IFS
  55. COMPREPLY=( $(compgen -W "${names[*]} ${containers[*]}" -- "$cur") )
  56. }
  57. __docker_containers_running() {
  58. __docker_containers_all '.State.Running'
  59. }
  60. __docker_containers_stopped() {
  61. __docker_containers_all 'not .State.Running'
  62. }
  63. __docker_containers_pauseable() {
  64. __docker_containers_all 'and .State.Running (not .State.Paused)'
  65. }
  66. __docker_containers_unpauseable() {
  67. __docker_containers_all '.State.Paused'
  68. }
  69. __docker_container_names() {
  70. local containers=( $(__docker_q ps -aq --no-trunc) )
  71. local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") )
  72. names=( "${names[@]#/}" ) # trim off the leading "/" from the container names
  73. COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") )
  74. }
  75. __docker_container_ids() {
  76. local containers=( $(__docker_q ps -aq) )
  77. COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") )
  78. }
  79. __docker_images() {
  80. local images_args=""
  81. case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in
  82. all)
  83. images_args="--no-trunc -a"
  84. ;;
  85. non-intermediate)
  86. images_args="--no-trunc"
  87. ;;
  88. esac
  89. local repo_print_command
  90. if [ "${DOCKER_COMPLETION_SHOW_TAGS:-yes}" = "yes" ]; then
  91. repo_print_command='print $1; print $1":"$2'
  92. else
  93. repo_print_command='print $1'
  94. fi
  95. local awk_script
  96. case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in
  97. all|non-intermediate)
  98. awk_script='NR>1 { print $3; if ($1 != "<none>") { '"$repo_print_command"' } }'
  99. ;;
  100. none|*)
  101. awk_script='NR>1 && $1 != "<none>" { '"$repo_print_command"' }'
  102. ;;
  103. esac
  104. local images=$(__docker_q images $images_args | awk "$awk_script")
  105. COMPREPLY=( $(compgen -W "$images" -- "$cur") )
  106. __ltrim_colon_completions "$cur"
  107. }
  108. __docker_image_repos() {
  109. local repos="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1 }')"
  110. COMPREPLY=( $(compgen -W "$repos" -- "$cur") )
  111. }
  112. __docker_image_repos_and_tags() {
  113. local reposAndTags="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1; print $1":"$2 }')"
  114. COMPREPLY=( $(compgen -W "$reposAndTags" -- "$cur") )
  115. __ltrim_colon_completions "$cur"
  116. }
  117. __docker_containers_and_images() {
  118. __docker_containers_all
  119. local containers=( "${COMPREPLY[@]}" )
  120. __docker_images
  121. COMPREPLY+=( "${containers[@]}" )
  122. }
  123. __docker_volumes() {
  124. COMPREPLY=( $(compgen -W "$(__docker_q volume ls -q)" -- "$cur") )
  125. }
  126. # Finds the position of the first word that is neither option nor an option's argument.
  127. # If there are options that require arguments, you should pass a glob describing those
  128. # options, e.g. "--option1|-o|--option2"
  129. # Use this function to restrict completions to exact positions after the argument list.
  130. __docker_pos_first_nonflag() {
  131. local argument_flags=$1
  132. local counter=$((command_pos + 1))
  133. while [ $counter -le $cword ]; do
  134. if [ -n "$argument_flags" ] && eval "case '${words[$counter]}' in $argument_flags) true ;; *) false ;; esac"; then
  135. (( counter++ ))
  136. # eat "=" in case of --option=arg syntax
  137. [ "${words[$counter]}" = "=" ] && (( counter++ ))
  138. else
  139. case "${words[$counter]}" in
  140. -*)
  141. ;;
  142. *)
  143. break
  144. ;;
  145. esac
  146. fi
  147. # Bash splits words at "=", retaining "=" as a word, examples:
  148. # "--debug=false" => 3 words, "--log-opt syslog-facility=daemon" => 4 words
  149. while [ "${words[$counter + 1]}" = "=" ] ; do
  150. counter=$(( counter + 2))
  151. done
  152. (( counter++ ))
  153. done
  154. echo $counter
  155. }
  156. # Returns the value of the first option matching option_glob.
  157. # Valid values for option_glob are option names like '--log-level' and
  158. # globs like '--log-level|-l'
  159. # Only positions between the command and the current word are considered.
  160. __docker_value_of_option() {
  161. local option_extglob=$(__docker_to_extglob "$1")
  162. local counter=$((command_pos + 1))
  163. while [ $counter -lt $cword ]; do
  164. case ${words[$counter]} in
  165. $option_extglob )
  166. echo ${words[$counter + 1]}
  167. break
  168. ;;
  169. esac
  170. (( counter++ ))
  171. done
  172. }
  173. # Transforms a multiline list of strings into a single line string
  174. # with the words separated by "|".
  175. # This is used to prepare arguments to __docker_pos_first_nonflag().
  176. __docker_to_alternatives() {
  177. local parts=( $1 )
  178. local IFS='|'
  179. echo "${parts[*]}"
  180. }
  181. # Transforms a multiline list of options into an extglob pattern
  182. # suitable for use in case statements.
  183. __docker_to_extglob() {
  184. local extglob=$( __docker_to_alternatives "$1" )
  185. echo "@($extglob)"
  186. }
  187. __docker_resolve_hostname() {
  188. command -v host >/dev/null 2>&1 || return
  189. COMPREPLY=( $(host 2>/dev/null "${cur%:}" | awk '/has address/ {print $4}') )
  190. }
  191. __docker_capabilities() {
  192. # The list of capabilities is defined in types.go, ALL was added manually.
  193. COMPREPLY=( $( compgen -W "
  194. ALL
  195. AUDIT_CONTROL
  196. AUDIT_WRITE
  197. AUDIT_READ
  198. BLOCK_SUSPEND
  199. CHOWN
  200. DAC_OVERRIDE
  201. DAC_READ_SEARCH
  202. FOWNER
  203. FSETID
  204. IPC_LOCK
  205. IPC_OWNER
  206. KILL
  207. LEASE
  208. LINUX_IMMUTABLE
  209. MAC_ADMIN
  210. MAC_OVERRIDE
  211. MKNOD
  212. NET_ADMIN
  213. NET_BIND_SERVICE
  214. NET_BROADCAST
  215. NET_RAW
  216. SETFCAP
  217. SETGID
  218. SETPCAP
  219. SETUID
  220. SYS_ADMIN
  221. SYS_BOOT
  222. SYS_CHROOT
  223. SYSLOG
  224. SYS_MODULE
  225. SYS_NICE
  226. SYS_PACCT
  227. SYS_PTRACE
  228. SYS_RAWIO
  229. SYS_RESOURCE
  230. SYS_TIME
  231. SYS_TTY_CONFIG
  232. WAKE_ALARM
  233. " -- "$cur" ) )
  234. }
  235. __docker_log_drivers() {
  236. COMPREPLY=( $( compgen -W "
  237. fluentd
  238. gelf
  239. journald
  240. json-file
  241. none
  242. syslog
  243. " -- "$cur" ) )
  244. }
  245. __docker_log_driver_options() {
  246. # see docs/reference/logging/index.md
  247. local fluentd_options="fluentd-address fluentd-tag"
  248. local gelf_options="gelf-address gelf-tag"
  249. local json_file_options="max-file max-size"
  250. local syslog_options="syslog-address syslog-facility syslog-tag"
  251. local awslogs_options="awslogs-region awslogs-group awslogs-stream"
  252. case $(__docker_value_of_option --log-driver) in
  253. '')
  254. COMPREPLY=( $( compgen -W "$fluentd_options $gelf_options $json_file_options $syslog_options" -S = -- "$cur" ) )
  255. ;;
  256. fluentd)
  257. COMPREPLY=( $( compgen -W "$fluentd_options" -S = -- "$cur" ) )
  258. ;;
  259. gelf)
  260. COMPREPLY=( $( compgen -W "$gelf_options" -S = -- "$cur" ) )
  261. ;;
  262. json-file)
  263. COMPREPLY=( $( compgen -W "$json_file_options" -S = -- "$cur" ) )
  264. ;;
  265. syslog)
  266. COMPREPLY=( $( compgen -W "$syslog_options" -S = -- "$cur" ) )
  267. ;;
  268. awslogs)
  269. COMPREPLY=( $( compgen -W "$awslogs_options" -S = -- "$cur" ) )
  270. ;;
  271. *)
  272. return
  273. ;;
  274. esac
  275. compopt -o nospace
  276. }
  277. __docker_complete_log_driver_options() {
  278. # "=" gets parsed to a word and assigned to either $cur or $prev depending on whether
  279. # it is the last character or not. So we search for "xxx=" in the the last two words.
  280. case "${words[$cword-2]}$prev=" in
  281. *gelf-address=*)
  282. COMPREPLY=( $( compgen -W "udp" -S "://" -- "${cur#=}" ) )
  283. compopt -o nospace
  284. return
  285. ;;
  286. *syslog-address=*)
  287. COMPREPLY=( $( compgen -W "tcp udp unix" -S "://" -- "${cur#=}" ) )
  288. compopt -o nospace
  289. return
  290. ;;
  291. *syslog-facility=*)
  292. COMPREPLY=( $( compgen -W "
  293. auth
  294. authpriv
  295. cron
  296. daemon
  297. ftp
  298. kern
  299. local0
  300. local1
  301. local2
  302. local3
  303. local4
  304. local5
  305. local6
  306. local7
  307. lpr
  308. mail
  309. news
  310. syslog
  311. user
  312. uucp
  313. " -- "${cur#=}" ) )
  314. return
  315. ;;
  316. esac
  317. return 1
  318. }
  319. __docker_log_levels() {
  320. COMPREPLY=( $( compgen -W "debug info warn error fatal" -- "$cur" ) )
  321. }
  322. # a selection of the available signals that is most likely of interest in the
  323. # context of docker containers.
  324. __docker_signals() {
  325. local signals=(
  326. SIGCONT
  327. SIGHUP
  328. SIGINT
  329. SIGKILL
  330. SIGQUIT
  331. SIGSTOP
  332. SIGTERM
  333. SIGUSR1
  334. SIGUSR2
  335. )
  336. COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo $cur | tr '[:lower:]' '[:upper:]')" ) )
  337. }
  338. # global options that may appear after the docker command
  339. _docker_docker() {
  340. local boolean_options="
  341. $global_boolean_options
  342. --help
  343. --version -v
  344. "
  345. case "$prev" in
  346. --config)
  347. _filedir -d
  348. return
  349. ;;
  350. --log-level|-l)
  351. __docker_log_levels
  352. return
  353. ;;
  354. $(__docker_to_extglob "$global_options_with_args") )
  355. return
  356. ;;
  357. esac
  358. case "$cur" in
  359. -*)
  360. COMPREPLY=( $( compgen -W "$boolean_options $global_options_with_args" -- "$cur" ) )
  361. ;;
  362. *)
  363. local counter=$( __docker_pos_first_nonflag $(__docker_to_extglob "$global_options_with_args") )
  364. if [ $cword -eq $counter ]; then
  365. COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) )
  366. fi
  367. ;;
  368. esac
  369. }
  370. _docker_attach() {
  371. case "$cur" in
  372. -*)
  373. COMPREPLY=( $( compgen -W "--help --no-stdin --sig-proxy" -- "$cur" ) )
  374. ;;
  375. *)
  376. local counter="$(__docker_pos_first_nonflag)"
  377. if [ $cword -eq $counter ]; then
  378. __docker_containers_running
  379. fi
  380. ;;
  381. esac
  382. }
  383. _docker_build() {
  384. case "$prev" in
  385. --cgroup-parent|--cpuset-cpus|--cpuset-mems|--cpu-shares|-c|--cpu-period|--cpu-quota|--memory|-m|--memory-swap)
  386. return
  387. ;;
  388. --file|-f)
  389. _filedir
  390. return
  391. ;;
  392. --tag|-t)
  393. __docker_image_repos_and_tags
  394. return
  395. ;;
  396. esac
  397. case "$cur" in
  398. -*)
  399. COMPREPLY=( $( compgen -W "--cgroup-parent --cpuset-cpus --cpuset-mems --cpu-shares -c --cpu-period --cpu-quota --file -f --force-rm --help --memory -m --memory-swap --no-cache --pull --quiet -q --rm --tag -t --ulimit" -- "$cur" ) )
  400. ;;
  401. *)
  402. local counter="$(__docker_pos_first_nonflag '--cgroup-parent|--cpuset-cpus|--cpuset-mems|--cpu-shares|-c|--cpu-period|--cpu-quota|--file|-f|--memory|-m|--memory-swap|--tag|-t')"
  403. if [ $cword -eq $counter ]; then
  404. _filedir -d
  405. fi
  406. ;;
  407. esac
  408. }
  409. _docker_commit() {
  410. case "$prev" in
  411. --author|-a|--change|-c|--message|-m)
  412. return
  413. ;;
  414. esac
  415. case "$cur" in
  416. -*)
  417. COMPREPLY=( $( compgen -W "--author -a --change -c --help --message -m --pause -p" -- "$cur" ) )
  418. ;;
  419. *)
  420. local counter=$(__docker_pos_first_nonflag '--author|-a|--change|-c|--message|-m')
  421. if [ $cword -eq $counter ]; then
  422. __docker_containers_all
  423. return
  424. fi
  425. (( counter++ ))
  426. if [ $cword -eq $counter ]; then
  427. __docker_image_repos_and_tags
  428. return
  429. fi
  430. ;;
  431. esac
  432. }
  433. _docker_cp() {
  434. case "$cur" in
  435. -*)
  436. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  437. ;;
  438. *)
  439. local counter=$(__docker_pos_first_nonflag)
  440. if [ $cword -eq $counter ]; then
  441. case "$cur" in
  442. *:)
  443. return
  444. ;;
  445. *)
  446. __docker_containers_all
  447. COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) )
  448. compopt -o nospace
  449. return
  450. ;;
  451. esac
  452. fi
  453. (( counter++ ))
  454. if [ $cword -eq $counter ]; then
  455. _filedir -d
  456. return
  457. fi
  458. ;;
  459. esac
  460. }
  461. _docker_create() {
  462. _docker_run
  463. }
  464. _docker_daemon() {
  465. local boolean_options="
  466. $global_boolean_options
  467. --help
  468. --icc=false
  469. --ip-forward=false
  470. --ip-masq=false
  471. --iptables=false
  472. --ipv6
  473. --selinux-enabled
  474. --userland-proxy=false
  475. "
  476. local options_with_args="
  477. $global_options_with_args
  478. --api-cors-header
  479. --bip
  480. --bridge -b
  481. --default-gateway
  482. --default-gateway-v6
  483. --default-ulimit
  484. --dns
  485. --dns-search
  486. --exec-driver -e
  487. --exec-opt
  488. --exec-root
  489. --fixed-cidr
  490. --fixed-cidr-v6
  491. --graph -g
  492. --group -G
  493. --insecure-registry
  494. --ip
  495. --label
  496. --log-driver
  497. --log-opt
  498. --mtu
  499. --pidfile -p
  500. --registry-mirror
  501. --storage-driver -s
  502. --storage-opt
  503. "
  504. case "$prev" in
  505. --exec-root|--graph|-g)
  506. _filedir -d
  507. return
  508. ;;
  509. --log-driver)
  510. __docker_log_drivers
  511. return
  512. ;;
  513. --pidfile|-p|--tlscacert|--tlscert|--tlskey)
  514. _filedir
  515. return
  516. ;;
  517. --storage-driver|-s)
  518. COMPREPLY=( $( compgen -W "aufs btrfs devicemapper overlay vfs zfs" -- "$(echo $cur | tr '[:upper:]' '[:lower:]')" ) )
  519. return
  520. ;;
  521. --storage-opt)
  522. local devicemapper_options="
  523. dm.basesize
  524. dm.blkdiscard
  525. dm.blocksize
  526. dm.fs
  527. dm.loopdatasize
  528. dm.loopmetadatasize
  529. dm.mkfsarg
  530. dm.mountopt
  531. dm.override_udev_sync_check
  532. dm.thinpooldev
  533. "
  534. local zfs_options="zfs.fsname"
  535. case $(__docker_value_of_option '--storage-driver|-s') in
  536. '')
  537. COMPREPLY=( $( compgen -W "$devicemapper_options $zfs_options" -S = -- "$cur" ) )
  538. ;;
  539. devicemapper)
  540. COMPREPLY=( $( compgen -W "$devicemapper_options" -S = -- "$cur" ) )
  541. ;;
  542. zfs)
  543. COMPREPLY=( $( compgen -W "$zfs_options" -S = -- "$cur" ) )
  544. ;;
  545. *)
  546. return
  547. ;;
  548. esac
  549. compopt -o nospace
  550. return
  551. ;;
  552. --log-level|-l)
  553. __docker_log_levels
  554. return
  555. ;;
  556. --log-opt)
  557. __docker_log_driver_options
  558. return
  559. ;;
  560. $(__docker_to_extglob "$options_with_args") )
  561. return
  562. ;;
  563. esac
  564. __docker_complete_log_driver_options && return
  565. # completions for --storage-opt
  566. case "${words[$cword-2]}$prev=" in
  567. *dm.blkdiscard=*)
  568. COMPREPLY=( $( compgen -W "false true" -- "${cur#=}" ) )
  569. return
  570. ;;
  571. *dm.fs=*)
  572. COMPREPLY=( $( compgen -W "ext4 xfs" -- "${cur#=}" ) )
  573. return
  574. ;;
  575. *dm.override_udev_sync_check=*)
  576. COMPREPLY=( $( compgen -W "false true" -- "${cur#=}" ) )
  577. return
  578. ;;
  579. *dm.thinpooldev=*)
  580. _filedir
  581. return
  582. ;;
  583. esac
  584. case "$cur" in
  585. -*)
  586. COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
  587. ;;
  588. esac
  589. }
  590. _docker_diff() {
  591. case "$cur" in
  592. -*)
  593. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  594. ;;
  595. *)
  596. local counter=$(__docker_pos_first_nonflag)
  597. if [ $cword -eq $counter ]; then
  598. __docker_containers_all
  599. fi
  600. ;;
  601. esac
  602. }
  603. _docker_events() {
  604. case "$prev" in
  605. --filter|-f)
  606. COMPREPLY=( $( compgen -S = -W "container event image" -- "$cur" ) )
  607. compopt -o nospace
  608. return
  609. ;;
  610. --since|--until)
  611. return
  612. ;;
  613. esac
  614. case "${words[$cword-2]}$prev=" in
  615. *container=*)
  616. cur="${cur#=}"
  617. __docker_containers_all
  618. return
  619. ;;
  620. *event=*)
  621. COMPREPLY=( $( compgen -W "
  622. attach
  623. commit
  624. copy
  625. create
  626. delete
  627. destroy
  628. die
  629. exec_create
  630. exec_start
  631. export
  632. import
  633. kill
  634. oom
  635. pause
  636. pull
  637. push
  638. rename
  639. resize
  640. restart
  641. start
  642. stop
  643. tag
  644. top
  645. unpause
  646. untag
  647. " -- "${cur#=}" ) )
  648. return
  649. ;;
  650. *image=*)
  651. cur="${cur#=}"
  652. __docker_images
  653. return
  654. ;;
  655. esac
  656. case "$cur" in
  657. -*)
  658. COMPREPLY=( $( compgen -W "--filter -f --help --since --until" -- "$cur" ) )
  659. ;;
  660. esac
  661. }
  662. _docker_exec() {
  663. case "$prev" in
  664. --user|-u)
  665. return
  666. ;;
  667. esac
  668. case "$cur" in
  669. -*)
  670. COMPREPLY=( $( compgen -W "--detach -d --help --interactive -i --privileged -t --tty -u --user" -- "$cur" ) )
  671. ;;
  672. *)
  673. __docker_containers_running
  674. ;;
  675. esac
  676. }
  677. _docker_export() {
  678. case "$cur" in
  679. -*)
  680. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  681. ;;
  682. *)
  683. local counter=$(__docker_pos_first_nonflag)
  684. if [ $cword -eq $counter ]; then
  685. __docker_containers_all
  686. fi
  687. ;;
  688. esac
  689. }
  690. _docker_help() {
  691. local counter=$(__docker_pos_first_nonflag)
  692. if [ $cword -eq $counter ]; then
  693. COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
  694. fi
  695. }
  696. _docker_history() {
  697. case "$cur" in
  698. -*)
  699. COMPREPLY=( $( compgen -W "--help --no-trunc --quiet -q" -- "$cur" ) )
  700. ;;
  701. *)
  702. local counter=$(__docker_pos_first_nonflag)
  703. if [ $cword -eq $counter ]; then
  704. __docker_images
  705. fi
  706. ;;
  707. esac
  708. }
  709. _docker_images() {
  710. case "$prev" in
  711. --filter|-f)
  712. COMPREPLY=( $( compgen -W "dangling=true label=" -- "$cur" ) )
  713. if [ "$COMPREPLY" = "label=" ]; then
  714. compopt -o nospace
  715. fi
  716. return
  717. ;;
  718. esac
  719. case "${words[$cword-2]}$prev=" in
  720. *dangling=*)
  721. COMPREPLY=( $( compgen -W "true false" -- "${cur#=}" ) )
  722. return
  723. ;;
  724. *label=*)
  725. return
  726. ;;
  727. esac
  728. case "$cur" in
  729. -*)
  730. COMPREPLY=( $( compgen -W "--all -a --digests --filter -f --help --no-trunc --quiet -q" -- "$cur" ) )
  731. ;;
  732. =)
  733. return
  734. ;;
  735. *)
  736. __docker_image_repos
  737. ;;
  738. esac
  739. }
  740. _docker_import() {
  741. case "$cur" in
  742. -*)
  743. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  744. ;;
  745. *)
  746. local counter=$(__docker_pos_first_nonflag)
  747. if [ $cword -eq $counter ]; then
  748. return
  749. fi
  750. (( counter++ ))
  751. if [ $cword -eq $counter ]; then
  752. __docker_image_repos_and_tags
  753. return
  754. fi
  755. ;;
  756. esac
  757. }
  758. _docker_info() {
  759. case "$cur" in
  760. -*)
  761. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  762. ;;
  763. esac
  764. }
  765. _docker_inspect() {
  766. case "$prev" in
  767. --format|-f)
  768. return
  769. ;;
  770. --type)
  771. COMPREPLY=( $( compgen -W "image container" -- "$cur" ) )
  772. return
  773. ;;
  774. esac
  775. case "$cur" in
  776. -*)
  777. COMPREPLY=( $( compgen -W "--format -f --type --help" -- "$cur" ) )
  778. ;;
  779. *)
  780. case $(__docker_value_of_option --type) in
  781. '')
  782. __docker_containers_and_images
  783. ;;
  784. container)
  785. __docker_containers_all
  786. ;;
  787. image)
  788. __docker_images
  789. ;;
  790. esac
  791. esac
  792. }
  793. _docker_kill() {
  794. case "$prev" in
  795. --signal|-s)
  796. __docker_signals
  797. return
  798. ;;
  799. esac
  800. case "$cur" in
  801. -*)
  802. COMPREPLY=( $( compgen -W "--help --signal -s" -- "$cur" ) )
  803. ;;
  804. *)
  805. __docker_containers_running
  806. ;;
  807. esac
  808. }
  809. _docker_load() {
  810. case "$prev" in
  811. --input|-i)
  812. _filedir
  813. return
  814. ;;
  815. esac
  816. case "$cur" in
  817. -*)
  818. COMPREPLY=( $( compgen -W "--help --input -i" -- "$cur" ) )
  819. ;;
  820. esac
  821. }
  822. _docker_login() {
  823. case "$prev" in
  824. --email|-e|--password|-p|--username|-u)
  825. return
  826. ;;
  827. esac
  828. case "$cur" in
  829. -*)
  830. COMPREPLY=( $( compgen -W "--email -e --help --password -p --username -u" -- "$cur" ) )
  831. ;;
  832. esac
  833. }
  834. _docker_logout() {
  835. case "$cur" in
  836. -*)
  837. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  838. ;;
  839. esac
  840. }
  841. _docker_logs() {
  842. case "$prev" in
  843. --since|--tail)
  844. return
  845. ;;
  846. esac
  847. case "$cur" in
  848. -*)
  849. COMPREPLY=( $( compgen -W "--follow -f --help --since --tail --timestamps -t" -- "$cur" ) )
  850. ;;
  851. *)
  852. local counter=$(__docker_pos_first_nonflag '--tail')
  853. if [ $cword -eq $counter ]; then
  854. __docker_containers_all
  855. fi
  856. ;;
  857. esac
  858. }
  859. _docker_pause() {
  860. case "$cur" in
  861. -*)
  862. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  863. ;;
  864. *)
  865. local counter=$(__docker_pos_first_nonflag)
  866. if [ $cword -eq $counter ]; then
  867. __docker_containers_pauseable
  868. fi
  869. ;;
  870. esac
  871. }
  872. _docker_port() {
  873. case "$cur" in
  874. -*)
  875. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  876. ;;
  877. *)
  878. local counter=$(__docker_pos_first_nonflag)
  879. if [ $cword -eq $counter ]; then
  880. __docker_containers_all
  881. fi
  882. ;;
  883. esac
  884. }
  885. _docker_ps() {
  886. case "$prev" in
  887. --before|--since)
  888. __docker_containers_all
  889. ;;
  890. --filter|-f)
  891. COMPREPLY=( $( compgen -S = -W "ancestor exited id label name status" -- "$cur" ) )
  892. compopt -o nospace
  893. return
  894. ;;
  895. --format|-n)
  896. return
  897. ;;
  898. esac
  899. case "${words[$cword-2]}$prev=" in
  900. *ancestor=*)
  901. cur="${cur#=}"
  902. __docker_images
  903. return
  904. ;;
  905. *id=*)
  906. cur="${cur#=}"
  907. __docker_container_ids
  908. return
  909. ;;
  910. *name=*)
  911. cur="${cur#=}"
  912. __docker_container_names
  913. return
  914. ;;
  915. *status=*)
  916. COMPREPLY=( $( compgen -W "exited paused restarting running" -- "${cur#=}" ) )
  917. return
  918. ;;
  919. esac
  920. case "$cur" in
  921. -*)
  922. COMPREPLY=( $( compgen -W "--all -a --before --filter -f --format --help --latest -l -n --no-trunc --quiet -q --size -s --since" -- "$cur" ) )
  923. ;;
  924. esac
  925. }
  926. _docker_pull() {
  927. case "$cur" in
  928. -*)
  929. COMPREPLY=( $( compgen -W "--all-tags -a --help" -- "$cur" ) )
  930. ;;
  931. *)
  932. local counter=$(__docker_pos_first_nonflag)
  933. if [ $cword -eq $counter ]; then
  934. for arg in "${COMP_WORDS[@]}"; do
  935. case "$arg" in
  936. --all-tags|-a)
  937. __docker_image_repos
  938. return
  939. ;;
  940. esac
  941. done
  942. __docker_image_repos_and_tags
  943. fi
  944. ;;
  945. esac
  946. }
  947. _docker_push() {
  948. case "$cur" in
  949. -*)
  950. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  951. ;;
  952. *)
  953. local counter=$(__docker_pos_first_nonflag)
  954. if [ $cword -eq $counter ]; then
  955. __docker_image_repos_and_tags
  956. fi
  957. ;;
  958. esac
  959. }
  960. _docker_rename() {
  961. case "$cur" in
  962. -*)
  963. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  964. ;;
  965. *)
  966. local counter=$(__docker_pos_first_nonflag)
  967. if [ $cword -eq $counter ]; then
  968. __docker_containers_all
  969. fi
  970. ;;
  971. esac
  972. }
  973. _docker_restart() {
  974. case "$prev" in
  975. --time|-t)
  976. return
  977. ;;
  978. esac
  979. case "$cur" in
  980. -*)
  981. COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) )
  982. ;;
  983. *)
  984. __docker_containers_all
  985. ;;
  986. esac
  987. }
  988. _docker_rm() {
  989. case "$cur" in
  990. -*)
  991. COMPREPLY=( $( compgen -W "--force -f --help --link -l --volumes -v" -- "$cur" ) )
  992. ;;
  993. *)
  994. for arg in "${COMP_WORDS[@]}"; do
  995. case "$arg" in
  996. --force|-f)
  997. __docker_containers_all
  998. return
  999. ;;
  1000. esac
  1001. done
  1002. __docker_containers_stopped
  1003. ;;
  1004. esac
  1005. }
  1006. _docker_rmi() {
  1007. case "$cur" in
  1008. -*)
  1009. COMPREPLY=( $( compgen -W "--force -f --help --no-prune" -- "$cur" ) )
  1010. ;;
  1011. *)
  1012. __docker_images
  1013. ;;
  1014. esac
  1015. }
  1016. _docker_run() {
  1017. local options_with_args="
  1018. --add-host
  1019. --attach -a
  1020. --blkio-weight
  1021. --cap-add
  1022. --cap-drop
  1023. --cgroup-parent
  1024. --cidfile
  1025. --cpu-period
  1026. --cpu-quota
  1027. --cpuset-cpus
  1028. --cpuset-mems
  1029. --cpu-shares -c
  1030. --device
  1031. --dns
  1032. --dns-search
  1033. --entrypoint
  1034. --env -e
  1035. --env-file
  1036. --expose
  1037. --group-add
  1038. --hostname -h
  1039. --ipc
  1040. --kernel-memory
  1041. --label-file
  1042. --label -l
  1043. --link
  1044. --log-driver
  1045. --log-opt
  1046. --lxc-conf
  1047. --mac-address
  1048. --memory -m
  1049. --memory-swap
  1050. --memory-swappiness
  1051. --name
  1052. --net
  1053. --pid
  1054. --publish -p
  1055. --restart
  1056. --security-opt
  1057. --stop-signal
  1058. --ulimit
  1059. --user -u
  1060. --uts
  1061. --volumes-from
  1062. --volume -v
  1063. --workdir -w
  1064. "
  1065. local all_options="$options_with_args
  1066. --disable-content-trust=false
  1067. --help
  1068. --interactive -i
  1069. --oom-kill-disable
  1070. --privileged
  1071. --publish-all -P
  1072. --read-only
  1073. --tty -t
  1074. "
  1075. [ "$command" = "run" ] && all_options="$all_options
  1076. --detach -d
  1077. --rm
  1078. --sig-proxy=false
  1079. "
  1080. local options_with_args_glob=$(__docker_to_extglob "$options_with_args")
  1081. case "$prev" in
  1082. --add-host)
  1083. case "$cur" in
  1084. *:)
  1085. __docker_resolve_hostname
  1086. return
  1087. ;;
  1088. esac
  1089. ;;
  1090. --attach|-a)
  1091. COMPREPLY=( $( compgen -W 'stdin stdout stderr' -- "$cur" ) )
  1092. return
  1093. ;;
  1094. --cap-add|--cap-drop)
  1095. __docker_capabilities
  1096. return
  1097. ;;
  1098. --cidfile|--env-file|--label-file)
  1099. _filedir
  1100. return
  1101. ;;
  1102. --device|--volume|-v)
  1103. case "$cur" in
  1104. *:*)
  1105. # TODO somehow do _filedir for stuff inside the image, if it's already specified (which is also somewhat difficult to determine)
  1106. ;;
  1107. '')
  1108. COMPREPLY=( $( compgen -W '/' -- "$cur" ) )
  1109. compopt -o nospace
  1110. ;;
  1111. /*)
  1112. _filedir
  1113. compopt -o nospace
  1114. ;;
  1115. esac
  1116. return
  1117. ;;
  1118. --env|-e)
  1119. COMPREPLY=( $( compgen -e -- "$cur" ) )
  1120. compopt -o nospace
  1121. return
  1122. ;;
  1123. --ipc)
  1124. case "$cur" in
  1125. *:*)
  1126. cur="${cur#*:}"
  1127. __docker_containers_running
  1128. ;;
  1129. *)
  1130. COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) )
  1131. if [ "$COMPREPLY" = "container:" ]; then
  1132. compopt -o nospace
  1133. fi
  1134. ;;
  1135. esac
  1136. return
  1137. ;;
  1138. --link)
  1139. case "$cur" in
  1140. *:*)
  1141. ;;
  1142. *)
  1143. __docker_containers_running
  1144. COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) )
  1145. compopt -o nospace
  1146. ;;
  1147. esac
  1148. return
  1149. ;;
  1150. --log-driver)
  1151. __docker_log_drivers
  1152. return
  1153. ;;
  1154. --log-opt)
  1155. __docker_log_driver_options
  1156. return
  1157. ;;
  1158. --net)
  1159. case "$cur" in
  1160. container:*)
  1161. local cur=${cur#*:}
  1162. __docker_containers_all
  1163. ;;
  1164. *)
  1165. COMPREPLY=( $( compgen -W "bridge none container: host" -- "$cur") )
  1166. if [ "${COMPREPLY[*]}" = "container:" ] ; then
  1167. compopt -o nospace
  1168. fi
  1169. ;;
  1170. esac
  1171. return
  1172. ;;
  1173. --restart)
  1174. case "$cur" in
  1175. on-failure:*)
  1176. ;;
  1177. *)
  1178. COMPREPLY=( $( compgen -W "no on-failure on-failure: always" -- "$cur") )
  1179. ;;
  1180. esac
  1181. return
  1182. ;;
  1183. --security-opt)
  1184. case "$cur" in
  1185. label:*:*)
  1186. ;;
  1187. label:*)
  1188. local cur=${cur##*:}
  1189. COMPREPLY=( $( compgen -W "user: role: type: level: disable" -- "$cur") )
  1190. if [ "${COMPREPLY[*]}" != "disable" ] ; then
  1191. compopt -o nospace
  1192. fi
  1193. ;;
  1194. *)
  1195. COMPREPLY=( $( compgen -W "label apparmor" -S ":" -- "$cur") )
  1196. compopt -o nospace
  1197. ;;
  1198. esac
  1199. return
  1200. ;;
  1201. --volumes-from)
  1202. __docker_containers_all
  1203. return
  1204. ;;
  1205. $options_with_args_glob )
  1206. return
  1207. ;;
  1208. esac
  1209. __docker_complete_log_driver_options && return
  1210. case "$cur" in
  1211. -*)
  1212. COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
  1213. ;;
  1214. *)
  1215. local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
  1216. if [ $cword -eq $counter ]; then
  1217. __docker_images
  1218. fi
  1219. ;;
  1220. esac
  1221. }
  1222. _docker_save() {
  1223. case "$prev" in
  1224. --output|-o)
  1225. _filedir
  1226. return
  1227. ;;
  1228. esac
  1229. case "$cur" in
  1230. -*)
  1231. COMPREPLY=( $( compgen -W "--help --output -o" -- "$cur" ) )
  1232. ;;
  1233. *)
  1234. __docker_images
  1235. ;;
  1236. esac
  1237. }
  1238. _docker_search() {
  1239. case "$prev" in
  1240. --stars|-s)
  1241. return
  1242. ;;
  1243. esac
  1244. case "$cur" in
  1245. -*)
  1246. COMPREPLY=( $( compgen -W "--automated --help --no-trunc --stars -s" -- "$cur" ) )
  1247. ;;
  1248. esac
  1249. }
  1250. _docker_start() {
  1251. case "$cur" in
  1252. -*)
  1253. COMPREPLY=( $( compgen -W "--attach -a --help --interactive -i" -- "$cur" ) )
  1254. ;;
  1255. *)
  1256. __docker_containers_stopped
  1257. ;;
  1258. esac
  1259. }
  1260. _docker_stats() {
  1261. case "$cur" in
  1262. -*)
  1263. COMPREPLY=( $( compgen -W "--no-stream --help" -- "$cur" ) )
  1264. ;;
  1265. *)
  1266. __docker_containers_running
  1267. ;;
  1268. esac
  1269. }
  1270. _docker_stop() {
  1271. case "$prev" in
  1272. --time|-t)
  1273. return
  1274. ;;
  1275. esac
  1276. case "$cur" in
  1277. -*)
  1278. COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) )
  1279. ;;
  1280. *)
  1281. __docker_containers_running
  1282. ;;
  1283. esac
  1284. }
  1285. _docker_tag() {
  1286. case "$cur" in
  1287. -*)
  1288. COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
  1289. ;;
  1290. *)
  1291. local counter=$(__docker_pos_first_nonflag)
  1292. if [ $cword -eq $counter ]; then
  1293. __docker_image_repos_and_tags
  1294. return
  1295. fi
  1296. (( counter++ ))
  1297. if [ $cword -eq $counter ]; then
  1298. __docker_image_repos_and_tags
  1299. return
  1300. fi
  1301. ;;
  1302. esac
  1303. }
  1304. _docker_unpause() {
  1305. case "$cur" in
  1306. -*)
  1307. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  1308. ;;
  1309. *)
  1310. local counter=$(__docker_pos_first_nonflag)
  1311. if [ $cword -eq $counter ]; then
  1312. __docker_containers_unpauseable
  1313. fi
  1314. ;;
  1315. esac
  1316. }
  1317. _docker_top() {
  1318. case "$cur" in
  1319. -*)
  1320. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  1321. ;;
  1322. *)
  1323. local counter=$(__docker_pos_first_nonflag)
  1324. if [ $cword -eq $counter ]; then
  1325. __docker_containers_running
  1326. fi
  1327. ;;
  1328. esac
  1329. }
  1330. _docker_version() {
  1331. case "$cur" in
  1332. -*)
  1333. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  1334. ;;
  1335. esac
  1336. }
  1337. _docker_volume_create() {
  1338. case "$prev" in
  1339. --driver|-d)
  1340. COMPREPLY=( $( compgen -W "local" -- "$cur" ) )
  1341. return
  1342. ;;
  1343. --name|--opt|-o)
  1344. return
  1345. ;;
  1346. esac
  1347. case "$cur" in
  1348. -*)
  1349. COMPREPLY=( $( compgen -W "--driver -d --help --name --opt -o" -- "$cur" ) )
  1350. ;;
  1351. esac
  1352. }
  1353. _docker_volume_inspect() {
  1354. case "$prev" in
  1355. --format|-f)
  1356. return
  1357. ;;
  1358. esac
  1359. case "$cur" in
  1360. -*)
  1361. COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
  1362. ;;
  1363. *)
  1364. __docker_volumes
  1365. ;;
  1366. esac
  1367. }
  1368. _docker_volume_ls() {
  1369. case "$prev" in
  1370. --filter|-f)
  1371. COMPREPLY=( $( compgen -W "dangling=true" -- "$cur" ) )
  1372. return
  1373. ;;
  1374. esac
  1375. case "$cur" in
  1376. -*)
  1377. COMPREPLY=( $( compgen -W "--filter -f --help --quiet -q" -- "$cur" ) )
  1378. ;;
  1379. esac
  1380. }
  1381. _docker_volume_rm() {
  1382. case "$cur" in
  1383. -*)
  1384. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  1385. ;;
  1386. *)
  1387. __docker_volumes
  1388. ;;
  1389. esac
  1390. }
  1391. _docker_volume() {
  1392. local subcommands=(
  1393. create
  1394. inspect
  1395. ls
  1396. rm
  1397. )
  1398. local counter=$(($command_pos + 1))
  1399. while [ $counter -lt $cword ]; do
  1400. case "${words[$counter]}" in
  1401. $(__docker_to_extglob "${subcommands[*]}") )
  1402. local subcommand=${words[$counter]}
  1403. local completions_func=_docker_volume_$subcommand
  1404. declare -F $completions_func >/dev/null && $completions_func
  1405. return
  1406. ;;
  1407. esac
  1408. (( counter++ ))
  1409. done
  1410. case "$cur" in
  1411. -*)
  1412. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  1413. ;;
  1414. *)
  1415. COMPREPLY=( $( compgen -W "${subcommands[*]}" -- "$cur" ) )
  1416. ;;
  1417. esac
  1418. }
  1419. _docker_wait() {
  1420. case "$cur" in
  1421. -*)
  1422. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  1423. ;;
  1424. *)
  1425. __docker_containers_all
  1426. ;;
  1427. esac
  1428. }
  1429. _docker() {
  1430. local previous_extglob_setting=$(shopt -p extglob)
  1431. shopt -s extglob
  1432. local commands=(
  1433. attach
  1434. build
  1435. commit
  1436. cp
  1437. create
  1438. daemon
  1439. diff
  1440. events
  1441. exec
  1442. export
  1443. history
  1444. images
  1445. import
  1446. info
  1447. inspect
  1448. kill
  1449. load
  1450. login
  1451. logout
  1452. logs
  1453. pause
  1454. port
  1455. ps
  1456. pull
  1457. push
  1458. rename
  1459. restart
  1460. rm
  1461. rmi
  1462. run
  1463. save
  1464. search
  1465. start
  1466. stats
  1467. stop
  1468. tag
  1469. top
  1470. unpause
  1471. version
  1472. volume
  1473. wait
  1474. )
  1475. # These options are valid as global options for all client commands
  1476. # and valid as command options for `docker daemon`
  1477. local global_boolean_options="
  1478. --debug -D
  1479. --tls
  1480. --tlsverify
  1481. "
  1482. local global_options_with_args="
  1483. --config
  1484. --host -H
  1485. --log-level -l
  1486. --tlscacert
  1487. --tlscert
  1488. --tlskey
  1489. "
  1490. local host config
  1491. COMPREPLY=()
  1492. local cur prev words cword
  1493. _get_comp_words_by_ref -n : cur prev words cword
  1494. local command='docker' command_pos=0
  1495. local counter=1
  1496. while [ $counter -lt $cword ]; do
  1497. case "${words[$counter]}" in
  1498. # save host so that completion can use custom daemon
  1499. --host|-H)
  1500. (( counter++ ))
  1501. host="${words[$counter]}"
  1502. ;;
  1503. # save config so that completion can use custom configuration directories
  1504. --config)
  1505. (( counter++ ))
  1506. config="${words[$counter]}"
  1507. ;;
  1508. $(__docker_to_extglob "$global_options_with_args") )
  1509. (( counter++ ))
  1510. ;;
  1511. -*)
  1512. ;;
  1513. =)
  1514. (( counter++ ))
  1515. ;;
  1516. *)
  1517. command="${words[$counter]}"
  1518. command_pos=$counter
  1519. break
  1520. ;;
  1521. esac
  1522. (( counter++ ))
  1523. done
  1524. local completions_func=_docker_${command}
  1525. declare -F $completions_func >/dev/null && $completions_func
  1526. eval "$previous_extglob_setting"
  1527. return 0
  1528. }
  1529. complete -F _docker docker