How to edit file after I shell to a docker container?

0 votes

I successfully went inside docker container by using below command:

docker exec -i -t 69f1711a205e bash

Now I need to edit file and it seems like I don't have any editors inside the container.

root@69f1711a205e:/# nano
bash: nano: command not found
root@69f1711a205e:/# pico
bash: pico: command not found
root@69f1711a205e:/# vi
bash: vi: command not found
root@69f1711a205e:/# vim
bash: vim: command not found
root@69f1711a205e:/# emacs
bash: emacs: command not found

How do I edit files?

Can anyone help me with this?


Sep 11, 2018 in DevOps & Agile by shubham
• 6,560 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

Since docker images are trimmed to bare minimum configuration so that it can be lightweight therefore no editor is installed with the shipped container. That's why there's a need to install it manually. You can use below command to install an editor.

docker exec -it <container> bash

and run:

apt-get update
apt-get install vim

or use the following Dockerfile:

FROM  confluent/postgres-bw:0.1

RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "vim"]
answered Sep 11, 2018 by Damon Salvatore
• 5,450 points

Related Questions In DevOps & Agile

+1 vote
2 answers

How do I run Apache server from Docker without mapping to a location?

If you're seeing a 500 error, that's ...READ MORE

answered Oct 18, 2018 in DevOps & Agile by lina
• 8,100 points
+13 votes
5 answers

How do I run a cron job inside a docker container

If you can SSH into your server ...READ MORE

answered Jul 27, 2018 in DevOps & Agile by Kalgi
• 36,300 points
0 votes
1 answer
0 votes
1 answer

How do I restart a single container with docker-compose?

Actually it's not that difficult. Here is ...READ MORE

answered Nov 8, 2018 in DevOps & Agile by Damon Salvatore
• 5,450 points
0 votes
1 answer
0 votes
1 answer

Deploy Docker Containers from Docker Cloud

To solve this problem, I followed advice ...READ MORE

answered Sep 3, 2018 in AWS by Priyaj
• 56,140 points
0 votes
1 answer
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.