Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bash completion for docker compose doesn't work #3816

Closed
sloanlance opened this issue Oct 13, 2022 · 8 comments
Closed

Bash completion for docker compose doesn't work #3816

sloanlance opened this issue Oct 13, 2022 · 8 comments

Comments

@sloanlance
Copy link

sloanlance commented Oct 13, 2022

Description

The Bash completion for docker compose (note: this is not for the version with a dash, docker-compose) doesn't work. When I press the completion key (the ⇥ TAB key in my case), it doesn't show any of the subcommands or options. If I enter docker compose -, then press the completion key, it should show the options, but does not.

Not only does it not complete the commands and options, it is preventing Bash from doing any of its usual completion. For example, if my compose file is not the standard docker-compose.yml and I want to specify a new name, then I need to type docker compose -f followed by the filename. However, if I try to use Bash's completion to fill in that filename, it will not do it. Bash simply beeps at me to say there are no completions available. However, I can see the name of my file right there in the file listing.

Reproduce

Type…

docker compose [TAB]

Expected behavior

Bash should show the subcommands, options, and also let me use completion to pick out the related filenames.

docker version

Client:
 Cloud integration: v1.0.29
 Version:           20.10.17
 API version:       1.41
 Go version:        go1.17.11
 Git commit:        100c701
 Built:             Mon Jun  6 23:04:45 2022
 OS/Arch:           darwin/amd64
 Context:           default
 Experimental:      true

Server: Docker Desktop 4.12.0 (85629)
 Engine:
  Version:          20.10.17
  API version:      1.41 (minimum version 1.12)
  Go version:       go1.17.11
  Git commit:       a89b842
  Built:            Mon Jun  6 23:01:23 2022
  OS/Arch:          linux/amd64
  Experimental:     false
 containerd:
  Version:          1.6.8
  GitCommit:        9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc:
  Version:          1.1.4
  GitCommit:        v1.1.4-0-g5fd4c4d
 docker-init:
  Version:          0.19.0
  GitCommit:        de40ad0

docker info

Client:
 Context:    default
 Debug Mode: false
 Plugins:
  buildx: Docker Buildx (Docker Inc., v0.9.1)
  compose: Docker Compose (Docker Inc., v2.10.2)
  extension: Manages Docker extensions (Docker Inc., v0.2.9)
  sbom: View the packaged-based Software Bill Of Materials (SBOM) for an image (Anchore Inc., 0.6.0)
  scan: Docker Scan (Docker Inc., v0.19.0)

Server:
 Containers: 7
  Running: 0
  Paused: 0
  Stopped: 7
 Images: 26
 Server Version: 20.10.17
 Storage Driver: overlay2
  Backing Filesystem: extfs
  Supports d_type: true
  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 io.containerd.runtime.v1.linux runc
 Default Runtime: runc
 Init Binary: docker-init
 containerd version: 9cd3357b7fd7218e4aec3eae239db1f68a5a6ec6
 runc version: v1.1.4-0-g5fd4c4d
 init version: de40ad0
 Security Options:
  seccomp
   Profile: default
  cgroupns
 Kernel Version: 5.10.124-linuxkit
 Operating System: Docker Desktop
 OSType: linux
 Architecture: x86_64
 CPUs: 6
 Total Memory: 13.67GiB
 Name: docker-desktop
 ID: 2ZGT:WFKP:DUQ7:CEQO:LL5N:F336:KI2O:SWE7:UW3L:FZDV:JCDU:63NX
 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
 Registry: https://index.docker.io/v1/
 Labels:
 Experimental: false
 Insecure Registries:
  hubproxy.docker.internal:5000
  127.0.0.0/8
 Live Restore Enabled: false

Additional Info

No response

@mrinaald
Copy link

mrinaald commented Oct 17, 2022

Hi Maintainers,

I would like to look into this issue. Could anyone help me a little for starting on this like which major files could I start looking into?

Thanks!

@sloanlance sloanlance changed the title bash completion for docker compose doesn't work Bash completion for docker compose doesn't work Oct 17, 2022
@jhdxr
Copy link

jhdxr commented Oct 21, 2022

@mrinaald shell completions are seems to be generated by Cobra (check #3429), I guess it will be a good starting point. Btw, if there is any chance, I would appreciate it if you can complete docker system as well (#3826)

@mrinaald
Copy link

@jhdxr Thanks for the help.
And sure, I will try looking into the docker system completions as well.

@mrinaald
Copy link

mrinaald commented Nov 1, 2022

@sloanlance I think the issue is from the docker compose plugin https://github.com/docker/compose/ instead of this cli package.

It also shows that you have installed the Docker Compose plugin in the shared docker info

Client:
...
 Plugins:
  ...
  compose: Docker Compose (Docker Inc., v2.10.2)

You can open a similar issue there and can link this issue in the description. Also, please add your reply in this chat thread relating to the newly opened issue in the compose repo. I am currently working on this, will be creating a pull request in that project.

@bsousaa
Copy link
Contributor

bsousaa commented Nov 24, 2022

This may be fixed by #3752. Are you still having this issue on the latest version?

@thomscode
Copy link

thomscode commented Dec 21, 2022

In the latest version of Docker Engine - Community running on Ubuntu 20.04, the docker compose completions do work.

However, I'm running the latest version of Docker Desktop for Mac and the built in bash completion does not work. This is the one that is a symlink:

/usr/local/etc/bash_completion.d/docker -> /Applications/Docker.app/Contents/Resources/etc/docker.bash_completion

If I download the Docker completion file directly from GitHub and manually install it:

curl -L https://raw.githubusercontent.com/docker/cli/master/contrib/completion/bash/docker -o /usr/local/etc/bash_completion.d/docker

The docker compose completions now work for Docker Desktop.

Hopefully subsequent updates of Docker Desktop don't overwrite my custom downloaded file.

Update:
I created this issue on the For Mac repo to look into updating the Docker Desktop for Mac bash completions:
docker/for-mac#6642

@bsousaa
Copy link
Contributor

bsousaa commented Jan 10, 2023

ok, thank you. I'm closing the issue here in favour of docker/for-mac#6642.

@bsousaa bsousaa closed this as not planned Won't fix, can't repro, duplicate, stale Jan 10, 2023
@ricky0123
Copy link

ricky0123 commented Feb 15, 2023

Edit: Created issue 4034

I am still having a completion issue with respect to the -f option. I believe I am using the most recent docker engine ce on ubuntu (docker version shows 23.0.1). When I type docker compose -f and hit tab to complete, the behavior is as follows, and note that I have files ending in both "yaml" and "yml" in the directory. I hit tab once and it completes a "y". I hit it again and it shows the words "yaml" and "yml" as possible completions. However, if I continue to type, eg "yaml" (not that I would actually want to), and hit tab, it deletes what I have typed and just keeps the "y" again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants