Portainer CLI access

Discussion of applications not mentioned above.
Post Reply
User avatar
mutedjam
Posts: 2
Joined: 01 Dec 2023, 23:37

Portainer CLI access

Post by mutedjam »

Hi folks, first of all I wanted to say hello! Decided to get a TerraMaster NAS (F2-223) after browsing this forum quite a bit, so thanks a million everyone!

One problem for which I couldn't find a solution was the one described here. Since this problem still persisted with my current TOS version 5.1.95 on my NAS, here's what I did to fix it (assuming the default Portainer app from the TOS App Center):

1. Connect to the NAS via SSH (make sure the Allow SSH access option is enabled under Control Center > Network Services > Terminal & SNMP
2. Create a backup of /etc/nginx/conf.d/portainer.conf just in case:

Code: Select all

cp /etc/nginx/conf.d/portainer.conf $HOME/portainer.conf.backup
3. Open /etc/nginx/conf.d/portainer.conf for editing:

Code: Select all

nano /etc/nginx/conf.d/portainer.conf
4. Add the headers required for nginx to allow websockets connections. The file should look like so:

Code: Select all

location /portainer/ {
	proxy_pass http://127.0.0.1:19000/;
	proxy_http_version 1.1;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "Upgrade";
}
5. Restart nginx using

Code: Select all

service nginx restart
Afterwards opening a console within Portainer works as expected for me:

Image

Note: I only have a single NAS, so couldn't test run extensive tests here. This approach might not survive an OS update, your device might use a port other than 19000 for portainer, etc. Pay close attention to the existing content of /etc/nginx/conf.d/portainer.conf and any error messages or warnings you might encounter. Make sure to document what exactly you do so you can revert changes if something breaks along the way.

Hope this helps :)
User avatar
mutedjam
Posts: 2
Joined: 01 Dec 2023, 23:37

Re: Portainer CLI access

Post by mutedjam »

mutedjam wrote: 02 Dec 2023, 00:02

Code: Select all

nano /etc/nginx/conf.d/portainer.conf
Sorry folks, just noticed I made a mistake after sending. This command won't work by default as nano is not available on TOS. Instead you have to use

Code: Select all

vi /etc/nginx/conf.d/portainer.conf
to edit the file using vi. This editor is not immediately intuitive, but here's a quick cheat sheet if needed.
User avatar
mightymouse
Posts: 14
Joined: 17 Dec 2023, 08:13

Re: Portainer CLI access

Post by mightymouse »

I have created an account just to say you're an absolute legend. This works perfectly, thank you!
User avatar
topo01
Posts: 45
Joined: 27 Dec 2022, 20:19
Germany

Re: Portainer CLI access

Post by topo01 »

{L_BUTTON_AT}mutedjam
Thank you so much! You are a genius!

It's really a shame this remains unfixed by the TM-team...
F2-220, TOS 5.1.123 (8GB system partition), Docker 2.0.16 (Nextcloud, AdGuard Home), Terra Photos 2.0.13
User avatar
mightymouse
Posts: 14
Joined: 17 Dec 2023, 08:13

Re: Portainer CLI access

Post by mightymouse »

The solution doesn't seem to survive a restart for me so I decided to uninstall the Portainer app from the store and install it manually. I can confirm this way the CLI works as it should and the Portainer version is at it's latest one (unlike the outdated one from the store).

If you want to give it a go...
1.) Stop and delete all containers and stacks from you existing Portainer instance
2.) Uninstall Portainer (might as well also chose to delete all config and data at this point when prompted)
3.) SSH into the NAS and spin up Portainer using

Code: Select all

docker run -d --name=portainer_ce --restart always -v /Volume1/docker/portainer_ce/data:/data -v /var/run/docker.sock:/var/run/docker.sock -p 9000:9000 --pid=host portainer/portainer-ce:latest
4.) That's all, no further configs required. Just set up and deploy your stacks like previously, the container data are untouched so your containers will just spin up and run as they did previously without the need for further configs.
User avatar
DCCentR
Posts: 7
Joined: 14 Apr 2024, 16:08
Russia

Re: Portainer CLI access

Post by DCCentR »

mutedjam wrote: 02 Dec 2023, 00:02
Thanks for the workaround! I hope terramaster will fix this in new version of portainer
F4-424 Pro
Post Reply

Return to “Others”