Zsh Docker Plugin not Working

ZshOh My-ZshZsh Completion

Zsh Problem Overview


I have been using oh-my-zsh for a while now and the docker plugin as recently stopped working for me for some reason.

I checked my ~/.zshrc file and the plugin is included

plugins=(git colored-man colorize github jira vagrant virtualenv pip python brew osx zsh-syntax-highlighting docker)

I checked the ~/.oh-my-zsh/plugins/docker directory and there is a _docker file in there. Yet when I type docker and press Tab, I get none of the autocomplete shortcuts that I used to get.

I can confirm that my git plugin works just fine but not the docker plugin. Tried doing exec zsh and source ~/.zshrc and restarted my terminal but no luck.

Am I missing something?

Zsh Solutions


Solution 1 - Zsh

You might want to try and remove any .zcompdump-(...) files you may have on your user's home directory - using something like rm ~/.zcompdump* on a terminal, or some file browser - and then reload the .zschrc file with the command source ~/.zshrc or restart the terminal - whichever works best for you. See this

Then see if it works.

Solution 2 - Zsh

It seems oh-my-zsh is not loading plugins/docker/_docker file. You must add it to ~/.zshrc in an another way. Add these lines to your ~/.zshrc file:

fpath+=($ZSH/plugins/docker)
autoload -U compinit && compinit

Solution 3 - Zsh

For me it was simply the case that I needed to launch Docker for the first time from spotlight on my Mac in order for Docker for Desktop to get the access it needed. Then the docker version command worked just fine.

Solution 4 - Zsh

In my case: Windows 10 + WSL2 + Hyper

I was having this error because I stopped Docker on Windows... Starting it again makes the error disappear in Hyper (thus, also in ZSH).

No .zshrc changes or additional commands to add inside.

Solution 5 - Zsh

Follow these steps if you are using oh-my-zsh and autocomplete is not working:

  1. Make the following three links:

     ln -s /Applications/Docker.app/Contents/Resources/etc/docker.zsh-completion /usr/local/share/zsh/site-functions/_docker
     ln -s /Applications/Docker.app/Contents/Resources/etc/docker-machine.zsh-completion /usr/local/share/zsh/site-functions/_docker-machine
     ln -s /Applications/Docker.app/Contents/Resources/etc/docker-compose.zsh-completion /usr/local/share/zsh/site-functions/_docker-compose
    
  2. Either add autoload -Uz compinit; compinit to .zshrc or run in your shell:

     echo "autoload -Uz compinit; compinit" >> .zshrc
    

Solution 6 - Zsh

@youhans's solution worked for me permanently. You might have permission issue to make needed adjustment on "zshrc". I have changed the permission to "read and write" and added the code snippet from @youhans's response to the end of "zshrc" file. Now completion system always works.

  • Before I had to type below snippet in command line whenever open a new terminal.

    > autoload -Uz compinit && compinit

Solution 7 - Zsh

In my case it occurred because of an alias. I had defined alias docker=docker.exe. Removing that did it work again.

System & Environment

  • O.S.: Windows 10 Home, x64
  • Shell: Zsh (on Gitbash)

Solution 8 - Zsh

I think you may be missing ,'s in between each plugin.

plugins=(git, colored-man, colorize, github, jira, vagrant, virtualenv, pip, python, brew, osx, zsh-syntax-highlighting, docker)

Alternatively you can place each plugin on a separate line:

plugins=(
  git
  colored-man
  colorize 
  github
  jira
  vagrant
  virtualenv
  pip
  python
  brew
  osx
  zsh-syntax-highlighting 
  docker
)

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionMikhail D'SouzaView Question on Stackoverflow
Solution 1 - ZshRui CarvalhoView Answer on Stackoverflow
Solution 2 - ZshyouhansView Answer on Stackoverflow
Solution 3 - ZshScott SkilesView Answer on Stackoverflow
Solution 4 - ZshMaxime LafarieView Answer on Stackoverflow
Solution 5 - ZshAnujView Answer on Stackoverflow
Solution 6 - ZshrcepView Answer on Stackoverflow
Solution 7 - ZshLeo TapiaView Answer on Stackoverflow
Solution 8 - ZshShmeinsteinView Answer on Stackoverflow