如何编辑文件后我shell到docker容器? [英] How to edit file after I shell to a docker container?

查看:145
本文介绍了如何编辑文件后我shell到docker容器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用

docker exec -i -t 69f1711a205e bash

现在我需要编辑文件,我没有在

Now I need to edit file and I don't have any editors inside

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
root@69f1711a205e:/#

如何编辑文件?

推荐答案

与评论一样,没有默认的编辑器 - 奇怪 - code> $ EDITOR env变量为空。您可以通过以下方式登录到容器中:

As in the comments, there's no default editor set - strange - $EDITOR env variable is empty. You can login into container with:

docker exec -it <container> bash

并运行:

apt-get update
apt-get install vim

或使用以下Docker文件:

or use the following Dockerfile:

FROM  confluent/postgres-bw:0.1

RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "vim"]

编辑

Docker图像被传递修剪到最低限度 - 所以没有编辑器发货集装箱这就是为什么需要手动安装。

Docker images are delivered trimmed to bare minimum - so no editor is installed with the shipped container. That's why there's a need to install it manually.

这篇关于如何编辑文件后我shell到docker容器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