docker 87 KB

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