Docker Community Forums

Share and learn in the Docker community.

Cannot use vim, vi, nano, yum inside docker container

docker

(Bluemind2005) #1

Hi Guys,

Started a dockerised application called nginx and then executed bash inside it. To my holy surprise I cannot find vim , vi or even yum inside that container.

Please forgive me as I am very much new to docker and learning.

The below commands can be used to reproduce the issue.

docker run -d --name=my_nginxtemp nginx
docker exec -i -t my_nginxtemp bash
docker commit my_nginxtemp my_nginx

My Host is Ubuntu 16.04 and I am using Latest docker-engine and docker cli

root@jim-Ubuntu1504:/home/jim/web# docker version
Client:
Version: 1.11.2
API version: 1.23
Go version: go1.5.4
Git commit: b9f10c9
Built: Wed Jun 1 22:00:43 2016
OS/Arch: linux/amd64

Server:
Version: 1.11.2
API version: 1.23
Go version: go1.5.4
Git commit: b9f10c9
Built: Wed Jun 1 22:00:43 2016
OS/Arch: linux/amd64
root@jim-Ubuntu1504:/home/jim/web#

Please don’t go on my hostname I have upgraded since 15.04 :slight_smile:
root@jim-Ubuntu1504:/home/jim/web# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04 LTS
Release: 16.04
Codename: xenial
root@jim-Ubuntu1504:/home/jim/web#

Any help would be very much appreciated !!

Many Thanks
Jim


(David Maze) #2

They’re not required to run most applications, and it’s not at all unusual to install only the minimum amount of stuff required to actually run things. (A couple of containers I build don’t even have a shell!)

Also, many public images are built on a Debian or Ubuntu base, and those will have apt-get and not yum.

[If you docker run -it ubuntu:16.04 bash, there will not be a vi, you need to manually install it.]


(Bluemind2005) #3

Ok, I am still finding it difficult to understand the utility of “docker”. I posted the same question on another forum and response I got I would to share. nginx is the base image and they don’t have vim. I was advised to use nginx and build on the top of that.


(Gmcollins) #4

As the previous reply stated… You can install the packages needed after the container is up… If you want the
packages installed at runtime then look into creating your own image to use. You can baseline from nginix.
Then add your packages… See references to Dockerfile or simple google finds this…


(Packeteer) #5

Containers are not VM’s, thus a different approach is required.

ie. a container should only have the daemon and related tools and nothing else.

keep the editing / management tools in the host, and then mount configs to the container


(Stuartzvernonco) #6

Also, if you want to be able to use nano when entering a container, you will need to set
-e TERM=xterm
in the docker run command or docker-compose.yml file for it to display correctly.


(Davidhu) #7

you can run:
apt-get update
apt-get install vim -y


(Jarfar) #8

Actually you don’t have to use vim in container, try lighter version vim-tiny:
apt-get update
apt-get install -y vim-tiny


(Poojaraja) #9

Thanks Jarfar. This helped. :slight_smile:


(Schitipr) #10

I am getting permission denied error while executing apt-get update as below

Reading package lists… Done
E: List directory /var/lib/apt/lists/partial is missing. - Acquire (13: Permission denied)