Solution to installing vim in docker container

Solution to installing vim in docker container

The beginning of the story

Many Internet companies, after going through the wild growth of 0-1, must have refined management; especially for their own users, you need to understand your users’ characteristics/needs/like a scumbag to know how to make them happy; only then will they follow you wholeheartedly.

If it is for business users, the problem is very simple: visit different partner companies/industry leaders. Everyone has a purpose, and mutual benefit will become clear after a few visits.

But for a user-oriented company like us, if we randomly sample users and invite them to the company to conduct questionnaire surveys, let alone a one-time survey, is the sampled user data representative? Are the questions raised by users the current development direction of the team?

So my recent work is to add another layer to the original business analysis: user tags. Mark the user's behavior in your application, analyze user characteristics and usage habits

Big data is needed in the middle process, so I choose to use docker to build the environment for my own test development. I encountered problems installing vim in the middle.

Install vim and edit hadoop-hive.env

Install hive image using docker on centos 7

$ docker ps
CONTAINER ID IMAGE COMMAND PORTS NAMES
dc387ff5c56d bde2020/hive:2.1.0-postgresql-metastore "entrypoint.sh /bin/…" 0.0.0.0:10000->10000/tcp, 10002/tcp hive-server

$ docker exec -it dc387ff5c56d /bin/bash

# vim edit hadoop-hive.env
/opt# vi hadoop-hive.env
bash: vi: command not found

# It is understandable that the image is pure, compile and install it./opt# yum install vim
bash: yum: command not found
/opt#rpm
bash: rpm: command not found

# curl is still reliable/opt# wget http://yum.baseurl.org/download/3.2/yum-3.2.28.tar.gz
bash: wget: command not found
/opt# rz
bash: rz: command not found

/opt# curl
curl: try 'curl --help' or 'curl --manual' for more information
/opt# curl -o yum-3.2.28.tar.gz http://yum.baseurl.org/download/3.2/yum-3.2.28.tar.gz
  % Total % Received % Xferd Average Speed ​​Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 864k 100 864k 0 0 276k 0 0:00:03 0:00:03 --:--:-- 667k

# You are too pure./opt# tar -zxvf yum-3.2.28.tar.gz
/opt/yum-3.2.28# ls
AUTHORS ChangeLog INSTALL PLUGINS TODO callback.py docs output.py rpmUtils test yum yum.spec yummain.py
COPYING FAQ Makefile README bin cli.py etc po shell.py utils.py yum-updatesd.py yumcommands.py

/opt/yum-3.2.28# make
bash: make: command not found

At this time~ bash: make: command not found Hmm? There is not even a make compilation command. Are containers so wild now?

I was careless and didn't dodge. It turned out to be Debian.

No, maybe the image is not for centos 7?

# Check the Linux kernel version /opt/yum-3.2.28# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 7 (wheezy)"
NAME="Debian GNU/Linux"
VERSION_ID="7"
VERSION="7 (wheezy)"
ID=debian
ANSI_COLOR="1;31"
HOME_URL="http://www.debian.org/"
SUPPORT_URL="http://www.debian.org/support/"
BUG_REPORT_URL="http://bugs.debian.org/"

PRETTY_NAME="Debian GNU/Linux 7 (wheezy)" Oh my goodness, it's Debian. Let me check the apt-get installation command

/opt/yum-3.2.28# apt-get install vim
Reading package lists... Done
Building dependency tree       
Reading state information... Done
E:

I know it's not that simple. Unable to locate package vim is usually because the apt-get source used by Debian in China needs to be bypassed. Just configure the domestic mirror.

# Back up the original `apt-get` source file and reconfigure it/# mv /etc/apt/sources.list /etc/apt/sources.list.bak
deb http://mirrors.163.com/debian/ jessie main non-free contrib
/opt/yum-3.2.28# echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" >/etc/apt/sources.list

/opt/yum-3.2.28# echo "deb http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list

/opt/yum-3.2.28# echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list

/opt/yum-3.2.28# echo "deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list

# Update apt-get, install vim
/opt/yum-3.2.28# apt-get update
/opt/yum-3.2.28# apt-get install vim

Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following extra packages will be installed:
  libc6 vim-common vim-runtime
Suggested packages:
  glibc-doc locales ctags vim-doc vim-scripts
The following NEW packages will be installed:
  vim vim-common vim-runtime
The following packages will be upgraded:
  libc6
1 upgraded, 3 newly installed, 0 to remove and 179 not upgraded.
Need to get 10.8 MB of archives.
After this operation, 29.6 MB of additional disk space will be used.
Do you want to continue [Y/n]?

Other methods

In addition, if it is just a simple configuration file replacement. You can also edit the hadoop-hive.env configuration file on the host machine, docker cp hadoop-hive.env dc387ff5c56d:/opt and copy it to the specified folder of the container.

Summarize

When installing a docker image, you need to pay attention to the system version kernel; if the version is wrong/the version number does not match the docker container, problems will occur

This is the end of this article about solving the problem of installing vim in docker container. For more relevant content about installing vim in docker, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to solve the problem that Docker container has no vim command
  • Solve the problem that vim commands cannot be used in Docker containers

<<:  Use image to submit the form instead of using button to submit the form

>>:  Detailed explanation of the top ten commonly used string functions in MySQL

Recommend

Detailed explanation of redundant and duplicate indexes in MySQL

MySQL allows you to create multiple indexes on th...

MySQL 5.7.18 Installer installation download graphic tutorial

This article records the detailed installation tu...

Vue+Element realizes paging effect

This article example shares the specific code of ...

Flex layout realizes left text overflow and omits right text adaptation

I want to achieve a situation where the width of ...

Comparison of CSS shadow effects: drop-Shadow and box-Shadow

Drop-shadow and box-shadow are both CSS propertie...

Linux common text processing commands and vim text editor

Today, let's introduce several common text pr...

Simple setup of VMware ESXi6.7 (with pictures and text)

1. Introduction to VMware vSphere VMware vSphere ...

How to deploy MongoDB container with Docker

Table of contents What is Docker deploy 1. Pull t...

Web page comments cause text overflow in IE

The experimental code is as follows: </head>...

WeChat applet realizes left-right linkage

This article shares the specific code for WeChat ...

Vue3 based on script setup syntax $refs usage

Table of contents 1. Vue2 syntax 2. Use of Vue3 1...

Vue implements an Input component that gets the key display shortcut key effect

I encountered a requirement to customize shortcut...

Linux kernel device driver address mapping notes

#include <asm/io.h> #define ioremap(cookie,...