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

后端 未结 16 1975
你的背包
你的背包 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:54

    If you don't want to add an editor just to make a few small changes (e.g., change the Tomcat configuration), you can just use:

    docker cp :/path/to/file.ext .
    

    which copies it to your local machine (to your current directory). Then edit the file locally using your favorite editor, and then do a

    docker cp file.ext :/path/to/file.ext
    

    to replace the old file.

提交回复
热议问题