Edit files in Docker container with Terminal

To login to a Docker container you can run the following command:

docker exec -it your_container_name bash

Once you have logged into the container you will need install your favourite editor such as Nano or Vim.

apt-get update

apt-get install nano

When trying to edit a file you might encounter the following error:

Error opening terminal: unknown.

This is a known bug in Docker and can be solved by running the following command:

export TERM=xterm