'Is there any text editor inside docker container?

I have run 3 docker containers on one server.One - with nginx, two - with node apps.I can enter inside nginx container using exec command, but I want to look through the hosts file in etc. Is there any ability to do this?

Update There is only cat util. You can call it as cat your_filename



Solution 1:[1]

If you docker is a linux emulation, you can use nano.

$ nano file.txt

If you only want to read the file, but not edit it, you can do this:

$ less file.txt

Solution 2:[2]

The node images do not have these utilities, in order to keep them lightweight for production environments.

Once you've gotten into the container (with docker exec -it (containerName) bash) you can install nano using apt-get update followed by apt-get install nano.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Gregory