Enable Docker CLI Autocomplete on Linux

This Docker blog post will learn how to enable the Docker CLI command autocomplete on Linux.

Autocomplete

Command Autocomplete is a time-saver feature that is a must. It saves time and makes us more productive when using Docker CLI.

Enable Autocomplete

To get started, we need to install the bash-completion package first. You might already have it installed on your system; however, it might not install by default if you have a new machine. So go ahead and install it.

sudo apt-get install bash-completion

Note: If you use Redhat based Linux, use sudo yum install bash-completion

Next, we need to create a directory called bash_completion.d inside etc. You can create the directory using the following command.

sudo mkdir /etc/bash_completion.d

Now, run the following command, which will download the Autocomplete bash script to handle the autocomplete.

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

The final step is to reload the Bash shell, as shown below.

source ~/.bashrc
Published
Categorized as Docker

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.