docs icon indicating copy to clipboard operation
docs copied to clipboard

Please add documentation for docker and docker compose shell completions

Open benatshippabo opened this issue 2 years ago • 20 comments

Problem description

Please add documentation for docker and docker compose shell completions. Currently, searching for completions only brings up the deprecated docker app completions.

There is an ongoing issue about the completion command being implemented, but not being available for users.

Are we supposed to curl from cli/contrib/completion/zsh/ for docker cli and compose/contrib/completion/zsh/ even though it's only for docker compose v1?

Are we supposed to use the docker completion and docker compose completion commands even though they aren't exposed?

I believe not having any documentation or guidance is confusing many users

Problem location

  • I saw a problem at the following URL: https://docs.docker.com/engine/reference/commandline/app_completion/

  • I couldn't find the information I wanted. I expected to find it near the following URL

    • https://docs.docker.com/compose/reference/
    • https://docs.docker.com/engine/reference/commandline/docker/
  • Other: please offer some guidance to the end user on the proper method to obtain shell completions for bash, zsh, fish, etc

Project version(s) affected

Docker version 20.10.21, build baeda1f Docker Compose version v2.13.0

Suggestions for a fix

Please offer some guidance to the end user on the proper method to obtain shell completions for bash, zsh, fish, etc

Many commands such as kubectl and helm offer very clear guidance on generating, obtaining, and configuring shell completions in their documentation

benatshippabo avatar Dec 24 '22 01:12 benatshippabo

To me docker completion zsh > ~/.zsh/completions/_docker (using 23.0.1) does the trick.

powerman avatar Mar 19 '23 07:03 powerman

@powerman that completions work for the parent command (docker) but we are still without completions for the compose plugin

layoaster avatar Mar 29 '23 09:03 layoaster

@powerman that completions work for the parent command (docker) but we are still without completions for the compose plugin

Not sure what you mean. Issue you referenced is closed as completed 6 months ago, as of today completion for the compose plugin works - at least using workaround in my previous comment.

powerman avatar Mar 29 '23 11:03 powerman

@powerman pressing TAB after this command docker compose does not produce any completions/suggestions.

  • I have ubuntu with zsh and omzh.
  • I previously created completions for docker with docker completion zsh > .oh-my-zsh/completions/_docker
  • the completion command for compose is not available docker compose completion
  • Docker version 23.0.2
  • Docker Compose version v2.17.2

layoaster avatar Mar 29 '23 11:03 layoaster

Well, for me it works, so you probably doing something wrong. Maybe you need to run that command once again to update completions or reload zsh.

# lsb_release -d
Description:    Ubuntu 22.04.2 LTS
# docker version -f '{{.Client.Version}}'
23.0.1
# docker compose version
Docker Compose version v2.16.0
# docker compose <Tab>
 -- completions --
build    -- Build or rebuild services
config   -- Parse, resolve and render compose file in canonical format
cp       -- Copy files/folders between a service container and the local filesystem
create   -- Creates containers for a service.
down     -- Stop and remove containers, networks
events   -- Receive real time events from containers.
exec     -- Execute a command in a running container.
images   -- List images used by the created containers
kill     -- Force stop service containers.
logs     -- View output from containers
ls       -- List running compose projects
pause    -- Pause services
port     -- Print the public port for a port binding.
ps       -- List containers
pull     -- Pull service images
push     -- Push service images
restart  -- Restart service containers
rm       -- Removes stopped service containers
run      -- Run a one-off command on a service.
start    -- Start services
stop     -- Stop services
top      -- Display the running processes
unpause  -- Unpause services
up       -- Create and start containers
version  -- Show the Docker Compose version information

powerman avatar Mar 29 '23 12:03 powerman

this is weird, still not working

  • I downgraded to match your versions (except Ubuntu) @powerman
# lsb_release -d
Description:    Ubuntu 22.10
# docker version -f '{{.Client.Version}}'
23.0.1
# docker compose version
Docker Compose version v2.16.0
  • Regenerated completions to with docker completion zsh > ~/.zsh/completions/_docker.
  • removed rm .zcompdump* which usually messes with completions
  • Reloaded but docker compose <Tab> still doesn't work

