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

后端 未结 16 1881
你的背包
你的背包 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 14:47

    See Stack Overflow question sed edit file in place

    It would be a good option here, if:

    1. To modify a large file, it's impossible to use cat.
    2. Install Vim is not allowed or takes too long. My situation is using the MySQL 5.7 image when I want to change the my.cnf file, there is no vim, vi, and Vim install takes too long (China Great Firewall). sed is provided in the image, and it's quite simple. My usage is like

      sed -i /s/testtobechanged/textwanted/g filename

      Use man sed or look for other tutorials for more complex usage.

提交回复
热议问题