• linux下二进制安装docker最新版docker-24.0.6


    一.基础环境

    本次实操是公司技术培训下基于centos7.9操作系统安装docker最新版docker-24.0.6,下载地址是:https://download.docker.com/linux/static/stable/x86_64/docker-24.0.6.tgz

    二. 下载Docker压缩包

    mkdir -p /opt/docker-soft

    cd /opt/docker-soft

    wget https://download.docker.com/linux/static/stable/x86_64/docker-24.0.6.tgz

    三.解压压缩包

    tar xf docker-24.0.6.tgz 

    解压缩后会出现一个docker文件夹,具体内容如下

     [root@TDCS docker-soft]# cd docker
    [root@TDCS docker]# ll
    总用量 182244
    -rwxr-xr-x 1 1000 1000 39129088 9月   4 20:34 containerd
    -rwxr-xr-x 1 1000 1000 12374016 9月   4 20:34 containerd-shim-runc-v2
    -rwxr-xr-x 1 1000 1000 19140608 9月   4 20:34 ctr
    -rwxr-xr-x 1 1000 1000 34752096 9月   4 20:34 docker
    -rwxr-xr-x 1 1000 1000 63346888 9月   4 20:34 dockerd
    -rwxr-xr-x 1 1000 1000   761712 9月   4 20:34 docker-init
    -rwxr-xr-x 1 1000 1000  1965694 9月   4 20:34 docker-proxy
    -rwxr-xr-x 1 1000 1000 15142440 9月   4 20:34 runc

     四.docker相关的二进制文件软链接或者拷贝到指定的/usr/bin目录

    1. 二者操作其一即可
    2. 1.做软链接
    3. ln -sv /opt/docker-soft/docker/* /usr/bin/
    4. 2.拷贝二进制文件到/usr/bin/
    5. /opt/docker-soft/docker/* /usr/bin/

    五.创建containerd的service文件,并且启动

    1. cat > /usr/lib/systemd/system/containerd.service <<EOF
    2. [Unit]
    3. Description=containerd container runtime
    4. Documentation=https://containerd.io
    5. After=network.target local-fs.target
    6. [Service]
    7. ExecStartPre=-/sbin/modprobe overlay
    8. ExecStart=/usr/bin/containerd
    9. Type=notify
    10. Delegate=yes
    11. KillMode=process
    12. Restart=always
    13. RestartSec=5
    14. # Having non-zero Limit*s causes performance problems due to accounting overhead
    15. # in the kernel. We recommend using cgroups to do container-local accounting.
    16. LimitNPROC=infinity
    17. LimitCORE=infinity
    18. LimitNOFILE=1048576
    19. # Comment TasksMax if your systemd version does not supports it.
    20. # Only systemd 226 and above support this version.
    21. TasksMax=infinity
    22. OOMScoreAdjust=-999
    23. [Install]
    24. WantedBy=multi-user.target
    25. EOF

    启动containerd

    #启动
    systemctl enable containerd.service && systemctl restart containerd

    #查看状态

    systemctl status containerd

    五.创建docker的service文件 

    1. #docker.service文件
    2. cat > /usr/lib/systemd/system/docker.service <<EOF
    3. [Unit]
    4. Description=Docker Application Container Engine
    5. Documentation=https://docs.docker.com
    6. After=network-online.target firewalld.service containerd.service
    7. Wants=network-online.target
    8. Requires=docker.socket containerd.service
    9. [Service]
    10. Type=notify
    11. ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock
    12. ExecReload=/bin/kill -s HUP $MAINPID
    13. TimeoutSec=0
    14. RestartSec=2
    15. Restart=always
    16. StartLimitBurst=3
    17. StartLimitInterval=60s
    18. LimitNOFILE=infinity
    19. LimitNPROC=infinity
    20. LimitCORE=infinity
    21. TasksMax=infinity
    22. Delegate=yes
    23. # kill only the docker process, not all processes in the cgroup
    24. KillMode=process
    25. OOMScoreAdjust=-500
    26. [Install]
    27. WantedBy=multi-user.target
    28. EOF
    29. #docker.socket文件
    30. cat > /usr/lib/systemd/system/docker.socket <<EOF
    31. [Unit]
    32. Description=Docker Socket for the API
    33. [Socket]
    34. ListenStream=/var/run/docker.sock
    35. SocketMode=0660
    36. SocketUser=root
    37. SocketGroup=docker
    38. [Install]
    39. WantedBy=sockets.target
    40. EOF

    六.创建docker组

    1. #创建docker组
    2. groupadd docker

    七.启动docker

    1. #启动
    2. systemctl enable docker.service && systemctl restart docker
    3. #查看状态
    4. systemctl status docker
    5. #验证
    6. docker info

    八.操作系统内核优化

    1. vi /etc/sysctl.conf
    2. net.bridge.bridge-nf-call-ip6tables = 1
    3. net.bridge.bridge-nf-call-iptables = 1
    4. vm.swappiness=0

    九.docker优化配置

    1. mkdir -p /etc/docker
    2. cat >/etc/docker/daemon.json <<EOF
    3. {
    4. "data-root": "/var/lib/docker", #数据目录
    5. "storage-driver": "overlay2", // 存储驱动程序
    6. "storage-opts": [
    7. "overlay2.override_kernel_check=true"
    8. ],
    9. "max-concurrent-downloads": 10,
    10. "max-concurrent-uploads": 5,
    11. "registry-mirrors": ["https://9916w1ow.mirror.aliyuncs.com"], #注册表的镜像集合,加快镜像下载速度
    12. "exec-opts": ["native.cgroupdriver=systemd"], #默认的cgroup driver
    13. "log-opts": { // 设置日志选项
    14. "max-file": "5",
    15. "max-size": "100m"
    16. },
    17. "live-restore": true
    18. }
    19. EOF

    常用的配置如下:
    log-driver:设置 Docker 层级记录使用的默认日志驱动器,可能的值包括 json-file、syslog和journald,默认为 json-file。
    log-opts:通过 log-driver 设置的默认日志选项。可选择的日志选项根据所使用的各种驱动程序而异。
    storage-driver:设置容器使用的默认存储驱动程序。可能的值包括 aufs、devicemapper、btrfs、vfs等,不同的驱动程序可能会对性能和稳定性产生不同的影响。从 Docker 19.03 开始,默认值为 overlay2。
    iptables:指定是否启用 Docker 管理的 iptables 规则,默认为 true。
    ipv6:启用或禁用IPv6支持,默认为false。
    registry-mirrors:设置 Docker Hub 镜像的镜像地址
    max-concurrent-downloads # 下载并发数
    max-concurrent-uploads   # 上传并发数
    live-restore             # 开启这个参数,重启docker不会影响上面的参数

    报错failed to start daemon: error initializing graphdriver: overlay2: unknown option overlay2.override_kernel_check
    去掉 
    "storage-opts": [
        "overlay2.override_kernel_check=true"
      ],

     十.修改配置后验证启动

    1. 启动
    2. systemctl restart docker
    3. # 查看docker版本
    4. docker --version
    5. #docker信息
    6. docker info
    7. # 验证dokcer启动
    8. docker run hello-world

    十一.docker命令补全

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