I am running an ubuntu container in docker. I tried everything I found online, including:

auto-completion does not work for "sudo apt-get install"

but pressing "tab" still has no effect

1 Answer 1


I know this is old, but I ran into it too. It's clear what is failing with the help of debug mode in bash: set -x.

Once you get your into your docker container and apt install bash-completion, and edit your users .bashrc to source the right directory, and logout/login (basically follow the steps in the q/a you referenced.

The command that is failing is:

# apt-cache --no-generate pkgnames firefox
E: Could not open file  - open (2: No such file or directory)

The '--no-generate' in there should give you a clue what is going on (something, something, cache is missing). If you run without it, you get back a list of packages.

This led me to search in some of my reference links with how this system is supposed to work, and eventually inspect the apt configuration:

root@edb76551d1dd:/var/cache/apt# apt-config dump |grep Dir::C
Dir::Cache "var/cache/apt/";
Dir::Cache::archives "archives/";
Dir::Cache::srcpkgcache "";
Dir::Cache::pkgcache "";

Notice that 'pkgcache' is empty. Try that on a normal install (like a lxd container), and you will notice it is set. This led me to the place that configuration information is stored, /etc/apt/apt.conf.d/. On the docker container:

# grep cache *
docker-clean:Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";

You'll notice above that docker images are actively unsetting this value, to keep apt from storing the cache file locally (to reduce image size). I commented out everything in that file, so the file now looks like:

# file: /etc/apt/apt.conf.d/docker-clean 
#DPkg::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };
#APT::Update::Post-Invoke { "rm -f /var/cache/apt/archives/*.deb /var/cache/apt/archives/partial/*.deb /var/cache/apt/*.bin || true"; };
#Dir::Cache::pkgcache ""; Dir::Cache::srcpkgcache "";

And now, things work (after running apt update once:

# apt update
# apt install firefox-d<tab>   
firefox-dbg  firefox-dev


These helped me figure out how this system worked...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.