Editing Content in Docker Container

Pawel Grajewski
2 min readDec 27, 2020

I start my journey with docker a few mounts ago. It fixes many problems with environments and dependencies but when I started to use it more with more complicated think and get a problem with content which is in the docker container package. I have started thinking about how to solve the problem. How can I edit content in the docker container. The problem was with the old package puput wagtail blog system CMS and the mistake was in a template that was situated in the package. The first thought was to open the container and edit the file but first, we must install a program to edit this file, and this how can handle it:

First, we must enter our container to do it I use visual studio code extension Docker which helps to work with docker as a visual environment to show the content of images, containers, volumes all that stuff to see you will use many commands. By clicking right click on docker container we have the option Attach Shell which will start the shell in our terminal panel. Then the magic commands:

root@4b72fbabb0af:/app# apt-get update
root@4b72fbabb0af:/app# apt-get -y install vim

That's what your system needs and then with vim, we can edit what we need . This is a solution for local deployment for a fast fix in normal project better solution will be to add the package as a folder in the main folder and use it as python module but editing content in a container can be helpful or sometimes necessary when we want to check or fix one line of code which break our app.

Helpful links:

--

--