How do I edit a file after I shell to a Docker container?

后端 未结 16 1768
你的背包
你的背包 2020-11-29 14:22

I successfully shelled to a Docker container using:

docker exec -i -t 69f1711a205e bash

Now I need to edit file and I don\'t have any edito

16条回答
  •  有刺的猬
    2020-11-29 15:08

    You can open existing file with

    cat filename.extension
    

    and copy all the existing text on clipboard.

    Then delete old file with

    rm filename.extension
    

    or rename old file with

    mv old-filename.extension new-filename.extension
    

    Create new file with

    cat > new-file.extension
    

    Then paste all text copied on clipboard, press Enter and exit with save by pressing ctrl+z. And voila no need to install any kind of editors.

提交回复
热议问题