cli: Docker autocompletion for containers not working on MacOS
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.
- If I type
docker
and ⮕Tab it shows me a list of commands - If I type
docker 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:
- deactivate ohmyzsh (no completions at all)
- ask google (obviously)
- try the help sections for common problems on the ohmyzsh FAQ
- ask apple stackexchange
- ask ohmyzsh community who referred me to ask here
Screenshots and recordings
.zshrc
# Path to your oh-my-zsh installation.
export ZSH="$HOME/.oh-my-zsh"
# history
SAVEHIST=10000
# ohmyzsh
ZSH_THEME="lukerandall"
zstyle ':omz:update' mode reminder # just remind me to update when it's time
# docker autocompletion
#zstyle ':completion:*:*:docker:*' option-stacking yes
#zstyle ':completion:*:*:docker-*:*' option-stacking yes
plugins=(brew docker docker-compose git kubectl kubectx)
source $ZSH/oh-my-zsh.sh
# nvm
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
autoload -U compinit && compinit
# kubectl
alias k="kubectl"
# krew
export PATH="${KREW_ROOT:-$HOME/.krew}/bin:$PATH"
#THIS MUST BE AT THE END OF THE FILE FOR SDKMAN TO WORK!!!
export SDKMAN_DIR="$HOME/.sdkman"
[[ -s "$HOME/.sdkman/bin/sdkman-init.sh" ]] && source "$HOME/.sdkman/bin/sdkman-init.sh"
Screenshots:
Reproduce
docker start
+ ⮕Tab
Expected behavior
Show list of containers which are ready to start
docker version
Client:
Cloud integration: v1.0.33
Version: 24.0.2
API version: 1.43
Go version: go1.20.4
Git commit: cb74dfc
Built: Thu May 25 21:51:16 2023
OS/Arch: darwin/arm64
Context: desktop-linux
Server: Docker Desktop 4.20.1 (110738)
Engine:
Version: 24.0.2
API version: 1.43 (minimum version 1.12)
Go version: go1.20.4
Git commit: 659604f
Built: Thu May 25 21:50:59 2023
OS/Arch: linux/arm64
Experimental: false
containerd:
Version: 1.6.21
GitCommit: 3dce8eb055cbb6872793272b4f20ed16117344f8
runc:
Version: 1.1.7
GitCommit: v1.1.7-0-g860f061
docker-init:
Version: 0.19.0
GitCommit: de40ad0
docker info
Client:
Version: 24.0.2
Context: desktop-linux
Debug Mode: false
Plugins:
buildx: Docker Buildx (Docker Inc.)
Version: v0.10.5
Path: /Users/julian/.docker/cli-plugins/docker-buildx
compose: Docker Compose (Docker Inc.)
Version: v2.18.1
Path: /Users/julian/.docker/cli-plugins/docker-compose
dev: Docker Dev Environments (Docker Inc.)
Version: v0.1.0
Path: /Users/julian/.docker/cli-plugins/docker-dev
extension: Manages Docker extensions (Docker Inc.)
Version: v0.2.19
Path: /Users/julian/.docker/cli-plugins/docker-extension
init: Creates Docker-related starter files for your project (Docker Inc.)
Version: v0.1.0-beta.4
Path: /Users/julian/.docker/cli-plugins/docker-init
sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc.)
Version: 0.6.0
Path: /Users/julian/.docker/cli-plugins/docker-sbom
scan: Docker Scan (Docker Inc.)
Version: v0.26.0
Path: /Users/julian/.docker/cli-plugins/docker-scan
scout: Command line tool for Docker Scout (Docker Inc.)
Version: v0.12.0
Path: /Users/julian/.docker/cli-plugins/docker-scout
Server:
Containers: 3
Running: 2
Paused: 0
Stopped: 1
Images: 5
Server Version: 24.0.2
Storage Driver: overlay2
Backing Filesystem: extfs
Supports d_type: true
Using metacopy: false
Native Overlay Diff: true
userxattr: false
Logging Driver: json-file
Cgroup Driver: cgroupfs
Cgroup Version: 2
Plugins:
Volume: local
Network: bridge host ipvlan macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: io.containerd.runc.v2 runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 3dce8eb055cbb6872793272b4f20ed16117344f8
runc version: v1.1.7-0-g860f061
init version: de40ad0
Security Options:
seccomp
Profile: builtin
cgroupns
Kernel Version: 5.15.49-linuxkit-pr
Operating System: Docker Desktop
OSType: linux
Architecture: aarch64
CPUs: 6
Total Memory: 7.667GiB
Name: docker-desktop
ID: 235862c7-714f-4c03-a56e-fed6a8f78116
Docker Root Dir: /var/lib/docker
Debug Mode: false
HTTP Proxy: http.docker.internal:3128
HTTPS Proxy: http.docker.internal:3128
No Proxy: hubproxy.docker.internal
Experimental: false
Insecure Registries:
hubproxy.docker.internal:5555
127.0.0.0/8
Live Restore Enabled: false
Additional Info
macOS 13.14.1 Zsh version 5.9
About this issue
- Original URL
- State: open
- Created a year ago
- Reactions: 11
- Comments: 16 (2 by maintainers)
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: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:and the first one is auto-generate if you setting at
~/.zshrc plugins=(docker)
, but it’s older version (I think this fromdocker 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: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/_dockerand 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:
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
I have the same issue - Docker desktop and Mac OS Ventura on ZSH with Oh My ZSH.
I did it the official recommended way with .dmg file.
This has no effect, no matter if I run the command in the console or add it to my
.zshrc
.