How to Edit file content in docker container without installing any editor

In Docker, there's not any default editor. We can edit files by installing any editor manually for example: vim, gedit etc.

However if we want to change very minute things in files or if we don't want to install any editor we can do this by following below steps:

In your command line Run:

docker cp containername:/your/file.ext .

. represents destination path.

This will copy your file to your local machine where you can edit it with your favourite editor.

Then run,

docker cp file.ext containername:/your/file.ext

It will replace your old file on container with edited local file.