How to Run Vi on Docker Container

Vi or Vim not found on Ubuntu docker container

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.

How do I edit a file after I shell to a Docker container?

As in the comments, there's no default editor set - strange - the $EDITOR environment variable is empty. You can log in into a container with:

docker exec -it <container> bash

And run:

apt-get update
apt-get install vim

Or use the following Dockerfile:

FROM  confluent/postgres-bw:0.1

RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "vim"]

Docker images are delivered trimmed to the bare minimum - so no editor is installed with the shipped container. That's why there's a need to install it manually.

EDIT

I also encourage you to read my post about the topic.

Unable to install vim or nano inside docker container

The solution is to run docker with:

docker run --net=host

How to install vim in a docker image based on mysql version 8?

If you take a look at the Tag for 8.0 you can see that the base uses a different version of Oracle linux (8 vs 7). Yum is not installed in 8. Instead, there's a minimal installer (microdnf). So this substitution should work for you:

microdnf install -y vim

Install vim in node Docker image

You are only using a single ampersand (&) in your RUN directive, which runs a command in the background in bash. Change it to include two ampersands (&&). Please also notice the -y (automatic yes to prompts) I have added to the apt-get statement, without which your docker build command will fail:

RUN apt-get update && apt-get install -y vim


Related Topics



Leave a reply



Submit