_docker 84 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147
  1. #compdef docker dockerd
  2. #
  3. # zsh completion for docker (http://docker.com)
  4. #
  5. # version: 0.3.0
  6. # github: https://github.com/felixr/docker-zsh-completion
  7. #
  8. # contributors:
  9. # - Felix Riedel
  10. # - Steve Durrheimer
  11. # - Vincent Bernat
  12. #
  13. # license:
  14. #
  15. # Copyright (c) 2013, Felix Riedel
  16. # All rights reserved.
  17. #
  18. # Redistribution and use in source and binary forms, with or without
  19. # modification, are permitted provided that the following conditions are met:
  20. # * Redistributions of source code must retain the above copyright
  21. # notice, this list of conditions and the following disclaimer.
  22. # * Redistributions in binary form must reproduce the above copyright
  23. # notice, this list of conditions and the following disclaimer in the
  24. # documentation and/or other materials provided with the distribution.
  25. # * Neither the name of the <organization> nor the
  26. # names of its contributors may be used to endorse or promote products
  27. # derived from this software without specific prior written permission.
  28. #
  29. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  30. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  31. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  32. # DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
  33. # DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  34. # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  35. # LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  36. # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  37. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  38. # SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  39. #
  40. # Short-option stacking can be enabled with:
  41. # zstyle ':completion:*:*:docker:*' option-stacking yes
  42. # zstyle ':completion:*:*:docker-*:*' option-stacking yes
  43. __docker_arguments() {
  44. if zstyle -t ":completion:${curcontext}:" option-stacking; then
  45. print -- -s
  46. fi
  47. }
  48. __docker_get_containers() {
  49. [[ $PREFIX = -* ]] && return 1
  50. integer ret=1
  51. local kind type line s
  52. declare -a running stopped lines args names
  53. kind=$1; shift
  54. type=$1; shift
  55. [[ $kind = (stopped|all) ]] && args=($args -a)
  56. lines=(${(f)"$(_call_program commands docker $docker_options ps --format 'table' --no-trunc $args)"})
  57. # Parse header line to find columns
  58. local i=1 j=1 k header=${lines[1]}
  59. declare -A begin end
  60. while (( j < ${#header} - 1 )); do
  61. i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 ))
  62. j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 ))
  63. k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 ))
  64. begin[${header[$i,$((j-1))]}]=$i
  65. end[${header[$i,$((j-1))]}]=$k
  66. done
  67. end[${header[$i,$((j-1))]}]=-1 # Last column, should go to the end of the line
  68. lines=(${lines[2,-1]})
  69. # Container ID
  70. if [[ $type = (ids|all) ]]; then
  71. for line in $lines; do
  72. s="${${line[${begin[CONTAINER ID]},${end[CONTAINER ID]}]%% ##}[0,12]}"
  73. s="$s:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}"
  74. s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}"
  75. if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then
  76. stopped=($stopped $s)
  77. else
  78. running=($running $s)
  79. fi
  80. done
  81. fi
  82. # Names: we only display the one without slash. All other names
  83. # are generated and may clutter the completion. However, with
  84. # Swarm, all names may be prefixed by the swarm node name.
  85. if [[ $type = (names|all) ]]; then
  86. for line in $lines; do
  87. names=(${(ps:,:)${${line[${begin[NAMES]},${end[NAMES]}]}%% *}})
  88. # First step: find a common prefix and strip it (swarm node case)
  89. (( ${#${(u)names%%/*}} == 1 )) && names=${names#${names[1]%%/*}/}
  90. # Second step: only keep the first name without a /
  91. s=${${names:#*/*}[1]}
  92. # If no name, well give up.
  93. (( $#s != 0 )) || continue
  94. s="$s:${(l:15:: :::)${${line[${begin[CREATED]},${end[CREATED]}]/ ago/}%% ##}}"
  95. s="$s, ${${${line[${begin[IMAGE]},${end[IMAGE]}]}/:/\\:}%% ##}"
  96. if [[ ${line[${begin[STATUS]},${end[STATUS]}]} = Exit* ]]; then
  97. stopped=($stopped $s)
  98. else
  99. running=($running $s)
  100. fi
  101. done
  102. fi
  103. [[ $kind = (running|all) ]] && _describe -t containers-running "running containers" running "$@" && ret=0
  104. [[ $kind = (stopped|all) ]] && _describe -t containers-stopped "stopped containers" stopped "$@" && ret=0
  105. return ret
  106. }
  107. __docker_stoppedcontainers() {
  108. [[ $PREFIX = -* ]] && return 1
  109. __docker_get_containers stopped all "$@"
  110. }
  111. __docker_runningcontainers() {
  112. [[ $PREFIX = -* ]] && return 1
  113. __docker_get_containers running all "$@"
  114. }
  115. __docker_containers() {
  116. [[ $PREFIX = -* ]] && return 1
  117. __docker_get_containers all all "$@"
  118. }
  119. __docker_containers_ids() {
  120. [[ $PREFIX = -* ]] && return 1
  121. __docker_get_containers all ids "$@"
  122. }
  123. __docker_containers_names() {
  124. [[ $PREFIX = -* ]] && return 1
  125. __docker_get_containers all names "$@"
  126. }
  127. __docker_complete_info_plugins() {
  128. [[ $PREFIX = -* ]] && return 1
  129. integer ret=1
  130. emulate -L zsh
  131. setopt extendedglob
  132. local -a plugins
  133. plugins=(${(ps: :)${(M)${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'Plugins:}%%$'\n'^ *}}:# $1: *}## $1: })
  134. _describe -t plugins "$1 plugins" plugins && ret=0
  135. return ret
  136. }
  137. __docker_images() {
  138. [[ $PREFIX = -* ]] && return 1
  139. integer ret=1
  140. declare -a images
  141. images=(${${${(f)"$(_call_program commands docker $docker_options images)"}[2,-1]}/(#b)([^ ]##) ##([^ ]##) ##([^ ]##)*/${match[3]}:${(r:15:: :::)match[2]} in ${match[1]}})
  142. _describe -t docker-images "images" images && ret=0
  143. __docker_repositories_with_tags && ret=0
  144. return ret
  145. }
  146. __docker_repositories() {
  147. [[ $PREFIX = -* ]] && return 1
  148. declare -a repos
  149. repos=(${${${(f)"$(_call_program commands docker $docker_options images)"}%% *}[2,-1]})
  150. repos=(${repos#<none>})
  151. _describe -t docker-repos "repositories" repos
  152. }
  153. __docker_repositories_with_tags() {
  154. [[ $PREFIX = -* ]] && return 1
  155. integer ret=1
  156. declare -a repos onlyrepos matched
  157. declare m
  158. repos=(${${${${(f)"$(_call_program commands docker $docker_options images)"}[2,-1]}/ ##/:::}%% *})
  159. repos=(${${repos%:::<none>}#<none>})
  160. # Check if we have a prefix-match for the current prefix.
  161. onlyrepos=(${repos%::*})
  162. for m in $onlyrepos; do
  163. [[ ${PREFIX##${~~m}} != ${PREFIX} ]] && {
  164. # Yes, complete with tags
  165. repos=(${${repos/:::/:}/:/\\:})
  166. _describe -t docker-repos-with-tags "repositories with tags" repos && ret=0
  167. return ret
  168. }
  169. done
  170. # No, only complete repositories
  171. onlyrepos=(${${repos%:::*}/:/\\:})
  172. _describe -t docker-repos "repositories" onlyrepos -qS : && ret=0
  173. return ret
  174. }
  175. __docker_search() {
  176. [[ $PREFIX = -* ]] && return 1
  177. local cache_policy
  178. zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
  179. if [[ -z "$cache_policy" ]]; then
  180. zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy
  181. fi
  182. local searchterm cachename
  183. searchterm="${words[$CURRENT]%/}"
  184. cachename=_docker-search-$searchterm
  185. local expl
  186. local -a result
  187. if ( [[ ${(P)+cachename} -eq 0 ]] || _cache_invalid ${cachename#_} ) \
  188. && ! _retrieve_cache ${cachename#_}; then
  189. _message "Searching for ${searchterm}..."
  190. result=(${${${(f)"$(_call_program commands docker $docker_options search $searchterm)"}%% *}[2,-1]})
  191. _store_cache ${cachename#_} result
  192. fi
  193. _wanted dockersearch expl 'available images' compadd -a result
  194. }
  195. __docker_get_log_options() {
  196. [[ $PREFIX = -* ]] && return 1
  197. integer ret=1
  198. local log_driver=${opt_args[--log-driver]:-"all"}
  199. local -a awslogs_options fluentd_options gelf_options journald_options json_file_options syslog_options splunk_options
  200. awslogs_options=("awslogs-region" "awslogs-group" "awslogs-stream")
  201. fluentd_options=("env" "fluentd-address" "fluentd-async-connect" "fluentd-buffer-limit" "fluentd-retry-wait" "fluentd-max-retries" "labels" "tag")
  202. gcplogs_options=("env" "gcp-log-cmd" "gcp-project" "labels")
  203. gelf_options=("env" "gelf-address" "gelf-compression-level" "gelf-compression-type" "labels" "tag")
  204. journald_options=("env" "labels" "tag")
  205. json_file_options=("env" "labels" "max-file" "max-size")
  206. 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")
  207. splunk_options=("env" "labels" "splunk-caname" "splunk-capath" "splunk-format" "splunk-gzip" "splunk-gzip-level" "splunk-index" "splunk-insecureskipverify" "splunk-source" "splunk-sourcetype" "splunk-token" "splunk-url" "splunk-verify-connection" "tag")
  208. [[ $log_driver = (awslogs|all) ]] && _describe -t awslogs-options "awslogs options" awslogs_options "$@" && ret=0
  209. [[ $log_driver = (fluentd|all) ]] && _describe -t fluentd-options "fluentd options" fluentd_options "$@" && ret=0
  210. [[ $log_driver = (gcplogs|all) ]] && _describe -t gcplogs-options "gcplogs options" gcplogs_options "$@" && ret=0
  211. [[ $log_driver = (gelf|all) ]] && _describe -t gelf-options "gelf options" gelf_options "$@" && ret=0
  212. [[ $log_driver = (journald|all) ]] && _describe -t journald-options "journald options" journald_options "$@" && ret=0
  213. [[ $log_driver = (json-file|all) ]] && _describe -t json-file-options "json-file options" json_file_options "$@" && ret=0
  214. [[ $log_driver = (syslog|all) ]] && _describe -t syslog-options "syslog options" syslog_options "$@" && ret=0
  215. [[ $log_driver = (splunk|all) ]] && _describe -t splunk-options "splunk options" splunk_options "$@" && ret=0
  216. return ret
  217. }
  218. __docker_log_drivers() {
  219. [[ $PREFIX = -* ]] && return 1
  220. integer ret=1
  221. drivers=(awslogs etwlogs fluentd gcplogs gelf journald json-file none splunk syslog)
  222. _describe -t log-drivers "log drivers" drivers && ret=0
  223. return ret
  224. }
  225. __docker_log_options() {
  226. [[ $PREFIX = -* ]] && return 1
  227. integer ret=1
  228. if compset -P '*='; then
  229. case "${${words[-1]%=*}#*=}" in
  230. (syslog-format)
  231. syslog_format_opts=('rfc3164' 'rfc5424' 'rfc5424micro')
  232. _describe -t syslog-format-opts "Syslog format Options" syslog_format_opts && ret=0
  233. ;;
  234. *)
  235. _message 'value' && ret=0
  236. ;;
  237. esac
  238. else
  239. __docker_get_log_options -qS "=" && ret=0
  240. fi
  241. return ret
  242. }
  243. __docker_complete_detach_keys() {
  244. [[ $PREFIX = -* ]] && return 1
  245. integer ret=1
  246. compset -P "*,"
  247. keys=(${:-{a-z}})
  248. ctrl_keys=(${:-ctrl-{{a-z},{@,'[','\\','^',']',_}}})
  249. _describe -t detach_keys "[a-z]" keys -qS "," && ret=0
  250. _describe -t detach_keys-ctrl "'ctrl-' + 'a-z @ [ \\\\ ] ^ _'" ctrl_keys -qS "," && ret=0
  251. }
  252. __docker_complete_pid() {
  253. [[ $PREFIX = -* ]] && return 1
  254. integer ret=1
  255. local -a opts vopts
  256. opts=('host')
  257. vopts=('container')
  258. if compset -P '*:'; then
  259. case "${${words[-1]%:*}#*=}" in
  260. (container)
  261. __docker_runningcontainers && ret=0
  262. ;;
  263. *)
  264. _message 'value' && ret=0
  265. ;;
  266. esac
  267. else
  268. _describe -t pid-value-opts "PID Options with value" vopts -qS ":" && ret=0
  269. _describe -t pid-opts "PID Options" opts && ret=0
  270. fi
  271. return ret
  272. }
  273. __docker_complete_runtimes() {
  274. [[ $PREFIX = -* ]] && return 1
  275. integer ret=1
  276. emulate -L zsh
  277. setopt extendedglob
  278. local -a runtimes_opts
  279. runtimes_opts=(${(ps: :)${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'Runtimes: }%%$'\n'^ *}}})
  280. _describe -t runtimes-opts "runtimes options" runtimes_opts && ret=0
  281. }
  282. __docker_complete_ps_filters() {
  283. [[ $PREFIX = -* ]] && return 1
  284. integer ret=1
  285. if compset -P '*='; then
  286. case "${${words[-1]%=*}#*=}" in
  287. (ancestor)
  288. __docker_images && ret=0
  289. ;;
  290. (before|since)
  291. __docker_containers && ret=0
  292. ;;
  293. (id)
  294. __docker_containers_ids && ret=0
  295. ;;
  296. (name)
  297. __docker_containers_names && ret=0
  298. ;;
  299. (network)
  300. __docker_networks && ret=0
  301. ;;
  302. (status)
  303. status_opts=('created' 'dead' 'exited' 'paused' 'restarting' 'running' 'removing')
  304. _describe -t status-filter-opts "Status Filter Options" status_opts && ret=0
  305. ;;
  306. (volume)
  307. __docker_volumes && ret=0
  308. ;;
  309. *)
  310. _message 'value' && ret=0
  311. ;;
  312. esac
  313. else
  314. opts=('ancestor' 'before' 'exited' 'id' 'label' 'name' 'network' 'since' 'status' 'volume')
  315. _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0
  316. fi
  317. return ret
  318. }
  319. __docker_complete_search_filters() {
  320. [[ $PREFIX = -* ]] && return 1
  321. integer ret=1
  322. declare -a boolean_opts opts
  323. boolean_opts=('true' 'false')
  324. opts=('is-automated' 'is-official' 'stars')
  325. if compset -P '*='; then
  326. case "${${words[-1]%=*}#*=}" in
  327. (is-automated|is-official)
  328. _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0
  329. ;;
  330. *)
  331. _message 'value' && ret=0
  332. ;;
  333. esac
  334. else
  335. _describe -t filter-opts "filter options" opts -qS "=" && ret=0
  336. fi
  337. return ret
  338. }
  339. __docker_complete_images_filters() {
  340. [[ $PREFIX = -* ]] && return 1
  341. integer ret=1
  342. declare -a boolean_opts opts
  343. boolean_opts=('true' 'false')
  344. opts=('before' 'dangling' 'label' 'since')
  345. if compset -P '*='; then
  346. case "${${words[-1]%=*}#*=}" in
  347. (before|since)
  348. __docker_images && ret=0
  349. ;;
  350. (dangling)
  351. _describe -t boolean-filter-opts "filter options" boolean_opts && ret=0
  352. ;;
  353. *)
  354. _message 'value' && ret=0
  355. ;;
  356. esac
  357. else
  358. _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0
  359. fi
  360. return ret
  361. }
  362. __docker_complete_events_filter() {
  363. [[ $PREFIX = -* ]] && return 1
  364. integer ret=1
  365. declare -a opts
  366. opts=('container' 'daemon' 'event' 'image' 'label' 'network' 'type' 'volume')
  367. if compset -P '*='; then
  368. case "${${words[-1]%=*}#*=}" in
  369. (container)
  370. __docker_containers && ret=0
  371. ;;
  372. (daemon)
  373. emulate -L zsh
  374. setopt extendedglob
  375. local -a daemon_opts
  376. daemon_opts=(
  377. ${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'Name: }%%$'\n'^ *}}
  378. ${${(f)${${"$(_call_program commands docker $docker_options info)"##*$'\n'ID: }%%$'\n'^ *}}//:/\\:}
  379. )
  380. _describe -t daemon-filter-opts "daemon filter options" daemon_opts && ret=0
  381. ;;
  382. (event)
  383. local -a event_opts
  384. event_opts=('attach' 'commit' 'connect' 'copy' 'create' 'delete' 'destroy' 'detach' 'die' 'disconnect' 'exec_create' 'exec_detach'
  385. 'exec_start' 'export' 'health_status' 'import' 'kill' 'load' 'mount' 'oom' 'pause' 'pull' 'push' 'reload' 'rename' 'resize' 'restart' 'save' 'start'
  386. 'stop' 'tag' 'top' 'unmount' 'unpause' 'untag' 'update')
  387. _describe -t event-filter-opts "event filter options" event_opts && ret=0
  388. ;;
  389. (image)
  390. __docker_images && ret=0
  391. ;;
  392. (network)
  393. __docker_networks && ret=0
  394. ;;
  395. (type)
  396. local -a type_opts
  397. type_opts=('container' 'daemon' 'image' 'network' 'volume')
  398. _describe -t type-filter-opts "type filter options" type_opts && ret=0
  399. ;;
  400. (volume)
  401. __docker_volumes && ret=0
  402. ;;
  403. *)
  404. _message 'value' && ret=0
  405. ;;
  406. esac
  407. else
  408. _describe -t filter-opts "filter options" opts -qS "=" && ret=0
  409. fi
  410. return ret
  411. }
  412. # BO network
  413. __docker_network_complete_ls_filters() {
  414. [[ $PREFIX = -* ]] && return 1
  415. integer ret=1
  416. if compset -P '*='; then
  417. case "${${words[-1]%=*}#*=}" in
  418. (driver)
  419. __docker_complete_info_plugins Network && ret=0
  420. ;;
  421. (id)
  422. __docker_networks_ids && ret=0
  423. ;;
  424. (name)
  425. __docker_networks_names && ret=0
  426. ;;
  427. (type)
  428. type_opts=('builtin' 'custom')
  429. _describe -t type-filter-opts "Type Filter Options" type_opts && ret=0
  430. ;;
  431. *)
  432. _message 'value' && ret=0
  433. ;;
  434. esac
  435. else
  436. opts=('driver' 'id' 'label' 'name' 'type')
  437. _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0
  438. fi
  439. return ret
  440. }
  441. __docker_get_networks() {
  442. [[ $PREFIX = -* ]] && return 1
  443. integer ret=1
  444. local line s
  445. declare -a lines networks
  446. type=$1; shift
  447. lines=(${(f)"$(_call_program commands docker $docker_options network ls)"})
  448. # Parse header line to find columns
  449. local i=1 j=1 k header=${lines[1]}
  450. declare -A begin end
  451. while (( j < ${#header} - 1 )); do
  452. i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 ))
  453. j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 ))
  454. k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 ))
  455. begin[${header[$i,$((j-1))]}]=$i
  456. end[${header[$i,$((j-1))]}]=$k
  457. done
  458. end[${header[$i,$((j-1))]}]=-1
  459. lines=(${lines[2,-1]})
  460. # Network ID
  461. if [[ $type = (ids|all) ]]; then
  462. for line in $lines; do
  463. s="${line[${begin[NETWORK ID]},${end[NETWORK ID]}]%% ##}"
  464. s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}"
  465. networks=($networks $s)
  466. done
  467. fi
  468. # Names
  469. if [[ $type = (names|all) ]]; then
  470. for line in $lines; do
  471. s="${line[${begin[NAME]},${end[NAME]}]%% ##}"
  472. s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}"
  473. networks=($networks $s)
  474. done
  475. fi
  476. _describe -t networks-list "networks" networks "$@" && ret=0
  477. return ret
  478. }
  479. __docker_networks() {
  480. [[ $PREFIX = -* ]] && return 1
  481. __docker_get_networks all "$@"
  482. }
  483. __docker_networks_ids() {
  484. [[ $PREFIX = -* ]] && return 1
  485. __docker_get_networks ids "$@"
  486. }
  487. __docker_networks_names() {
  488. [[ $PREFIX = -* ]] && return 1
  489. __docker_get_networks names "$@"
  490. }
  491. __docker_network_commands() {
  492. local -a _docker_network_subcommands
  493. _docker_network_subcommands=(
  494. "connect:Connect a container to a network"
  495. "create:Creates a new network with a name specified by the user"
  496. "disconnect:Disconnects a container from a network"
  497. "inspect:Displays detailed information on a network"
  498. "ls:Lists all the networks created by the user"
  499. "rm:Deletes one or more networks"
  500. )
  501. _describe -t docker-network-commands "docker network command" _docker_network_subcommands
  502. }
  503. __docker_network_subcommand() {
  504. local -a _command_args opts_help
  505. local expl help="--help"
  506. integer ret=1
  507. opts_help=("(: -)--help[Print usage]")
  508. case "$words[1]" in
  509. (connect)
  510. _arguments $(__docker_arguments) \
  511. $opts_help \
  512. "($help)*--alias=[Add network-scoped alias for the container]:alias: " \
  513. "($help)--ip=[Container IPv4 address]:IPv4: " \
  514. "($help)--ip6=[Container IPv6 address]:IPv6: " \
  515. "($help)*--link=[Add a link to another container]:link:->link" \
  516. "($help)*--link-local-ip=[Add a link-local address for the container]:IPv4/IPv6: " \
  517. "($help -)1:network:__docker_networks" \
  518. "($help -)2:containers:__docker_containers" && ret=0
  519. case $state in
  520. (link)
  521. if compset -P "*:"; then
  522. _wanted alias expl "Alias" compadd -E "" && ret=0
  523. else
  524. __docker_runningcontainers -qS ":" && ret=0
  525. fi
  526. ;;
  527. esac
  528. ;;
  529. (create)
  530. _arguments $(__docker_arguments) -A '-*' \
  531. $opts_help \
  532. "($help)*--aux-address[Auxiliary IPv4 or IPv6 addresses used by network driver]:key=IP: " \
  533. "($help -d --driver)"{-d=,--driver=}"[Driver to manage the Network]:driver:(null host bridge overlay)" \
  534. "($help)*--gateway=[IPv4 or IPv6 Gateway for the master subnet]:IP: " \
  535. "($help)--internal[Restricts external access to the network]" \
  536. "($help)*--ip-range=[Allocate container ip from a sub-range]:IP/mask: " \
  537. "($help)--ipam-driver=[IP Address Management Driver]:driver:(default)" \
  538. "($help)*--ipam-opt=[Custom IPAM plugin options]:opt=value: " \
  539. "($help)--ipv6[Enable IPv6 networking]" \
  540. "($help)*--label=[Set metadata on a network]:label=value: " \
  541. "($help)*"{-o=,--opt=}"[Driver specific options]:opt=value: " \
  542. "($help)*--subnet=[Subnet in CIDR format that represents a network segment]:IP/mask: " \
  543. "($help -)1:Network Name: " && ret=0
  544. ;;
  545. (disconnect)
  546. _arguments $(__docker_arguments) \
  547. $opts_help \
  548. "($help -)1:network:__docker_networks" \
  549. "($help -)2:containers:__docker_containers" && ret=0
  550. ;;
  551. (inspect)
  552. _arguments $(__docker_arguments) \
  553. $opts_help \
  554. "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \
  555. "($help -)*:network:__docker_networks" && ret=0
  556. ;;
  557. (ls)
  558. _arguments $(__docker_arguments) \
  559. $opts_help \
  560. "($help)--no-trunc[Do not truncate the output]" \
  561. "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
  562. "($help)--format=[Pretty-print networks using a Go template]:template: " \
  563. "($help -q --quiet)"{-q,--quiet}"[Only display numeric IDs]" && ret=0
  564. case $state in
  565. (filter-options)
  566. __docker_network_complete_ls_filters && ret=0
  567. ;;
  568. esac
  569. ;;
  570. (rm)
  571. _arguments $(__docker_arguments) \
  572. $opts_help \
  573. "($help -)*:network:__docker_networks" && ret=0
  574. ;;
  575. (help)
  576. _arguments $(__docker_arguments) ":subcommand:__docker_network_commands" && ret=0
  577. ;;
  578. esac
  579. return ret
  580. }
  581. # EO network
  582. # BO node
  583. __docker_node_complete_ls_filters() {
  584. [[ $PREFIX = -* ]] && return 1
  585. integer ret=1
  586. if compset -P '*='; then
  587. case "${${words[-1]%=*}#*=}" in
  588. (id)
  589. __docker_complete_nodes_ids && ret=0
  590. ;;
  591. (membership)
  592. membership_opts=('accepted' 'pending' 'rejected')
  593. _describe -t membership-opts "membership options" membership_opts && ret=0
  594. ;;
  595. (name)
  596. __docker_complete_nodes_names && ret=0
  597. ;;
  598. (role)
  599. role_opts=('manager' 'worker')
  600. _describe -t role-opts "role options" role_opts && ret=0
  601. ;;
  602. *)
  603. _message 'value' && ret=0
  604. ;;
  605. esac
  606. else
  607. opts=('id' 'label' 'membership' 'name' 'role')
  608. _describe -t filter-opts "filter options" opts -qS "=" && ret=0
  609. fi
  610. return ret
  611. }
  612. __docker_node_complete_ps_filters() {
  613. [[ $PREFIX = -* ]] && return 1
  614. integer ret=1
  615. if compset -P '*='; then
  616. case "${${words[-1]%=*}#*=}" in
  617. (desired-state)
  618. state_opts=('accepted' 'running')
  619. _describe -t state-opts "desired state options" state_opts && ret=0
  620. ;;
  621. *)
  622. _message 'value' && ret=0
  623. ;;
  624. esac
  625. else
  626. opts=('desired-state' 'id' 'label' 'name')
  627. _describe -t filter-opts "filter options" opts -qS "=" && ret=0
  628. fi
  629. return ret
  630. }
  631. __docker_nodes() {
  632. [[ $PREFIX = -* ]] && return 1
  633. integer ret=1
  634. local line s
  635. declare -a lines nodes args
  636. type=$1; shift
  637. filter=$1; shift
  638. [[ $filter != "none" ]] && args=("-f $filter")
  639. lines=(${(f)"$(_call_program commands docker $docker_options node ls $args)"})
  640. # Parse header line to find columns
  641. local i=1 j=1 k header=${lines[1]}
  642. declare -A begin end
  643. while (( j < ${#header} - 1 )); do
  644. i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 ))
  645. j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 ))
  646. k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 ))
  647. begin[${header[$i,$((j-1))]}]=$i
  648. end[${header[$i,$((j-1))]}]=$k
  649. done
  650. end[${header[$i,$((j-1))]}]=-1
  651. lines=(${lines[2,-1]})
  652. # Node ID
  653. if [[ $type = (ids|all) ]]; then
  654. for line in $lines; do
  655. s="${line[${begin[ID]},${end[ID]}]%% ##}"
  656. nodes=($nodes $s)
  657. done
  658. fi
  659. # Names
  660. if [[ $type = (names|all) ]]; then
  661. for line in $lines; do
  662. s="${line[${begin[NAME]},${end[NAME]}]%% ##}"
  663. nodes=($nodes $s)
  664. done
  665. fi
  666. _describe -t nodes-list "nodes" nodes "$@" && ret=0
  667. return ret
  668. }
  669. __docker_complete_nodes() {
  670. [[ $PREFIX = -* ]] && return 1
  671. __docker_nodes all none "$@"
  672. }
  673. __docker_complete_nodes_ids() {
  674. [[ $PREFIX = -* ]] && return 1
  675. __docker_nodes ids none "$@"
  676. }
  677. __docker_complete_nodes_names() {
  678. [[ $PREFIX = -* ]] && return 1
  679. __docker_nodes names none "$@"
  680. }
  681. __docker_complete_pending_nodes() {
  682. [[ $PREFIX = -* ]] && return 1
  683. __docker_nodes all "membership=pending" "$@"
  684. }
  685. __docker_complete_manager_nodes() {
  686. [[ $PREFIX = -* ]] && return 1
  687. __docker_nodes all "role=manager" "$@"
  688. }
  689. __docker_complete_worker_nodes() {
  690. [[ $PREFIX = -* ]] && return 1
  691. __docker_nodes all "role=worker" "$@"
  692. }
  693. __docker_node_commands() {
  694. local -a _docker_node_subcommands
  695. _docker_node_subcommands=(
  696. "demote:Demote a node as manager in the swarm"
  697. "inspect:Display detailed information on one or more nodes"
  698. "ls:List nodes in the swarm"
  699. "promote:Promote a node as manager in the swarm"
  700. "rm:Remove one or more nodes from the swarm"
  701. "ps:List tasks running on a node, defaults to current node"
  702. "update:Update a node"
  703. )
  704. _describe -t docker-node-commands "docker node command" _docker_node_subcommands
  705. }
  706. __docker_node_subcommand() {
  707. local -a _command_args opts_help
  708. local expl help="--help"
  709. integer ret=1
  710. opts_help=("(: -)--help[Print usage]")
  711. case "$words[1]" in
  712. (rm|remove)
  713. _arguments $(__docker_arguments) \
  714. $opts_help \
  715. "($help)--force[Force remove an active node]" \
  716. "($help -)*:node:__docker_complete_pending_nodes" && ret=0
  717. ;;
  718. (demote)
  719. _arguments $(__docker_arguments) \
  720. $opts_help \
  721. "($help -)*:node:__docker_complete_manager_nodes" && ret=0
  722. ;;
  723. (inspect)
  724. _arguments $(__docker_arguments) \
  725. $opts_help \
  726. "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \
  727. "($help)--pretty[Print the information in a human friendly format]" \
  728. "($help -)*:node:__docker_complete_nodes" && ret=0
  729. ;;
  730. (ls|list)
  731. _arguments $(__docker_arguments) \
  732. $opts_help \
  733. "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
  734. "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0
  735. case $state in
  736. (filter-options)
  737. __docker_node_complete_ls_filters && ret=0
  738. ;;
  739. esac
  740. ;;
  741. (promote)
  742. _arguments $(__docker_arguments) \
  743. $opts_help \
  744. "($help -)*:node:__docker_complete_worker_nodes" && ret=0
  745. ;;
  746. (ps)
  747. _arguments $(__docker_arguments) \
  748. $opts_help \
  749. "($help -a --all)"{-a,--all}"[Display all instances]" \
  750. "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
  751. "($help)--no-resolve[Do not map IDs to Names]" \
  752. "($help)--no-trunc[Do not truncate output]" \
  753. "($help -)1:node:__docker_complete_nodes" && ret=0
  754. case $state in
  755. (filter-options)
  756. __docker_node_complete_ps_filters && ret=0
  757. ;;
  758. esac
  759. ;;
  760. (update)
  761. _arguments $(__docker_arguments) \
  762. $opts_help \
  763. "($help)--availability=[Availability of the node]:availability:(active pause drain)" \
  764. "($help)*--label-add=[Add or update a node label]:key=value: " \
  765. "($help)*--label-rm=[Remove a node label if exists]:label: " \
  766. "($help)--role=[Role of the node]:role:(manager worker)" \
  767. "($help -)1:node:__docker_complete_nodes" && ret=0
  768. ;;
  769. (help)
  770. _arguments $(__docker_arguments) ":subcommand:__docker_node_commands" && ret=0
  771. ;;
  772. esac
  773. return ret
  774. }
  775. # EO node
  776. # BO plugin
  777. __docker_complete_plugins() {
  778. [[ $PREFIX = -* ]] && return 1
  779. integer ret=1
  780. local line s
  781. declare -a lines plugins
  782. lines=(${(f)"$(_call_program commands docker $docker_options plugin ls)"})
  783. # Parse header line to find columns
  784. local i=1 j=1 k header=${lines[1]}
  785. declare -A begin end
  786. while (( j < ${#header} - 1 )); do
  787. i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 ))
  788. j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 ))
  789. k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 ))
  790. begin[${header[$i,$((j-1))]}]=$i
  791. end[${header[$i,$((j-1))]}]=$k
  792. done
  793. end[${header[$i,$((j-1))]}]=-1
  794. lines=(${lines[2,-1]})
  795. # Name
  796. for line in $lines; do
  797. s="${line[${begin[NAME]},${end[NAME]}]%% ##}"
  798. s="$s:${(l:7:: :::)${${line[${begin[TAG]},${end[TAG]}]}%% ##}}"
  799. plugins=($plugins $s)
  800. done
  801. _describe -t plugins-list "plugins" plugins "$@" && ret=0
  802. return ret
  803. }
  804. __docker_plugin_commands() {
  805. local -a _docker_plugin_subcommands
  806. _docker_plugin_subcommands=(
  807. "disable:Disable a plugin"
  808. "enable:Enable a plugin"
  809. "inspect:Return low-level information about a plugin"
  810. "install:Install a plugin"
  811. "ls:List plugins"
  812. "push:Push a plugin"
  813. "rm:Remove a plugin"
  814. "set:Change settings for a plugin"
  815. )
  816. _describe -t docker-plugin-commands "docker plugin command" _docker_plugin_subcommands
  817. }
  818. __docker_plugin_subcommand() {
  819. local -a _command_args opts_help
  820. local expl help="--help"
  821. integer ret=1
  822. opts_help=("(: -)--help[Print usage]")
  823. case "$words[1]" in
  824. (disable|enable|inspect|install|ls|push|rm)
  825. _arguments $(__docker_arguments) \
  826. $opts_help \
  827. "($help -)1:plugin:__docker_complete_plugins" && ret=0
  828. ;;
  829. (set)
  830. _arguments $(__docker_arguments) \
  831. $opts_help \
  832. "($help -)1:plugin:__docker_complete_plugins" \
  833. "($help-)*:key=value: " && ret=0
  834. ;;
  835. (help)
  836. _arguments $(__docker_arguments) ":subcommand:__docker_plugin_commands" && ret=0
  837. ;;
  838. esac
  839. return ret
  840. }
  841. # EO plugin
  842. # BO service
  843. __docker_service_complete_ls_filters() {
  844. [[ $PREFIX = -* ]] && return 1
  845. integer ret=1
  846. if compset -P '*='; then
  847. case "${${words[-1]%=*}#*=}" in
  848. (id)
  849. __docker_complete_services_ids && ret=0
  850. ;;
  851. (name)
  852. __docker_complete_services_names && ret=0
  853. ;;
  854. *)
  855. _message 'value' && ret=0
  856. ;;
  857. esac
  858. else
  859. opts=('id' 'label' 'name')
  860. _describe -t filter-opts "filter options" opts -qS "=" && ret=0
  861. fi
  862. return ret
  863. }
  864. __docker_service_complete_ps_filters() {
  865. [[ $PREFIX = -* ]] && return 1
  866. integer ret=1
  867. if compset -P '*='; then
  868. case "${${words[-1]%=*}#*=}" in
  869. (desired-state)
  870. state_opts=('accepted' 'running')
  871. _describe -t state-opts "desired state options" state_opts && ret=0
  872. ;;
  873. *)
  874. _message 'value' && ret=0
  875. ;;
  876. esac
  877. else
  878. opts=('desired-state' 'id' 'label' 'name')
  879. _describe -t filter-opts "filter options" opts -qS "=" && ret=0
  880. fi
  881. return ret
  882. }
  883. __docker_services() {
  884. [[ $PREFIX = -* ]] && return 1
  885. integer ret=1
  886. local line s
  887. declare -a lines services
  888. type=$1; shift
  889. lines=(${(f)"$(_call_program commands docker $docker_options service ls)"})
  890. # Parse header line to find columns
  891. local i=1 j=1 k header=${lines[1]}
  892. declare -A begin end
  893. while (( j < ${#header} - 1 )); do
  894. i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 ))
  895. j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 ))
  896. k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 ))
  897. begin[${header[$i,$((j-1))]}]=$i
  898. end[${header[$i,$((j-1))]}]=$k
  899. done
  900. end[${header[$i,$((j-1))]}]=-1
  901. lines=(${lines[2,-1]})
  902. # Service ID
  903. if [[ $type = (ids|all) ]]; then
  904. for line in $lines; do
  905. s="${line[${begin[ID]},${end[ID]}]%% ##}"
  906. s="$s:${(l:7:: :::)${${line[${begin[IMAGE]},${end[IMAGE]}]}%% ##}}"
  907. services=($services $s)
  908. done
  909. fi
  910. # Names
  911. if [[ $type = (names|all) ]]; then
  912. for line in $lines; do
  913. s="${line[${begin[NAME]},${end[NAME]}]%% ##}"
  914. s="$s:${(l:7:: :::)${${line[${begin[IMAGE]},${end[IMAGE]}]}%% ##}}"
  915. services=($services $s)
  916. done
  917. fi
  918. _describe -t services-list "services" services "$@" && ret=0
  919. return ret
  920. }
  921. __docker_complete_services() {
  922. [[ $PREFIX = -* ]] && return 1
  923. __docker_services all "$@"
  924. }
  925. __docker_complete_services_ids() {
  926. [[ $PREFIX = -* ]] && return 1
  927. __docker_services ids "$@"
  928. }
  929. __docker_complete_services_names() {
  930. [[ $PREFIX = -* ]] && return 1
  931. __docker_services names "$@"
  932. }
  933. __docker_service_commands() {
  934. local -a _docker_service_subcommands
  935. _docker_service_subcommands=(
  936. "create:Create a new service"
  937. "inspect:Display detailed information on one or more services"
  938. "ls:List services"
  939. "rm:Remove one or more services"
  940. "scale:Scale one or multiple services"
  941. "ps:List the tasks of a service"
  942. "update:Update a service"
  943. )
  944. _describe -t docker-service-commands "docker service command" _docker_service_subcommands
  945. }
  946. __docker_service_subcommand() {
  947. local -a _command_args opts_help opts_create_update
  948. local expl help="--help"
  949. integer ret=1
  950. opts_help=("(: -)--help[Print usage]")
  951. opts_create_update=(
  952. "($help)*--constraint=[Placement constraints]:constraint: "
  953. "($help)--endpoint-mode=[Placement constraints]:mode:(dnsrr vip)"
  954. "($help)*"{-e=,--env=}"[Set environment variables]:env: "
  955. "($help)*--group-add=[Add additional user groups to the container]:group:_groups"
  956. "($help)*--label=[Service labels]:label: "
  957. "($help)--limit-cpu=[Limit CPUs]:value: "
  958. "($help)--limit-memory=[Limit Memory]:value: "
  959. "($help)--log-driver=[Logging driver for service]:logging driver:__docker_log_drivers"
  960. "($help)*--log-opt=[Logging driver options]:log driver options:__docker_log_options"
  961. "($help)*--mount=[Attach a mount to the service]:mount: "
  962. "($help)--name=[Service name]:name: "
  963. "($help)*--network=[Network attachments]:network: "
  964. "($help)*"{-p=,--publish=}"[Publish a port as a node port]:port: "
  965. "($help)--replicas=[Number of tasks]:replicas: "
  966. "($help)--reserve-cpu=[Reserve CPUs]:value: "
  967. "($help)--reserve-memory=[Reserve Memory]:value: "
  968. "($help)--restart-condition=[Restart when condition is met]:mode:(any none on-failure)"
  969. "($help)--restart-delay=[Delay between restart attempts]:delay: "
  970. "($help)--restart-max-attempts=[Maximum number of restarts before giving up]:max-attempts: "
  971. "($help)--restart-window=[Window used to evaluate the restart policy]:window: "
  972. "($help)--stop-grace-period=[Time to wait before force killing a container]:grace period: "
  973. "($help)--update-delay=[Delay between updates]:delay: "
  974. "($help)--update-failure-action=[Action on update failure]:mode:(pause continue)"
  975. "($help)--update-parallelism=[Maximum number of tasks updated simultaneously]:number: "
  976. "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users"
  977. "($help)--with-registry-auth[Send registry authentication details to swarm agents]"
  978. "($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories"
  979. )
  980. case "$words[1]" in
  981. (create)
  982. _arguments $(__docker_arguments) \
  983. $opts_help \
  984. $opts_create_update \
  985. "($help)*--container-label=[Container labels]:label: " \
  986. "($help)--mode=[Service Mode]:mode:(global replicated)" \
  987. "($help -): :__docker_images" \
  988. "($help -):command: _command_names -e" \
  989. "($help -)*::arguments: _normal" && ret=0
  990. ;;
  991. (inspect)
  992. _arguments $(__docker_arguments) \
  993. $opts_help \
  994. "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \
  995. "($help)--pretty[Print the information in a human friendly format]" \
  996. "($help -)*:service:__docker_complete_services" && ret=0
  997. ;;
  998. (ls|list)
  999. _arguments $(__docker_arguments) \
  1000. $opts_help \
  1001. "($help)*"{-f=,--filter=}"[Filter output based on conditions provided]:filter:->filter-options" \
  1002. "($help -q --quiet)"{-q,--quiet}"[Only display IDs]" && ret=0
  1003. case $state in
  1004. (filter-options)
  1005. __docker_service_complete_ls_filters && ret=0
  1006. ;;
  1007. esac
  1008. ;;
  1009. (rm|remove)
  1010. _arguments $(__docker_arguments) \
  1011. $opts_help \
  1012. "($help -)*:service:__docker_complete_services" && ret=0
  1013. ;;
  1014. (scale)
  1015. _arguments $(__docker_arguments) \
  1016. $opts_help \
  1017. "($help -)*:service:->values" && ret=0
  1018. case $state in
  1019. (values)
  1020. if compset -P '*='; then
  1021. _message 'replicas' && ret=0
  1022. else
  1023. __docker_complete_services -qS "="
  1024. fi
  1025. ;;
  1026. esac
  1027. ;;
  1028. (ps)
  1029. _arguments $(__docker_arguments) \
  1030. $opts_help \
  1031. "($help -a --all)"{-a,--all}"[Display all tasks]" \
  1032. "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
  1033. "($help)--no-resolve[Do not map IDs to Names]" \
  1034. "($help)--no-trunc[Do not truncate output]" \
  1035. "($help -)1:service:__docker_complete_services" && ret=0
  1036. case $state in
  1037. (filter-options)
  1038. __docker_service_complete_ps_filters && ret=0
  1039. ;;
  1040. esac
  1041. ;;
  1042. (update)
  1043. _arguments $(__docker_arguments) \
  1044. $opts_help \
  1045. $opts_create_update \
  1046. "($help)--arg=[Service command args]:arguments: _normal" \
  1047. "($help)*--container-label-add=[Add or update container labels]:label: " \
  1048. "($help)*--container-label-rm=[Remove a container label by its key]:label: " \
  1049. "($help)*--group-rm=[Remove previously added user groups from the container]:group:_groups" \
  1050. "($help)--image=[Service image tag]:image:__docker_repositories" \
  1051. "($help -)1:service:__docker_complete_services" && ret=0
  1052. ;;
  1053. (help)
  1054. _arguments $(__docker_arguments) ":subcommand:__docker_service_commands" && ret=0
  1055. ;;
  1056. esac
  1057. return ret
  1058. }
  1059. # EO service
  1060. # BO swarm
  1061. __docker_swarm_commands() {
  1062. local -a _docker_swarm_subcommands
  1063. _docker_swarm_subcommands=(
  1064. "init:Initialize a swarm"
  1065. "join:Join a swarm as a node and/or manager"
  1066. "join-token:Manage join tokens"
  1067. "leave:Leave a swarm"
  1068. "update:Update the swarm"
  1069. )
  1070. _describe -t docker-swarm-commands "docker swarm command" _docker_swarm_subcommands
  1071. }
  1072. __docker_swarm_subcommand() {
  1073. local -a _command_args opts_help
  1074. local expl help="--help"
  1075. integer ret=1
  1076. opts_help=("(: -)--help[Print usage]")
  1077. case "$words[1]" in
  1078. (init)
  1079. _arguments $(__docker_arguments) \
  1080. $opts_help \
  1081. "($help)--advertise-addr[Advertised address]:ip\:port: " \
  1082. "($help)*--external-ca=[Specifications of one or more certificate signing endpoints]:endpoint: " \
  1083. "($help)--force-new-cluster[Force create a new cluster from current state]" \
  1084. "($help)--listen-addr=[Listen address]:ip\:port: " && ret=0
  1085. ;;
  1086. (join)
  1087. _arguments $(__docker_arguments) \
  1088. $opts_help \
  1089. "($help)--advertise-addr[Advertised address]:ip\:port: " \
  1090. "($help)--listen-addr=[Listen address]:ip\:port: " \
  1091. "($help)--token=[Token for entry into the swarm]:secret: " \
  1092. "($help -):host\:port: " && ret=0
  1093. ;;
  1094. (join-token)
  1095. _arguments $(__docker_arguments) \
  1096. $opts_help \
  1097. "($help -q --quiet)"{-q,--quiet}"[Only display token]" \
  1098. "($help)--rotate[Rotate join token]" \
  1099. "($help -):role:(manager worker)" && ret=0
  1100. ;;
  1101. (leave)
  1102. _arguments $(__docker_arguments) \
  1103. $opts_help && ret=0
  1104. ;;
  1105. (update)
  1106. _arguments $(__docker_arguments) \
  1107. $opts_help \
  1108. "($help)--cert-expiry=[Validity period for node certificates]:duration: " \
  1109. "($help)--dispatcher-heartbeat=[Dispatcher heartbeat period]:duration: " \
  1110. "($help)--task-history-limit=[Task history retention limit]:limit: " && ret=0
  1111. ;;
  1112. (help)
  1113. _arguments $(__docker_arguments) ":subcommand:__docker_network_commands" && ret=0
  1114. ;;
  1115. esac
  1116. return ret
  1117. }
  1118. # EO swarm
  1119. # BO volume
  1120. __docker_volume_complete_ls_filters() {
  1121. [[ $PREFIX = -* ]] && return 1
  1122. integer ret=1
  1123. if compset -P '*='; then
  1124. case "${${words[-1]%=*}#*=}" in
  1125. (dangling)
  1126. dangling_opts=('true' 'false')
  1127. _describe -t dangling-filter-opts "Dangling Filter Options" dangling_opts && ret=0
  1128. ;;
  1129. (driver)
  1130. __docker_complete_info_plugins Volume && ret=0
  1131. ;;
  1132. (name)
  1133. __docker_volumes && ret=0
  1134. ;;
  1135. *)
  1136. _message 'value' && ret=0
  1137. ;;
  1138. esac
  1139. else
  1140. opts=('dangling' 'driver' 'label' 'name')
  1141. _describe -t filter-opts "Filter Options" opts -qS "=" && ret=0
  1142. fi
  1143. return ret
  1144. }
  1145. __docker_volumes() {
  1146. [[ $PREFIX = -* ]] && return 1
  1147. integer ret=1
  1148. declare -a lines volumes
  1149. lines=(${(f)"$(_call_program commands docker $docker_options volume ls)"})
  1150. # Parse header line to find columns
  1151. local i=1 j=1 k header=${lines[1]}
  1152. declare -A begin end
  1153. while (( j < ${#header} - 1 )); do
  1154. i=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 1 ))
  1155. j=$(( i + ${${header[$i,-1]}[(i) ]} - 1 ))
  1156. k=$(( j + ${${header[$j,-1]}[(i)[^ ]]} - 2 ))
  1157. begin[${header[$i,$((j-1))]}]=$i
  1158. end[${header[$i,$((j-1))]}]=$k
  1159. done
  1160. end[${header[$i,$((j-1))]}]=-1
  1161. lines=(${lines[2,-1]})
  1162. # Names
  1163. local line s
  1164. for line in $lines; do
  1165. s="${line[${begin[VOLUME NAME]},${end[VOLUME NAME]}]%% ##}"
  1166. s="$s:${(l:7:: :::)${${line[${begin[DRIVER]},${end[DRIVER]}]}%% ##}}"
  1167. volumes=($volumes $s)
  1168. done
  1169. _describe -t volumes-list "volumes" volumes && ret=0
  1170. return ret
  1171. }
  1172. __docker_volume_commands() {
  1173. local -a _docker_volume_subcommands
  1174. _docker_volume_subcommands=(
  1175. "create:Create a volume"
  1176. "inspect:Display detailed information on one or more volumes"
  1177. "ls:List volumes"
  1178. "rm:Remove one or more volumes"
  1179. )
  1180. _describe -t docker-volume-commands "docker volume command" _docker_volume_subcommands
  1181. }
  1182. __docker_volume_subcommand() {
  1183. local -a _command_args opts_help
  1184. local expl help="--help"
  1185. integer ret=1
  1186. opts_help=("(: -)--help[Print usage]")
  1187. case "$words[1]" in
  1188. (create)
  1189. _arguments $(__docker_arguments) -A '-*' \
  1190. $opts_help \
  1191. "($help -d --driver)"{-d=,--driver=}"[Volume driver name]:Driver name:(local)" \
  1192. "($help)*--label=[Set metadata for a volume]:label=value: " \
  1193. "($help)*"{-o=,--opt=}"[Driver specific options]:Driver option: " \
  1194. "($help -)1:Volume name: " && ret=0
  1195. ;;
  1196. (inspect)
  1197. _arguments $(__docker_arguments) \
  1198. $opts_help \
  1199. "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \
  1200. "($help -)1:volume:__docker_volumes" && ret=0
  1201. ;;
  1202. (ls)
  1203. _arguments $(__docker_arguments) \
  1204. $opts_help \
  1205. "($help)*"{-f=,--filter=}"[Provide filter values]:filter:->filter-options" \
  1206. "($help)--format=[Pretty-print volumes using a Go template]:template: " \
  1207. "($help -q --quiet)"{-q,--quiet}"[Only display volume names]" && ret=0
  1208. case $state in
  1209. (filter-options)
  1210. __docker_volume_complete_ls_filters && ret=0
  1211. ;;
  1212. esac
  1213. ;;
  1214. (rm)
  1215. _arguments $(__docker_arguments) \
  1216. $opts_help \
  1217. "($help -f --force)"{-f,--force}"[Force the removal of one or more volumes]" \
  1218. "($help -):volume:__docker_volumes" && ret=0
  1219. ;;
  1220. (help)
  1221. _arguments $(__docker_arguments) ":subcommand:__docker_volume_commands" && ret=0
  1222. ;;
  1223. esac
  1224. return ret
  1225. }
  1226. # EO volume
  1227. __docker_caching_policy() {
  1228. oldp=( "$1"(Nmh+1) ) # 1 hour
  1229. (( $#oldp ))
  1230. }
  1231. __docker_commands() {
  1232. local cache_policy
  1233. zstyle -s ":completion:${curcontext}:" cache-policy cache_policy
  1234. if [[ -z "$cache_policy" ]]; then
  1235. zstyle ":completion:${curcontext}:" cache-policy __docker_caching_policy
  1236. fi
  1237. if ( [[ ${+_docker_subcommands} -eq 0 ]] || _cache_invalid docker_subcommands) \
  1238. && ! _retrieve_cache docker_subcommands;
  1239. then
  1240. local -a lines
  1241. lines=(${(f)"$(_call_program commands docker 2>&1)"})
  1242. _docker_subcommands=(${${${lines[$((${lines[(i)Commands:]} + 1)),${lines[(I) *]}]}## #}/ ##/:})
  1243. _docker_subcommands=($_docker_subcommands 'daemon:Enable daemon mode' 'help:Show help for a command')
  1244. (( $#_docker_subcommands > 2 )) && _store_cache docker_subcommands _docker_subcommands
  1245. fi
  1246. _describe -t docker-commands "docker command" _docker_subcommands
  1247. }
  1248. __docker_subcommand() {
  1249. local -a _command_args opts_help opts_build_create_run opts_build_create_run_update opts_create_run opts_create_run_update
  1250. local expl help="--help"
  1251. integer ret=1
  1252. opts_help=("(: -)--help[Print usage]")
  1253. opts_build_create_run=(
  1254. "($help)--cgroup-parent=[Parent cgroup for the container]:cgroup: "
  1255. "($help)--isolation=[Container isolation technology]:isolation:(default hyperv process)"
  1256. "($help)--disable-content-trust[Skip image verification]"
  1257. "($help)*--shm-size=[Size of '/dev/shm' (format is '<number><unit>')]:shm size: "
  1258. "($help)*--ulimit=[ulimit options]:ulimit: "
  1259. "($help)--userns=[Container user namespace]:user namespace:(host)"
  1260. )
  1261. opts_build_create_run_update=(
  1262. "($help -c --cpu-shares)"{-c=,--cpu-shares=}"[CPU shares (relative weight)]:CPU shares:(0 10 100 200 500 800 1000)"
  1263. "($help)--cpu-period=[Limit the CPU CFS (Completely Fair Scheduler) period]:CPU period: "
  1264. "($help)--cpu-quota=[Limit the CPU CFS (Completely Fair Scheduler) quota]:CPU quota: "
  1265. "($help)--cpuset-cpus=[CPUs in which to allow execution]:CPUs: "
  1266. "($help)--cpuset-mems=[MEMs in which to allow execution]:MEMs: "
  1267. "($help -m --memory)"{-m=,--memory=}"[Memory limit]:Memory limit: "
  1268. "($help)--memory-swap=[Total memory limit with swap]:Memory limit: "
  1269. )
  1270. opts_create_run=(
  1271. "($help -a --attach)"{-a=,--attach=}"[Attach to stdin, stdout or stderr]:device:(STDIN STDOUT STDERR)"
  1272. "($help)*--add-host=[Add a custom host-to-IP mapping]:host\:ip mapping: "
  1273. "($help)*--blkio-weight-device=[Block IO (relative device weight)]:device:Block IO weight: "
  1274. "($help)*--cap-add=[Add Linux capabilities]:capability: "
  1275. "($help)*--cap-drop=[Drop Linux capabilities]:capability: "
  1276. "($help)--cidfile=[Write the container ID to the file]:CID file:_files"
  1277. "($help)*--device=[Add a host device to the container]:device:_files"
  1278. "($help)*--device-read-bps=[Limit the read rate (bytes per second) from a device]:device:IO rate: "
  1279. "($help)*--device-read-iops=[Limit the read rate (IO per second) from a device]:device:IO rate: "
  1280. "($help)*--device-write-bps=[Limit the write rate (bytes per second) to a device]:device:IO rate: "
  1281. "($help)*--device-write-iops=[Limit the write rate (IO per second) to a device]:device:IO rate: "
  1282. "($help)*--dns=[Custom DNS servers]:DNS server: "
  1283. "($help)*--dns-opt=[Custom DNS options]:DNS option: "
  1284. "($help)*--dns-search=[Custom DNS search domains]:DNS domains: "
  1285. "($help)*"{-e=,--env=}"[Environment variables]:environment variable: "
  1286. "($help)--entrypoint=[Overwrite the default entrypoint of the image]:entry point: "
  1287. "($help)*--env-file=[Read environment variables from a file]:environment file:_files"
  1288. "($help)*--expose=[Expose a port from the container without publishing it]: "
  1289. "($help)*--group-add=[Add additional groups to run as]:group:_groups"
  1290. "($help -h --hostname)"{-h=,--hostname=}"[Container host name]:hostname:_hosts"
  1291. "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]"
  1292. "($help)--ip=[Container IPv4 address]:IPv4: "
  1293. "($help)--ip6=[Container IPv6 address]:IPv6: "
  1294. "($help)--ipc=[IPC namespace to use]:IPC namespace: "
  1295. "($help)*--link=[Add link to another container]:link:->link"
  1296. "($help)*--link-local-ip=[Add a link-local address for the container]:IPv4/IPv6: "
  1297. "($help)*"{-l=,--label=}"[Container metadata]:label: "
  1298. "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_log_drivers"
  1299. "($help)*--log-opt=[Log driver specific options]:log driver options:__docker_log_options"
  1300. "($help)--mac-address=[Container MAC address]:MAC address: "
  1301. "($help)--name=[Container name]:name: "
  1302. "($help)--network=[Connect a container to a network]:network mode:(bridge none container host)"
  1303. "($help)*--network-alias=[Add network-scoped alias for the container]:alias: "
  1304. "($help)--oom-kill-disable[Disable OOM Killer]"
  1305. "($help)--oom-score-adj[Tune the host's OOM preferences for containers (accepts -1000 to 1000)]"
  1306. "($help)--pids-limit[Tune container pids limit (set -1 for unlimited)]"
  1307. "($help -P --publish-all)"{-P,--publish-all}"[Publish all exposed ports]"
  1308. "($help)*"{-p=,--publish=}"[Expose a container's port to the host]:port:_ports"
  1309. "($help)--pid=[PID namespace to use]:PID namespace:__docker_complete_pid"
  1310. "($help)--privileged[Give extended privileges to this container]"
  1311. "($help)--read-only[Mount the container's root filesystem as read only]"
  1312. "($help)*--security-opt=[Security options]:security option: "
  1313. "($help)*--sysctl=-[sysctl options]:sysctl: "
  1314. "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]"
  1315. "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users"
  1316. "($help)--tmpfs[mount tmpfs]"
  1317. "($help)*-v[Bind mount a volume]:volume: "
  1318. "($help)--volume-driver=[Optional volume driver for the container]:volume driver:(local)"
  1319. "($help)*--volumes-from=[Mount volumes from the specified container]:volume: "
  1320. "($help -w --workdir)"{-w=,--workdir=}"[Working directory inside the container]:directory:_directories"
  1321. )
  1322. opts_create_run_update=(
  1323. "($help)--blkio-weight=[Block IO (relative weight), between 10 and 1000]:Block IO weight:(10 100 500 1000)"
  1324. "($help)--kernel-memory=[Kernel memory limit in bytes]:Memory limit: "
  1325. "($help)--memory-reservation=[Memory soft limit]:Memory limit: "
  1326. "($help)--restart=[Restart policy]:restart policy:(no on-failure always unless-stopped)"
  1327. )
  1328. opts_attach_exec_run_start=(
  1329. "($help)--detach-keys=[Escape key sequence used to detach a container]:sequence:__docker_complete_detach_keys"
  1330. )
  1331. case "$words[1]" in
  1332. (attach)
  1333. _arguments $(__docker_arguments) \
  1334. $opts_help \
  1335. $opts_attach_exec_run_start \
  1336. "($help)--no-stdin[Do not attach stdin]" \
  1337. "($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \
  1338. "($help -):containers:__docker_runningcontainers" && ret=0
  1339. ;;
  1340. (build)
  1341. _arguments $(__docker_arguments) \
  1342. $opts_help \
  1343. $opts_build_create_run \
  1344. $opts_build_create_run_update \
  1345. "($help)*--build-arg[Build-time variables]:<varname>=<value>: " \
  1346. "($help -f --file)"{-f=,--file=}"[Name of the Dockerfile]:Dockerfile:_files" \
  1347. "($help)--force-rm[Always remove intermediate containers]" \
  1348. "($help)*--label=[Set metadata for an image]:label=value: " \
  1349. "($help)--no-cache[Do not use cache when building the image]" \
  1350. "($help)--pull[Attempt to pull a newer version of the image]" \
  1351. "($help -q --quiet)"{-q,--quiet}"[Suppress verbose build output]" \
  1352. "($help)--rm[Remove intermediate containers after a successful build]" \
  1353. "($help -t --tag)*"{-t=,--tag=}"[Repository, name and tag for the image]: :__docker_repositories_with_tags" \
  1354. "($help -):path or URL:_directories" && ret=0
  1355. ;;
  1356. (commit)
  1357. _arguments $(__docker_arguments) \
  1358. $opts_help \
  1359. "($help -a --author)"{-a=,--author=}"[Author]:author: " \
  1360. "($help)*"{-c=,--change=}"[Apply Dockerfile instruction to the created image]:Dockerfile:_files" \
  1361. "($help -m --message)"{-m=,--message=}"[Commit message]:message: " \
  1362. "($help -p --pause)"{-p,--pause}"[Pause container during commit]" \
  1363. "($help -):container:__docker_containers" \
  1364. "($help -): :__docker_repositories_with_tags" && ret=0
  1365. ;;
  1366. (cp)
  1367. _arguments $(__docker_arguments) \
  1368. $opts_help \
  1369. "($help -L --follow-link)"{-L,--follow-link}"[Always follow symbol link]" \
  1370. "($help -)1:container:->container" \
  1371. "($help -)2:hostpath:_files" && ret=0
  1372. case $state in
  1373. (container)
  1374. if compset -P "*:"; then
  1375. _files && ret=0
  1376. else
  1377. __docker_containers -qS ":" && ret=0
  1378. fi
  1379. ;;
  1380. esac
  1381. ;;
  1382. (create)
  1383. _arguments $(__docker_arguments) \
  1384. $opts_help \
  1385. $opts_build_create_run \
  1386. $opts_build_create_run_update \
  1387. $opts_create_run \
  1388. $opts_create_run_update \
  1389. "($help -): :__docker_images" \
  1390. "($help -):command: _command_names -e" \
  1391. "($help -)*::arguments: _normal" && ret=0
  1392. case $state in
  1393. (link)
  1394. if compset -P "*:"; then
  1395. _wanted alias expl "Alias" compadd -E "" && ret=0
  1396. else
  1397. __docker_runningcontainers -qS ":" && ret=0
  1398. fi
  1399. ;;
  1400. esac
  1401. ;;
  1402. (daemon)
  1403. _arguments $(__docker_arguments) \
  1404. $opts_help \
  1405. "($help)*--add-runtime=[Register an additional OCI compatible runtime]:runtime:__docker_complete_runtimes" \
  1406. "($help)--api-cors-header=[CORS headers in the remote API]:CORS headers: " \
  1407. "($help)*--authorization-plugin=[Authorization plugins to load]" \
  1408. "($help -b --bridge)"{-b=,--bridge=}"[Attach containers to a network bridge]:bridge:_net_interfaces" \
  1409. "($help)--bip=[Network bridge IP]:IP address: " \
  1410. "($help)--cgroup-parent=[Parent cgroup for all containers]:cgroup: " \
  1411. "($help)--config-file=[Path to daemon configuration file]:Config File:_files" \
  1412. "($help)--containerd=[Path to containerd socket]:socket:_files -g \"*.sock\"" \
  1413. "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \
  1414. "($help)--default-gateway[Container default gateway IPv4 address]:IPv4 address: " \
  1415. "($help)--default-gateway-v6[Container default gateway IPv6 address]:IPv6 address: " \
  1416. "($help)--cluster-store=[URL of the distributed storage backend]:Cluster Store:->cluster-store" \
  1417. "($help)--cluster-advertise=[Address or interface name to advertise]:Instance to advertise (host\:port): " \
  1418. "($help)*--cluster-store-opt=[Cluster store options]:Cluster options:->cluster-store-options" \
  1419. "($help)*--dns=[DNS server to use]:DNS: " \
  1420. "($help)*--dns-search=[DNS search domains to use]:DNS search: " \
  1421. "($help)*--dns-opt=[DNS options to use]:DNS option: " \
  1422. "($help)*--default-ulimit=[Default ulimits for containers]:ulimit: " \
  1423. "($help)--disable-legacy-registry[Disable contacting legacy registries]" \
  1424. "($help)*--exec-opt=[Runtime execution options]:runtime execution options: " \
  1425. "($help)--exec-root=[Root directory for execution state files]:path:_directories" \
  1426. "($help)--fixed-cidr=[IPv4 subnet for fixed IPs]:IPv4 subnet: " \
  1427. "($help)--fixed-cidr-v6=[IPv6 subnet for fixed IPs]:IPv6 subnet: " \
  1428. "($help -G --group)"{-G=,--group=}"[Group for the unix socket]:group:_groups" \
  1429. "($help -g --graph)"{-g=,--graph=}"[Root of the Docker runtime]:path:_directories" \
  1430. "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \
  1431. "($help)--icc[Enable inter-container communication]" \
  1432. "($help)*--insecure-registry=[Enable insecure registry communication]:registry: " \
  1433. "($help)--ip=[Default IP when binding container ports]" \
  1434. "($help)--ip-forward[Enable net.ipv4.ip_forward]" \
  1435. "($help)--ip-masq[Enable IP masquerading]" \
  1436. "($help)--iptables[Enable addition of iptables rules]" \
  1437. "($help)--ipv6[Enable IPv6 networking]" \
  1438. "($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \
  1439. "($help)*--label=[Key=value labels]:label: " \
  1440. "($help)--live-restore[Enable live restore of docker when containers are still running]" \
  1441. "($help)--log-driver=[Default driver for container logs]:logging driver:__docker_log_drivers" \
  1442. "($help)*--log-opt=[Default log driver options for containers]:log driver options:__docker_log_options" \
  1443. "($help)--max-concurrent-downloads[Set the max concurrent downloads for each pull]" \
  1444. "($help)--max-concurrent-uploads[Set the max concurrent uploads for each push]" \
  1445. "($help)--mtu=[Network MTU]:mtu:(0 576 1420 1500 9000)" \
  1446. "($help)--oom-score-adjust=[Set the oom_score_adj for the daemon]:oom-score:(-500)" \
  1447. "($help -p --pidfile)"{-p=,--pidfile=}"[Path to use for daemon PID file]:PID file:_files" \
  1448. "($help)--raw-logs[Full timestamps without ANSI coloring]" \
  1449. "($help)*--registry-mirror=[Preferred Docker registry mirror]:registry mirror: " \
  1450. "($help -s --storage-driver)"{-s=,--storage-driver=}"[Storage driver to use]:driver:(aufs btrfs devicemapper overlay overlay2 vfs zfs)" \
  1451. "($help)--selinux-enabled[Enable selinux support]" \
  1452. "($help)*--storage-opt=[Storage driver options]:storage driver options: " \
  1453. "($help)--tls[Use TLS]" \
  1454. "($help)--tlscacert=[Trust certs signed only by this CA]:PEM file:_files -g \"*.(pem|crt)\"" \
  1455. "($help)--tlscert=[Path to TLS certificate file]:PEM file:_files -g \"*.(pem|crt)\"" \
  1456. "($help)--tlskey=[Path to TLS key file]:Key file:_files -g \"*.(pem|key)\"" \
  1457. "($help)--tlsverify[Use TLS and verify the remote]" \
  1458. "($help)--userns-remap=[User/Group setting for user namespaces]:user\:group:->users-groups" \
  1459. "($help)--userland-proxy[Use userland proxy for loopback traffic]" && ret=0
  1460. case $state in
  1461. (cluster-store)
  1462. if compset -P '*://'; then
  1463. _message 'host:port' && ret=0
  1464. else
  1465. store=('consul' 'etcd' 'zk')
  1466. _describe -t cluster-store "Cluster Store" store -qS "://" && ret=0
  1467. fi
  1468. ;;
  1469. (cluster-store-options)
  1470. if compset -P '*='; then
  1471. _files && ret=0
  1472. else
  1473. opts=('discovery.heartbeat' 'discovery.ttl' 'kv.cacertfile' 'kv.certfile' 'kv.keyfile' 'kv.path')
  1474. _describe -t cluster-store-opts "Cluster Store Options" opts -qS "=" && ret=0
  1475. fi
  1476. ;;
  1477. (users-groups)
  1478. if compset -P '*:'; then
  1479. _groups && ret=0
  1480. else
  1481. _describe -t userns-default "default Docker user management" '(default)' && ret=0
  1482. _users && ret=0
  1483. fi
  1484. ;;
  1485. esac
  1486. ;;
  1487. (diff)
  1488. _arguments $(__docker_arguments) \
  1489. $opts_help \
  1490. "($help -)*:containers:__docker_containers" && ret=0
  1491. ;;
  1492. (events)
  1493. _arguments $(__docker_arguments) \
  1494. $opts_help \
  1495. "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_events_filter" \
  1496. "($help)--since=[Events created since this timestamp]:timestamp: " \
  1497. "($help)--until=[Events created until this timestamp]:timestamp: " \
  1498. "($help)--format=[Format the output using the given go template]:template: " && ret=0
  1499. ;;
  1500. (exec)
  1501. local state
  1502. _arguments $(__docker_arguments) \
  1503. $opts_help \
  1504. $opts_attach_exec_run_start \
  1505. "($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \
  1506. "($help -i --interactive)"{-i,--interactive}"[Keep stdin open even if not attached]" \
  1507. "($help)--privileged[Give extended Linux capabilities to the command]" \
  1508. "($help -t --tty)"{-t,--tty}"[Allocate a pseudo-tty]" \
  1509. "($help -u --user)"{-u=,--user=}"[Username or UID]:user:_users" \
  1510. "($help -):containers:__docker_runningcontainers" \
  1511. "($help -)*::command:->anycommand" && ret=0
  1512. case $state in
  1513. (anycommand)
  1514. shift 1 words
  1515. (( CURRENT-- ))
  1516. _normal && ret=0
  1517. ;;
  1518. esac
  1519. ;;
  1520. (export)
  1521. _arguments $(__docker_arguments) \
  1522. $opts_help \
  1523. "($help -o --output)"{-o=,--output=}"[Write to a file, instead of stdout]:output file:_files" \
  1524. "($help -)*:containers:__docker_containers" && ret=0
  1525. ;;
  1526. (history)
  1527. _arguments $(__docker_arguments) \
  1528. $opts_help \
  1529. "($help -H --human)"{-H,--human}"[Print sizes and dates in human readable format]" \
  1530. "($help)--no-trunc[Do not truncate output]" \
  1531. "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \
  1532. "($help -)*: :__docker_images" && ret=0
  1533. ;;
  1534. (images)
  1535. _arguments $(__docker_arguments) \
  1536. $opts_help \
  1537. "($help -a --all)"{-a,--all}"[Show all images]" \
  1538. "($help)--digests[Show digests]" \
  1539. "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \
  1540. "($help)--format[Pretty-print images using a Go template]:template: " \
  1541. "($help)--no-trunc[Do not truncate output]" \
  1542. "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \
  1543. "($help -): :__docker_repositories" && ret=0
  1544. case $state in
  1545. (filter-options)
  1546. __docker_complete_images_filters && ret=0
  1547. ;;
  1548. esac
  1549. ;;
  1550. (import)
  1551. _arguments $(__docker_arguments) \
  1552. $opts_help \
  1553. "($help)*"{-c=,--change=}"[Apply Dockerfile instruction to the created image]:Dockerfile:_files" \
  1554. "($help -m --message)"{-m=,--message=}"[Commit message for imported image]:message: " \
  1555. "($help -):URL:(- http:// file://)" \
  1556. "($help -): :__docker_repositories_with_tags" && ret=0
  1557. ;;
  1558. (info|version)
  1559. _arguments $(__docker_arguments) \
  1560. $opts_help \
  1561. "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " && ret=0
  1562. ;;
  1563. (inspect)
  1564. local state
  1565. _arguments $(__docker_arguments) \
  1566. $opts_help \
  1567. "($help -f --format)"{-f=,--format=}"[Format the output using the given go template]:template: " \
  1568. "($help -s --size)"{-s,--size}"[Display total file sizes if the type is container]" \
  1569. "($help)--type=[Return JSON for specified type]:type:(image container)" \
  1570. "($help -)*: :->values" && ret=0
  1571. case $state in
  1572. (values)
  1573. if [[ ${words[(r)--type=container]} == --type=container ]]; then
  1574. __docker_containers && ret=0
  1575. elif [[ ${words[(r)--type=image]} == --type=image ]]; then
  1576. __docker_images && ret=0
  1577. else
  1578. __docker_images && __docker_containers && ret=0
  1579. fi
  1580. ;;
  1581. esac
  1582. ;;
  1583. (kill)
  1584. _arguments $(__docker_arguments) \
  1585. $opts_help \
  1586. "($help -s --signal)"{-s=,--signal=}"[Signal to send]:signal:_signals" \
  1587. "($help -)*:containers:__docker_runningcontainers" && ret=0
  1588. ;;
  1589. (load)
  1590. _arguments $(__docker_arguments) \
  1591. $opts_help \
  1592. "($help -i --input)"{-i=,--input=}"[Read from tar archive file]:archive file:_files -g \"*.((tar|TAR)(.gz|.GZ|.Z|.bz2|.lzma|.xz|)|(tbz|tgz|txz))(-.)\"" \
  1593. "($help -q --quiet)"{-q,--quiet}"[Suppress the load output]" && ret=0
  1594. ;;
  1595. (login)
  1596. _arguments $(__docker_arguments) \
  1597. $opts_help \
  1598. "($help -p --password)"{-p=,--password=}"[Password]:password: " \
  1599. "($help -u --user)"{-u=,--user=}"[Username]:username: " \
  1600. "($help -)1:server: " && ret=0
  1601. ;;
  1602. (logout)
  1603. _arguments $(__docker_arguments) \
  1604. $opts_help \
  1605. "($help -)1:server: " && ret=0
  1606. ;;
  1607. (logs)
  1608. _arguments $(__docker_arguments) \
  1609. $opts_help \
  1610. "($help)--details[Show extra details provided to logs]" \
  1611. "($help -f --follow)"{-f,--follow}"[Follow log output]" \
  1612. "($help -s --since)"{-s=,--since=}"[Show logs since this timestamp]:timestamp: " \
  1613. "($help -t --timestamps)"{-t,--timestamps}"[Show timestamps]" \
  1614. "($help)--tail=[Output the last K lines]:lines:(1 10 20 50 all)" \
  1615. "($help -)*:containers:__docker_containers" && ret=0
  1616. ;;
  1617. (network)
  1618. local curcontext="$curcontext" state
  1619. _arguments $(__docker_arguments) \
  1620. $opts_help \
  1621. "($help -): :->command" \
  1622. "($help -)*:: :->option-or-argument" && ret=0
  1623. case $state in
  1624. (command)
  1625. __docker_network_commands && ret=0
  1626. ;;
  1627. (option-or-argument)
  1628. curcontext=${curcontext%:*:*}:docker-${words[-1]}:
  1629. __docker_network_subcommand && ret=0
  1630. ;;
  1631. esac
  1632. ;;
  1633. (node)
  1634. local curcontext="$curcontext" state
  1635. _arguments $(__docker_arguments) \
  1636. $opts_help \
  1637. "($help -): :->command" \
  1638. "($help -)*:: :->option-or-argument" && ret=0
  1639. case $state in
  1640. (command)
  1641. __docker_node_commands && ret=0
  1642. ;;
  1643. (option-or-argument)
  1644. curcontext=${curcontext%:*:*}:docker-${words[-1]}:
  1645. __docker_node_subcommand && ret=0
  1646. ;;
  1647. esac
  1648. ;;
  1649. (pause|unpause)
  1650. _arguments $(__docker_arguments) \
  1651. $opts_help \
  1652. "($help -)*:containers:__docker_runningcontainers" && ret=0
  1653. ;;
  1654. (plugin)
  1655. local curcontext="$curcontext" state
  1656. _arguments $(__docker_arguments) \
  1657. $opts_help \
  1658. "($help -): :->command" \
  1659. "($help -)*:: :->option-or-argument" && ret=0
  1660. case $state in
  1661. (command)
  1662. __docker_plugin_commands && ret=0
  1663. ;;
  1664. (option-or-argument)
  1665. curcontext=${curcontext%:*:*}:docker-${words[-1]}:
  1666. __docker_plugin_subcommand && ret=0
  1667. ;;
  1668. esac
  1669. ;;
  1670. (port)
  1671. _arguments $(__docker_arguments) \
  1672. $opts_help \
  1673. "($help -)1:containers:__docker_runningcontainers" \
  1674. "($help -)2:port:_ports" && ret=0
  1675. ;;
  1676. (ps)
  1677. _arguments $(__docker_arguments) \
  1678. $opts_help \
  1679. "($help -a --all)"{-a,--all}"[Show all containers]" \
  1680. "($help)--before=[Show only container created before...]:containers:__docker_containers" \
  1681. "($help)*"{-f=,--filter=}"[Filter values]:filter:__docker_complete_ps_filters" \
  1682. "($help)--format[Pretty-print containers using a Go template]:template: " \
  1683. "($help -l --latest)"{-l,--latest}"[Show only the latest created container]" \
  1684. "($help -n --last)"{-n=,--last=}"[Show n last created containers (includes all states)]:n:(1 5 10 25 50)" \
  1685. "($help)--no-trunc[Do not truncate output]" \
  1686. "($help -q --quiet)"{-q,--quiet}"[Only show numeric IDs]" \
  1687. "($help -s --size)"{-s,--size}"[Display total file sizes]" \
  1688. "($help)--since=[Show only containers created since...]:containers:__docker_containers" && ret=0
  1689. ;;
  1690. (pull)
  1691. _arguments $(__docker_arguments) \
  1692. $opts_help \
  1693. "($help -a --all-tags)"{-a,--all-tags}"[Download all tagged images]" \
  1694. "($help)--disable-content-trust[Skip image verification]" \
  1695. "($help -):name:__docker_search" && ret=0
  1696. ;;
  1697. (push)
  1698. _arguments $(__docker_arguments) \
  1699. $opts_help \
  1700. "($help)--disable-content-trust[Skip image signing]" \
  1701. "($help -): :__docker_images" && ret=0
  1702. ;;
  1703. (rename)
  1704. _arguments $(__docker_arguments) \
  1705. $opts_help \
  1706. "($help -):old name:__docker_containers" \
  1707. "($help -):new name: " && ret=0
  1708. ;;
  1709. (restart|stop)
  1710. _arguments $(__docker_arguments) \
  1711. $opts_help \
  1712. "($help -t --time)"{-t=,--time=}"[Number of seconds to try to stop for before killing the container]:seconds to before killing:(1 5 10 30 60)" \
  1713. "($help -)*:containers:__docker_runningcontainers" && ret=0
  1714. ;;
  1715. (rm)
  1716. _arguments $(__docker_arguments) \
  1717. $opts_help \
  1718. "($help -f --force)"{-f,--force}"[Force removal]" \
  1719. "($help -l --link)"{-l,--link}"[Remove the specified link and not the underlying container]" \
  1720. "($help -v --volumes)"{-v,--volumes}"[Remove the volumes associated to the container]" \
  1721. "($help -)*:containers:->values" && ret=0
  1722. case $state in
  1723. (values)
  1724. if [[ ${words[(r)-f]} == -f || ${words[(r)--force]} == --force ]]; then
  1725. __docker_containers && ret=0
  1726. else
  1727. __docker_stoppedcontainers && ret=0
  1728. fi
  1729. ;;
  1730. esac
  1731. ;;
  1732. (rmi)
  1733. _arguments $(__docker_arguments) \
  1734. $opts_help \
  1735. "($help -f --force)"{-f,--force}"[Force removal]" \
  1736. "($help)--no-prune[Do not delete untagged parents]" \
  1737. "($help -)*: :__docker_images" && ret=0
  1738. ;;
  1739. (run)
  1740. _arguments $(__docker_arguments) \
  1741. $opts_help \
  1742. $opts_build_create_run \
  1743. $opts_build_create_run_update \
  1744. $opts_create_run \
  1745. $opts_create_run_update \
  1746. $opts_attach_exec_run_start \
  1747. "($help -d --detach)"{-d,--detach}"[Detached mode: leave the container running in the background]" \
  1748. "($help)--health-cmd=[Command to run to check health]:command: " \
  1749. "($help)--health-interval=[Time between running the check]:time: " \
  1750. "($help)--health-retries=[Consecutive failures needed to report unhealthy]:retries:(1 2 3 4 5)" \
  1751. "($help)--health-timeout=[Maximum time to allow one check to run]:time: " \
  1752. "($help)--no-healthcheck[Disable any container-specified HEALTHCHECK]" \
  1753. "($help)--rm[Remove intermediate containers when it exits]" \
  1754. "($help)--runtime=[Name of the runtime to be used for that container]:runtime:__docker_complete_runtimes" \
  1755. "($help)--sig-proxy[Proxy all received signals to the process (non-TTY mode only)]" \
  1756. "($help)--stop-signal=[Signal to kill a container]:signal:_signals" \
  1757. "($help)--storage-opt=[Storage driver options for the container]:storage options:->storage-opt" \
  1758. "($help -): :__docker_images" \
  1759. "($help -):command: _command_names -e" \
  1760. "($help -)*::arguments: _normal" && ret=0
  1761. case $state in
  1762. (link)
  1763. if compset -P "*:"; then
  1764. _wanted alias expl "Alias" compadd -E "" && ret=0
  1765. else
  1766. __docker_runningcontainers -qS ":" && ret=0
  1767. fi
  1768. ;;
  1769. (storage-opt)
  1770. if compset -P "*="; then
  1771. _message "value" && ret=0
  1772. else
  1773. opts=('size')
  1774. _describe -t filter-opts "storage options" opts -qS "=" && ret=0
  1775. fi
  1776. ;;
  1777. esac
  1778. ;;
  1779. (save)
  1780. _arguments $(__docker_arguments) \
  1781. $opts_help \
  1782. "($help -o --output)"{-o=,--output=}"[Write to file]:file:_files" \
  1783. "($help -)*: :__docker_images" && ret=0
  1784. ;;
  1785. (search)
  1786. _arguments $(__docker_arguments) \
  1787. $opts_help \
  1788. "($help)*"{-f=,--filter=}"[Filter values]:filter:->filter-options" \
  1789. "($help)--limit=[Maximum returned search results]:limit:(1 5 10 25 50)" \
  1790. "($help)--no-trunc[Do not truncate output]" \
  1791. "($help -):term: " && ret=0
  1792. case $state in
  1793. (filter-options)
  1794. __docker_complete_search_filters && ret=0
  1795. ;;
  1796. esac
  1797. ;;
  1798. (service)
  1799. local curcontext="$curcontext" state
  1800. _arguments $(__docker_arguments) \
  1801. $opts_help \
  1802. "($help -): :->command" \
  1803. "($help -)*:: :->option-or-argument" && ret=0
  1804. case $state in
  1805. (command)
  1806. __docker_service_commands && ret=0
  1807. ;;
  1808. (option-or-argument)
  1809. curcontext=${curcontext%:*:*}:docker-${words[-1]}:
  1810. __docker_service_subcommand && ret=0
  1811. ;;
  1812. esac
  1813. ;;
  1814. (start)
  1815. _arguments $(__docker_arguments) \
  1816. $opts_help \
  1817. $opts_attach_exec_run_start \
  1818. "($help -a --attach)"{-a,--attach}"[Attach container's stdout/stderr and forward all signals]" \
  1819. "($help -i --interactive)"{-i,--interactive}"[Attach container's stding]" \
  1820. "($help -)*:containers:__docker_stoppedcontainers" && ret=0
  1821. ;;
  1822. (stats)
  1823. _arguments $(__docker_arguments) \
  1824. $opts_help \
  1825. "($help -a --all)"{-a,--all}"[Show all containers (default shows just running)]" \
  1826. "($help)--no-stream[Disable streaming stats and only pull the first result]" \
  1827. "($help -)*:containers:__docker_runningcontainers" && ret=0
  1828. ;;
  1829. (swarm)
  1830. local curcontext="$curcontext" state
  1831. _arguments $(__docker_arguments) \
  1832. $opts_help \
  1833. "($help -): :->command" \
  1834. "($help -)*:: :->option-or-argument" && ret=0
  1835. case $state in
  1836. (command)
  1837. __docker_swarm_commands && ret=0
  1838. ;;
  1839. (option-or-argument)
  1840. curcontext=${curcontext%:*:*}:docker-${words[-1]}:
  1841. __docker_swarm_subcommand && ret=0
  1842. ;;
  1843. esac
  1844. ;;
  1845. (tag)
  1846. _arguments $(__docker_arguments) \
  1847. $opts_help \
  1848. "($help -):source:__docker_images"\
  1849. "($help -):destination:__docker_repositories_with_tags" && ret=0
  1850. ;;
  1851. (top)
  1852. _arguments $(__docker_arguments) \
  1853. $opts_help \
  1854. "($help -)1:containers:__docker_runningcontainers" \
  1855. "($help -)*:: :->ps-arguments" && ret=0
  1856. case $state in
  1857. (ps-arguments)
  1858. _ps && ret=0
  1859. ;;
  1860. esac
  1861. ;;
  1862. (update)
  1863. _arguments $(__docker_arguments) \
  1864. $opts_help \
  1865. $opts_create_run_update \
  1866. $opts_build_create_run_update \
  1867. "($help -)*: :->values" && ret=0
  1868. case $state in
  1869. (values)
  1870. if [[ ${words[(r)--kernel-memory*]} = (--kernel-memory*) ]]; then
  1871. __docker_stoppedcontainers && ret=0
  1872. else
  1873. __docker_containers && ret=0
  1874. fi
  1875. ;;
  1876. esac
  1877. ;;
  1878. (volume)
  1879. local curcontext="$curcontext" state
  1880. _arguments $(__docker_arguments) \
  1881. $opts_help \
  1882. "($help -): :->command" \
  1883. "($help -)*:: :->option-or-argument" && ret=0
  1884. case $state in
  1885. (command)
  1886. __docker_volume_commands && ret=0
  1887. ;;
  1888. (option-or-argument)
  1889. curcontext=${curcontext%:*:*}:docker-${words[-1]}:
  1890. __docker_volume_subcommand && ret=0
  1891. ;;
  1892. esac
  1893. ;;
  1894. (wait)
  1895. _arguments $(__docker_arguments) \
  1896. $opts_help \
  1897. "($help -)*:containers:__docker_runningcontainers" && ret=0
  1898. ;;
  1899. (help)
  1900. _arguments $(__docker_arguments) ":subcommand:__docker_commands" && ret=0
  1901. ;;
  1902. esac
  1903. return ret
  1904. }
  1905. _docker() {
  1906. # Support for subservices, which allows for `compdef _docker docker-shell=_docker_containers`.
  1907. # Based on /usr/share/zsh/functions/Completion/Unix/_git without support for `ret`.
  1908. if [[ $service != docker ]]; then
  1909. _call_function - _$service
  1910. return
  1911. fi
  1912. local curcontext="$curcontext" state line help="-h --help"
  1913. integer ret=1
  1914. typeset -A opt_args
  1915. _arguments $(__docker_arguments) -C \
  1916. "(: -)"{-h,--help}"[Print usage]" \
  1917. "($help)--config[Location of client config files]:path:_directories" \
  1918. "($help -D --debug)"{-D,--debug}"[Enable debug mode]" \
  1919. "($help -H --host)"{-H=,--host=}"[tcp://host:port to bind/connect to]:host: " \
  1920. "($help -l --log-level)"{-l=,--log-level=}"[Logging level]:level:(debug info warn error fatal)" \
  1921. "($help)--tls[Use TLS]" \
  1922. "($help)--tlscacert=[Trust certs signed only by this CA]:PEM file:_files -g "*.(pem|crt)"" \
  1923. "($help)--tlscert=[Path to TLS certificate file]:PEM file:_files -g "*.(pem|crt)"" \
  1924. "($help)--tlskey=[Path to TLS key file]:Key file:_files -g "*.(pem|key)"" \
  1925. "($help)--tlsverify[Use TLS and verify the remote]" \
  1926. "($help)--userland-proxy[Use userland proxy for loopback traffic]" \
  1927. "($help -v --version)"{-v,--version}"[Print version information and quit]" \
  1928. "($help -): :->command" \
  1929. "($help -)*:: :->option-or-argument" && ret=0
  1930. local host=${opt_args[-H]}${opt_args[--host]}
  1931. local config=${opt_args[--config]}
  1932. local docker_options="${host:+--host $host} ${config:+--config $config}"
  1933. case $state in
  1934. (command)
  1935. __docker_commands && ret=0
  1936. ;;
  1937. (option-or-argument)
  1938. curcontext=${curcontext%:*:*}:docker-$words[1]:
  1939. __docker_subcommand && ret=0
  1940. ;;
  1941. esac
  1942. return ret
  1943. }
  1944. _dockerd() {
  1945. integer ret=1
  1946. words[1]='daemon'
  1947. __docker_subcommand && ret=0
  1948. return ret
  1949. }
  1950. _docker "$@"
  1951. # Local Variables:
  1952. # mode: Shell-Script
  1953. # sh-indentation: 4
  1954. # indent-tabs-mode: nil
  1955. # sh-basic-offset: 4
  1956. # End:
  1957. # vim: ft=zsh sw=4 ts=4 et