skip to Main Content

I have an nginx-controller container running in k8s based on an Ubuntu image:

Image: quay.io/kubernetes-ingress-controller/nginx-ingress-controller:0.25.0

Inside the container:

$ kubectl exec -it nginx-ingress-controller-xyz bash
$ uname -a
Linux nginx-ingress-controller-xyz 4.15.0-1111-azure #123~16.04.1-Ubuntu SMP Sat Mar 20 01:52:07 UTC 2021 x86_64 GNU/Linux

Seems that neither vi or vim is available:

$ vi
bash: vi: command not found
$ vim
bash: vim: command not found

I thought vi/vim would always be on a linux machine?

4

Answers


  1. In this situation, For me, this method always works.
    At first go to your container and then use these commands:

    apt update
    apt install vim
    

    or

    apt update
    apt install nano
    
    Login or Signup to reply.
  2. A vi command that behaves as per the POSIX specification is mandatory for an OS to call itself Unix.

    Ubuntu and other Linux-based operating systems are not certified and being certified is not exactly a goal so all they do is follow the specification as closely as they want/need/can. Therefore, it is unreasonable to expect vi to "always be on a linux machine" or that vi command to be provided by Vim. There is simply no guarantee.

    Moreover, it is customary to make Docker images meant for production as lightweight (and secure) as possible by removing as much cruft as possible. You don’t need vi to run your Ingress Controller so it isn’t there.

    Login or Signup to reply.
  3. If there is apt or apt-get command in your container, just run apt update && apt install vim, otherwise you can try:
    nsenter -t <Pid> -n -m vi <your-file> to reuse the tools on your host but change the namespace.

    Login or Signup to reply.
  4. You won’t find many commonly available programs in docker images. Because these images are made to be lightweight.
    You can install vim on an ubuntu image by

    apt-get update && apt-get install vim
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search