Search code examples
linuxubuntuvimvi

Vi or Vim not found on Ubuntu docker container


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?


Solution

  • 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.