I have installed docker on many machines in the past and auto-completion always had just worked out of the box. Strangely, in a new docker install on an Ubuntu 20.04.2 LTS (Focal Fossa) virtual machine, when I press tab, nothing happens. I tried it on my WSL terminal, and if I type sudo docker start g
and then tab, it autocompletes to sudo docker start gifted_hofstadter
. Yet, both only have these two files in:
# ls /etc/bash_completion.d/
apport_completion git-prompt
So I don't understand why I would have to add a /etc/bash_completion.d/docker
file as an article suggests. How do I fix it with minimal changes? To be clear, regular bash autocompletion works fine, the issue is specific to docker. Thanks.
Update: Installed podman and the same autocomplete issue exists although I don't think it's related.
I copied this docker.sh file to /etc/bash_completion.d/
and restarted the shell. Now docker commands autocomplete, e.g. docker sta [tab]
expands to docker start
. Also if I do docker start f
it expands to docker start f36da5e5a9a8
i.e. the container ID.
However, it won't expand the container name, such as frosty_tu
when I do docker start fro [tab]
. While I appreciate the solution, this is another reason I don't want to shop around for third party scripts and prefer the out-of-the-box experience I have seen on new installs before.