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.
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
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#
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.]
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.
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…
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.
Why do you need an editor inside the container? You should be writing your own Dockerfile and/or docker-compose file that takes the stock nginx container image and customizes it to your liking. Then you just launch that.
I do agree there are occasions when it’s faster to experiment by changing a file on the fly, but even then I use docker cp to copy the file out, make my changes on the host and then docker cp the file back in. Or I just bind mount the config dir and make my edits on the host.
So please describe the problem you are trying to solve and maybe we can suggest a better work flow for you.
I do have a docker container running with custom user with read-only mode for security reasons. Now the trade off is debuggability, we are unable to install any text editors.