1、 安装 bash-completion 软件包
yum install -y bash-completion
zypper install -y bash-completion
2、 配置 bash-completion 软件包
bash /usr/share/bash-completion/bash_completion
bash
3、 下载 Docker 命令补全文件
contrib/completion/bash/docker
文件示例:
wget https://ghproxy.com/https://raw.githubusercontent.com/docker/cli/v24.0.4/contrib/completion/bash/docker
4、 移动 Docker 命令补全文件至指定目录
目标目录: /etc/bash_completion.d
mv docker /etc/bash_completion.d/docker
5、 加载 Docker 命令补全文件
source /etc/bash_completion.d/docker
6、 检查 Docker 命令自动补全是否生效
命令行终端输入 docker
后按 Tab
键检查是否有提示即可
[root@localhost ~]# docker
attach commit context diff export image info load logs node port push rm save service stats system trust version
build config cp events help images inspect login manifest pause ps rename rmi search stack stop tag unpause volume
builder container create exec history import kill logout network plugin pull restart run secret start swarm top update wait