我成功地shell到Docker容器使用:
docker exec -i -t 69f1711a205e bash
现在我需要编辑文件,我没有任何编辑器在里面:
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:/#
如何编辑文件?
在注释中,没有默认的编辑器设置-奇怪- $ editor环境变量是空的。您可以通过以下方式登录到容器:
docker exec -it <container> bash
并运行:
apt-get update
apt-get install vim
或者使用下面的Dockerfile:
FROM confluent/postgres-bw:0.1
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "vim"]
Docker镜像在交付时被裁剪到最少——所以没有编辑器被安装在发货的容器中。这就是为什么需要手动安装它。
EDIT
我也鼓励你阅读我关于这个话题的文章。
在注释中,没有默认的编辑器设置-奇怪- $ editor环境变量是空的。您可以通过以下方式登录到容器:
docker exec -it <container> bash
并运行:
apt-get update
apt-get install vim
或者使用下面的Dockerfile:
FROM confluent/postgres-bw:0.1
RUN ["apt-get", "update"]
RUN ["apt-get", "install", "-y", "vim"]
Docker镜像在交付时被裁剪到最少——所以没有编辑器被安装在发货的容器中。这就是为什么需要手动安装它。
EDIT
我也鼓励你阅读我关于这个话题的文章。