1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081 |
- #!/bin/bash
- #
- # bash completion file for core docker commands
- #
- # This script provides completion of:
- # - commands and their options
- # - container ids and names
- # - image repos and tags
- # - filepaths
- #
- # To enable the completions either:
- # - place this file in /etc/bash_completion.d
- # or
- # - copy this file to e.g. ~/.docker-completion.sh and add the line
- # below to your .bashrc after bash completion features are loaded
- # . ~/.docker-completion.sh
- #
- # Configuration:
- #
- # For several commands, the amount of completions can be configured by
- # setting environment variables.
- #
- # DOCKER_COMPLETION_SHOW_CONTAINER_IDS
- # DOCKER_COMPLETION_SHOW_NETWORK_IDS
- # DOCKER_COMPLETION_SHOW_NODE_IDS
- # DOCKER_COMPLETION_SHOW_SECRET_IDS
- # DOCKER_COMPLETION_SHOW_SERVICE_IDS
- # "no" - Show names only (default)
- # "yes" - Show names and ids
- #
- # You can tailor completion for the "events", "history", "inspect", "run",
- # "rmi" and "save" commands by settings the following environment
- # variables:
- #
- # DOCKER_COMPLETION_SHOW_IMAGE_IDS
- # "none" - Show names only (default)
- # "non-intermediate" - Show names and ids, but omit intermediate image IDs
- # "all" - Show names and ids, including intermediate image IDs
- #
- # DOCKER_COMPLETION_SHOW_TAGS
- # "yes" - include tags in completion options (default)
- # "no" - don't include tags in completion options
- #
- # Note:
- # Currently, the completions will not work if the docker daemon is not
- # bound to the default communication port/socket
- # If the docker daemon is using a unix socket for communication your user
- # must have access to the socket for the completions to function correctly
- #
- # Note for developers:
- # Please arrange options sorted alphabetically by long name with the short
- # options immediately following their corresponding long form.
- # This order should be applied to lists, alternatives and code blocks.
- __docker_previous_extglob_setting=$(shopt -p extglob)
- shopt -s extglob
- __docker_q() {
- docker ${host:+-H "$host"} ${config:+--config "$config"} 2>/dev/null "$@"
- }
- # __docker_containers returns a list of containers. Additional options to
- # `docker ps` may be specified in order to filter the list, e.g.
- # `__docker_containers --filter status=running`
- # By default, only names are returned.
- # Set DOCKER_COMPLETION_SHOW_CONTAINER_IDS=yes to also complete IDs.
- # An optional first option `--id|--name` may be used to limit the
- # output to the IDs or names of matching items. This setting takes
- # precedence over the environment setting.
- __docker_containers() {
- local format
- if [ "$1" = "--id" ] ; then
- format='{{.ID}}'
- shift
- elif [ "$1" = "--name" ] ; then
- format='{{.Names}}'
- shift
- elif [ "${DOCKER_COMPLETION_SHOW_CONTAINER_IDS}" = yes ] ; then
- format='{{.ID}} {{.Names}}'
- else
- format='{{.Names}}'
- fi
- __docker_q ps --format "$format" "$@"
- }
- # __docker_complete_containers applies completion of containers based on the current
- # value of `$cur` or the value of the optional first option `--cur`, if given.
- # Additional filters may be appended, see `__docker_containers`.
- __docker_complete_containers() {
- local current="$cur"
- if [ "$1" = "--cur" ] ; then
- current="$2"
- shift 2
- fi
- COMPREPLY=( $(compgen -W "$(__docker_containers "$@")" -- "$current") )
- }
- __docker_complete_containers_all() {
- __docker_complete_containers "$@" --all
- }
- __docker_complete_containers_running() {
- __docker_complete_containers "$@" --filter status=running
- }
- __docker_complete_containers_stopped() {
- __docker_complete_containers "$@" --filter status=exited
- }
- __docker_complete_containers_unpauseable() {
- __docker_complete_containers "$@" --filter status=paused
- }
- __docker_complete_container_names() {
- local containers=( $(__docker_q ps -aq --no-trunc) )
- local names=( $(__docker_q inspect --format '{{.Name}}' "${containers[@]}") )
- names=( "${names[@]#/}" ) # trim off the leading "/" from the container names
- COMPREPLY=( $(compgen -W "${names[*]}" -- "$cur") )
- }
- __docker_complete_container_ids() {
- local containers=( $(__docker_q ps -aq) )
- COMPREPLY=( $(compgen -W "${containers[*]}" -- "$cur") )
- }
- __docker_images() {
- local images_args=""
- case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in
- all)
- images_args="--no-trunc -a"
- ;;
- non-intermediate)
- images_args="--no-trunc"
- ;;
- esac
- local repo_print_command
- if [ "${DOCKER_COMPLETION_SHOW_TAGS:-yes}" = "yes" ]; then
- repo_print_command='print $1; print $1":"$2'
- else
- repo_print_command='print $1'
- fi
- local awk_script
- case "$DOCKER_COMPLETION_SHOW_IMAGE_IDS" in
- all|non-intermediate)
- awk_script='NR>1 { print $3; if ($1 != "<none>") { '"$repo_print_command"' } }'
- ;;
- none|*)
- awk_script='NR>1 && $1 != "<none>" { '"$repo_print_command"' }'
- ;;
- esac
- __docker_q images $images_args | awk "$awk_script" | grep -v '<none>$'
- }
- __docker_complete_images() {
- COMPREPLY=( $(compgen -W "$(__docker_images)" -- "$cur") )
- __ltrim_colon_completions "$cur"
- }
- __docker_complete_image_repos() {
- local repos="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1 }')"
- COMPREPLY=( $(compgen -W "$repos" -- "$cur") )
- }
- __docker_complete_image_repos_and_tags() {
- local reposAndTags="$(__docker_q images | awk 'NR>1 && $1 != "<none>" { print $1; print $1":"$2 }')"
- COMPREPLY=( $(compgen -W "$reposAndTags" -- "$cur") )
- __ltrim_colon_completions "$cur"
- }
- # __docker_networks returns a list of all networks. Additional options to
- # `docker network ls` may be specified in order to filter the list, e.g.
- # `__docker_networks --filter type=custom`
- # By default, only names are returned.
- # Set DOCKER_COMPLETION_SHOW_NETWORK_IDS=yes to also complete IDs.
- # An optional first option `--id|--name` may be used to limit the
- # output to the IDs or names of matching items. This setting takes
- # precedence over the environment setting.
- __docker_networks() {
- local format
- if [ "$1" = "--id" ] ; then
- format='{{.ID}}'
- shift
- elif [ "$1" = "--name" ] ; then
- format='{{.Name}}'
- shift
- elif [ "${DOCKER_COMPLETION_SHOW_NETWORK_IDS}" = yes ] ; then
- format='{{.ID}} {{.Name}}'
- else
- format='{{.Name}}'
- fi
- __docker_q network ls --format "$format" "$@"
- }
- # __docker_complete_networks applies completion of networks based on the current
- # value of `$cur` or the value of the optional first option `--cur`, if given.
- # Additional filters may be appended, see `__docker_networks`.
- __docker_complete_networks() {
- local current="$cur"
- if [ "$1" = "--cur" ] ; then
- current="$2"
- shift 2
- fi
- COMPREPLY=( $(compgen -W "$(__docker_networks "$@")" -- "$current") )
- }
- __docker_complete_containers_in_network() {
- local containers=$(__docker_q network inspect -f '{{range $i, $c := .Containers}}{{$i}} {{$c.Name}} {{end}}' "$1")
- COMPREPLY=( $(compgen -W "$containers" -- "$cur") )
- }
- # __docker_volumes returns a list of all volumes. Additional options to
- # `docker volume ls` may be specified in order to filter the list, e.g.
- # `__docker_volumes --filter dangling=true`
- # Because volumes do not have IDs, this function does not distinguish between
- # IDs and names.
- __docker_volumes() {
- __docker_q volume ls -q "$@"
- }
- # __docker_complete_volumes applies completion of volumes based on the current
- # value of `$cur` or the value of the optional first option `--cur`, if given.
- # Additional filters may be appended, see `__docker_volumes`.
- __docker_complete_volumes() {
- local current="$cur"
- if [ "$1" = "--cur" ] ; then
- current="$2"
- shift 2
- fi
- COMPREPLY=( $(compgen -W "$(__docker_volumes "$@")" -- "$current") )
- }
- # __docker_plugins_bundled returns a list of all plugins of a given type.
- # The type has to be specified with the mandatory option `--type`.
- # Valid types are: Network, Volume, Authorization.
- # Completions may be added or removed with `--add` and `--remove`
- # This function only deals with plugins that come bundled with Docker.
- # For plugins managed by `docker plugin`, see `__docker_plugins_installed`.
- __docker_plugins_bundled() {
- local type add=() remove=()
- while true ; do
- case "$1" in
- --type)
- type="$2"
- shift 2
- ;;
- --add)
- add+=("$2")
- shift 2
- ;;
- --remove)
- remove+=("$2")
- shift 2
- ;;
- *)
- break
- ;;
- esac
- done
- local plugins=($(__docker_q info | sed -n "/^Plugins/,/^[^ ]/s/ $type: //p"))
- for del in "${remove[@]}" ; do
- plugins=(${plugins[@]/$del/})
- done
- echo "${plugins[@]} ${add[@]}"
- }
- # __docker_complete_plugins_bundled applies completion of plugins based on the current
- # value of `$cur` or the value of the optional first option `--cur`, if given.
- # The plugin type has to be specified with the next option `--type`.
- # This function only deals with plugins that come bundled with Docker.
- # For completion of plugins managed by `docker plugin`, see
- # `__docker_complete_plugins_installed`.
- __docker_complete_plugins_bundled() {
- local current="$cur"
- if [ "$1" = "--cur" ] ; then
- current="$2"
- shift 2
- fi
- COMPREPLY=( $(compgen -W "$(__docker_plugins_bundled "$@")" -- "$current") )
- }
- # __docker_plugins_installed returns a list of all plugins that were installed with
- # the Docker plugin API.
- # For built-in pugins, see `__docker_plugins_bundled`.
- __docker_plugins_installed() {
- __docker_q plugin ls | awk 'NR>1 {print $1}'
- }
- # __docker_complete_plugins_installed applies completion of plugins that were installed
- # with the Docker plugin API, based on the current value of `$cur` or the value of
- # the optional first option `--cur`, if given.
- # For completion of built-in pugins, see `__docker_complete_plugins_bundled`.
- __docker_complete_plugins_installed() {
- local current="$cur"
- if [ "$1" = "--cur" ] ; then
- current="$2"
- shift 2
- fi
- COMPREPLY=( $(compgen -W "$(__docker_plugins_installed "$@")" -- "$current") )
- }
- __docker_runtimes() {
- __docker_q info | sed -n 's/^Runtimes: \(.*\)/\1/p'
- }
- __docker_complete_runtimes() {
- COMPREPLY=( $(compgen -W "$(__docker_runtimes)" -- "$cur") )
- }
- # __docker_secrets returns a list of all secrets.
- # By default, only names of secrets are returned.
- # Set DOCKER_COMPLETION_SHOW_SECRET_IDS=yes to also complete IDs of secrets.
- __docker_secrets() {
- local fields='$2' # default: name only
- [ "${DOCKER_COMPLETION_SHOW_SECRET_IDS}" = yes ] && fields='$1,$2' # ID and name
- __docker_q secret ls | awk "NR>1 {print $fields}"
- }
- # __docker_complete_secrets applies completion of secrets based on the current value
- # of `$cur`.
- __docker_complete_secrets() {
- COMPREPLY=( $(compgen -W "$(__docker_secrets)" -- "$cur") )
- }
- # __docker_stacks returns a list of all stacks.
- __docker_stacks() {
- __docker_q stack ls | awk 'NR>1 {print $1}'
- }
- # __docker_complete_stacks applies completion of stacks based on the current value
- # of `$cur` or the value of the optional first option `--cur`, if given.
- __docker_complete_stacks() {
- local current="$cur"
- if [ "$1" = "--cur" ] ; then
- current="$2"
- shift 2
- fi
- COMPREPLY=( $(compgen -W "$(__docker_stacks "$@")" -- "$current") )
- }
- # __docker_nodes returns a list of all nodes. Additional options to
- # `docker node ls` may be specified in order to filter the list, e.g.
- # `__docker_nodes --filter role=manager`
- # By default, only node names are returned.
- # Set DOCKER_COMPLETION_SHOW_NODE_IDS=yes to also complete node IDs.
- # An optional first option `--id|--name` may be used to limit the
- # output to the IDs or names of matching items. This setting takes
- # precedence over the environment setting.
- __docker_nodes() {
- local fields='$2' # default: node name only
- [ "${DOCKER_COMPLETION_SHOW_NODE_IDS}" = yes ] && fields='$1,$2' # ID and name
- if [ "$1" = "--id" ] ; then
- fields='$1' # IDs only
- shift
- elif [ "$1" = "--name" ] ; then
- fields='$2' # names only
- shift
- fi
- __docker_q node ls "$@" | tr -d '*' | awk "NR>1 {print $fields}"
- }
- # __docker_complete_nodes applies completion of nodes based on the current
- # value of `$cur` or the value of the optional first option `--cur`, if given.
- # Additional filters may be appended, see `__docker_nodes`.
- __docker_complete_nodes() {
- local current="$cur"
- if [ "$1" = "--cur" ] ; then
- current="$2"
- shift 2
- fi
- COMPREPLY=( $(compgen -W "$(__docker_nodes "$@")" -- "$current") )
- }
- __docker_complete_nodes_plus_self() {
- __docker_complete_nodes "$@"
- COMPREPLY+=( self )
- }
- # __docker_services returns a list of all services. Additional options to
- # `docker service ls` may be specified in order to filter the list, e.g.
- # `__docker_services --filter name=xxx`
- # By default, only node names are returned.
- # Set DOCKER_COMPLETION_SHOW_SERVICE_IDS=yes to also complete IDs.
- # An optional first option `--id|--name` may be used to limit the
- # output to the IDs or names of matching items. This setting takes
- # precedence over the environment setting.
- __docker_services() {
- local fields='$2' # default: service name only
- [ "${DOCKER_COMPLETION_SHOW_SERVICE_IDS}" = yes ] && fields='$1,$2' # ID & name
- if [ "$1" = "--id" ] ; then
- fields='$1' # IDs only
- shift
- elif [ "$1" = "--name" ] ; then
- fields='$2' # names only
- shift
- fi
- __docker_q service ls "$@" | awk "NR>1 {print $fields}"
- }
- # __docker_complete_services applies completion of services based on the current
- # value of `$cur` or the value of the optional first option `--cur`, if given.
- # Additional filters may be appended, see `__docker_services`.
- __docker_complete_services() {
- local current="$cur"
- if [ "$1" = "--cur" ] ; then
- current="$2"
- shift 2
- fi
- COMPREPLY=( $(compgen -W "$(__docker_services "$@")" -- "$current") )
- }
- # __docker_append_to_completions appends the word passed as an argument to every
- # word in `$COMPREPLY`.
- # Normally you do this with `compgen -S` while generating the completions.
- # This function allows you to append a suffix later. It allows you to use
- # the __docker_complete_XXX functions in cases where you need a suffix.
- __docker_append_to_completions() {
- COMPREPLY=( ${COMPREPLY[@]/%/"$1"} )
- }
- # __docker_is_experimental tests whether the currently configured Docker daemon
- # runs in experimental mode. If so, the function exits with 0 (true).
- # Otherwise, or if the result cannot be determined, the exit value is 1 (false).
- __docker_is_experimental() {
- [ "$(__docker_q version -f '{{.Server.Experimental}}')" = "true" ]
- }
- # __docker_pos_first_nonflag finds the position of the first word that is neither
- # option nor an option's argument. If there are options that require arguments,
- # you should pass a glob describing those options, e.g. "--option1|-o|--option2"
- # Use this function to restrict completions to exact positions after the argument list.
- __docker_pos_first_nonflag() {
- local argument_flags=$1
- local counter=$((${subcommand_pos:-${command_pos}} + 1))
- while [ $counter -le $cword ]; do
- if [ -n "$argument_flags" ] && eval "case '${words[$counter]}' in $argument_flags) true ;; *) false ;; esac"; then
- (( counter++ ))
- # eat "=" in case of --option=arg syntax
- [ "${words[$counter]}" = "=" ] && (( counter++ ))
- else
- case "${words[$counter]}" in
- -*)
- ;;
- *)
- break
- ;;
- esac
- fi
- # Bash splits words at "=", retaining "=" as a word, examples:
- # "--debug=false" => 3 words, "--log-opt syslog-facility=daemon" => 4 words
- while [ "${words[$counter + 1]}" = "=" ] ; do
- counter=$(( counter + 2))
- done
- (( counter++ ))
- done
- echo $counter
- }
- # __docker_map_key_of_current_option returns `key` if we are currently completing the
- # value of a map option (`key=value`) which matches the extglob given as an argument.
- # This function is needed for key-specific completions.
- __docker_map_key_of_current_option() {
- local glob="$1"
- local key glob_pos
- if [ "$cur" = "=" ] ; then # key= case
- key="$prev"
- glob_pos=$((cword - 2))
- elif [[ $cur == *=* ]] ; then # key=value case (OSX)
- key=${cur%=*}
- glob_pos=$((cword - 1))
- elif [ "$prev" = "=" ] ; then
- key=${words[$cword - 2]} # key=value case
- glob_pos=$((cword - 3))
- else
- return
- fi
- [ "${words[$glob_pos]}" = "=" ] && ((glob_pos--)) # --option=key=value syntax
- [[ ${words[$glob_pos]} == @($glob) ]] && echo "$key"
- }
- # __docker_value_of_option returns the value of the first option matching `option_glob`.
- # Valid values for `option_glob` are option names like `--log-level` and globs like
- # `--log-level|-l`
- # Only positions between the command and the current word are considered.
- __docker_value_of_option() {
- local option_extglob=$(__docker_to_extglob "$1")
- local counter=$((command_pos + 1))
- while [ $counter -lt $cword ]; do
- case ${words[$counter]} in
- $option_extglob )
- echo ${words[$counter + 1]}
- break
- ;;
- esac
- (( counter++ ))
- done
- }
- # __docker_to_alternatives transforms a multiline list of strings into a single line
- # string with the words separated by `|`.
- # This is used to prepare arguments to __docker_pos_first_nonflag().
- __docker_to_alternatives() {
- local parts=( $1 )
- local IFS='|'
- echo "${parts[*]}"
- }
- # __docker_to_extglob transforms a multiline list of options into an extglob pattern
- # suitable for use in case statements.
- __docker_to_extglob() {
- local extglob=$( __docker_to_alternatives "$1" )
- echo "@($extglob)"
- }
- # __docker_subcommands processes subcommands
- # Locates the first occurrence of any of the subcommands contained in the
- # first argument. In case of a match, calls the corresponding completion
- # function and returns 0.
- # If no match is found, 1 is returned. The calling function can then
- # continue processing its completion.
- #
- # TODO if the preceding command has options that accept arguments and an
- # argument is equal ot one of the subcommands, this is falsely detected as
- # a match.
- __docker_subcommands() {
- local subcommands="$1"
- local counter=$(($command_pos + 1))
- while [ $counter -lt $cword ]; do
- case "${words[$counter]}" in
- $(__docker_to_extglob "$subcommands") )
- subcommand_pos=$counter
- local subcommand=${words[$counter]}
- local completions_func=_docker_${command}_${subcommand}
- declare -F $completions_func >/dev/null && $completions_func
- return 0
- ;;
- esac
- (( counter++ ))
- done
- return 1
- }
- # __docker_nospace suppresses trailing whitespace
- __docker_nospace() {
- # compopt is not available in ancient bash versions
- type compopt &>/dev/null && compopt -o nospace
- }
- __docker_complete_resolved_hostname() {
- command -v host >/dev/null 2>&1 || return
- COMPREPLY=( $(host 2>/dev/null "${cur%:}" | awk '/has address/ {print $4}') )
- }
- __docker_local_interfaces() {
- command -v ip >/dev/null 2>&1 || return
- ip addr show scope global 2>/dev/null | sed -n 's| \+inet \([0-9.]\+\).* \([^ ]\+\)|\1 \2|p'
- }
- __docker_complete_local_interfaces() {
- local additional_interface
- if [ "$1" = "--add" ] ; then
- additional_interface="$2"
- fi
- COMPREPLY=( $( compgen -W "$(__docker_local_interfaces) $additional_interface" -- "$cur" ) )
- }
- __docker_complete_capabilities() {
- # The list of capabilities is defined in types.go, ALL was added manually.
- COMPREPLY=( $( compgen -W "
- ALL
- AUDIT_CONTROL
- AUDIT_WRITE
- AUDIT_READ
- BLOCK_SUSPEND
- CHOWN
- DAC_OVERRIDE
- DAC_READ_SEARCH
- FOWNER
- FSETID
- IPC_LOCK
- IPC_OWNER
- KILL
- LEASE
- LINUX_IMMUTABLE
- MAC_ADMIN
- MAC_OVERRIDE
- MKNOD
- NET_ADMIN
- NET_BIND_SERVICE
- NET_BROADCAST
- NET_RAW
- SETFCAP
- SETGID
- SETPCAP
- SETUID
- SYS_ADMIN
- SYS_BOOT
- SYS_CHROOT
- SYSLOG
- SYS_MODULE
- SYS_NICE
- SYS_PACCT
- SYS_PTRACE
- SYS_RAWIO
- SYS_RESOURCE
- SYS_TIME
- SYS_TTY_CONFIG
- WAKE_ALARM
- " -- "$cur" ) )
- }
- __docker_complete_detach-keys() {
- case "$prev" in
- --detach-keys)
- case "$cur" in
- *,)
- COMPREPLY=( $( compgen -W "${cur}ctrl-" -- "$cur" ) )
- ;;
- *)
- COMPREPLY=( $( compgen -W "ctrl-" -- "$cur" ) )
- ;;
- esac
- __docker_nospace
- return
- ;;
- esac
- return 1
- }
- __docker_complete_isolation() {
- COMPREPLY=( $( compgen -W "default hyperv process" -- "$cur" ) )
- }
- __docker_complete_log_drivers() {
- COMPREPLY=( $( compgen -W "
- awslogs
- etwlogs
- fluentd
- gcplogs
- gelf
- journald
- json-file
- logentries
- none
- splunk
- syslog
- " -- "$cur" ) )
- }
- __docker_complete_log_options() {
- # see docs/reference/logging/index.md
- local awslogs_options="awslogs-region awslogs-group awslogs-stream"
- local fluentd_options="env fluentd-address fluentd-async-connect fluentd-buffer-limit fluentd-retry-wait fluentd-max-retries labels tag"
- local gcplogs_options="env gcp-log-cmd gcp-project labels"
- local gelf_options="env gelf-address gelf-compression-level gelf-compression-type labels tag"
- local journald_options="env labels tag"
- local json_file_options="env labels max-file max-size"
- local logentries_options="logentries-token"
- local syslog_options="env labels syslog-address syslog-facility syslog-format syslog-tls-ca-cert syslog-tls-cert syslog-tls-key syslog-tls-skip-verify tag"
- local splunk_options="env labels splunk-caname splunk-capath splunk-format splunk-gzip splunk-gzip-level splunk-index splunk-insecureskipverify splunk-source splunk-sourcetype splunk-token splunk-url splunk-verify-connection tag"
- local all_options="$fluentd_options $gcplogs_options $gelf_options $journald_options $logentries_options $json_file_options $syslog_options $splunk_options"
- case $(__docker_value_of_option --log-driver) in
- '')
- COMPREPLY=( $( compgen -W "$all_options" -S = -- "$cur" ) )
- ;;
- awslogs)
- COMPREPLY=( $( compgen -W "$awslogs_options" -S = -- "$cur" ) )
- ;;
- fluentd)
- COMPREPLY=( $( compgen -W "$fluentd_options" -S = -- "$cur" ) )
- ;;
- gcplogs)
- COMPREPLY=( $( compgen -W "$gcplogs_options" -S = -- "$cur" ) )
- ;;
- gelf)
- COMPREPLY=( $( compgen -W "$gelf_options" -S = -- "$cur" ) )
- ;;
- journald)
- COMPREPLY=( $( compgen -W "$journald_options" -S = -- "$cur" ) )
- ;;
- json-file)
- COMPREPLY=( $( compgen -W "$json_file_options" -S = -- "$cur" ) )
- ;;
- logentries)
- COMPREPLY=( $( compgen -W "$logentries_options" -S = -- "$cur" ) )
- ;;
- syslog)
- COMPREPLY=( $( compgen -W "$syslog_options" -S = -- "$cur" ) )
- ;;
- splunk)
- COMPREPLY=( $( compgen -W "$splunk_options" -S = -- "$cur" ) )
- ;;
- *)
- return
- ;;
- esac
- __docker_nospace
- }
- __docker_complete_log_driver_options() {
- local key=$(__docker_map_key_of_current_option '--log-opt')
- case "$key" in
- fluentd-async-connect)
- COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) )
- return
- ;;
- gelf-address)
- COMPREPLY=( $( compgen -W "udp" -S "://" -- "${cur##*=}" ) )
- __docker_nospace
- return
- ;;
- gelf-compression-level)
- COMPREPLY=( $( compgen -W "1 2 3 4 5 6 7 8 9" -- "${cur##*=}" ) )
- return
- ;;
- gelf-compression-type)
- COMPREPLY=( $( compgen -W "gzip none zlib" -- "${cur##*=}" ) )
- return
- ;;
- syslog-address)
- COMPREPLY=( $( compgen -W "tcp:// tcp+tls:// udp:// unix://" -- "${cur##*=}" ) )
- __docker_nospace
- __ltrim_colon_completions "${cur}"
- return
- ;;
- syslog-facility)
- COMPREPLY=( $( compgen -W "
- auth
- authpriv
- cron
- daemon
- ftp
- kern
- local0
- local1
- local2
- local3
- local4
- local5
- local6
- local7
- lpr
- mail
- news
- syslog
- user
- uucp
- " -- "${cur##*=}" ) )
- return
- ;;
- syslog-format)
- COMPREPLY=( $( compgen -W "rfc3164 rfc5424 rfc5424micro" -- "${cur##*=}" ) )
- return
- ;;
- syslog-tls-ca-cert|syslog-tls-cert|syslog-tls-key)
- _filedir
- return
- ;;
- syslog-tls-skip-verify)
- COMPREPLY=( $( compgen -W "true" -- "${cur##*=}" ) )
- return
- ;;
- splunk-url)
- COMPREPLY=( $( compgen -W "http:// https://" -- "${cur##*=}" ) )
- __docker_nospace
- __ltrim_colon_completions "${cur}"
- return
- ;;
- splunk-gzip|splunk-insecureskipverify|splunk-verify-connection)
- COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) )
- return
- ;;
- splunk-format)
- COMPREPLY=( $( compgen -W "inline json raw" -- "${cur##*=}" ) )
- return
- ;;
- esac
- return 1
- }
- __docker_complete_log_levels() {
- COMPREPLY=( $( compgen -W "debug info warn error fatal" -- "$cur" ) )
- }
- __docker_complete_restart() {
- case "$prev" in
- --restart)
- case "$cur" in
- on-failure:*)
- ;;
- *)
- COMPREPLY=( $( compgen -W "always no on-failure on-failure: unless-stopped" -- "$cur") )
- ;;
- esac
- return
- ;;
- esac
- return 1
- }
- # __docker_complete_signals returns a subset of the available signals that is most likely
- # relevant in the context of docker containers
- __docker_complete_signals() {
- local signals=(
- SIGCONT
- SIGHUP
- SIGINT
- SIGKILL
- SIGQUIT
- SIGSTOP
- SIGTERM
- SIGUSR1
- SIGUSR2
- )
- COMPREPLY=( $( compgen -W "${signals[*]} ${signals[*]#SIG}" -- "$( echo $cur | tr '[:lower:]' '[:upper:]')" ) )
- }
- __docker_complete_user_group() {
- if [[ $cur == *:* ]] ; then
- COMPREPLY=( $(compgen -g -- "${cur#*:}") )
- else
- COMPREPLY=( $(compgen -u -S : -- "$cur") )
- __docker_nospace
- fi
- }
- _docker_docker() {
- # global options that may appear after the docker command
- local boolean_options="
- $global_boolean_options
- --help
- --version -v
- "
- case "$prev" in
- --config)
- _filedir -d
- return
- ;;
- --log-level|-l)
- __docker_complete_log_levels
- return
- ;;
- $(__docker_to_extglob "$global_options_with_args") )
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "$boolean_options $global_options_with_args" -- "$cur" ) )
- ;;
- *)
- local counter=$( __docker_pos_first_nonflag "$(__docker_to_extglob "$global_options_with_args")" )
- if [ $cword -eq $counter ]; then
- __docker_is_experimental && commands+=(${experimental_commands[*]})
- COMPREPLY=( $( compgen -W "${commands[*]} help" -- "$cur" ) )
- fi
- ;;
- esac
- }
- _docker_attach() {
- _docker_container_attach
- }
- _docker_build() {
- _docker_image_build
- }
- _docker_container() {
- local subcommands="
- attach
- commit
- cp
- create
- diff
- exec
- export
- inspect
- kill
- logs
- ls
- pause
- port
- prune
- rename
- restart
- rm
- run
- start
- stats
- stop
- top
- unpause
- update
- wait
- "
- local aliases="
- list
- ps
- "
- __docker_subcommands "$subcommands $aliases" && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
- ;;
- esac
- }
- _docker_container_attach() {
- __docker_complete_detach-keys && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--detach-keys --help --no-stdin --sig-proxy=false" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag '--detach-keys')
- if [ $cword -eq $counter ]; then
- __docker_complete_containers_running
- fi
- ;;
- esac
- }
- _docker_container_commit() {
- case "$prev" in
- --author|-a|--change|-c|--message|-m)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--author -a --change -c --help --message -m --pause=false -p=false" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag '--author|-a|--change|-c|--message|-m')
- if [ $cword -eq $counter ]; then
- __docker_complete_containers_all
- return
- fi
- (( counter++ ))
- if [ $cword -eq $counter ]; then
- __docker_complete_image_repos_and_tags
- return
- fi
- ;;
- esac
- }
- _docker_container_cp() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--follow-link -L --help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- case "$cur" in
- *:)
- return
- ;;
- *)
- # combined container and filename completion
- _filedir
- local files=( ${COMPREPLY[@]} )
- __docker_complete_containers_all
- COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) )
- local containers=( ${COMPREPLY[@]} )
- COMPREPLY=( $( compgen -W "${files[*]} ${containers[*]}" -- "$cur" ) )
- if [[ "$COMPREPLY" == *: ]]; then
- __docker_nospace
- fi
- return
- ;;
- esac
- fi
- (( counter++ ))
- if [ $cword -eq $counter ]; then
- if [ -e "$prev" ]; then
- __docker_complete_containers_all
- COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) )
- __docker_nospace
- else
- _filedir
- fi
- return
- fi
- ;;
- esac
- }
- _docker_container_create() {
- _docker_container_run
- }
- _docker_container_diff() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_containers_all
- fi
- ;;
- esac
- }
- _docker_container_exec() {
- __docker_complete_detach-keys && return
- case "$prev" in
- --env|-e)
- # we do not append a "=" here because "-e VARNAME" is legal systax, too
- COMPREPLY=( $( compgen -e -- "$cur" ) )
- __docker_nospace
- return
- ;;
- --user|-u)
- __docker_complete_user_group
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--detach -d --detach-keys --env -e --help --interactive -i --privileged -t --tty -u --user" -- "$cur" ) )
- ;;
- *)
- __docker_complete_containers_running
- ;;
- esac
- }
- _docker_container_export() {
- case "$prev" in
- --output|-o)
- _filedir
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --output -o" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_containers_all
- fi
- ;;
- esac
- }
- _docker_container_inspect() {
- _docker_inspect --type container
- }
- _docker_container_kill() {
- case "$prev" in
- --signal|-s)
- __docker_complete_signals
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --signal -s" -- "$cur" ) )
- ;;
- *)
- __docker_complete_containers_running
- ;;
- esac
- }
- _docker_container_logs() {
- case "$prev" in
- --since|--tail)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--details --follow -f --help --since --tail --timestamps -t" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag '--since|--tail')
- if [ $cword -eq $counter ]; then
- __docker_complete_containers_all
- fi
- ;;
- esac
- }
- _docker_container_list() {
- _docker_container_ls
- }
- _docker_container_ls() {
- local key=$(__docker_map_key_of_current_option '--filter|-f')
- case "$key" in
- ancestor)
- cur="${cur##*=}"
- __docker_complete_images
- return
- ;;
- before)
- __docker_complete_containers_all --cur "${cur##*=}"
- return
- ;;
- id)
- __docker_complete_containers_all --cur "${cur##*=}" --id
- return
- ;;
- health)
- COMPREPLY=( $( compgen -W "healthy starting none unhealthy" -- "${cur##*=}" ) )
- return
- ;;
- is-task)
- COMPREPLY=( $( compgen -W "true false" -- "${cur##*=}" ) )
- return
- ;;
- name)
- __docker_complete_containers_all --cur "${cur##*=}" --name
- return
- ;;
- network)
- __docker_complete_networks --cur "${cur##*=}"
- return
- ;;
- since)
- __docker_complete_containers_all --cur "${cur##*=}"
- return
- ;;
- status)
- COMPREPLY=( $( compgen -W "created dead exited paused restarting running removing" -- "${cur##*=}" ) )
- return
- ;;
- volume)
- __docker_complete_volumes --cur "${cur##*=}"
- return
- ;;
- esac
- case "$prev" in
- --filter|-f)
- COMPREPLY=( $( compgen -S = -W "ancestor before exited health id is-task label name network since status volume" -- "$cur" ) )
- __docker_nospace
- return
- ;;
- --format|--last|-n)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--all -a --filter -f --format --help --last -n --latest -l --no-trunc --quiet -q --size -s" -- "$cur" ) )
- ;;
- esac
- }
- _docker_container_pause() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_containers_running
- ;;
- esac
- }
- _docker_container_port() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_containers_all
- fi
- ;;
- esac
- }
- _docker_container_prune() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
- ;;
- esac
- }
- _docker_container_ps() {
- _docker_container_ls
- }
- _docker_container_rename() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_containers_all
- fi
- ;;
- esac
- }
- _docker_container_restart() {
- case "$prev" in
- --time|-t)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) )
- ;;
- *)
- __docker_complete_containers_all
- ;;
- esac
- }
- _docker_container_rm() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--force -f --help --link -l --volumes -v" -- "$cur" ) )
- ;;
- *)
- for arg in "${COMP_WORDS[@]}"; do
- case "$arg" in
- --force|-f)
- __docker_complete_containers_all
- return
- ;;
- esac
- done
- __docker_complete_containers_stopped
- ;;
- esac
- }
- _docker_container_run() {
- local options_with_args="
- --add-host
- --attach -a
- --blkio-weight
- --blkio-weight-device
- --cap-add
- --cap-drop
- --cgroup-parent
- --cidfile
- --cpu-period
- --cpu-quota
- --cpu-rt-period
- --cpu-rt-runtime
- --cpuset-cpus
- --cpus
- --cpuset-mems
- --cpu-shares -c
- --device
- --device-read-bps
- --device-read-iops
- --device-write-bps
- --device-write-iops
- --dns
- --dns-option
- --dns-search
- --entrypoint
- --env -e
- --env-file
- --expose
- --group-add
- --hostname -h
- --ip
- --ip6
- --ipc
- --isolation
- --kernel-memory
- --label-file
- --label -l
- --link
- --link-local-ip
- --log-driver
- --log-opt
- --mac-address
- --memory -m
- --memory-swap
- --memory-swappiness
- --memory-reservation
- --name
- --network
- --network-alias
- --oom-score-adj
- --pid
- --pids-limit
- --publish -p
- --restart
- --runtime
- --security-opt
- --shm-size
- --stop-signal
- --stop-timeout
- --storage-opt
- --tmpfs
- --sysctl
- --ulimit
- --user -u
- --userns
- --uts
- --volume-driver
- --volumes-from
- --volume -v
- --workdir -w
- "
- local boolean_options="
- --disable-content-trust=false
- --help
- --interactive -i
- --oom-kill-disable
- --privileged
- --publish-all -P
- --read-only
- --tty -t
- "
- if [ "$command" = "run" -o "$subcommand" = "run" ] ; then
- options_with_args="$options_with_args
- --detach-keys
- --health-cmd
- --health-interval
- --health-retries
- --health-timeout
- "
- boolean_options="$boolean_options
- --detach -d
- --no-healthcheck
- --rm
- --sig-proxy=false
- "
- __docker_complete_detach-keys && return
- fi
- local all_options="$options_with_args $boolean_options"
- __docker_complete_log_driver_options && return
- __docker_complete_restart && return
- local key=$(__docker_map_key_of_current_option '--security-opt')
- case "$key" in
- label)
- [[ $cur == *: ]] && return
- COMPREPLY=( $( compgen -W "user: role: type: level: disable" -- "${cur##*=}") )
- if [ "${COMPREPLY[*]}" != "disable" ] ; then
- __docker_nospace
- fi
- return
- ;;
- seccomp)
- local cur=${cur##*=}
- _filedir
- COMPREPLY+=( $( compgen -W "unconfined" -- "$cur" ) )
- return
- ;;
- esac
- case "$prev" in
- --add-host)
- case "$cur" in
- *:)
- __docker_complete_resolved_hostname
- return
- ;;
- esac
- ;;
- --attach|-a)
- COMPREPLY=( $( compgen -W 'stdin stdout stderr' -- "$cur" ) )
- return
- ;;
- --cap-add|--cap-drop)
- __docker_complete_capabilities
- return
- ;;
- --cidfile|--env-file|--label-file)
- _filedir
- return
- ;;
- --device|--tmpfs|--volume|-v)
- case "$cur" in
- *:*)
- # TODO somehow do _filedir for stuff inside the image, if it's already specified (which is also somewhat difficult to determine)
- ;;
- '')
- COMPREPLY=( $( compgen -W '/' -- "$cur" ) )
- __docker_nospace
- ;;
- /*)
- _filedir
- __docker_nospace
- ;;
- esac
- return
- ;;
- --env|-e)
- # we do not append a "=" here because "-e VARNAME" is legal systax, too
- COMPREPLY=( $( compgen -e -- "$cur" ) )
- __docker_nospace
- return
- ;;
- --ipc)
- case "$cur" in
- *:*)
- cur="${cur#*:}"
- __docker_complete_containers_running
- ;;
- *)
- COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) )
- if [ "$COMPREPLY" = "container:" ]; then
- __docker_nospace
- fi
- ;;
- esac
- return
- ;;
- --isolation)
- __docker_complete_isolation
- return
- ;;
- --link)
- case "$cur" in
- *:*)
- ;;
- *)
- __docker_complete_containers_running
- COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) )
- __docker_nospace
- ;;
- esac
- return
- ;;
- --log-driver)
- __docker_complete_log_drivers
- return
- ;;
- --log-opt)
- __docker_complete_log_options
- return
- ;;
- --network)
- case "$cur" in
- container:*)
- __docker_complete_containers_all --cur "${cur#*:}"
- ;;
- *)
- COMPREPLY=( $( compgen -W "$(__docker_plugins_bundled --type Network) $(__docker_networks) container:" -- "$cur") )
- if [ "${COMPREPLY[*]}" = "container:" ] ; then
- __docker_nospace
- fi
- ;;
- esac
- return
- ;;
- --pid)
- case "$cur" in
- *:*)
- __docker_complete_containers_running --cur "${cur#*:}"
- ;;
- *)
- COMPREPLY=( $( compgen -W 'host container:' -- "$cur" ) )
- if [ "$COMPREPLY" = "container:" ]; then
- __docker_nospace
- fi
- ;;
- esac
- return
- ;;
- --runtime)
- __docker_complete_runtimes
- return
- ;;
- --security-opt)
- COMPREPLY=( $( compgen -W "apparmor= label= no-new-privileges seccomp=" -- "$cur") )
- if [ "${COMPREPLY[*]}" != "no-new-privileges" ] ; then
- __docker_nospace
- fi
- return
- ;;
- --storage-opt)
- COMPREPLY=( $( compgen -W "size" -S = -- "$cur") )
- __docker_nospace
- return
- ;;
- --user|-u)
- __docker_complete_user_group
- return
- ;;
- --userns)
- COMPREPLY=( $( compgen -W "host" -- "$cur" ) )
- return
- ;;
- --volume-driver)
- __docker_complete_plugins_bundled --type Volume
- return
- ;;
- --volumes-from)
- __docker_complete_containers_all
- return
- ;;
- $(__docker_to_extglob "$options_with_args") )
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
- ;;
- *)
- local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
- if [ $cword -eq $counter ]; then
- __docker_complete_images
- fi
- ;;
- esac
- }
- _docker_container_start() {
- __docker_complete_detach-keys && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--attach -a --detach-keys --help --interactive -i" -- "$cur" ) )
- ;;
- *)
- __docker_complete_containers_stopped
- ;;
- esac
- }
- _docker_container_stats() {
- case "$prev" in
- --format)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--all -a --format --help --no-stream" -- "$cur" ) )
- ;;
- *)
- __docker_complete_containers_running
- ;;
- esac
- }
- _docker_container_stop() {
- case "$prev" in
- --time|-t)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --time -t" -- "$cur" ) )
- ;;
- *)
- __docker_complete_containers_running
- ;;
- esac
- }
- _docker_container_top() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_containers_running
- fi
- ;;
- esac
- }
- _docker_container_unpause() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_containers_unpauseable
- fi
- ;;
- esac
- }
- _docker_container_update() {
- local options_with_args="
- --blkio-weight
- --cpu-period
- --cpu-quota
- --cpu-rt-period
- --cpu-rt-runtime
- --cpuset-cpus
- --cpuset-mems
- --cpu-shares -c
- --kernel-memory
- --memory -m
- --memory-reservation
- --memory-swap
- --restart
- "
- local boolean_options="
- --help
- "
- local all_options="$options_with_args $boolean_options"
- __docker_complete_restart && return
- case "$prev" in
- $(__docker_to_extglob "$options_with_args") )
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
- ;;
- *)
- __docker_complete_containers_all
- ;;
- esac
- }
- _docker_container_wait() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_containers_all
- ;;
- esac
- }
- _docker_commit() {
- _docker_container_commit
- }
- _docker_cp() {
- _docker_container_cp
- }
- _docker_create() {
- _docker_container_run
- }
- _docker_daemon() {
- local boolean_options="
- $global_boolean_options
- --disable-legacy-registry
- --experimental
- --help
- --icc=false
- --ip-forward=false
- --ip-masq=false
- --iptables=false
- --ipv6
- --live-restore
- --raw-logs
- --selinux-enabled
- --userland-proxy=false
- "
- local options_with_args="
- $global_options_with_args
- --add-runtime
- --api-cors-header
- --authorization-plugin
- --bip
- --bridge -b
- --cgroup-parent
- --cluster-advertise
- --cluster-store
- --cluster-store-opt
- --config-file
- --containerd
- --default-gateway
- --default-gateway-v6
- --default-ulimit
- --dns
- --dns-search
- --dns-opt
- --exec-opt
- --exec-root
- --fixed-cidr
- --fixed-cidr-v6
- --graph -g
- --group -G
- --init-path
- --insecure-registry
- --ip
- --label
- --log-driver
- --log-opt
- --max-concurrent-downloads
- --max-concurrent-uploads
- --mtu
- --oom-score-adjust
- --pidfile -p
- --registry-mirror
- --seccomp-profile
- --shutdown-timeout
- --storage-driver -s
- --storage-opt
- --userland-proxy-path
- --userns-remap
- "
- __docker_complete_log_driver_options && return
- key=$(__docker_map_key_of_current_option '--cluster-store-opt')
- case "$key" in
- kv.*file)
- cur=${cur##*=}
- _filedir
- return
- ;;
- esac
- local key=$(__docker_map_key_of_current_option '--storage-opt')
- case "$key" in
- dm.blkdiscard|dm.override_udev_sync_check|dm.use_deferred_removal|dm.use_deferred_deletion)
- COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) )
- return
- ;;
- dm.fs)
- COMPREPLY=( $( compgen -W "ext4 xfs" -- "${cur##*=}" ) )
- return
- ;;
- dm.thinpooldev)
- cur=${cur##*=}
- _filedir
- return
- ;;
- esac
- case "$prev" in
- --authorization-plugin)
- __docker_complete_plugins_bundled --type Authorization
- return
- ;;
- --cluster-store)
- COMPREPLY=( $( compgen -W "consul etcd zk" -S "://" -- "$cur" ) )
- __docker_nospace
- return
- ;;
- --cluster-store-opt)
- COMPREPLY=( $( compgen -W "discovery.heartbeat discovery.ttl kv.cacertfile kv.certfile kv.keyfile kv.path" -S = -- "$cur" ) )
- __docker_nospace
- return
- ;;
- --config-file|--containerd|--init-path|--pidfile|-p|--tlscacert|--tlscert|--tlskey|--userland-proxy-path)
- _filedir
- return
- ;;
- --exec-root|--graph|-g)
- _filedir -d
- return
- ;;
- --log-driver)
- __docker_complete_log_drivers
- return
- ;;
- --storage-driver|-s)
- COMPREPLY=( $( compgen -W "aufs btrfs devicemapper overlay overlay2 vfs zfs" -- "$(echo $cur | tr '[:upper:]' '[:lower:]')" ) )
- return
- ;;
- --storage-opt)
- local btrfs_options="btrfs.min_space"
- local devicemapper_options="
- dm.basesize
- dm.blkdiscard
- dm.blocksize
- dm.fs
- dm.loopdatasize
- dm.loopmetadatasize
- dm.min_free_space
- dm.mkfsarg
- dm.mountopt
- dm.override_udev_sync_check
- dm.thinpooldev
- dm.use_deferred_deletion
- dm.use_deferred_removal
- "
- local zfs_options="zfs.fsname"
- case $(__docker_value_of_option '--storage-driver|-s') in
- '')
- COMPREPLY=( $( compgen -W "$btrfs_options $devicemapper_options $zfs_options" -S = -- "$cur" ) )
- ;;
- btrfs)
- COMPREPLY=( $( compgen -W "$btrfs_options" -S = -- "$cur" ) )
- ;;
- devicemapper)
- COMPREPLY=( $( compgen -W "$devicemapper_options" -S = -- "$cur" ) )
- ;;
- zfs)
- COMPREPLY=( $( compgen -W "$zfs_options" -S = -- "$cur" ) )
- ;;
- *)
- return
- ;;
- esac
- __docker_nospace
- return
- ;;
- --log-level|-l)
- __docker_complete_log_levels
- return
- ;;
- --log-opt)
- __docker_complete_log_options
- return
- ;;
- --seccomp-profile)
- _filedir json
- return
- ;;
- --userns-remap)
- __docker_complete_user_group
- return
- ;;
- $(__docker_to_extglob "$options_with_args") )
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
- ;;
- esac
- }
- _docker_deploy() {
- __docker_is_experimental && _docker_stack_deploy
- }
- _docker_diff() {
- _docker_container_diff
- }
- _docker_events() {
- _docker_system_events
- }
- _docker_exec() {
- _docker_container_exec
- }
- _docker_export() {
- _docker_container_export
- }
- _docker_help() {
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- COMPREPLY=( $( compgen -W "${commands[*]}" -- "$cur" ) )
- fi
- }
- _docker_history() {
- _docker_image_history
- }
- _docker_image() {
- local subcommands="
- build
- history
- import
- inspect
- load
- ls
- prune
- pull
- push
- rm
- save
- tag
- "
- local aliases="
- images
- list
- remove
- rmi
- "
- __docker_subcommands "$subcommands $aliases" && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
- ;;
- esac
- }
- _docker_image_build() {
- local options_with_args="
- --build-arg
- --cache-from
- --cgroup-parent
- --cpuset-cpus
- --cpuset-mems
- --cpu-shares -c
- --cpu-period
- --cpu-quota
- --file -f
- --isolation
- --label
- --memory -m
- --memory-swap
- --network
- --shm-size
- --tag -t
- --ulimit
- "
- local boolean_options="
- --compress
- --disable-content-trust=false
- --force-rm
- --help
- --no-cache
- --pull
- --quiet -q
- --rm
- "
- local all_options="$options_with_args $boolean_options"
- case "$prev" in
- --build-arg)
- COMPREPLY=( $( compgen -e -- "$cur" ) )
- __docker_nospace
- return
- ;;
- --cache-from)
- __docker_complete_image_repos_and_tags
- return
- ;;
- --file|-f)
- _filedir
- return
- ;;
- --isolation)
- __docker_complete_isolation
- return
- ;;
- --network)
- case "$cur" in
- container:*)
- __docker_complete_containers_all --cur "${cur#*:}"
- ;;
- *)
- COMPREPLY=( $( compgen -W "$(__docker_plugins --type Network) $(__docker_networks) container:" -- "$cur") )
- if [ "${COMPREPLY[*]}" = "container:" ] ; then
- __docker_nospace
- fi
- ;;
- esac
- return
- ;;
- --tag|-t)
- __docker_complete_image_repos_and_tags
- return
- ;;
- $(__docker_to_extglob "$options_with_args") )
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "$all_options" -- "$cur" ) )
- ;;
- *)
- local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
- if [ $cword -eq $counter ]; then
- _filedir -d
- fi
- ;;
- esac
- }
- _docker_image_history() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --human=false -H=false --no-trunc --quiet -q" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_images
- fi
- ;;
- esac
- }
- _docker_image_images() {
- _docker_image_ls
- }
- _docker_image_import() {
- case "$prev" in
- --change|-c|--message|-m)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--change -c --help --message -m" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag '--change|-c|--message|-m')
- if [ $cword -eq $counter ]; then
- return
- fi
- (( counter++ ))
- if [ $cword -eq $counter ]; then
- __docker_complete_image_repos_and_tags
- return
- fi
- ;;
- esac
- }
- _docker_image_inspect() {
- _docker_inspect --type image
- }
- _docker_image_load() {
- case "$prev" in
- --input|-i)
- _filedir
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --input -i --quiet -q" -- "$cur" ) )
- ;;
- esac
- }
- _docker_image_list() {
- _docker_image_ls
- }
- _docker_image_ls() {
- local key=$(__docker_map_key_of_current_option '--filter|-f')
- case "$key" in
- before|since|reference)
- cur="${cur##*=}"
- __docker_complete_images
- return
- ;;
- dangling)
- COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) )
- return
- ;;
- label)
- return
- ;;
- esac
- case "$prev" in
- --filter|-f)
- COMPREPLY=( $( compgen -S = -W "before dangling label reference since" -- "$cur" ) )
- __docker_nospace
- return
- ;;
- --format)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--all -a --digests --filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) )
- ;;
- =)
- return
- ;;
- *)
- __docker_complete_image_repos
- ;;
- esac
- }
- _docker_image_prune() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--all -a --force -f --help" -- "$cur" ) )
- ;;
- esac
- }
- _docker_image_pull() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--all-tags -a --disable-content-trust=false --help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- for arg in "${COMP_WORDS[@]}"; do
- case "$arg" in
- --all-tags|-a)
- __docker_complete_image_repos
- return
- ;;
- esac
- done
- __docker_complete_image_repos_and_tags
- fi
- ;;
- esac
- }
- _docker_image_push() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--disable-content-trust=false --help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_image_repos_and_tags
- fi
- ;;
- esac
- }
- _docker_image_remove() {
- _docker_image_rm
- }
- _docker_image_rm() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--force -f --help --no-prune" -- "$cur" ) )
- ;;
- *)
- __docker_complete_images
- ;;
- esac
- }
- _docker_image_rmi() {
- _docker_image_rm
- }
- _docker_image_save() {
- case "$prev" in
- --output|-o)
- _filedir
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --output -o" -- "$cur" ) )
- ;;
- *)
- __docker_complete_images
- ;;
- esac
- }
- _docker_image_tag() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_image_repos_and_tags
- return
- fi
- (( counter++ ))
- if [ $cword -eq $counter ]; then
- __docker_complete_image_repos_and_tags
- return
- fi
- ;;
- esac
- }
- _docker_images() {
- _docker_image_ls
- }
- _docker_import() {
- _docker_image_import
- }
- _docker_info() {
- _docker_system_info
- }
- _docker_inspect() {
- local preselected_type
- local type
- if [ "$1" = "--type" ] ; then
- preselected_type=yes
- type="$2"
- else
- type=$(__docker_value_of_option --type)
- fi
- case "$prev" in
- --format|-f)
- return
- ;;
- --type)
- if [ -z "$preselected_type" ] ; then
- COMPREPLY=( $( compgen -W "container image network node plugin service volume" -- "$cur" ) )
- return
- fi
- ;;
- esac
- case "$cur" in
- -*)
- local options="--format -f --help --size -s"
- if [ -z "$preselected_type" ] ; then
- options+=" --type"
- fi
- COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
- ;;
- *)
- case "$type" in
- '')
- COMPREPLY=( $( compgen -W "
- $(__docker_containers --all)
- $(__docker_images)
- $(__docker_networks)
- $(__docker_nodes)
- $(__docker_plugins_installed)
- $(__docker_services)
- $(__docker_volumes)
- " -- "$cur" ) )
- ;;
- container)
- __docker_complete_containers_all
- ;;
- image)
- __docker_complete_images
- ;;
- network)
- __docker_complete_networks
- ;;
- node)
- __docker_complete_nodes
- ;;
- plugin)
- __docker_complete_plugins_installed
- ;;
- service)
- __docker_complete_services
- ;;
- volume)
- __docker_complete_volumes
- ;;
- esac
- esac
- }
- _docker_kill() {
- _docker_container_kill
- }
- _docker_load() {
- _docker_image_load
- }
- _docker_login() {
- case "$prev" in
- --password|-p|--username|-u)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --password -p --username -u" -- "$cur" ) )
- ;;
- esac
- }
- _docker_logout() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- esac
- }
- _docker_logs() {
- _docker_container_logs
- }
- _docker_network_connect() {
- local options_with_args="
- --alias
- --ip
- --ip6
- --link
- --link-local-ip
- "
- local boolean_options="
- --help
- "
- case "$prev" in
- --link)
- case "$cur" in
- *:*)
- ;;
- *)
- __docker_complete_containers_running
- COMPREPLY=( $( compgen -W "${COMPREPLY[*]}" -S ':' ) )
- __docker_nospace
- ;;
- esac
- return
- ;;
- $(__docker_to_extglob "$options_with_args") )
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
- ;;
- *)
- local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
- if [ $cword -eq $counter ]; then
- __docker_complete_networks
- elif [ $cword -eq $(($counter + 1)) ]; then
- __docker_complete_containers_all
- fi
- ;;
- esac
- }
- _docker_network_create() {
- case "$prev" in
- --aux-address|--gateway|--internal|--ip-range|--ipam-opt|--ipv6|--opt|-o|--subnet)
- return
- ;;
- --ipam-driver)
- COMPREPLY=( $( compgen -W "default" -- "$cur" ) )
- return
- ;;
- --driver|-d)
- # remove drivers that allow one instance only, add drivers missing in `docker info`
- __docker_complete_plugins_bundled --type Network --remove host --remove null --add macvlan
- return
- ;;
- --label)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--attachable --aux-address --driver -d --gateway --help --internal --ip-range --ipam-driver --ipam-opt --ipv6 --label --opt -o --subnet" -- "$cur" ) )
- ;;
- esac
- }
- _docker_network_disconnect() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_networks
- elif [ $cword -eq $(($counter + 1)) ]; then
- __docker_complete_containers_in_network "$prev"
- fi
- ;;
- esac
- }
- _docker_network_inspect() {
- case "$prev" in
- --format|-f)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_networks
- esac
- }
- _docker_network_ls() {
- local key=$(__docker_map_key_of_current_option '--filter|-f')
- case "$key" in
- driver)
- __docker_complete_plugins_bundled --cur "${cur##*=}" --type Network --add macvlan
- return
- ;;
- id)
- __docker_complete_networks --cur "${cur##*=}" --id
- return
- ;;
- name)
- __docker_complete_networks --cur "${cur##*=}" --name
- return
- ;;
- type)
- COMPREPLY=( $( compgen -W "builtin custom" -- "${cur##*=}" ) )
- return
- ;;
- esac
- case "$prev" in
- --filter|-f)
- COMPREPLY=( $( compgen -S = -W "driver id label name type" -- "$cur" ) )
- __docker_nospace
- return
- ;;
- --format)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--filter -f --format --help --no-trunc --quiet -q" -- "$cur" ) )
- ;;
- esac
- }
- _docker_network_prune() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
- ;;
- esac
- }
- _docker_network_rm() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_networks --filter type=custom
- esac
- }
- _docker_network() {
- local subcommands="
- connect
- create
- disconnect
- inspect
- ls
- prune
- rm
- "
- __docker_subcommands "$subcommands" && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
- ;;
- esac
- }
- _docker_service() {
- local subcommands="
- create
- inspect
- ls list
- rm remove
- scale
- ps
- update
- "
- __docker_subcommands "$subcommands" && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
- ;;
- esac
- }
- _docker_service_create() {
- _docker_service_update
- }
- _docker_service_inspect() {
- case "$prev" in
- --format|-f)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--format -f --help --pretty" -- "$cur" ) )
- ;;
- *)
- __docker_complete_services
- esac
- }
- _docker_service_list() {
- _docker_service_ls
- }
- _docker_service_ls() {
- local key=$(__docker_map_key_of_current_option '--filter|-f')
- case "$key" in
- id)
- __docker_complete_services --cur "${cur##*=}" --id
- return
- ;;
- name)
- __docker_complete_services --cur "${cur##*=}" --name
- return
- ;;
- esac
- case "$prev" in
- --filter|-f)
- COMPREPLY=( $( compgen -W "id label name" -S = -- "$cur" ) )
- __docker_nospace
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--filter -f --help --quiet -q" -- "$cur" ) )
- ;;
- esac
- }
- _docker_service_remove() {
- _docker_service_rm
- }
- _docker_service_rm() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_services
- esac
- }
- _docker_service_scale() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_services
- __docker_append_to_completions "="
- __docker_nospace
- ;;
- esac
- }
- _docker_service_ps() {
- local key=$(__docker_map_key_of_current_option '--filter|-f')
- case "$key" in
- desired-state)
- COMPREPLY=( $( compgen -W "accepted running" -- "${cur##*=}" ) )
- return
- ;;
- name)
- __docker_complete_services --cur "${cur##*=}" --name
- return
- ;;
- esac
- case "$prev" in
- --filter|-f)
- COMPREPLY=( $( compgen -W "desired-state id name" -S = -- "$cur" ) )
- __docker_nospace
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--filter -f --help --no-resolve --no-trunc --quiet -q" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag '--filter|-f')
- if [ $cword -eq $counter ]; then
- __docker_complete_services
- fi
- ;;
- esac
- }
- _docker_service_update() {
- local $subcommand="${words[$subcommand_pos]}"
- local options_with_args="
- --constraint
- --endpoint-mode
- --env -e
- --force
- --health-cmd
- --health-interval
- --health-retries
- --health-timeout
- --hostname
- --label -l
- --limit-cpu
- --limit-memory
- --log-driver
- --log-opt
- --mount
- --network
- --no-healthcheck
- --publish -p
- --replicas
- --reserve-cpu
- --reserve-memory
- --restart-condition
- --restart-delay
- --restart-max-attempts
- --restart-window
- --rollback
- --stop-grace-period
- --update-delay
- --update-failure-action
- --update-max-failure-ratio
- --update-monitor
- --update-parallelism
- --user -u
- --workdir -w
- "
- local boolean_options="
- --help
- --tty -t
- --with-registry-auth
- "
- __docker_complete_log_driver_options && return
- if [ "$subcommand" = "create" ] ; then
- options_with_args="$options_with_args
- --container-label
- --dns
- --dns-option
- --dns-search
- --env-file
- --group
- --host
- --mode
- --name
- --publish
- --secret
- "
- case "$prev" in
- --env-file)
- _filedir
- return
- ;;
- --host)
- case "$cur" in
- *:)
- __docker_complete_resolved_hostname
- return
- ;;
- esac
- ;;
- --mode)
- COMPREPLY=( $( compgen -W "global replicated" -- "$cur" ) )
- return
- ;;
- --secret)
- __docker_complete_secrets
- return
- ;;
- --group)
- COMPREPLY=( $(compgen -g -- "$cur") )
- return
- ;;
- esac
- fi
- if [ "$subcommand" = "update" ] ; then
- options_with_args="$options_with_args
- --arg
- --container-label-add
- --container-label-rm
- --dns-add
- --dns-option-add
- --dns-option-rm
- --dns-rm
- --dns-search-add
- --dns-search-rm
- --group-add
- --group-rm
- --host-add
- --host-rm
- --image
- --publish-add
- --publish-rm
- --secret-add
- --secret-rm
- "
- case "$prev" in
- --group-add)
- COMPREPLY=( $(compgen -g -- "$cur") )
- return
- ;;
- --group-rm)
- COMPREPLY=( $(compgen -g -- "$cur") )
- return
- ;;
- --host-add|--host-rm)
- case "$cur" in
- *:)
- __docker_complete_resolved_hostname
- return
- ;;
- esac
- ;;
- --image)
- __docker_complete_image_repos_and_tags
- return
- ;;
- --secret-add|--secret-rm)
- __docker_complete_secrets
- return
- ;;
- esac
- fi
- case "$prev" in
- --endpoint-mode)
- COMPREPLY=( $( compgen -W "dnsrr vip" -- "$cur" ) )
- return
- ;;
- --env|-e)
- # we do not append a "=" here because "-e VARNAME" is legal systax, too
- COMPREPLY=( $( compgen -e -- "$cur" ) )
- __docker_nospace
- return
- ;;
- --log-driver)
- __docker_complete_log_drivers
- return
- ;;
- --log-opt)
- __docker_complete_log_options
- return
- ;;
- --network)
- __docker_complete_networks
- return
- ;;
- --restart-condition)
- COMPREPLY=( $( compgen -W "any none on-failure" -- "$cur" ) )
- return
- ;;
- --user|-u)
- __docker_complete_user_group
- return
- ;;
- $(__docker_to_extglob "$options_with_args") )
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "$boolean_options $options_with_args" -- "$cur" ) )
- ;;
- *)
- local counter=$( __docker_pos_first_nonflag $( __docker_to_alternatives "$options_with_args" ) )
- if [ "$subcommand" = "update" ] ; then
- if [ $cword -eq $counter ]; then
- __docker_complete_services
- fi
- else
- if [ $cword -eq $counter ]; then
- __docker_complete_images
- fi
- fi
- ;;
- esac
- }
- _docker_swarm() {
- local subcommands="
- init
- join
- join-token
- leave
- update
- "
- __docker_subcommands "$subcommands" && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
- ;;
- esac
- }
- _docker_swarm_init() {
- case "$prev" in
- --advertise-addr)
- if [[ $cur == *: ]] ; then
- COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
- else
- __docker_complete_local_interfaces
- __docker_nospace
- fi
- return
- ;;
- --listen-addr)
- if [[ $cur == *: ]] ; then
- COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
- else
- __docker_complete_local_interfaces --add 0.0.0.0
- __docker_nospace
- fi
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--advertise-addr --force-new-cluster --help --listen-addr" -- "$cur" ) )
- ;;
- esac
- }
- _docker_swarm_join() {
- case "$prev" in
- --advertise-addr)
- if [[ $cur == *: ]] ; then
- COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
- else
- __docker_complete_local_interfaces
- __docker_nospace
- fi
- return
- ;;
- --listen-addr)
- if [[ $cur == *: ]] ; then
- COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
- else
- __docker_complete_local_interfaces --add 0.0.0.0
- __docker_nospace
- fi
- return
- ;;
- --token)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--advertise-addr --help --listen-addr --token" -- "$cur" ) )
- ;;
- *:)
- COMPREPLY=( $( compgen -W "2377" -- "${cur##*:}" ) )
- ;;
- esac
- }
- _docker_swarm_join-token() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --quiet -q --rotate" -- "$cur" ) )
- ;;
- *)
- local counter=$( __docker_pos_first_nonflag )
- if [ $cword -eq $counter ]; then
- COMPREPLY=( $( compgen -W "manager worker" -- "$cur" ) )
- fi
- ;;
- esac
- }
- _docker_swarm_leave() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
- ;;
- esac
- }
- _docker_swarm_update() {
- case "$prev" in
- --cert-expiry|--dispatcher-heartbeat|--max-snapshots|--snapshot-interval|--task-history-limit)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--cert-expiry --dispatcher-heartbeat --help --max-snapshots --snapshot-interval --task-history-limit" -- "$cur" ) )
- ;;
- esac
- }
- _docker_node() {
- local subcommands="
- demote
- inspect
- ls list
- promote
- rm remove
- ps
- update
- "
- __docker_subcommands "$subcommands" && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
- ;;
- esac
- }
- _docker_node_demote() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_nodes --filter role=manager
- esac
- }
- _docker_node_inspect() {
- case "$prev" in
- --format|-f)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--format -f --help --pretty" -- "$cur" ) )
- ;;
- *)
- __docker_complete_nodes_plus_self
- esac
- }
- _docker_node_list() {
- _docker_node_ls
- }
- _docker_node_ls() {
- local key=$(__docker_map_key_of_current_option '--filter|-f')
- case "$key" in
- id)
- __docker_complete_nodes --cur "${cur##*=}" --id
- return
- ;;
- name)
- __docker_complete_nodes --cur "${cur##*=}" --name
- return
- ;;
- esac
- case "$prev" in
- --filter|-f)
- COMPREPLY=( $( compgen -W "id label name" -S = -- "$cur" ) )
- __docker_nospace
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--filter -f --help --quiet -q" -- "$cur" ) )
- ;;
- esac
- }
- _docker_node_promote() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_nodes --filter role=worker
- esac
- }
- _docker_node_remove() {
- _docker_node_rm
- }
- _docker_node_rm() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_nodes
- esac
- }
- _docker_node_ps() {
- local key=$(__docker_map_key_of_current_option '--filter|-f')
- case "$key" in
- desired-state)
- COMPREPLY=( $( compgen -W "accepted running" -- "${cur##*=}" ) )
- return
- ;;
- name)
- __docker_complete_services --cur "${cur##*=}" --name
- return
- ;;
- esac
- case "$prev" in
- --filter|-f)
- COMPREPLY=( $( compgen -W "desired-state id label name" -S = -- "$cur" ) )
- __docker_nospace
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--filter -f --help --no-resolve --no-trunc" -- "$cur" ) )
- ;;
- *)
- __docker_complete_nodes_plus_self
- ;;
- esac
- }
- _docker_node_update() {
- case "$prev" in
- --availability)
- COMPREPLY=( $( compgen -W "active drain pause" -- "$cur" ) )
- return
- ;;
- --role)
- COMPREPLY=( $( compgen -W "manager worker" -- "$cur" ) )
- return
- ;;
- --label-add|--label-rm)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--availability --help --label-add --label-rm --role" -- "$cur" ) )
- ;;
- *)
- __docker_complete_nodes
- esac
- }
- _docker_pause() {
- _docker_container_pause
- }
- _docker_plugin() {
- local subcommands="
- create
- disable
- enable
- inspect
- install
- ls
- push
- rm
- set
- "
- local aliases="
- list
- remove
- "
- __docker_subcommands "$subcommands $aliases" && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
- ;;
- esac
- }
- _docker_plugin_create() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--compress --help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- # reponame
- return
- elif [ $cword -eq $((counter + 1)) ]; then
- _filedir -d
- fi
- ;;
- esac
- }
- _docker_plugin_disable() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_plugins_installed
- ;;
- esac
- }
- _docker_plugin_enable() {
- case "$prev" in
- --timeout)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --timeout" -- "$cur" ) )
- ;;
- *)
- __docker_complete_plugins_installed
- ;;
- esac
- }
- _docker_plugin_inspect() {
- case "$prev" in
- --format|f)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_plugins_installed
- ;;
- esac
- }
- _docker_plugin_install() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--disable --grant-all-permissions--help" -- "$cur" ) )
- ;;
- esac
- }
- _docker_plugin_list() {
- _docker_plugin_ls
- }
- _docker_plugin_ls() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --no-trunc" -- "$cur" ) )
- ;;
- esac
- }
- _docker_plugin_push() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_plugins_installed
- fi
- ;;
- esac
- }
- _docker_plugin_remove() {
- _docker_plugin_rm
- }
- _docker_plugin_rm() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_plugins_installed
- ;;
- esac
- }
- _docker_plugin_set() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_plugins_installed
- fi
- ;;
- esac
- }
- _docker_port() {
- _docker_container_port
- }
- _docker_ps() {
- _docker_container_ls
- }
- _docker_pull() {
- _docker_image_pull
- }
- _docker_push() {
- _docker_image_push
- }
- _docker_rename() {
- _docker_container_rename
- }
- _docker_restart() {
- _docker_container_restart
- }
- _docker_rm() {
- _docker_container_rm
- }
- _docker_rmi() {
- _docker_image_rm
- }
- _docker_run() {
- _docker_container_run
- }
- _docker_save() {
- _docker_image_save
- }
- _docker_secret() {
- local subcommands="
- create
- inspect
- ls
- rm
- "
- local aliases="
- list
- remove
- "
- __docker_subcommands "$subcommands $aliases" && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
- ;;
- esac
- }
- _docker_secret_create() {
- case "$prev" in
- --label|-l)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --label -l" -- "$cur" ) )
- ;;
- esac
- }
- _docker_secret_inspect() {
- case "$prev" in
- --format|-f)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_secrets
- ;;
- esac
- }
- _docker_secret_list() {
- _docker_secret_ls
- }
- _docker_secret_ls() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --quiet -q" -- "$cur" ) )
- ;;
- esac
- }
- _docker_secret_remove() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_secrets
- ;;
- esac
- }
- _docker_secret_rm() {
- _docker_secret_remove
- }
- _docker_search() {
- local key=$(__docker_map_key_of_current_option '--filter|-f')
- case "$key" in
- is-automated)
- COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) )
- return
- ;;
- is-official)
- COMPREPLY=( $( compgen -W "false true" -- "${cur##*=}" ) )
- return
- ;;
- esac
- case "$prev" in
- --filter|-f)
- COMPREPLY=( $( compgen -S = -W "is-automated is-official stars" -- "$cur" ) )
- __docker_nospace
- return
- ;;
- --limit)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--filter --help --limit --no-trunc" -- "$cur" ) )
- ;;
- esac
- }
- _docker_stack() {
- local subcommands="
- deploy
- ls
- ps
- rm
- services
- "
- local aliases="
- down
- list
- remove
- up
- "
- __docker_subcommands "$subcommands $aliases" && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
- ;;
- esac
- }
- _docker_stack_deploy() {
- case "$prev" in
- --bundle-file)
- if __docker_is_experimental ; then
- _filedir dab
- return
- fi
- ;;
- --compose-file|-c)
- _filedir yml
- return
- ;;
- esac
- case "$cur" in
- -*)
- local options="--compose-file -c --help --with-registry-auth"
- __docker_is_experimental && options+=" --bundle-file"
- COMPREPLY=( $( compgen -W "$options" -- "$cur" ) )
- ;;
- esac
- }
- _docker_stack_down() {
- _docker_stack_rm
- }
- _docker_stack_list() {
- _docker_stack_ls
- }
- _docker_stack_ls() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- esac
- }
- _docker_stack_ps() {
- local key=$(__docker_map_key_of_current_option '--filter|-f')
- case "$key" in
- desired-state)
- COMPREPLY=( $( compgen -W "accepted running" -- "${cur##*=}" ) )
- return
- ;;
- id)
- __docker_complete_stacks --cur "${cur##*=}" --id
- return
- ;;
- name)
- __docker_complete_stacks --cur "${cur##*=}" --name
- return
- ;;
- esac
- case "$prev" in
- --filter|-f)
- COMPREPLY=( $( compgen -S = -W "id name desired-state" -- "$cur" ) )
- __docker_nospace
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--all -a --filter -f --help --no-resolve --no-trunc" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag '--filter|-f')
- if [ $cword -eq $counter ]; then
- __docker_complete_stacks
- fi
- ;;
- esac
- }
- _docker_stack_remove() {
- _docker_stack_rm
- }
- _docker_stack_rm() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag)
- if [ $cword -eq $counter ]; then
- __docker_complete_stacks
- fi
- ;;
- esac
- }
- _docker_stack_services() {
- local key=$(__docker_map_key_of_current_option '--filter|-f')
- case "$key" in
- id)
- __docker_complete_services --cur "${cur##*=}" --id
- return
- ;;
- label)
- return
- ;;
- name)
- __docker_complete_services --cur "${cur##*=}" --name
- return
- ;;
- esac
- case "$prev" in
- --filter|-f)
- COMPREPLY=( $( compgen -S = -W "id label name" -- "$cur" ) )
- __docker_nospace
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--filter -f --help --quiet -q" -- "$cur" ) )
- ;;
- *)
- local counter=$(__docker_pos_first_nonflag '--filter|-f')
- if [ $cword -eq $counter ]; then
- __docker_complete_stacks
- fi
- ;;
- esac
- }
- _docker_stack_up() {
- _docker_stack_deploy
- }
- _docker_start() {
- _docker_container_start
- }
- _docker_stats() {
- _docker_container_stats
- }
- _docker_stop() {
- _docker_container_stop
- }
- _docker_system() {
- local subcommands="
- df
- events
- info
- prune
- "
- __docker_subcommands "$subcommands $aliases" && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
- ;;
- esac
- }
- _docker_system_df() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help --verbose -v" -- "$cur" ) )
- ;;
- esac
- }
- _docker_system_events() {
- local key=$(__docker_map_key_of_current_option '-f|--filter')
- case "$key" in
- container)
- __docker_complete_containers_all --cur "${cur##*=}"
- return
- ;;
- daemon)
- local name=$(__docker_q info | sed -n 's/^\(ID\|Name\): //p')
- COMPREPLY=( $( compgen -W "$name" -- "${cur##*=}" ) )
- return
- ;;
- event)
- COMPREPLY=( $( compgen -W "
- attach
- commit
- connect
- copy
- create
- delete
- destroy
- detach
- die
- disconnect
- exec_create
- exec_detach
- exec_start
- export
- health_status
- import
- kill
- load
- mount
- oom
- pause
- pull
- push
- reload
- rename
- resize
- restart
- save
- start
- stop
- tag
- top
- unmount
- unpause
- untag
- update
- " -- "${cur##*=}" ) )
- return
- ;;
- image)
- cur="${cur##*=}"
- __docker_complete_images
- return
- ;;
- network)
- __docker_complete_networks --cur "${cur##*=}"
- return
- ;;
- type)
- COMPREPLY=( $( compgen -W "container daemon image network volume" -- "${cur##*=}" ) )
- return
- ;;
- volume)
- __docker_complete_volumes --cur "${cur##*=}"
- return
- ;;
- esac
- case "$prev" in
- --filter|-f)
- COMPREPLY=( $( compgen -S = -W "container daemon event image label network type volume" -- "$cur" ) )
- __docker_nospace
- return
- ;;
- --since|--until)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--filter -f --help --since --until --format" -- "$cur" ) )
- ;;
- esac
- }
- _docker_system_info() {
- case "$prev" in
- --format|-f)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
- ;;
- esac
- }
- _docker_system_prune() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--all -a --force -f --help" -- "$cur" ) )
- ;;
- esac
- }
- _docker_tag() {
- _docker_image_tag
- }
- _docker_unpause() {
- _docker_container_unpause
- }
- _docker_update() {
- _docker_container_update
- }
- _docker_top() {
- _docker_container_top
- }
- _docker_version() {
- case "$prev" in
- --format|-f)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
- ;;
- esac
- }
- _docker_volume_create() {
- case "$prev" in
- --driver|-d)
- __docker_complete_plugins_bundled --type Volume
- return
- ;;
- --label|--opt|-o)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--driver -d --help --label --opt -o" -- "$cur" ) )
- ;;
- esac
- }
- _docker_volume_inspect() {
- case "$prev" in
- --format|-f)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--format -f --help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_volumes
- ;;
- esac
- }
- _docker_volume_ls() {
- local key=$(__docker_map_key_of_current_option '--filter|-f')
- case "$key" in
- dangling)
- COMPREPLY=( $( compgen -W "true false" -- "${cur##*=}" ) )
- return
- ;;
- driver)
- __docker_complete_plugins_bundled --cur "${cur##*=}" --type Volume
- return
- ;;
- name)
- __docker_complete_volumes --cur "${cur##*=}"
- return
- ;;
- esac
- case "$prev" in
- --filter|-f)
- COMPREPLY=( $( compgen -S = -W "dangling driver label name" -- "$cur" ) )
- __docker_nospace
- return
- ;;
- --format)
- return
- ;;
- esac
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--filter -f --format --help --quiet -q" -- "$cur" ) )
- ;;
- esac
- }
- _docker_volume_prune() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
- ;;
- esac
- }
- _docker_volume_rm() {
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--force -f --help" -- "$cur" ) )
- ;;
- *)
- __docker_complete_volumes
- ;;
- esac
- }
- _docker_volume() {
- local subcommands="
- create
- inspect
- ls
- prune
- rm
- "
- __docker_subcommands "$subcommands" && return
- case "$cur" in
- -*)
- COMPREPLY=( $( compgen -W "--help" -- "$cur" ) )
- ;;
- *)
- COMPREPLY=( $( compgen -W "$subcommands" -- "$cur" ) )
- ;;
- esac
- }
- _docker_wait() {
- _docker_container_wait
- }
- _docker() {
- local previous_extglob_setting=$(shopt -p extglob)
- shopt -s extglob
- local commands=(
- attach
- build
- commit
- container
- cp
- create
- daemon
- diff
- events
- exec
- export
- history
- image
- images
- import
- info
- inspect
- kill
- load
- login
- logout
- logs
- network
- node
- pause
- plugin
- port
- ps
- pull
- push
- rename
- restart
- rm
- rmi
- run
- save
- search
- secret
- service
- stack
- start
- stats
- stop
- swarm
- system
- tag
- top
- unpause
- update
- version
- volume
- wait
- )
- local experimental_commands=(
- deploy
- )
- # These options are valid as global options for all client commands
- # and valid as command options for `docker daemon`
- local global_boolean_options="
- --debug -D
- --tls
- --tlsverify
- "
- local global_options_with_args="
- --config
- --host -H
- --log-level -l
- --tlscacert
- --tlscert
- --tlskey
- "
- local host config
- COMPREPLY=()
- local cur prev words cword
- _get_comp_words_by_ref -n : cur prev words cword
- local command='docker' command_pos=0 subcommand_pos
- local counter=1
- while [ $counter -lt $cword ]; do
- case "${words[$counter]}" in
- # save host so that completion can use custom daemon
- --host|-H)
- (( counter++ ))
- host="${words[$counter]}"
- ;;
- # save config so that completion can use custom configuration directories
- --config)
- (( counter++ ))
- config="${words[$counter]}"
- ;;
- $(__docker_to_extglob "$global_options_with_args") )
- (( counter++ ))
- ;;
- -*)
- ;;
- =)
- (( counter++ ))
- ;;
- *)
- command="${words[$counter]}"
- command_pos=$counter
- break
- ;;
- esac
- (( counter++ ))
- done
- local binary="${words[0]}"
- if [[ $binary == ?(*/)dockerd ]] ; then
- # for the dockerd binary, we reuse completion of `docker daemon`.
- # dockerd does not have subcommands and global options.
- command=daemon
- command_pos=0
- fi
- local completions_func=_docker_${command}
- declare -F $completions_func >/dev/null && $completions_func
- eval "$previous_extglob_setting"
- return 0
- }
- eval "$__docker_previous_extglob_setting"
- unset __docker_previous_extglob_setting
- complete -F _docker docker dockerd
|