How to edit Docker container files from the host?

前端 未结 9 2218
孤城傲影
孤城傲影 2020-12-13 08:51

Now that I found a way to expose host files to the container (-v option) I would like to do kind of the opposite:

How can I edit files from a running container with

9条回答
  •  囚心锁ツ
    2020-12-13 09:15

    The best way is:

      $ docker cp CONTAINER:FILEPATH LOCALFILEPATH
      $ vi LOCALFILEPATH
      $ docker cp LOCALFILEPATH CONTAINER:FILEPATH
    

    Limitations with $ docker exec: it can only attach to a running container.

    Limitations with $ docker run: it will create a new container.

提交回复
热议问题