Change files inside the container using code-server¶
Overview
This guide will show you how to edit files in the volume of a running container using code-server.
Prerequisites
- Container with volume up and running (Example: Node-RED Documentation)
- CMTK Device connected to the internet
Install code-server¶
Access the list of containers by clicking on Containers
in the navigation menu on the left. This page is listing all the currently active containers. Click on Add container
to add your own container.
Portainer will automatically generates unique names for deployed containers but feel free to enter a name to easily identify your new container. Next, enter the name of your image in the image configuration section. In this case the correct name is linuxserver/code-server
.
In order to access the container in your browser, you need to publish a network port in the network port configuration. Click on publish a new network port
and enter port 50001
for the host and 8443
for the container.
Note
You may only use ports in the range from 49152 to 65535 on the host side.
At the very bottom of the page you will find the Advanced container settings
section. Click on Volumes
within that section and map additional volume
. To access in example the data of Node-RED you need to map /data
in the container to the volume node-red-local
.
Note
Here you can access all volumes that you have created. Just select the one you want to change.
The next setting that needs to be done is to set the user who is allowed to edit the files. Click on Env
within that section and Add an environment variable
. To change in example the data of Node-RED you need to set the PUID
in the container to the value 1000
and the PGID
also to the value 1000
.
Note
Here you can write to all different containers. You only need to enter the same user that is authorized in the container.
Click on Deploy the container
to save the changes, pull the image from DockerHub and start the container. This may take a few minutes. Afterwards Portainer will automatically return to the containers page.
Now you can access code-server using http://cmtk.local:50001. If you are using a different hostname or IP-address to access your device, replace cmtk.local accordingly.
Edit files in code-server¶
Click on Mark Done
to skip the instructions. Then you can click on Open Folder...
and enter /data/
and then click on OK
.
Then you can view, edit and delete the files on the left side. It is also possible to add files via drag and drop. After you are done, you only have to restart the target container (here node-red) so that these settings are applied. (Of course it depends on the settings, some containers don't need a restart).
Note
After you are done, it is best to shut down the container to avoid security issues.