跳到正文

新浪的 docker 容器 SC2 如何在线编辑文件? vi/vim/nano/emacs 都没,貌似也不能 sudo

网友提供8 条回复
用的 python 容器,用的 Web 终端

~$ vi
bash: vi: command not found
~$ vim
bash: vim: command not found
~$ nano
bash: nano: command not found
~$ emacs
bash: emacs: command not found
~$ sudo
bash: sudo: command not found
~$ apt-get install vim
E: Could not open lock file /var/lib/dpkg/lock - open (13: Permission denied)
E: Unable to lock the administration directory (/var/lib/dpkg/), are you root?
~$ su
su: must be run from a terminal

回复

fzinfz

@youxiachai 我要文本编辑器。。。 /再次手动忧伤脸

@66450146 貌似不支持 dockerfile : https://www.sinacloud.com/doc/sae/docker/python-getting-started.html

@cxbig 提醒我了,可以找个类似 phpfm 那样的简易在线编辑器,感谢~~ /手动兴奋脸~

@ETiV 能用 apt , debian/ubuntu 系的吧,具体不知, whoami/groups 结果都是“ u12345 ”

ETiV

基础镜像是啥…
sudo 都找不到的话估计是没在 path 下?

可以看看 groups 命令,就大概知道自己能不能用 sudo 了

cxbig

通常来说 docker 都是准备好文件丢进去
真要有一堆文件要编辑,做一个 sftp 共享,编辑器挂载远程文件夹修改好了

66450146

写个 Dockerfile 自己 build 一下呗。。。

youxiachai

tee 应该可以吧?

cat 一份出来,修改完用 tee 粘贴一下

fzinfz

sed/awk 能用,可惜我不会。。。
目前看起来可行的只有 python/open 编辑了吗。。。

fzinfz

@wweir 我要编辑,不要新建。。。 /手动忧伤脸

wweir

echo 打法好,重定向大法好

↑