Zsh Docker Plugin not Working
Asked Answered
O

10

55

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?

Open answered 25/5, 2016 at 4:58 Comment(1)
In my case I was looking for docker-compose functions, I forgot that docker has separate plugins: docker, docker-compose, docker-machine.. Maybe it's not the case, but it may help somebody elseBeverleybeverlie
N
-36

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
)
Normi answered 13/6, 2017 at 0:8 Comment(3)
Adding commas results in error messages like "git, plugin not found."Wardmote
This does not work and should not be marked as the answerHisto
oh-my-zsh documentation clearly states that entries should be separated by whitespaces.Derman
H
255

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 .zshrc file with the command source ~/.zshrc or restart the terminal - whichever works best for you. See this

Then see if it works.

Haswell answered 25/3, 2019 at 15:55 Comment(8)
This worked for me too on Ubuntu Mate 18.04, zsh 5.4.2, mate-terminal 1.20.0. Had to delete .zcompdump-<device-name>-5.4.2 and restart the terminal.Earthman
Worked for me on Mac OS CatalinaCentroid
Worked on Fedora ! Thank you for this simple answer.Susuable
Had multiple .zcomp-dump* files in ~ and after deleting both docker autocomplete works perfectly. The solution has not generated any bugs on my system. Using OS X Catalina.Glyceric
For those unaware, source ~/.zshrc also 'restarts' your terminal. No need to actually close your terminal, or lose what you're in the middle of.Cipolin
It works! But why? What is broken and how did that happen?Areaway
[1/2] @CorneliusRoemer The reason it works is because of how OMZ/ZSH plugins and autocomplete work. OMZ/ZSH uses .zcompdump as cache files for its shell completion system when you're typing, to make completion faster. These zcompdump files are compiled by OMZ/ZSH to map commands to functions it will run, many defined in plugins as well. So it runs through plugins folder and builds this cached file it uses while you type. When active plugin list changes in OMZ/ZSH config it does not automatically do what it should to rebuild this zcompdump cache file. By removing it you force it to be rebuilt.Haswell
[2/2] It's actually safe to delete them, since they will be recreated if not there, in your user home folder. Also, OMZ/ZSH uses the hostname as the suffix to each .zcompdump file. You can also browse through OMZ code at github.com/ohmyzsh/ohmyzsh to understand how the plugin system works. Look at this file github.com/ohmyzsh/ohmyzsh/blob/master/oh-my-zsh.sh#L57-L71 and lines ~57 onwards to understand the usage of zcompdump files.Haswell
S
68

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

fpath+=($ZSH/plugins/docker)
autoload -U compinit && compinit
Seamus answered 31/7, 2017 at 2:16 Comment(7)
This just fixed it for me. Is this a known issue? (did not find it on the omz issue list).Epistle
Neither answer worked for me. I've opened a issue on GH github.com/robbyrussell/oh-my-zsh/issues/7687Brinna
I've been cracking my head the entire afternoon for this. Thanks, it solved the issue.Kornher
Confirmed, autocompletion started working for me after applying this to my ~/.zshrc file, thanks!Wahkuna
Only autoload -U compinit && compinit was enough to get that working. I also moved the source $ZSH/oh-my-zsh.sh to be executed before that. It's working now.Lashundalasker
I had to change permissions with compaudit | xargs chmod g-w,o-w and then do this and it worked Using CatalinaTechnicolor
This makes the problem worse on WSL.Ossy
S
6

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.

Sorcim answered 12/8, 2019 at 8:30 Comment(0)
J
3

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
    
Jactitation answered 31/3, 2019 at 21:28 Comment(0)
A
3

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.

Annecorinne answered 14/8, 2020 at 8:37 Comment(2)
Can you explain to me what your Windows 10 + WSL2 + Hyper looks like? A link to some docs online would be really helpful.Knowing
Sure, here are some links (sorry I can't find the original one I used before): blog.usejournal.com/… // medium.com/@myrlandnu/…Annecorinne
B
1

@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

Bolding answered 3/5, 2020 at 9:25 Comment(0)
G
0

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)
Graaf answered 9/4, 2021 at 22:50 Comment(0)
S
0

For my case only was necessary the leave git plugin until the end instead, originally my first attempt was:

plugins=(git kubectl kubectx)

When start to work was:

plugins=(z kubectl kubectx git)
Stopping answered 6/10, 2023 at 19:42 Comment(0)
S
0

As per the docker plugin's README, put zstyle ':omz:plugins:docker' legacy-completion yes in your ~/.zshrc, yet make sure it is before source $ZSH/oh-my-zsh.sh.

Shammy answered 17/12, 2023 at 17:17 Comment(0)
N
-36

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
)
Normi answered 13/6, 2017 at 0:8 Comment(3)
Adding commas results in error messages like "git, plugin not found."Wardmote
This does not work and should not be marked as the answerHisto
oh-my-zsh documentation clearly states that entries should be separated by whitespaces.Derman

© 2022 - 2024 — McMap. All rights reserved.