Docker image https://gallery.ecr.aws/amazonlinux/amazonlinux:2023 vi: command not found

0

Hi everyone,

I use https://gallery.ecr.aws/amazonlinux/amazonlinux:2023 to build docker image, But when I run container, i was notified that vi: command not found. Why? Amazon linux 2 is not happen!

docker run -it public.ecr.aws/amazonlinux/amazonlinux:2023 /bin/sh
sh-5.2# vi
sh: vi: command not found
profile picture
asked a year ago312 views
3 Answers
0
Accepted Answer

vim-minimal is the package that provides the vi editor. It comes pre-installed on Amazon Linux 2023 EC2 image, maybe you need to specify it in your container image.

[ec2-user@ip-172-31-42-163 ~]$ cat /etc/amazon-linux-release
Amazon Linux release 2023 (Amazon Linux)
[ec2-user@ip-172-31-42-163 ~]$ which vi
/usr/bin/vi
[ec2-user@ip-172-31-42-163 ~]$ rpm -qf /usr/bin/vi
vim-minimal-9.0.1592-1.amzn2023.0.1.x86_64
[ec2-user@ip-172-31-42-163 ~]$ rpm -qi vim-minimal
Name        : vim-minimal
Epoch       : 2
Version     : 9.0.1592
Release     : 1.amzn2023.0.1
Architecture: x86_64
Install Date: Fri Jun  9 20:44:09 2023
Group       : Unspecified
Size        : 1718845
License     : Vim AND LGPL-2.1-or-later AND MIT AND GPL-1.0-only AND (GPL-2.0-only OR Vim) AND Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND GPL-2.0-or-later AND GPL-3.0-or-later AND OPUBL-1.0
Signature   : RSA/SHA512, Thu Jun  1 17:39:25 2023, Key ID e951904ad832c631
Source RPM  : vim-9.0.1592-1.amzn2023.0.1.src.rpm
Build Date  : Thu Jun  1 17:33:46 2023
Build Host  : ip-10-0-36-62.us-west-2.compute.internal
Packager    : Amazon Linux
Vendor      : Amazon Linux
URL         : http://www.vim.org/
Summary     : A minimal version of the VIM editor
Description :
VIM (VIsual editor iMproved) is an updated and improved version of the
vi editor.  Vi was the first real screen-based editor for UNIX, and is
still very popular.  VIM improves on vi by adding new features:
multiple windows, multi-level undo, block highlighting and more. The
vim-minimal package includes a minimal version of VIM, providing
the commands vi, view, ex, rvi, and rview. NOTE: The online help is
only available when the vim-common package is installed.
[ec2-user@ip-172-31-42-163 ~]$ 
profile picture
EXPERT
Steve_M
answered a year ago
profile pictureAWS
EXPERT
reviewed 3 months ago
0

Hi, if you look at https://docs.aws.amazon.com/linux/al2023/release-notes/version-compare.html, you will see that vim packages are still part of AL2023 in updated versions

vim stands for "vi improved" and is upward compatible: https://www.baeldung.com/linux/vi-vim-editors

So, switching to vim may be the right solution for you.

profile pictureAWS
EXPERT
answered a year ago
0

You can see the section in the AL2023 User Guide that compares the container image to the AMIs, Comparing packages installed on Amazon Linux 2023 Minimal AMI and Container Images.

The reason for these changes is that for most containerized applications, you don't need vi (or vim), and thus we save disk space (and network transfer time) for the base image, as well as reducing the number of patching runs that customers have to perform as if you look at the Security Advisories for AL2023 and for AL2, you'll see a decent number of CVEs for vim.

You can see a comparison of base container image sizes in the Minimal Container Image section of the AL2023 Use Guide.

answered 3 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions