DEV Community

Reishi Mitani
Reishi Mitani

Posted on

30 2

Installing Vim in a Docker Container

I just realized that my docker container did not have vim installed, and had to google some commands.

All you need to do is run the commands below in the container. These commands are mainly used in Ubuntu containers.

apt-get update
apt-get install vim
Enter fullscreen mode Exit fullscreen mode

In case of CentOS, the commands below will work.

yum install vim
Enter fullscreen mode Exit fullscreen mode

Lastly for Alpine:

apk update
apk add vim
Enter fullscreen mode Exit fullscreen mode

If you want to directly write the commands in the Dockerfile:

FROM ubuntu

RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "vim"]
Enter fullscreen mode Exit fullscreen mode

Top comments (2)

Collapse
 
shubhamkhandare profile image
Shubham Khandare

That's great you figured it out.
But most of the containers come with vi which is sufficient for basic editing.

Collapse
 
mattkenefick profile image
Matt Kenefick

In my experience, most docker containers are intentionally stripped to their bare minimum and will not come with vim.

When you do install vi, note that you can use vim-tiny to reduce footprint.

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay