Enable Docker command-line auto completion in bash on Centos/Ubuntu

 

Docker comes with command completion for the bash and zsh shell.
Here is the procedure to enable bash auto completion in Docker CE on Centos 7 and Ubuntu

 

Install bash-completion package

on CentOS/RedHat

# yum -y install bash-completion

on Ubuntu

apt-get install bash-completion

 

Download bash completion file into /etc/bash_completion.d

# curl https://raw.githubusercontent.com/docker/docker-ce/master/components/cli/contrib/completion/bash/docker -o /etc/bash_completion.d/docker.sh

 

Logout and login again.

When I type docker im and enter TAB then, I will get the possible parameters

# docker im<TAB>
image images import

If I type docker images then TAB, docker will list the available images.

# docker images  <TAB>
nginx:latest redis

It alo shows us the parameter of each command

 

# docker ps -<TAB>
-a -f --format -l --latest --no-trunc --quiet --size 
--all --filter --help --last -n -q -s

 

 

İsmail Yenigül

Linux & AWS Certified Cloud Expert

 

 

 

 

Advertisements
Enable Docker command-line auto completion in bash on Centos/Ubuntu

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s