nerdctl icon indicating copy to clipboard operation
nerdctl copied to clipboard

New version can not auto completion in bash shell

Open vndroid opened this issue 2 years ago • 6 comments

Description

The completion can not work in the bash. Why is this happening and is it an incorrect operation?

Steps to reproduce the issue

  1. Install the containerd and nerdctl.
  2. Configuration the completion. (Already installed bash-completion)
sudo mkdir /etc/bash_completion.d/
nerdctl completion bash | sudo tee /etc/bash_completion.d/nerdctl
  1. Relogin the shell. It can not be worked.
kane@deb12:~$ sudo nerdctl 
.bash_history                        cni-plugins-linux-amd64-v1.3.0.tgz   .profile                             .viminfo
.bash_logout                         containerd-1.7.8-linux-amd64.tar.gz  runc.amd64                           .wget-hsts
.bashrc                              nerdctl-1.6.2-linux-amd64.tar.gz     .sudo_as_admin_successful 

Describe the results you received and expected

Completion worked.

What version of nerdctl are you using?

v1.6.2

Are you using a variant of nerdctl? (e.g., Rancher Desktop)

None

Host information

$ sudo nerdctl info
Client:
 Namespace:     default
 Debug Mode:    false

Server:
 Server Version: v1.7.8
 Storage Driver: overlayfs
 Logging Driver: json-file
 Cgroup Driver: systemd
 Cgroup Version: 2
 Plugins:
  Log: fluentd journald json-file syslog
  Storage: native overlayfs
 Security Options:
  apparmor
  seccomp
   Profile: builtin
  cgroupns
 Kernel Version: 6.1.0-13-amd64
 Operating System: Debian GNU/Linux 12 (bookworm)
 OSType: linux
 Architecture: x86_64
 CPUs: 1
 Total Memory: 1.921GiB
 Name: deb12
 ID: 4e1a2897-84bd-4ceb-a4e5-a8c73ac8a621

vndroid avatar Oct 30 '23 07:10 vndroid

Try:

  • nerdctl <TAB> inside sudo -i
  • Run containerd-rootless-setuptool.sh install

AkihiroSuda avatar Oct 30 '23 11:10 AkihiroSuda

Try:

  • nerdctl <TAB> inside sudo -i
  • Run containerd-rootless-setuptool.sh install

I tried sudo -i, it can not be worked.

kane@deb12:~$ sudo -i nerdctl 
.bash_history                        buildkit-v0.12.3.linux-amd64.tar.gz  docker-library/                      runc.amd64                           .viminfo
.bash_logout                         cni-plugins-linux-amd64-v1.3.0.tgz   nerdctl-1.6.2-linux-amd64.tar.gz     .ssh/                                .wget-hsts
.bashrc                              containerd-1.7.8-linux-amd64.tar.gz  .profile                             .sudo_as_admin_successful            
kane@deb12:~$ sudo -i nerdctl ima

By the way. I run the command source /etc/bash_completion.d/nerdctl, It also can not be work.

The containerd-rootless-setuptool.sh install, I didn't execute it because I was using a traditional deployment method.

wget https://github.com/containerd/containerd/releases/download/v1.7.8/containerd-1.7.8-linux-amd64.tar.gz
sudo tar Cxf /usr/local containerd-1.7.8-linux-amd64.tar.gz
sudo mkdir -p /usr/local/lib/systemd/system/
sudo wget https://raw.githubusercontent.com/containerd/containerd/main/containerd.service -O /usr/local/lib/systemd/system/containerd.service
sudo systemctl daemon-reload
sudo systemctl enable --now containerd
wget https://github.com/opencontainers/runc/releases/download/v1.1.9/runc.amd64
sudo install -m 755 runc.amd64 /usr/local/sbin/runc
sudo install -m 0755 -d /etc/containerd/
containerd config default | sudo tee /etc/containerd/config.toml
sudo sed -i 's#SystemdCgroup\s=\sfalse#SystemdCgroup = true#g' /etc/containerd/config.toml
sudo systemctl restart containerd.service

Is this the correct procedure? Do I still need to run a rootless install?

vndroid avatar Oct 30 '23 13:10 vndroid

Is there any progress? @AkihiroSuda

vndroid avatar Nov 07 '23 08:11 vndroid

  • nerdctl <TAB> inside sudo -i

Jeez, I ran into the same "issue" and that resolution wasn't obvious. It might be great to somehow let user know shell completion would only work under root creds 🤔

yermulnik avatar Nov 30 '23 13:11 yermulnik

Just tested now, on main:

nerdctl completion bash | sudo tee /usr/share/bash-completion/completions/nerdctl
$ nerdctl p<TAB>
pause  (Pause all processes within one or more containers)
port   (List port mappings or a specific mapping for the container)
ps     (List containers)
pull   (Pull an image from a registry. Optionally specify "ipfs://" or "ipns://" scheme to pull image from IPFS.)
push   (Push an image or a repository to a registry. Optionally specify "ipfs://" or "ipns://" scheme to push image to IPFS.)
sudo nerdctl i<TAB>
image    (Manage images)                             inspect  (Return low-level information on objects.)
images   (List images)                               ipfs     (Distributing images on IPFS)
info     (Display system-wide information)

Works well in both cases, without sudo -i.

This is on Ubuntu 24.04 LTS.

AFAIK, /etc/bash_completion.d/ is a deprecated location, where completion are always loaded on startup, instead of being loaded on demand. I would not use it.

Not sure what OS you are on, but LMK if using /usr/share/bash-completion/completions/nerdctl instead is giving you better results.

apostasie avatar Aug 13 '24 00:08 apostasie

@vndroid do you feel this is still an issue in light of last comment?

apostasie avatar Aug 18 '24 05:08 apostasie