bashdockerautocompletekuberneteskubectl

kubectl bash completion doesn't work in ubuntu docker container


I'm using kubectl from within a docker container running on a Mac. I've already successfully configured the bash completion for kubectl to work on the Mac, however, it doesn't work within the docker container. I always get bash: _get_comp_words_by_ref: command not found.

The docker image is based on ubuntu:16.04 and kubectl is installed via the line (snippet from the dockerfile)

curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && \
mv kubectl /usr/local/bin

echo $BASH_VERSION gives me 4.3.48(1)-release, and according to apt, the bash-completionpackage is installed.

I'm using iTerm2 as terminal.

Any idea why it doesn't work or how to get it to work?


Solution

  • Ok, I found it - I simply needed to do a source /etc/bash_completion before or after the source <(kubectl completion bash).