docker 88 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488
  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. --stop-signal)
  1565. __docker_complete_signals
  1566. return
  1567. ;;
  1568. --storage-opt)
  1569. COMPREPLY=( $( compgen -W "size" -S = -- "$cur") )
  1570. __docker_nospace
  1571. return
  1572. ;;
  1573. --user|-u)
  1574. __docker_complete_user_group
  1575. return
  1576. ;;
  1577. --userns)
  1578. COMPREPLY=( $( compgen -W "host" -- "$cur" ) )
  1579. return
  1580. ;;
  1581. --volume-driver)
  1582. __docker_complete_plugins_bundled --type Volume
  1583. return
  1584. ;;
  1585. --volumes-from)
  1586. __docker_complete_containers_all
  1587. return
  1588. ;;
  1589. $(__docker_to_extglob "$options_with_args") )
  1590. return
  1591. ;;
  1592. esac
  1593. case "$cur" in
  1594. -*)
  1595. COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
  1596. ;;
  1597. *)
  1598. local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
  1599. if [ $cword -eq $counter ]; then
  1600. __docker_complete_images
  1601. fi
  1602. ;;
  1603. esac
  1604. }
  1605. _docker_container_start() {
  1606. __docker_complete_detach_keys && return
  1607. case "$prev" in
  1608. --checkpoint)
  1609. if [ __docker_daemon_is_experimental ] ; then
  1610. return
  1611. fi
  1612. ;;
  1613. --checkpoint-dir)
  1614. if [ __docker_daemon_is_experimental ] ; then
  1615. _filedir -d
  1616. return
  1617. fi
  1618. ;;
  1619. esac
  1620. case "$cur" in
  1621. -*)
  1622. local options="--attach -a --detach-keys --help --interactive -i"
  1623. __docker_daemon_is_experimental && options+=" --checkpoint --checkpoint-dir"
  1624. COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
  1625. ;;
  1626. *)
  1627. __docker_complete_containers_stopped
  1628. ;;
  1629. esac
  1630. }
  1631. _docker_container_stats() {
  1632. case "$prev" in
  1633. --format)
  1634. return
  1635. ;;
  1636. esac
  1637. case "$cur" in
  1638. -*)
  1639. COMPREPLY=( $( compgen -W "--all -a --format --help --no-stream" -- "$cur" ) )
  1640. ;;
  1641. *)
  1642. __docker_complete_containers_running
  1643. ;;
  1644. esac
  1645. }
  1646. _docker_container_stop() {
  1647. case "$prev" in
  1648. --time|-t)
  1649. return
  1650. ;;
  1651. esac
  1652. case "$cur" in
  1653. -*)
  1654. COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) )
  1655. ;;
  1656. *)
  1657. __docker_complete_containers_running
  1658. ;;
  1659. esac
  1660. }
  1661. _docker_container_top() {
  1662. case "$cur" in
  1663. -*)
  1664. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  1665. ;;
  1666. *)
  1667. local counter=$(__docker_pos_first_nonflag)
  1668. if [ $cword -eq $counter ]; then
  1669. __docker_complete_containers_running
  1670. fi
  1671. ;;
  1672. esac
  1673. }
  1674. _docker_container_unpause() {
  1675. case "$cur" in
  1676. -*)
  1677. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  1678. ;;
  1679. *)
  1680. local counter=$(__docker_pos_first_nonflag)
  1681. if [ $cword -eq $counter ]; then
  1682. __docker_complete_containers_unpauseable
  1683. fi
  1684. ;;
  1685. esac
  1686. }
  1687. _docker_container_update() {
  1688. local options_with_args="
  1689. --blkio-weight
  1690. --cpu-period
  1691. --cpu-quota
  1692. --cpu-rt-period
  1693. --cpu-rt-runtime
  1694. --cpuset-cpus
  1695. --cpuset-mems
  1696. --cpu-shares -c
  1697. --kernel-memory
  1698. --memory -m
  1699. --memory-reservation
  1700. --memory-swap
  1701. --restart
  1702. "
  1703. local boolean_options="
  1704. --help
  1705. "
  1706. local all_options="$options_with_args $boolean_options"
  1707. __docker_complete_restart && return
  1708. case "$prev" in
  1709. $(__docker_to_extglob "$options_with_args") )
  1710. return
  1711. ;;
  1712. esac
  1713. case "$cur" in
  1714. -*)
  1715. COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
  1716. ;;
  1717. *)
  1718. __docker_complete_containers_all
  1719. ;;
  1720. esac
  1721. }
  1722. _docker_container_wait() {
  1723. case "$cur" in
  1724. -*)
  1725. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  1726. ;;
  1727. *)
  1728. __docker_complete_containers_all
  1729. ;;
  1730. esac
  1731. }
  1732. _docker_commit() {
  1733. _docker_container_commit
  1734. }
  1735. _docker_cp() {
  1736. _docker_container_cp
  1737. }
  1738. _docker_create() {
  1739. _docker_container_create
  1740. }
  1741. _docker_daemon() {
  1742. local boolean_options="
  1743. $global_boolean_options
  1744. --disable-legacy-registry
  1745. --experimental
  1746. --help
  1747. --icc=false
  1748. --init
  1749. --ip-forward=false
  1750. --ip-masq=false
  1751. --iptables=false
  1752. --ipv6
  1753. --live-restore
  1754. --raw-logs
  1755. --selinux-enabled
  1756. --userland-proxy=false
  1757. "
  1758. local options_with_args="
  1759. $global_options_with_args
  1760. --add-runtime
  1761. --api-cors-header
  1762. --authorization-plugin
  1763. --bip
  1764. --bridge -b
  1765. --cgroup-parent
  1766. --cluster-advertise
  1767. --cluster-store
  1768. --cluster-store-opt
  1769. --config-file
  1770. --containerd
  1771. --default-gateway
  1772. --default-gateway-v6
  1773. --default-shm-size
  1774. --default-ulimit
  1775. --dns
  1776. --dns-search
  1777. --dns-opt
  1778. --exec-opt
  1779. --exec-root
  1780. --fixed-cidr
  1781. --fixed-cidr-v6
  1782. --graph -g
  1783. --group -G
  1784. --init-path
  1785. --insecure-registry
  1786. --ip
  1787. --label
  1788. --log-driver
  1789. --log-opt
  1790. --max-concurrent-downloads
  1791. --max-concurrent-uploads
  1792. --mtu
  1793. --oom-score-adjust
  1794. --pidfile -p
  1795. --registry-mirror
  1796. --seccomp-profile
  1797. --shutdown-timeout
  1798. --storage-driver -s
  1799. --storage-opt
  1800. --userland-proxy-path
  1801. --userns-remap
  1802. "
  1803. __docker_complete_log_driver_options && return
  1804. key=$(__docker_map_key_of_current_option '--cluster-store-opt')
  1805. case "$key" in
  1806. kv.*file)
  1807. cur=${cur##*=}
  1808. _filedir
  1809. return
  1810. ;;
  1811. esac
  1812. local key=$(__docker_map_key_of_current_option '--storage-opt')
  1813. case "$key" in
  1814. dm.blkdiscard|dm.override_udev_sync_check|dm.use_deferred_removal|dm.use_deferred_deletion)
  1815. COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) )
  1816. return
  1817. ;;
  1818. dm.fs)
  1819. COMPREPLY=( $( compgen -W "ext4 xfs" -- "${cur##*=}" ) )
  1820. return
  1821. ;;
  1822. dm.thinpooldev)
  1823. cur=${cur##*=}
  1824. _filedir
  1825. return
  1826. ;;
  1827. esac
  1828. case "$prev" in
  1829. --authorization-plugin)
  1830. __docker_complete_plugins_bundled --type Authorization
  1831. return
  1832. ;;
  1833. --cluster-store)
  1834. COMPREPLY=( $( compgen -W "consul etcd zk" -S "://" -- "$cur" ) )
  1835. __docker_nospace
  1836. return
  1837. ;;
  1838. --cluster-store-opt)
  1839. COMPREPLY=( $( compgen -W "discovery.heartbeat discovery.ttl kv.cacertfile kv.certfile kv.keyfile kv.path" -S = -- "$cur" ) )
  1840. __docker_nospace
  1841. return
  1842. ;;
  1843. --config-file|--containerd|--init-path|--pidfile|-p|--tlscacert|--tlscert|--tlskey|--userland-proxy-path)
  1844. _filedir
  1845. return
  1846. ;;
  1847. --exec-root|--graph|-g)
  1848. _filedir -d
  1849. return
  1850. ;;
  1851. --log-driver)
  1852. __docker_complete_log_drivers
  1853. return
  1854. ;;
  1855. --storage-driver|-s)
  1856. COMPREPLY=( $( compgen -W "aufs btrfs devicemapper overlay overlay2 vfs zfs" -- "$(echo $cur | tr '[:upper:]' '[:lower:]')" ) )
  1857. return
  1858. ;;
  1859. --storage-opt)
  1860. local btrfs_options="btrfs.min_space"
  1861. local devicemapper_options="
  1862. dm.basesize
  1863. dm.blkdiscard
  1864. dm.blocksize
  1865. dm.fs
  1866. dm.loopdatasize
  1867. dm.loopmetadatasize
  1868. dm.min_free_space
  1869. dm.mkfsarg
  1870. dm.mountopt
  1871. dm.override_udev_sync_check
  1872. dm.thinpooldev
  1873. dm.use_deferred_deletion
  1874. dm.use_deferred_removal
  1875. "
  1876. local zfs_options="zfs.fsname"
  1877. case $(__docker_value_of_option '--storage-driver|-s') in
  1878. '')
  1879. COMPREPLY=( $( compgen -W "$btrfs_options $devicemapper_options $zfs_options" -S = -- "$cur" ) )
  1880. ;;
  1881. btrfs)
  1882. COMPREPLY=( $( compgen -W "$btrfs_options" -S = -- "$cur" ) )
  1883. ;;
  1884. devicemapper)
  1885. COMPREPLY=( $( compgen -W "$devicemapper_options" -S = -- "$cur" ) )
  1886. ;;
  1887. zfs)
  1888. COMPREPLY=( $( compgen -W "$zfs_options" -S = -- "$cur" ) )
  1889. ;;
  1890. *)
  1891. return
  1892. ;;
  1893. esac
  1894. __docker_nospace
  1895. return
  1896. ;;
  1897. --log-level|-l)
  1898. __docker_complete_log_levels
  1899. return
  1900. ;;
  1901. --log-opt)
  1902. __docker_complete_log_options
  1903. return
  1904. ;;
  1905. --seccomp-profile)
  1906. _filedir json
  1907. return
  1908. ;;
  1909. --userns-remap)
  1910. __docker_complete_user_group
  1911. return
  1912. ;;
  1913. $(__docker_to_extglob "$options_with_args") )
  1914. return
  1915. ;;
  1916. esac
  1917. case "$cur" in
  1918. -*)
  1919. COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
  1920. ;;
  1921. esac
  1922. }
  1923. _docker_deploy() {
  1924. __docker_daemon_is_experimental && _docker_stack_deploy
  1925. }
  1926. _docker_diff() {
  1927. _docker_container_diff
  1928. }
  1929. _docker_events() {
  1930. _docker_system_events
  1931. }
  1932. _docker_exec() {
  1933. _docker_container_exec
  1934. }
  1935. _docker_export() {
  1936. _docker_container_export
  1937. }
  1938. _docker_help() {
  1939. local counter=$(__docker_pos_first_nonflag)
  1940. if [ $cword -eq $counter ]; then
  1941. COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
  1942. fi
  1943. }
  1944. _docker_history() {
  1945. _docker_image_history
  1946. }
  1947. _docker_image() {
  1948. local subcommands="
  1949. build
  1950. history
  1951. import
  1952. inspect
  1953. load
  1954. ls
  1955. prune
  1956. pull
  1957. push
  1958. rm
  1959. save
  1960. tag
  1961. "
  1962. local aliases="
  1963. images
  1964. list
  1965. remove
  1966. rmi
  1967. "
  1968. __docker_subcommands "$subcommands $aliases" && return
  1969. case "$cur" in
  1970. -*)
  1971. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  1972. ;;
  1973. *)
  1974. COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
  1975. ;;
  1976. esac
  1977. }
  1978. _docker_image_build() {
  1979. local options_with_args="
  1980. --add-host
  1981. --build-arg
  1982. --cache-from
  1983. --cgroup-parent
  1984. --cpuset-cpus
  1985. --cpuset-mems
  1986. --cpu-shares -c
  1987. --cpu-period
  1988. --cpu-quota
  1989. --file -f
  1990. --label
  1991. --memory -m
  1992. --memory-swap
  1993. --network
  1994. --shm-size
  1995. --tag -t
  1996. --ulimit
  1997. "
  1998. __docker_daemon_os_is windows && options_with_args+="
  1999. --isolation
  2000. "
  2001. local boolean_options="
  2002. --compress
  2003. --disable-content-trust=false
  2004. --force-rm
  2005. --help
  2006. --no-cache
  2007. --pull
  2008. --quiet -q
  2009. --rm
  2010. "
  2011. __docker_daemon_is_experimental && boolean_options+="--squash"
  2012. local all_options="$options_with_args $boolean_options"
  2013. case "$prev" in
  2014. --add-host)
  2015. case "$cur" in
  2016. *:)
  2017. __docker_complete_resolved_hostname
  2018. return
  2019. ;;
  2020. esac
  2021. ;;
  2022. --build-arg)
  2023. COMPREPLY=( $( compgen -e -- "$cur" ) )
  2024. __docker_nospace
  2025. return
  2026. ;;
  2027. --cache-from)
  2028. __docker_complete_image_repos_and_tags
  2029. return
  2030. ;;
  2031. --file|-f)
  2032. _filedir
  2033. return
  2034. ;;
  2035. --isolation)
  2036. if __docker_daemon_os_is windows ; then
  2037. __docker_complete_isolation
  2038. return
  2039. fi
  2040. ;;
  2041. --network)
  2042. case "$cur" in
  2043. container:*)
  2044. __docker_complete_containers_all --cur "${cur#*:}"
  2045. ;;
  2046. *)
  2047. COMPREPLY=( $( compgen -W "$(__docker_plugins --type Network) $(__docker_networks) container:" -- "$cur") )
  2048. if [ "${COMPREPLY[*]}" = "container:" ] ; then
  2049. __docker_nospace
  2050. fi
  2051. ;;
  2052. esac
  2053. return
  2054. ;;
  2055. --tag|-t)
  2056. __docker_complete_image_repos_and_tags
  2057. return
  2058. ;;
  2059. $(__docker_to_extglob "$options_with_args") )
  2060. return
  2061. ;;
  2062. esac
  2063. case "$cur" in
  2064. -*)
  2065. COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
  2066. ;;
  2067. *)
  2068. local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
  2069. if [ $cword -eq $counter ]; then
  2070. _filedir -d
  2071. fi
  2072. ;;
  2073. esac
  2074. }
  2075. _docker_image_history() {
  2076. case "$cur" in
  2077. -*)
  2078. COMPREPLY=( $( compgen -W "--help --human=false -H=false --no-trunc --quiet -q" -- "$cur" ) )
  2079. ;;
  2080. *)
  2081. local counter=$(__docker_pos_first_nonflag)
  2082. if [ $cword -eq $counter ]; then
  2083. __docker_complete_images
  2084. fi
  2085. ;;
  2086. esac
  2087. }
  2088. _docker_image_images() {
  2089. _docker_image_ls
  2090. }
  2091. _docker_image_import() {
  2092. case "$prev" in
  2093. --change|-c|--message|-m)
  2094. return
  2095. ;;
  2096. esac
  2097. case "$cur" in
  2098. -*)
  2099. COMPREPLY=( $( compgen -W "--change -c --help --message -m" -- "$cur" ) )
  2100. ;;
  2101. *)
  2102. local counter=$(__docker_pos_first_nonflag '--change|-c|--message|-m')
  2103. if [ $cword -eq $counter ]; then
  2104. return
  2105. fi
  2106. (( counter++ ))
  2107. if [ $cword -eq $counter ]; then
  2108. __docker_complete_image_repos_and_tags
  2109. return
  2110. fi
  2111. ;;
  2112. esac
  2113. }
  2114. _docker_image_inspect() {
  2115. _docker_inspect --type image
  2116. }
  2117. _docker_image_load() {
  2118. case "$prev" in
  2119. --input|-i)
  2120. _filedir
  2121. return
  2122. ;;
  2123. esac
  2124. case "$cur" in
  2125. -*)
  2126. COMPREPLY=( $( compgen -W "--help --input -i --quiet -q" -- "$cur" ) )
  2127. ;;
  2128. esac
  2129. }
  2130. _docker_image_list() {
  2131. _docker_image_ls
  2132. }
  2133. _docker_image_ls() {
  2134. local key=$(__docker_map_key_of_current_option '--filter|-f')
  2135. case "$key" in
  2136. before|since|reference)
  2137. cur="${cur##*=}"
  2138. __docker_complete_images
  2139. return
  2140. ;;
  2141. dangling)
  2142. COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) )
  2143. return
  2144. ;;
  2145. label)
  2146. return
  2147. ;;
  2148. esac
  2149. case "$prev" in
  2150. --filter|-f)
  2151. COMPREPLY=( $( compgen -S = -W "before dangling label reference since" -- "$cur" ) )
  2152. __docker_nospace
  2153. return
  2154. ;;
  2155. --format)
  2156. return
  2157. ;;
  2158. esac
  2159. case "$cur" in
  2160. -*)
  2161. COMPREPLY=( $( compgen -W "--all -a --digests --filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) )
  2162. ;;
  2163. =)
  2164. return
  2165. ;;
  2166. *)
  2167. __docker_complete_image_repos
  2168. ;;
  2169. esac
  2170. }
  2171. _docker_image_prune() {
  2172. case "$prev" in
  2173. --filter)
  2174. COMPREPLY=( $( compgen -W "until" -S = -- "$cur" ) )
  2175. __docker_nospace
  2176. return
  2177. ;;
  2178. esac
  2179. case "$cur" in
  2180. -*)
  2181. COMPREPLY=( $( compgen -W "--all -a --force -f --filter --help" -- "$cur" ) )
  2182. ;;
  2183. esac
  2184. }
  2185. _docker_image_pull() {
  2186. case "$cur" in
  2187. -*)
  2188. COMPREPLY=( $( compgen -W "--all-tags -a --disable-content-trust=false --help" -- "$cur" ) )
  2189. ;;
  2190. *)
  2191. local counter=$(__docker_pos_first_nonflag)
  2192. if [ $cword -eq $counter ]; then
  2193. for arg in "${COMP_WORDS[@]}"; do
  2194. case "$arg" in
  2195. --all-tags|-a)
  2196. __docker_complete_image_repos
  2197. return
  2198. ;;
  2199. esac
  2200. done
  2201. __docker_complete_image_repos_and_tags
  2202. fi
  2203. ;;
  2204. esac
  2205. }
  2206. _docker_image_push() {
  2207. case "$cur" in
  2208. -*)
  2209. COMPREPLY=( $( compgen -W "--disable-content-trust=false --help" -- "$cur" ) )
  2210. ;;
  2211. *)
  2212. local counter=$(__docker_pos_first_nonflag)
  2213. if [ $cword -eq $counter ]; then
  2214. __docker_complete_image_repos_and_tags
  2215. fi
  2216. ;;
  2217. esac
  2218. }
  2219. _docker_image_remove() {
  2220. _docker_image_rm
  2221. }
  2222. _docker_image_rm() {
  2223. case "$cur" in
  2224. -*)
  2225. COMPREPLY=( $( compgen -W "--force -f --help --no-prune" -- "$cur" ) )
  2226. ;;
  2227. *)
  2228. __docker_complete_images
  2229. ;;
  2230. esac
  2231. }
  2232. _docker_image_rmi() {
  2233. _docker_image_rm
  2234. }
  2235. _docker_image_save() {
  2236. case "$prev" in
  2237. --output|-o)
  2238. _filedir
  2239. return
  2240. ;;
  2241. esac
  2242. case "$cur" in
  2243. -*)
  2244. COMPREPLY=( $( compgen -W "--help --output -o" -- "$cur" ) )
  2245. ;;
  2246. *)
  2247. __docker_complete_images
  2248. ;;
  2249. esac
  2250. }
  2251. _docker_image_tag() {
  2252. case "$cur" in
  2253. -*)
  2254. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  2255. ;;
  2256. *)
  2257. local counter=$(__docker_pos_first_nonflag)
  2258. if [ $cword -eq $counter ]; then
  2259. __docker_complete_image_repos_and_tags
  2260. return
  2261. fi
  2262. (( counter++ ))
  2263. if [ $cword -eq $counter ]; then
  2264. __docker_complete_image_repos_and_tags
  2265. return
  2266. fi
  2267. ;;
  2268. esac
  2269. }
  2270. _docker_images() {
  2271. _docker_image_ls
  2272. }
  2273. _docker_import() {
  2274. _docker_image_import
  2275. }
  2276. _docker_info() {
  2277. _docker_system_info
  2278. }
  2279. _docker_inspect() {
  2280. local preselected_type
  2281. local type
  2282. if [ "$1" = "--type" ] ; then
  2283. preselected_type=yes
  2284. type="$2"
  2285. else
  2286. type=$(__docker_value_of_option --type)
  2287. fi
  2288. case "$prev" in
  2289. --format|-f)
  2290. return
  2291. ;;
  2292. --type)
  2293. if [ -z "$preselected_type" ] ; then
  2294. COMPREPLY=( $( compgen -W "container image network node plugin service volume" -- "$cur" ) )
  2295. return
  2296. fi
  2297. ;;
  2298. esac
  2299. case "$cur" in
  2300. -*)
  2301. local options="--format -f --help --size -s"
  2302. if [ -z "$preselected_type" ] ; then
  2303. options+=" --type"
  2304. fi
  2305. COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
  2306. ;;
  2307. *)
  2308. case "$type" in
  2309. '')
  2310. COMPREPLY=( $( compgen -W "
  2311. $(__docker_containers --all)
  2312. $(__docker_images)
  2313. $(__docker_networks)
  2314. $(__docker_nodes)
  2315. $(__docker_plugins_installed)
  2316. $(__docker_services)
  2317. $(__docker_volumes)
  2318. " -- "$cur" ) )
  2319. ;;
  2320. container)
  2321. __docker_complete_containers_all
  2322. ;;
  2323. image)
  2324. __docker_complete_images
  2325. ;;
  2326. network)
  2327. __docker_complete_networks
  2328. ;;
  2329. node)
  2330. __docker_complete_nodes
  2331. ;;
  2332. plugin)
  2333. __docker_complete_plugins_installed
  2334. ;;
  2335. service)
  2336. __docker_complete_services
  2337. ;;
  2338. volume)
  2339. __docker_complete_volumes
  2340. ;;
  2341. esac
  2342. esac
  2343. }
  2344. _docker_kill() {
  2345. _docker_container_kill
  2346. }
  2347. _docker_load() {
  2348. _docker_image_load
  2349. }
  2350. _docker_login() {
  2351. case "$prev" in
  2352. --password|-p|--username|-u)
  2353. return
  2354. ;;
  2355. esac
  2356. case "$cur" in
  2357. -*)
  2358. COMPREPLY=( $( compgen -W "--help --password -p --username -u" -- "$cur" ) )
  2359. ;;
  2360. esac
  2361. }
  2362. _docker_logout() {
  2363. case "$cur" in
  2364. -*)
  2365. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  2366. ;;
  2367. esac
  2368. }
  2369. _docker_logs() {
  2370. _docker_container_logs
  2371. }
  2372. _docker_network_connect() {
  2373. local options_with_args="
  2374. --alias
  2375. --ip
  2376. --ip6
  2377. --link
  2378. --link-local-ip
  2379. "
  2380. local boolean_options="
  2381. --help
  2382. "
  2383. case "$prev" in
  2384. --link)
  2385. case "$cur" in
  2386. *:*)
  2387. ;;
  2388. *)
  2389. __docker_complete_containers_running
  2390. COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) )
  2391. __docker_nospace
  2392. ;;
  2393. esac
  2394. return
  2395. ;;
  2396. $(__docker_to_extglob "$options_with_args") )
  2397. return
  2398. ;;
  2399. esac
  2400. case "$cur" in
  2401. -*)
  2402. COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
  2403. ;;
  2404. *)
  2405. local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
  2406. if [ $cword -eq $counter ]; then
  2407. __docker_complete_networks
  2408. elif [ $cword -eq $(($counter + 1)) ]; then
  2409. __docker_complete_containers_all
  2410. fi
  2411. ;;
  2412. esac
  2413. }
  2414. _docker_network_create() {
  2415. case "$prev" in
  2416. --aux-address|--gateway|--internal|--ip-range|--ipam-opt|--ipv6|--opt|-o|--subnet)
  2417. return
  2418. ;;
  2419. --ipam-driver)
  2420. COMPREPLY=( $( compgen -W "default" -- "$cur" ) )
  2421. return
  2422. ;;
  2423. --driver|-d)
  2424. # remove drivers that allow one instance only, add drivers missing in `docker info`
  2425. __docker_complete_plugins_bundled --type Network --remove host --remove null --add macvlan
  2426. return
  2427. ;;
  2428. --label)
  2429. return
  2430. ;;
  2431. esac
  2432. case "$cur" in
  2433. -*)
  2434. COMPREPLY=( $( compgen -W "--attachable --aux-address --driver -d --gateway --help --internal --ip-range --ipam-driver --ipam-opt --ipv6 --label --opt -o --subnet" -- "$cur" ) )
  2435. ;;
  2436. esac
  2437. }
  2438. _docker_network_disconnect() {
  2439. case "$cur" in
  2440. -*)
  2441. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  2442. ;;
  2443. *)
  2444. local counter=$(__docker_pos_first_nonflag)
  2445. if [ $cword -eq $counter ]; then
  2446. __docker_complete_networks
  2447. elif [ $cword -eq $(($counter + 1)) ]; then
  2448. __docker_complete_containers_in_network "$prev"
  2449. fi
  2450. ;;
  2451. esac
  2452. }
  2453. _docker_network_inspect() {
  2454. case "$prev" in
  2455. --format|-f)
  2456. return
  2457. ;;
  2458. esac
  2459. case "$cur" in
  2460. -*)
  2461. COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
  2462. ;;
  2463. *)
  2464. __docker_complete_networks
  2465. esac
  2466. }
  2467. _docker_network_ls() {
  2468. local key=$(__docker_map_key_of_current_option '--filter|-f')
  2469. case "$key" in
  2470. driver)
  2471. __docker_complete_plugins_bundled --cur "${cur##*=}" --type Network --add macvlan
  2472. return
  2473. ;;
  2474. id)
  2475. __docker_complete_networks --cur "${cur##*=}" --id
  2476. return
  2477. ;;
  2478. name)
  2479. __docker_complete_networks --cur "${cur##*=}" --name
  2480. return
  2481. ;;
  2482. type)
  2483. COMPREPLY=( $( compgen -W "builtin custom" -- "${cur##*=}" ) )
  2484. return
  2485. ;;
  2486. esac
  2487. case "$prev" in
  2488. --filter|-f)
  2489. COMPREPLY=( $( compgen -S = -W "driver id label name type" -- "$cur" ) )
  2490. __docker_nospace
  2491. return
  2492. ;;
  2493. --format)
  2494. return
  2495. ;;
  2496. esac
  2497. case "$cur" in
  2498. -*)
  2499. COMPREPLY=( $( compgen -W "--filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) )
  2500. ;;
  2501. esac
  2502. }
  2503. _docker_network_prune() {
  2504. case "$prev" in
  2505. --filter)
  2506. COMPREPLY=( $( compgen -W "until" -S = -- "$cur" ) )
  2507. __docker_nospace
  2508. return
  2509. ;;
  2510. esac
  2511. case "$cur" in
  2512. -*)
  2513. COMPREPLY=( $( compgen -W "--force -f --filter --help" -- "$cur" ) )
  2514. ;;
  2515. esac
  2516. }
  2517. _docker_network_rm() {
  2518. case "$cur" in
  2519. -*)
  2520. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  2521. ;;
  2522. *)
  2523. __docker_complete_networks --filter type=custom
  2524. esac
  2525. }
  2526. _docker_network() {
  2527. local subcommands="
  2528. connect
  2529. create
  2530. disconnect
  2531. inspect
  2532. ls
  2533. prune
  2534. rm
  2535. "
  2536. local aliases="
  2537. list
  2538. remove
  2539. "
  2540. __docker_subcommands "$subcommands $aliases" && return
  2541. case "$cur" in
  2542. -*)
  2543. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  2544. ;;
  2545. *)
  2546. COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
  2547. ;;
  2548. esac
  2549. }
  2550. _docker_service() {
  2551. local subcommands="
  2552. create
  2553. inspect
  2554. ls
  2555. rm
  2556. scale
  2557. ps
  2558. update
  2559. "
  2560. __docker_daemon_is_experimental && subcommands+="logs"
  2561. local aliases="
  2562. list
  2563. remove
  2564. "
  2565. __docker_subcommands "$subcommands $aliases" && return
  2566. case "$cur" in
  2567. -*)
  2568. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  2569. ;;
  2570. *)
  2571. COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
  2572. ;;
  2573. esac
  2574. }
  2575. _docker_service_create() {
  2576. _docker_service_update_and_create
  2577. }
  2578. _docker_service_inspect() {
  2579. case "$prev" in
  2580. --format|-f)
  2581. return
  2582. ;;
  2583. esac
  2584. case "$cur" in
  2585. -*)
  2586. COMPREPLY=( $( compgen -W "--format -f --help --pretty" -- "$cur" ) )
  2587. ;;
  2588. *)
  2589. __docker_complete_services
  2590. esac
  2591. }
  2592. _docker_service_logs() {
  2593. case "$prev" in
  2594. --since|--tail)
  2595. return
  2596. ;;
  2597. esac
  2598. case "$cur" in
  2599. -*)
  2600. COMPREPLY=( $( compgen -W "--details --follow -f --help --no-resolve --since --tail --timestamps -t" -- "$cur" ) )
  2601. ;;
  2602. *)
  2603. local counter=$(__docker_pos_first_nonflag '--since|--tail')
  2604. if [ $cword -eq $counter ]; then
  2605. __docker_complete_services
  2606. fi
  2607. ;;
  2608. esac
  2609. }
  2610. _docker_service_list() {
  2611. _docker_service_ls
  2612. }
  2613. _docker_service_ls() {
  2614. local key=$(__docker_map_key_of_current_option '--filter|-f')
  2615. case "$key" in
  2616. id)
  2617. __docker_complete_services --cur "${cur##*=}" --id
  2618. return
  2619. ;;
  2620. name)
  2621. __docker_complete_services --cur "${cur##*=}" --name
  2622. return
  2623. ;;
  2624. esac
  2625. case "$prev" in
  2626. --filter|-f)
  2627. COMPREPLY=( $( compgen -W "id label name" -S = -- "$cur" ) )
  2628. __docker_nospace
  2629. return
  2630. ;;
  2631. --format)
  2632. return
  2633. ;;
  2634. esac
  2635. case "$cur" in
  2636. -*)
  2637. COMPREPLY=( $( compgen -W "--filter -f --format --help --quiet -q" -- "$cur" ) )
  2638. ;;
  2639. esac
  2640. }
  2641. _docker_service_remove() {
  2642. _docker_service_rm
  2643. }
  2644. _docker_service_rm() {
  2645. case "$cur" in
  2646. -*)
  2647. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  2648. ;;
  2649. *)
  2650. __docker_complete_services
  2651. esac
  2652. }
  2653. _docker_service_scale() {
  2654. case "$cur" in
  2655. -*)
  2656. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  2657. ;;
  2658. *)
  2659. __docker_complete_services
  2660. __docker_append_to_completions "="
  2661. __docker_nospace
  2662. ;;
  2663. esac
  2664. }
  2665. _docker_service_ps() {
  2666. local key=$(__docker_map_key_of_current_option '--filter|-f')
  2667. case "$key" in
  2668. desired-state)
  2669. COMPREPLY=( $( compgen -W "accepted running shutdown" -- "${cur##*=}" ) )
  2670. return
  2671. ;;
  2672. name)
  2673. __docker_complete_services --cur "${cur##*=}" --name
  2674. return
  2675. ;;
  2676. node)
  2677. __docker_complete_nodes --cur "${cur##*=}" --add self
  2678. return
  2679. ;;
  2680. esac
  2681. case "$prev" in
  2682. --filter|-f)
  2683. COMPREPLY=( $( compgen -W "desired-state id name node" -S = -- "$cur" ) )
  2684. __docker_nospace
  2685. return
  2686. ;;
  2687. esac
  2688. case "$cur" in
  2689. -*)
  2690. COMPREPLY=( $( compgen -W "--filter -f --help --no-resolve --no-trunc --quiet -q" -- "$cur" ) )
  2691. ;;
  2692. *)
  2693. local counter=$(__docker_pos_first_nonflag '--filter|-f')
  2694. if [ $cword -eq $counter ]; then
  2695. __docker_complete_services
  2696. fi
  2697. ;;
  2698. esac
  2699. }
  2700. _docker_service_update() {
  2701. _docker_service_update_and_create
  2702. }
  2703. # _docker_service_update_and_create is the combined completion for `docker service create`
  2704. # and `docker service update`
  2705. _docker_service_update_and_create() {
  2706. local $subcommand="${words[$subcommand_pos]}"
  2707. local options_with_args="
  2708. --constraint
  2709. --endpoint-mode
  2710. --env -e
  2711. --force
  2712. --health-cmd
  2713. --health-interval
  2714. --health-retries
  2715. --health-timeout
  2716. --hostname
  2717. --label -l
  2718. --limit-cpu
  2719. --limit-memory
  2720. --log-driver
  2721. --log-opt
  2722. --mount
  2723. --network
  2724. --no-healthcheck
  2725. --replicas
  2726. --reserve-cpu
  2727. --reserve-memory
  2728. --restart-condition
  2729. --restart-delay
  2730. --restart-max-attempts
  2731. --restart-window
  2732. --rollback-delay
  2733. --rollback-failure-action
  2734. --rollback-max-failure-ratio
  2735. --rollback-monitor
  2736. --rollback-parallelism
  2737. --stop-grace-period
  2738. --stop-signal
  2739. --update-delay
  2740. --update-failure-action
  2741. --update-max-failure-ratio
  2742. --update-monitor
  2743. --update-parallelism
  2744. --user -u
  2745. --workdir -w
  2746. "
  2747. local boolean_options="
  2748. --help
  2749. --read-only
  2750. --tty -t
  2751. --with-registry-auth
  2752. "
  2753. __docker_complete_log_driver_options && return
  2754. if [ "$subcommand" = "create" ] ; then
  2755. options_with_args="$options_with_args
  2756. --container-label
  2757. --dns
  2758. --dns-option
  2759. --dns-search
  2760. --env-file
  2761. --group
  2762. --host
  2763. --mode
  2764. --name
  2765. --publish -p
  2766. --secret
  2767. "
  2768. case "$prev" in
  2769. --env-file)
  2770. _filedir
  2771. return
  2772. ;;
  2773. --group)
  2774. COMPREPLY=( $(compgen -g -- "$cur") )
  2775. return
  2776. ;;
  2777. --host)
  2778. case "$cur" in
  2779. *:)
  2780. __docker_complete_resolved_hostname
  2781. return
  2782. ;;
  2783. esac
  2784. ;;
  2785. --mode)
  2786. COMPREPLY=( $( compgen -W "global replicated" -- "$cur" ) )
  2787. return
  2788. ;;
  2789. --secret)
  2790. __docker_complete_secrets
  2791. return
  2792. ;;
  2793. esac
  2794. fi
  2795. if [ "$subcommand" = "update" ] ; then
  2796. options_with_args="$options_with_args
  2797. --arg
  2798. --container-label-add
  2799. --container-label-rm
  2800. --dns-add
  2801. --dns-option-add
  2802. --dns-option-rm
  2803. --dns-rm
  2804. --dns-search-add
  2805. --dns-search-rm
  2806. --group-add
  2807. --group-rm
  2808. --host-add
  2809. --host-rm
  2810. --image
  2811. --publish-add
  2812. --publish-rm
  2813. --rollback
  2814. --secret-add
  2815. --secret-rm
  2816. "
  2817. case "$prev" in
  2818. --group-add|--group-rm)
  2819. COMPREPLY=( $(compgen -g -- "$cur") )
  2820. return
  2821. ;;
  2822. --host-add|--host-rm)
  2823. case "$cur" in
  2824. *:)
  2825. __docker_complete_resolved_hostname
  2826. return
  2827. ;;
  2828. esac
  2829. ;;
  2830. --image)
  2831. __docker_complete_image_repos_and_tags
  2832. return
  2833. ;;
  2834. --secret-add|--secret-rm)
  2835. __docker_complete_secrets
  2836. return
  2837. ;;
  2838. esac
  2839. fi
  2840. case "$prev" in
  2841. --endpoint-mode)
  2842. COMPREPLY=( $( compgen -W "dnsrr vip" -- "$cur" ) )
  2843. return
  2844. ;;
  2845. --env|-e)
  2846. # we do not append a "=" here because "-e VARNAME" is legal systax, too
  2847. COMPREPLY=( $( compgen -e -- "$cur" ) )
  2848. __docker_nospace
  2849. return
  2850. ;;
  2851. --log-driver)
  2852. __docker_complete_log_drivers
  2853. return
  2854. ;;
  2855. --log-opt)
  2856. __docker_complete_log_options
  2857. return
  2858. ;;
  2859. --network)
  2860. __docker_complete_networks
  2861. return
  2862. ;;
  2863. --restart-condition)
  2864. COMPREPLY=( $( compgen -W "any none on-failure" -- "$cur" ) )
  2865. return
  2866. ;;
  2867. --rollback-failure-action)
  2868. COMPREPLY=( $( compgen -W "continue pause" -- "$cur" ) )
  2869. return
  2870. ;;
  2871. --stop-signal)
  2872. __docker_complete_signals
  2873. return
  2874. ;;
  2875. --update-failure-action)
  2876. COMPREPLY=( $( compgen -W "continue pause rollback" -- "$cur" ) )
  2877. return
  2878. ;;
  2879. --user|-u)
  2880. __docker_complete_user_group
  2881. return
  2882. ;;
  2883. $(__docker_to_extglob "$options_with_args") )
  2884. return
  2885. ;;
  2886. esac
  2887. case "$cur" in
  2888. -*)
  2889. COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
  2890. ;;
  2891. *)
  2892. local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
  2893. if [ "$subcommand" = "update" ] ; then
  2894. if [ $cword -eq $counter ]; then
  2895. __docker_complete_services
  2896. fi
  2897. else
  2898. if [ $cword -eq $counter ]; then
  2899. __docker_complete_images
  2900. fi
  2901. fi
  2902. ;;
  2903. esac
  2904. }
  2905. _docker_swarm() {
  2906. local subcommands="
  2907. init
  2908. join
  2909. join-token
  2910. leave
  2911. unlock
  2912. unlock-key
  2913. update
  2914. "
  2915. __docker_subcommands "$subcommands" && return
  2916. case "$cur" in
  2917. -*)
  2918. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  2919. ;;
  2920. *)
  2921. COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
  2922. ;;
  2923. esac
  2924. }
  2925. _docker_swarm_init() {
  2926. case "$prev" in
  2927. --advertise-addr)
  2928. if [[ $cur == *: ]] ; then
  2929. COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
  2930. else
  2931. __docker_complete_local_interfaces
  2932. __docker_nospace
  2933. fi
  2934. return
  2935. ;;
  2936. --availability)
  2937. COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) )
  2938. return
  2939. ;;
  2940. --cert-expiry|--dispatcher-heartbeat|--external-ca|--max-snapshots|--snapshot-interval|--task-history-limit)
  2941. return
  2942. ;;
  2943. --listen-addr)
  2944. if [[ $cur == *: ]] ; then
  2945. COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
  2946. else
  2947. __docker_complete_local_interfaces --add 0.0.0.0
  2948. __docker_nospace
  2949. fi
  2950. return
  2951. ;;
  2952. esac
  2953. case "$cur" in
  2954. -*)
  2955. 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" ) )
  2956. ;;
  2957. esac
  2958. }
  2959. _docker_swarm_join() {
  2960. case "$prev" in
  2961. --advertise-addr)
  2962. if [[ $cur == *: ]] ; then
  2963. COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
  2964. else
  2965. __docker_complete_local_interfaces
  2966. __docker_nospace
  2967. fi
  2968. return
  2969. ;;
  2970. --listen-addr)
  2971. if [[ $cur == *: ]] ; then
  2972. COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
  2973. else
  2974. __docker_complete_local_interfaces --add 0.0.0.0
  2975. __docker_nospace
  2976. fi
  2977. return
  2978. ;;
  2979. --availability)
  2980. COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) )
  2981. return
  2982. ;;
  2983. --token)
  2984. return
  2985. ;;
  2986. esac
  2987. case "$cur" in
  2988. -*)
  2989. COMPREPLY=( $( compgen -W "--advertise-addr --availability --help --listen-addr --token" -- "$cur" ) )
  2990. ;;
  2991. *:)
  2992. COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
  2993. ;;
  2994. esac
  2995. }
  2996. _docker_swarm_join_token() {
  2997. case "$cur" in
  2998. -*)
  2999. COMPREPLY=( $( compgen -W "--help --quiet -q --rotate" -- "$cur" ) )
  3000. ;;
  3001. *)
  3002. local counter=$( __docker_pos_first_nonflag )
  3003. if [ $cword -eq $counter ]; then
  3004. COMPREPLY=( $( compgen -W "manager worker" -- "$cur" ) )
  3005. fi
  3006. ;;
  3007. esac
  3008. }
  3009. _docker_swarm_leave() {
  3010. case "$cur" in
  3011. -*)
  3012. COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
  3013. ;;
  3014. esac
  3015. }
  3016. _docker_swarm_unlock() {
  3017. case "$cur" in
  3018. -*)
  3019. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3020. ;;
  3021. esac
  3022. }
  3023. _docker_swarm_unlock_key() {
  3024. case "$cur" in
  3025. -*)
  3026. COMPREPLY=( $( compgen -W "--help --quiet -q --rotate" -- "$cur" ) )
  3027. ;;
  3028. esac
  3029. }
  3030. _docker_swarm_update() {
  3031. case "$prev" in
  3032. --cert-expiry|--dispatcher-heartbeat|--external-ca|--max-snapshots|--snapshot-interval|--task-history-limit)
  3033. return
  3034. ;;
  3035. esac
  3036. case "$cur" in
  3037. -*)
  3038. COMPREPLY=( $( compgen -W "--autolock --cert-expiry --dispatcher-heartbeat --external-ca --help --max-snapshots --snapshot-interval --task-history-limit" -- "$cur" ) )
  3039. ;;
  3040. esac
  3041. }
  3042. _docker_node() {
  3043. local subcommands="
  3044. demote
  3045. inspect
  3046. ls
  3047. promote
  3048. rm
  3049. ps
  3050. update
  3051. "
  3052. local aliases="
  3053. list
  3054. remove
  3055. "
  3056. __docker_subcommands "$subcommands $aliases" && return
  3057. case "$cur" in
  3058. -*)
  3059. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3060. ;;
  3061. *)
  3062. COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
  3063. ;;
  3064. esac
  3065. }
  3066. _docker_node_demote() {
  3067. case "$cur" in
  3068. -*)
  3069. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3070. ;;
  3071. *)
  3072. __docker_complete_nodes --filter role=manager
  3073. esac
  3074. }
  3075. _docker_node_inspect() {
  3076. case "$prev" in
  3077. --format|-f)
  3078. return
  3079. ;;
  3080. esac
  3081. case "$cur" in
  3082. -*)
  3083. COMPREPLY=( $( compgen -W "--format -f --help --pretty" -- "$cur" ) )
  3084. ;;
  3085. *)
  3086. __docker_complete_nodes --add self
  3087. esac
  3088. }
  3089. _docker_node_list() {
  3090. _docker_node_ls
  3091. }
  3092. _docker_node_ls() {
  3093. local key=$(__docker_map_key_of_current_option '--filter|-f')
  3094. case "$key" in
  3095. id)
  3096. __docker_complete_nodes --cur "${cur##*=}" --id
  3097. return
  3098. ;;
  3099. membership)
  3100. COMPREPLY=( $( compgen -W "accepted pending" -- "${cur##*=}" ) )
  3101. return
  3102. ;;
  3103. name)
  3104. __docker_complete_nodes --cur "${cur##*=}" --name
  3105. return
  3106. ;;
  3107. role)
  3108. COMPREPLY=( $( compgen -W "manager worker" -- "${cur##*=}" ) )
  3109. return
  3110. ;;
  3111. esac
  3112. case "$prev" in
  3113. --filter|-f)
  3114. COMPREPLY=( $( compgen -W "id label membership name role" -S = -- "$cur" ) )
  3115. __docker_nospace
  3116. return
  3117. ;;
  3118. esac
  3119. case "$cur" in
  3120. -*)
  3121. COMPREPLY=( $( compgen -W "--filter -f --help --quiet -q" -- "$cur" ) )
  3122. ;;
  3123. esac
  3124. }
  3125. _docker_node_promote() {
  3126. case "$cur" in
  3127. -*)
  3128. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3129. ;;
  3130. *)
  3131. __docker_complete_nodes --filter role=worker
  3132. esac
  3133. }
  3134. _docker_node_remove() {
  3135. _docker_node_rm
  3136. }
  3137. _docker_node_rm() {
  3138. case "$cur" in
  3139. -*)
  3140. COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
  3141. ;;
  3142. *)
  3143. __docker_complete_nodes
  3144. esac
  3145. }
  3146. _docker_node_ps() {
  3147. local key=$(__docker_map_key_of_current_option '--filter|-f')
  3148. case "$key" in
  3149. desired-state)
  3150. COMPREPLY=( $( compgen -W "accepted running shutdown" -- "${cur##*=}" ) )
  3151. return
  3152. ;;
  3153. name)
  3154. __docker_complete_services --cur "${cur##*=}" --name
  3155. return
  3156. ;;
  3157. esac
  3158. case "$prev" in
  3159. --filter|-f)
  3160. COMPREPLY=( $( compgen -W "desired-state id label name" -S = -- "$cur" ) )
  3161. __docker_nospace
  3162. return
  3163. ;;
  3164. esac
  3165. case "$cur" in
  3166. -*)
  3167. COMPREPLY=( $( compgen -W "--filter -f --help --no-resolve --no-trunc" -- "$cur" ) )
  3168. ;;
  3169. *)
  3170. __docker_complete_nodes --add self
  3171. ;;
  3172. esac
  3173. }
  3174. _docker_node_update() {
  3175. case "$prev" in
  3176. --availability)
  3177. COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) )
  3178. return
  3179. ;;
  3180. --role)
  3181. COMPREPLY=( $( compgen -W "manager worker" -- "$cur" ) )
  3182. return
  3183. ;;
  3184. --label-add|--label-rm)
  3185. return
  3186. ;;
  3187. esac
  3188. case "$cur" in
  3189. -*)
  3190. COMPREPLY=( $( compgen -W "--availability --help --label-add --label-rm --role" -- "$cur" ) )
  3191. ;;
  3192. *)
  3193. __docker_complete_nodes
  3194. esac
  3195. }
  3196. _docker_pause() {
  3197. _docker_container_pause
  3198. }
  3199. _docker_plugin() {
  3200. local subcommands="
  3201. create
  3202. disable
  3203. enable
  3204. inspect
  3205. install
  3206. ls
  3207. push
  3208. rm
  3209. set
  3210. upgrade
  3211. "
  3212. local aliases="
  3213. list
  3214. remove
  3215. "
  3216. __docker_subcommands "$subcommands $aliases" && return
  3217. case "$cur" in
  3218. -*)
  3219. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3220. ;;
  3221. *)
  3222. COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
  3223. ;;
  3224. esac
  3225. }
  3226. _docker_plugin_create() {
  3227. case "$cur" in
  3228. -*)
  3229. COMPREPLY=( $( compgen -W "--compress --help" -- "$cur" ) )
  3230. ;;
  3231. *)
  3232. local counter=$(__docker_pos_first_nonflag)
  3233. if [ $cword -eq $counter ]; then
  3234. # reponame
  3235. return
  3236. elif [ $cword -eq $((counter + 1)) ]; then
  3237. _filedir -d
  3238. fi
  3239. ;;
  3240. esac
  3241. }
  3242. _docker_plugin_disable() {
  3243. case "$cur" in
  3244. -*)
  3245. COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
  3246. ;;
  3247. *)
  3248. local counter=$(__docker_pos_first_nonflag)
  3249. if [ $cword -eq $counter ]; then
  3250. __docker_complete_plugins_installed --filter enabled=true
  3251. fi
  3252. ;;
  3253. esac
  3254. }
  3255. _docker_plugin_enable() {
  3256. case "$prev" in
  3257. --timeout)
  3258. return
  3259. ;;
  3260. esac
  3261. case "$cur" in
  3262. -*)
  3263. COMPREPLY=( $( compgen -W "--help --timeout" -- "$cur" ) )
  3264. ;;
  3265. *)
  3266. local counter=$(__docker_pos_first_nonflag '--timeout')
  3267. if [ $cword -eq $counter ]; then
  3268. __docker_complete_plugins_installed --filter enabled=false
  3269. fi
  3270. ;;
  3271. esac
  3272. }
  3273. _docker_plugin_inspect() {
  3274. case "$prev" in
  3275. --format|f)
  3276. return
  3277. ;;
  3278. esac
  3279. case "$cur" in
  3280. -*)
  3281. COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
  3282. ;;
  3283. *)
  3284. __docker_complete_plugins_installed
  3285. ;;
  3286. esac
  3287. }
  3288. _docker_plugin_install() {
  3289. case "$prev" in
  3290. --alias)
  3291. return
  3292. ;;
  3293. esac
  3294. case "$cur" in
  3295. -*)
  3296. COMPREPLY=( $( compgen -W "--alias --disable --disable-content-trust=false --grant-all-permissions --help" -- "$cur" ) )
  3297. ;;
  3298. esac
  3299. }
  3300. _docker_plugin_list() {
  3301. _docker_plugin_ls
  3302. }
  3303. _docker_plugin_ls() {
  3304. local key=$(__docker_map_key_of_current_option '--filter|-f')
  3305. case "$key" in
  3306. capability)
  3307. COMPREPLY=( $( compgen -W "authz ipamdriver networkdriver volumedriver" -- "${cur##*=}" ) )
  3308. return
  3309. ;;
  3310. enabled)
  3311. COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) )
  3312. return
  3313. ;;
  3314. esac
  3315. case "$prev" in
  3316. --filter|-f)
  3317. COMPREPLY=( $( compgen -S = -W "capability enabled" -- "$cur" ) )
  3318. __docker_nospace
  3319. return
  3320. ;;
  3321. --format)
  3322. return
  3323. ;;
  3324. esac
  3325. case "$cur" in
  3326. -*)
  3327. COMPREPLY=( $( compgen -W "--filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) )
  3328. ;;
  3329. esac
  3330. }
  3331. _docker_plugin_push() {
  3332. case "$cur" in
  3333. -*)
  3334. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3335. ;;
  3336. *)
  3337. local counter=$(__docker_pos_first_nonflag)
  3338. if [ $cword -eq $counter ]; then
  3339. __docker_complete_plugins_installed
  3340. fi
  3341. ;;
  3342. esac
  3343. }
  3344. _docker_plugin_remove() {
  3345. _docker_plugin_rm
  3346. }
  3347. _docker_plugin_rm() {
  3348. case "$cur" in
  3349. -*)
  3350. COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
  3351. ;;
  3352. *)
  3353. __docker_complete_plugins_installed
  3354. ;;
  3355. esac
  3356. }
  3357. _docker_plugin_set() {
  3358. case "$cur" in
  3359. -*)
  3360. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3361. ;;
  3362. *)
  3363. local counter=$(__docker_pos_first_nonflag)
  3364. if [ $cword -eq $counter ]; then
  3365. __docker_complete_plugins_installed
  3366. fi
  3367. ;;
  3368. esac
  3369. }
  3370. _docker_plugin_upgrade() {
  3371. case "$cur" in
  3372. -*)
  3373. COMPREPLY=( $( compgen -W "--disable-content-trust --grant-all-permissions --help --skip-remote-check" -- "$cur" ) )
  3374. ;;
  3375. *)
  3376. local counter=$(__docker_pos_first_nonflag)
  3377. if [ $cword -eq $counter ]; then
  3378. __docker_complete_plugins_installed
  3379. __ltrim_colon_completions "$cur"
  3380. elif [ $cword -eq $((counter + 1)) ]; then
  3381. local plugin_images="$(__docker_plugins_installed)"
  3382. COMPREPLY=( $(compgen -S : -W "${plugin_images%:*}" -- "$cur") )
  3383. __docker_nospace
  3384. fi
  3385. ;;
  3386. esac
  3387. }
  3388. _docker_port() {
  3389. _docker_container_port
  3390. }
  3391. _docker_ps() {
  3392. _docker_container_ls
  3393. }
  3394. _docker_pull() {
  3395. _docker_image_pull
  3396. }
  3397. _docker_push() {
  3398. _docker_image_push
  3399. }
  3400. _docker_rename() {
  3401. _docker_container_rename
  3402. }
  3403. _docker_restart() {
  3404. _docker_container_restart
  3405. }
  3406. _docker_rm() {
  3407. _docker_container_rm
  3408. }
  3409. _docker_rmi() {
  3410. _docker_image_rm
  3411. }
  3412. _docker_run() {
  3413. _docker_container_run
  3414. }
  3415. _docker_save() {
  3416. _docker_image_save
  3417. }
  3418. _docker_secret() {
  3419. local subcommands="
  3420. create
  3421. inspect
  3422. ls
  3423. rm
  3424. "
  3425. local aliases="
  3426. list
  3427. remove
  3428. "
  3429. __docker_subcommands "$subcommands $aliases" && return
  3430. case "$cur" in
  3431. -*)
  3432. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3433. ;;
  3434. *)
  3435. COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
  3436. ;;
  3437. esac
  3438. }
  3439. _docker_secret_create() {
  3440. case "$prev" in
  3441. --label|-l)
  3442. return
  3443. ;;
  3444. esac
  3445. case "$cur" in
  3446. -*)
  3447. COMPREPLY=( $( compgen -W "--help --label -l" -- "$cur" ) )
  3448. ;;
  3449. esac
  3450. }
  3451. _docker_secret_inspect() {
  3452. case "$prev" in
  3453. --format|-f)
  3454. return
  3455. ;;
  3456. esac
  3457. case "$cur" in
  3458. -*)
  3459. COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
  3460. ;;
  3461. *)
  3462. __docker_complete_secrets
  3463. ;;
  3464. esac
  3465. }
  3466. _docker_secret_list() {
  3467. _docker_secret_ls
  3468. }
  3469. _docker_secret_ls() {
  3470. case "$cur" in
  3471. -*)
  3472. COMPREPLY=( $( compgen -W "--help --quiet -q" -- "$cur" ) )
  3473. ;;
  3474. esac
  3475. }
  3476. _docker_secret_remove() {
  3477. case "$cur" in
  3478. -*)
  3479. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3480. ;;
  3481. *)
  3482. __docker_complete_secrets
  3483. ;;
  3484. esac
  3485. }
  3486. _docker_secret_rm() {
  3487. _docker_secret_remove
  3488. }
  3489. _docker_search() {
  3490. local key=$(__docker_map_key_of_current_option '--filter|-f')
  3491. case "$key" in
  3492. is-automated)
  3493. COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) )
  3494. return
  3495. ;;
  3496. is-official)
  3497. COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) )
  3498. return
  3499. ;;
  3500. esac
  3501. case "$prev" in
  3502. --filter|-f)
  3503. COMPREPLY=( $( compgen -S = -W "is-automated is-official stars" -- "$cur" ) )
  3504. __docker_nospace
  3505. return
  3506. ;;
  3507. --limit)
  3508. return
  3509. ;;
  3510. esac
  3511. case "$cur" in
  3512. -*)
  3513. COMPREPLY=( $( compgen -W "--filter --help --limit --no-trunc" -- "$cur" ) )
  3514. ;;
  3515. esac
  3516. }
  3517. _docker_stack() {
  3518. local subcommands="
  3519. deploy
  3520. ls
  3521. ps
  3522. rm
  3523. services
  3524. "
  3525. local aliases="
  3526. down
  3527. list
  3528. remove
  3529. up
  3530. "
  3531. __docker_subcommands "$subcommands $aliases" && return
  3532. case "$cur" in
  3533. -*)
  3534. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3535. ;;
  3536. *)
  3537. COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
  3538. ;;
  3539. esac
  3540. }
  3541. _docker_stack_deploy() {
  3542. case "$prev" in
  3543. --bundle-file)
  3544. if __docker_daemon_is_experimental ; then
  3545. _filedir dab
  3546. return
  3547. fi
  3548. ;;
  3549. --compose-file|-c)
  3550. _filedir yml
  3551. return
  3552. ;;
  3553. esac
  3554. case "$cur" in
  3555. -*)
  3556. local options="--compose-file -c --help --with-registry-auth"
  3557. __docker_daemon_is_experimental && options+=" --bundle-file"
  3558. COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
  3559. ;;
  3560. esac
  3561. }
  3562. _docker_stack_down() {
  3563. _docker_stack_rm
  3564. }
  3565. _docker_stack_list() {
  3566. _docker_stack_ls
  3567. }
  3568. _docker_stack_ls() {
  3569. case "$cur" in
  3570. -*)
  3571. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3572. ;;
  3573. esac
  3574. }
  3575. _docker_stack_ps() {
  3576. local key=$(__docker_map_key_of_current_option '--filter|-f')
  3577. case "$key" in
  3578. desired-state)
  3579. COMPREPLY=( $( compgen -W "accepted running shutdown" -- "${cur##*=}" ) )
  3580. return
  3581. ;;
  3582. id)
  3583. __docker_complete_stacks --cur "${cur##*=}" --id
  3584. return
  3585. ;;
  3586. name)
  3587. __docker_complete_stacks --cur "${cur##*=}" --name
  3588. return
  3589. ;;
  3590. esac
  3591. case "$prev" in
  3592. --filter|-f)
  3593. COMPREPLY=( $( compgen -S = -W "id name desired-state" -- "$cur" ) )
  3594. __docker_nospace
  3595. return
  3596. ;;
  3597. esac
  3598. case "$cur" in
  3599. -*)
  3600. COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve --no-trunc" -- "$cur" ) )
  3601. ;;
  3602. *)
  3603. local counter=$(__docker_pos_first_nonflag '--filter|-f')
  3604. if [ $cword -eq $counter ]; then
  3605. __docker_complete_stacks
  3606. fi
  3607. ;;
  3608. esac
  3609. }
  3610. _docker_stack_remove() {
  3611. _docker_stack_rm
  3612. }
  3613. _docker_stack_rm() {
  3614. case "$cur" in
  3615. -*)
  3616. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3617. ;;
  3618. *)
  3619. local counter=$(__docker_pos_first_nonflag)
  3620. if [ $cword -eq $counter ]; then
  3621. __docker_complete_stacks
  3622. fi
  3623. ;;
  3624. esac
  3625. }
  3626. _docker_stack_services() {
  3627. local key=$(__docker_map_key_of_current_option '--filter|-f')
  3628. case "$key" in
  3629. id)
  3630. __docker_complete_services --cur "${cur##*=}" --id
  3631. return
  3632. ;;
  3633. label)
  3634. return
  3635. ;;
  3636. name)
  3637. __docker_complete_services --cur "${cur##*=}" --name
  3638. return
  3639. ;;
  3640. esac
  3641. case "$prev" in
  3642. --filter|-f)
  3643. COMPREPLY=( $( compgen -S = -W "id label name" -- "$cur" ) )
  3644. __docker_nospace
  3645. return
  3646. ;;
  3647. --format)
  3648. return
  3649. ;;
  3650. esac
  3651. case "$cur" in
  3652. -*)
  3653. COMPREPLY=( $( compgen -W "--filter -f --format --help --quiet -q" -- "$cur" ) )
  3654. ;;
  3655. *)
  3656. local counter=$(__docker_pos_first_nonflag '--filter|-f|--format')
  3657. if [ $cword -eq $counter ]; then
  3658. __docker_complete_stacks
  3659. fi
  3660. ;;
  3661. esac
  3662. }
  3663. _docker_stack_up() {
  3664. _docker_stack_deploy
  3665. }
  3666. _docker_start() {
  3667. _docker_container_start
  3668. }
  3669. _docker_stats() {
  3670. _docker_container_stats
  3671. }
  3672. _docker_stop() {
  3673. _docker_container_stop
  3674. }
  3675. _docker_system() {
  3676. local subcommands="
  3677. df
  3678. events
  3679. info
  3680. prune
  3681. "
  3682. __docker_subcommands "$subcommands $aliases" && return
  3683. case "$cur" in
  3684. -*)
  3685. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3686. ;;
  3687. *)
  3688. COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
  3689. ;;
  3690. esac
  3691. }
  3692. _docker_system_df() {
  3693. case "$cur" in
  3694. -*)
  3695. COMPREPLY=( $( compgen -W "--help --verbose -v" -- "$cur" ) )
  3696. ;;
  3697. esac
  3698. }
  3699. _docker_system_events() {
  3700. local key=$(__docker_map_key_of_current_option '-f|--filter')
  3701. case "$key" in
  3702. container)
  3703. __docker_complete_containers_all --cur "${cur##*=}"
  3704. return
  3705. ;;
  3706. daemon)
  3707. local name=$(__docker_q info | sed -n 's/^\(ID\|Name\): //p')
  3708. COMPREPLY=( $( compgen -W "$name" -- "${cur##*=}" ) )
  3709. return
  3710. ;;
  3711. event)
  3712. COMPREPLY=( $( compgen -W "
  3713. attach
  3714. commit
  3715. connect
  3716. copy
  3717. create
  3718. delete
  3719. destroy
  3720. detach
  3721. die
  3722. disconnect
  3723. exec_create
  3724. exec_detach
  3725. exec_start
  3726. export
  3727. health_status
  3728. import
  3729. kill
  3730. load
  3731. mount
  3732. oom
  3733. pause
  3734. pull
  3735. push
  3736. reload
  3737. rename
  3738. resize
  3739. restart
  3740. save
  3741. start
  3742. stop
  3743. tag
  3744. top
  3745. unmount
  3746. unpause
  3747. untag
  3748. update
  3749. " -- "${cur##*=}" ) )
  3750. return
  3751. ;;
  3752. image)
  3753. cur="${cur##*=}"
  3754. __docker_complete_images
  3755. return
  3756. ;;
  3757. network)
  3758. __docker_complete_networks --cur "${cur##*=}"
  3759. return
  3760. ;;
  3761. type)
  3762. COMPREPLY=( $( compgen -W "container daemon image network volume" -- "${cur##*=}" ) )
  3763. return
  3764. ;;
  3765. volume)
  3766. __docker_complete_volumes --cur "${cur##*=}"
  3767. return
  3768. ;;
  3769. esac
  3770. case "$prev" in
  3771. --filter|-f)
  3772. COMPREPLY=( $( compgen -S = -W "container daemon event image label network type volume" -- "$cur" ) )
  3773. __docker_nospace
  3774. return
  3775. ;;
  3776. --since|--until)
  3777. return
  3778. ;;
  3779. esac
  3780. case "$cur" in
  3781. -*)
  3782. COMPREPLY=( $( compgen -W "--filter -f --help --since --until --format" -- "$cur" ) )
  3783. ;;
  3784. esac
  3785. }
  3786. _docker_system_info() {
  3787. case "$prev" in
  3788. --format|-f)
  3789. return
  3790. ;;
  3791. esac
  3792. case "$cur" in
  3793. -*)
  3794. COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
  3795. ;;
  3796. esac
  3797. }
  3798. _docker_system_prune() {
  3799. case "$prev" in
  3800. --filter)
  3801. COMPREPLY=( $( compgen -W "until" -S = -- "$cur" ) )
  3802. __docker_nospace
  3803. return
  3804. ;;
  3805. esac
  3806. case "$cur" in
  3807. -*)
  3808. COMPREPLY=( $( compgen -W "--all -a --force -f --filter --help" -- "$cur" ) )
  3809. ;;
  3810. esac
  3811. }
  3812. _docker_tag() {
  3813. _docker_image_tag
  3814. }
  3815. _docker_unpause() {
  3816. _docker_container_unpause
  3817. }
  3818. _docker_update() {
  3819. _docker_container_update
  3820. }
  3821. _docker_top() {
  3822. _docker_container_top
  3823. }
  3824. _docker_version() {
  3825. case "$prev" in
  3826. --format|-f)
  3827. return
  3828. ;;
  3829. esac
  3830. case "$cur" in
  3831. -*)
  3832. COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
  3833. ;;
  3834. esac
  3835. }
  3836. _docker_volume_create() {
  3837. case "$prev" in
  3838. --driver|-d)
  3839. __docker_complete_plugins_bundled --type Volume
  3840. return
  3841. ;;
  3842. --label|--opt|-o)
  3843. return
  3844. ;;
  3845. esac
  3846. case "$cur" in
  3847. -*)
  3848. COMPREPLY=( $( compgen -W "--driver -d --help --label --opt -o" -- "$cur" ) )
  3849. ;;
  3850. esac
  3851. }
  3852. _docker_volume_inspect() {
  3853. case "$prev" in
  3854. --format|-f)
  3855. return
  3856. ;;
  3857. esac
  3858. case "$cur" in
  3859. -*)
  3860. COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
  3861. ;;
  3862. *)
  3863. __docker_complete_volumes
  3864. ;;
  3865. esac
  3866. }
  3867. _docker_volume_list() {
  3868. _docker_volume_ls
  3869. }
  3870. _docker_volume_ls() {
  3871. local key=$(__docker_map_key_of_current_option '--filter|-f')
  3872. case "$key" in
  3873. dangling)
  3874. COMPREPLY=( $( compgen -W "true false" -- "${cur##*=}" ) )
  3875. return
  3876. ;;
  3877. driver)
  3878. __docker_complete_plugins_bundled --cur "${cur##*=}" --type Volume
  3879. return
  3880. ;;
  3881. name)
  3882. __docker_complete_volumes --cur "${cur##*=}"
  3883. return
  3884. ;;
  3885. esac
  3886. case "$prev" in
  3887. --filter|-f)
  3888. COMPREPLY=( $( compgen -S = -W "dangling driver label name" -- "$cur" ) )
  3889. __docker_nospace
  3890. return
  3891. ;;
  3892. --format)
  3893. return
  3894. ;;
  3895. esac
  3896. case "$cur" in
  3897. -*)
  3898. COMPREPLY=( $( compgen -W "--filter -f --format --help --quiet -q" -- "$cur" ) )
  3899. ;;
  3900. esac
  3901. }
  3902. _docker_volume_prune() {
  3903. case "$cur" in
  3904. -*)
  3905. COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
  3906. ;;
  3907. esac
  3908. }
  3909. _docker_volume_remove() {
  3910. _docker_volume_rm
  3911. }
  3912. _docker_volume_rm() {
  3913. case "$cur" in
  3914. -*)
  3915. COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
  3916. ;;
  3917. *)
  3918. __docker_complete_volumes
  3919. ;;
  3920. esac
  3921. }
  3922. _docker_volume() {
  3923. local subcommands="
  3924. create
  3925. inspect
  3926. ls
  3927. prune
  3928. rm
  3929. "
  3930. local aliases="
  3931. list
  3932. remove
  3933. "
  3934. __docker_subcommands "$subcommands $aliases" && return
  3935. case "$cur" in
  3936. -*)
  3937. COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
  3938. ;;
  3939. *)
  3940. COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
  3941. ;;
  3942. esac
  3943. }
  3944. _docker_wait() {
  3945. _docker_container_wait
  3946. }
  3947. _docker() {
  3948. local previous_extglob_setting=$(shopt -p extglob)
  3949. shopt -s extglob
  3950. local management_commands=(
  3951. container
  3952. image
  3953. network
  3954. node
  3955. plugin
  3956. secret
  3957. service
  3958. stack
  3959. system
  3960. volume
  3961. )
  3962. local top_level_commands=(
  3963. build
  3964. login
  3965. logout
  3966. run
  3967. search
  3968. version
  3969. )
  3970. local legacy_commands=(
  3971. commit
  3972. cp
  3973. create
  3974. diff
  3975. events
  3976. exec
  3977. export
  3978. history
  3979. images
  3980. import
  3981. info
  3982. inspect
  3983. kill
  3984. load
  3985. logs
  3986. pause
  3987. port
  3988. ps
  3989. pull
  3990. push
  3991. rename
  3992. restart
  3993. rm
  3994. rmi
  3995. save
  3996. start
  3997. stats
  3998. stop
  3999. swarm
  4000. tag
  4001. top
  4002. unpause
  4003. update
  4004. wait
  4005. )
  4006. local experimental_commands=(
  4007. checkpoint
  4008. deploy
  4009. )
  4010. local commands=(${management_commands[*]} ${top_level_commands[*]})
  4011. [ -z "$DOCKER_HIDE_LEGACY_COMMANDS" ] && commands+=(${legacy_commands[*]})
  4012. # These options are valid as global options for all client commands
  4013. # and valid as command options for `docker daemon`
  4014. local global_boolean_options="
  4015. --debug -D
  4016. --tls
  4017. --tlsverify
  4018. "
  4019. local global_options_with_args="
  4020. --config
  4021. --host -H
  4022. --log-level -l
  4023. --tlscacert
  4024. --tlscert
  4025. --tlskey
  4026. "
  4027. local host config daemon_os
  4028. COMPREPLY=()
  4029. local cur prev words cword
  4030. _get_comp_words_by_ref -n : cur prev words cword
  4031. local command='docker' command_pos=0 subcommand_pos
  4032. local counter=1
  4033. while [ $counter -lt $cword ]; do
  4034. case "${words[$counter]}" in
  4035. # save host so that completion can use custom daemon
  4036. --host|-H)
  4037. (( counter++ ))
  4038. host="${words[$counter]}"
  4039. ;;
  4040. # save config so that completion can use custom configuration directories
  4041. --config)
  4042. (( counter++ ))
  4043. config="${words[$counter]}"
  4044. ;;
  4045. $(__docker_to_extglob "$global_options_with_args") )
  4046. (( counter++ ))
  4047. ;;
  4048. -*)
  4049. ;;
  4050. =)
  4051. (( counter++ ))
  4052. ;;
  4053. *)
  4054. command="${words[$counter]}"
  4055. command_pos=$counter
  4056. break
  4057. ;;
  4058. esac
  4059. (( counter++ ))
  4060. done
  4061. local binary="${words[0]}"
  4062. if [[ $binary == ?(*/)dockerd ]] ; then
  4063. # for the dockerd binary, we reuse completion of `docker daemon`.
  4064. # dockerd does not have subcommands and global options.
  4065. command=daemon
  4066. command_pos=0
  4067. fi
  4068. local completions_func=_docker_${command//-/_}
  4069. declare -F $completions_func >/dev/null && $completions_func
  4070. eval "$previous_extglob_setting"
  4071. return 0
  4072. }
  4073. eval "$__docker_previous_extglob_setting"
  4074. unset __docker_previous_extglob_setting
  4075. complete -F _docker docker docker.exe dockerd dockerd.exe