layoaster avatar Mar 30 '23 16:03 layoaster

I don't think this is the right place to debug your issue, because it looks like it's related mostly to your zsh setup than to docker completions. If you like to you can try my zsh setup: https://github.com/powerman/flazsh.

powerman avatar Mar 30 '23 19:03 powerman

There hasn't been any activity on this issue for a long time. If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment. If not, this issue will be closed in 14 days. This helps our maintainers focus on the active issues.

Prevent issues from auto-closing with a /lifecycle frozen comment.

/lifecycle stale

docker-robot[bot] avatar Jun 28 '23 01:06 docker-robot[bot]

/remove-lifecycle stale

benatshippabo avatar Jun 28 '23 01:06 benatshippabo

I was having a similar issue with my docker compose completion with zsh on Arch Linux. The problem was being caused by the docker completion file being installed by the package manager. When I replaced /usr/share/zsh/site-functions/_docker with the output of the docker completion zsh command everything started working. So for me it is an issue I will take up with the Arch Linux packager.

jbigler avatar Jul 11 '23 16:07 jbigler

@jbigler This was definitely my issue's root cause except that in Ubuntu/Debian these outdated completions are installed in /usr/share/zsh/vendor-completions/_docker.

Seem like cli/contrib/completion/zsh/ must be updated or package builders omit it.

layoaster avatar Jul 17 '23 15:07 layoaster

I believe it is also an issue of documentation, as you mention in the main issue. I can't find official documentation for the docker completion <shell> command, so package maintainers might not know about it. I think if @powerman hadn't mentioned it then I wouldn't have known about it. It also doesn't show up as a command in docker help, though docker completion help does show the supported shells.

jbigler avatar Jul 18 '23 01:07 jbigler

I believe it is also an issue of documentation, as you mention in the main issue. I can't find official documentation for the docker completion <shell> command, so package maintainers might not know about it. I think if @powerman hadn't mentioned it then I wouldn't have known about it. It also doesn't show up as a command in docker help, though docker completion help does show the supported shells.

💯 totally agree that the completion command should be documented

benatshippabo avatar Jul 20 '23 23:07 benatshippabo

I was having a similar issue with my docker compose completion with zsh on Arch Linux. The problem was being caused by the docker completion file being installed by the package manager. When I replaced /usr/share/zsh/site-functions/_docker with the output of the docker completion zsh command everything started working. So for me it is an issue I will take up with the Arch Linux packager. @jbigler This was definitely my issue's root cause except that in Ubuntu/Debian these outdated completions are installed in /usr/share/zsh/vendor-completions/_docker.

Seem like cli/contrib/completion/zsh/ must be updated or package builders omit it.

I removed /usr/share/zsh/vendor-completions/_docker and used the completions installed in my oh-my-zsh plugins dir by using zsh-completions and now its working. Thanks!

Btw I'm using docker-rootless so it will probably not cause any problems since I won't use docker as a root user.

FeryET avatar Aug 09 '23 14:08 FeryET

There hasn't been any activity on this issue for a long time. If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment. If not, this issue will be closed in 14 days. This helps our maintainers focus on the active issues.

Prevent issues from auto-closing with a /lifecycle frozen comment.

/lifecycle stale

docker-robot[bot] avatar Nov 07 '23 01:11 docker-robot[bot]

/remove-lifecycle stale

benatshippabo avatar Nov 07 '23 17:11 benatshippabo

There is now documentation in the mac installation faq page, but none exists for linux users.

The methods in this thread definitely work properly, someone just needs to create a pull request to document it

benatshippabo avatar Nov 07 '23 17:11 benatshippabo

There hasn't been any activity on this issue for a long time. If the problem is still relevant, mark the issue as fresh with a /remove-lifecycle stale comment. If not, this issue will be closed in 14 days. This helps our maintainers focus on the active issues.

Prevent issues from auto-closing with a /lifecycle frozen comment.

/lifecycle stale

docker-robot[bot] avatar Mar 15 '24 01:03 docker-robot[bot]

/remove-lifecycle stale

benatshippabo avatar Mar 15 '24 16:03 benatshippabo