Docker Bash completion in macOS

I came across this when trying Docker in Ubuntu. Bash would autocomplete Docker commands. Things like docker im<tab> to complete commands, or even docker logs <tab> to complete container names. 

Googling on this got me to this page, which was for Docker Compose; and also this page, which was for Docker Machine. Somehow I then chanced on the correct page for Docker CLI Bash completion, which is what I was interested in. I forget how I stumbled upon it, it was through some blog post from 2016 or so which took me to an outdated GitHub page from which I came to the correct one – this. After installing bash-completion on macOS, follow the steps on that page and you are set. 

While Googling I also came across this page which I am yet to read fully. Looks useful.