Open Theiaz opened 1 year ago
Hiya @Theiaz, thanks for the report. Indeed, the current zsh completion script is a bit broken for container name completion – I started looking into fixing this some time ago, but haven't had the time yet. A quick alternative is to use the Cobra V2 completion script generated by docker completion zsh
: we haven't switched over to using these by default, but in my experience (at least for zsh), it seems to work pretty well.
You can try this out by running
$ source <(docker completion zsh)
This has no effect, no matter if I run the command in the console or add it to my .zshrc
.
Do you mean the script generated by docker completion zsh
doesn't do anything at all? I'd recommend checking the output of docker completion zsh --help
to see some more information on how to enable zsh completions (these can be different depending on environment/OS, so maybe you'll see something relevant – such as making sure autocompletions are enabled with echo "autoload -U compinit; compinit" >> ~/.zshrc
).
I have the same problem. If I use source <(docker completion zsh)
, and then enable debug logging with export BASH_COMP_DEBUG_FILE=~/docker-completion.log; touch $BASH_COMP_DEBUG_FILE
, I get the following:
========= starting completion logic ==========
CURRENT: 3, words[*]: docker rm
Truncated words[*]: docker rm ,
lastParam: , lastChar:
Adding extra empty parameter
About to call: eval docker __completeNoDesc rm ""
completion output: :0
last line: :0
directive: 0
completions:
flagPrefix:
Calling _describe
_describe did not find completions.
Checking if we should do file completion.
Activating file completion
This with docker rm <TAB>
and a number of stopped containers.
Hello Guys,
Same here!
========= starting completion logic ==========
CURRENT: 3, words[*]: docker rm
Truncated words[*]: docker rm ,
lastParam: , lastChar:
Adding extra empty parameter
About to call: eval docker __completeNoDesc rm ""
completion output: :0
last line: :0
directive: 0
completions:
flagPrefix:
Calling _describe
_describe did not find completions.
Checking if we should do file completion.
Activating file completion
this was triggered by docker rm <TAB>
Further: docker images paramtere is fully missing:
========= starting completion logic ==========
CURRENT: 2, words[*]: docker
Truncated words[*]: docker ,
lastParam: , lastChar:
Adding extra empty parameter
About to call: eval docker __completeNoDesc ""
completion output: completion
compose
context
ecs
exec
help
inspect
kill
login
logout
logs
prune
ps
rm
run
secret
serve
start
stop
version
volume
:4
last line: :4
directive: 4
completions: completion
compose
context
ecs
exec
help
inspect
kill
login
logout
logs
prune
ps
rm
run
secret
serve
start
stop
version
volume
flagPrefix:
Adding completion: completion
Adding completion: compose
Adding completion: context
Adding completion: ecs
Adding completion: exec
Adding completion: help
Adding completion: inspect
Adding completion: kill
Adding completion: login
Adding completion: logout
Adding completion: logs
Adding completion: prune
Adding completion: ps
Adding completion: rm
Adding completion: run
Adding completion: secret
Adding completion: serve
Adding completion: start
Adding completion: stop
Adding completion: version
Adding completion: volume
Calling _describe
_describe found some completions
@Theiaz did you installed docker desktop with download and install or with brew install --cask docker? Ive tried both way. In docker desktop installation (default) there is no docker 'image' argument. When you install docker with brew cask you will have another version and location of docker binary and it contains the image argumentum, but as you wrote, it doesn't work as same as docker rm is not working.
@Theiaz did you installed docker desktop with download and install or with brew install --cask docker?
I did it the official recommended way with .dmg file.
Hello there, if I want to contribute to this, how to contribute ?
I have the same issue - Docker desktop and Mac OS Ventura on ZSH with Oh My ZSH.
Same for me - I really miss being able to autocomplete running containers
Homebrew brew will download completion automatically when install a majority of application like docker. the completion file will be stored in $(brew --prefix)/share/zsh/site-functions/. but I still got some mojibake after source _docker completion file.
Same here, not only docker start
, but also the same for docker run and other subcomands. I type docker
then tab it shows an incomplete command list.
Hi! There is any update for this issue?a
Hi all, just find this issue on my macbook, I install docker through download .dmg docker desktop, and setting $PATH
env to use docker command on zsh, like this:
# ~/.zshrc
export PATH="$PATH:$HOME/.docker/bin"
plugins=(
...
docker
docker-compose
...
)
and my docker command can use completions, but it’s likely older version (not information for every sub-command and if I type docker rm <tab>
it will not check my system container ID)
like this:
and I using find
command check all _docker file, I get result:
find ~ 2>/dev/null | grep _docker
and the first one is auto-generate if you setting at ~/.zshrc plugins=(docker)
,
but it’s older version (I think this from docker completion zsh
)
the correct one is/Users/$USER/.oh-my-zsh/plugins/completions/_docker
, but at my macbook, if you check $FPATH envirable, there is no have /Users/$USER/.oh-my-zsh/plugins/docker/completions/
and there have /Users/$USER/.oh-my-zsh/plugins/docker
, so I create Symbolic link through:
ln -s /Users/$USER/.oh-my-zsh/plugins/docker/completions/_docker /Users/$USER/.oh-my-zsh/plugins/docker/_docker
# restart zsh or source ~/.zshrc
source ~/.zshrc
NOTE: If you don’t have /Users/$USER/.oh-my-zsh/plugins/docker/completions/_docker
you can get from here:https://raw.githubusercontent.com/docker/cli/master/contrib/completion/zsh/_docker
and now, docker command can get my tab like this:
Not a very pretty solution, but works for me.
hope this help someone :)
This my environment reference:
# docker version
Client:
Cloud integration: v1.0.35+desktop.5
Version: 24.0.6
API version: 1.43
Go version: go1.20.7
Git commit: ed223bc
Built: Mon Sep 4 12:28:49 2023
OS/Arch: darwin/arm64
Context: desktop-linux
Server: Docker Desktop 4.25.0 (126437)
Engine:
Version: 24.0.6
API version: 1.43 (minimum version 1.12)
Go version: go1.20.7
Git commit: 1a79695
Built: Mon Sep 4 12:31:36 2023
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.6.22
GitCommit: 8165feabfdfe38c65b599c4993d227328c231fca
runc:
Version: 1.1.8
GitCommit: v1.1.8-0-g82f18fe
docker-init:
Version: 0.19.0
GitCommit: de40ad0
# omz version
master (38c01a2)
docker network
is also missing (not only for me from what I see on the screenshots).
At the moment, the introduction of the new docker completion script (docker completion zsh
) isn't working very well. As I'm using oh-my-zsh, I would suggest using the legacy completion script as described here : https://github.com/ohmyzsh/ohmyzsh/blob/master/plugins/docker/README.md. It fixed the issue for me.
Further explanation here : https://github.com/ohmyzsh/ohmyzsh/issues/11789
@RayLin9981 thank you for details troubleshooting. It helped me a lot.
It worked for fish
, but is now also broken.
Hi all! I'd like to help fix the new docker completion [shell]
completion – but I'm having trouble collecting a list of what needs fixing.
@rlipscombe can you confirm that using source <(docker completion zsh)
, the completions for docker rm <TAB>
is broken? I see valid values:
Same for docker network <TAB>
@jkulak:
Can you all also append the output of docker version
?
@laurazard it seems to be working for me now.
One caveat: I had oh-my-zsh legacy docker completion enabled (see https://github.com/ohmyzsh/ohmyzsh/issues/11789). I think I disabled it, and that native docker completion still works.
Nice, I'm happy to hear that! Please ping me/comment here if you run into issues with the non-legacy completions code, we want to move away from the old scripts and start using that more/help users configure the new completions and so we want to make sure everything's working as expected.
Seems to work for me now aswell.
Description
I'm migrating from Ubuntu to MacOS with my MacBook Pro (M2). I'm using ohmyzsh with the docker and docker-compose plugin. Docker has been installed with Docker Desktop setup.
The docker plugin works fine except the autocompletion for the container names.
docker
and ⮕Tab it shows me a list of commandsdocker start
and ⮕Tab it just shows me the files of my current directory, but not the list of available containers.I'm expecting the autosuggestion to work here and show me a list of all containers which could be started. This worked fine within Ubuntus bash.
What I did so far:
Screenshots and recordings
.zshrc
Screenshots:
Reproduce
docker start
+ ⮕TabExpected behavior
Show list of containers which are ready to start
docker version
docker info
Additional Info
macOS 13.14.1 Zsh version 5.9