alpine container image terminal incorrect, text editors unusable

inbouto

New Member
Mar 1, 2020
5
0
1
44
Hi.
When I tried to setup an alpine container, I couldn't use nano or vim and would receive an error regarding the $TERM variable. Its value was "vt[container#]"
I'm not a linux expert by any means, but when I tried using the latest debian container instead, the $TERM value was just "linux". So I went back in the alpine container and changed the $TERM variable to "linux" and it worked just fine.
I don't know what exactly happened but I'm under the impression that something was wrong with the alpine image. Hopefully this post is helpful.
 
hi,

i can reproduce this issue as well.

i'll take a look at let you know
 
@matrix
my point is that, after installing nano or vim, the app fails to start (in the case of nano) or does not run correctly (vim).
 
Hi,

- What the error output when you type nano in terminal?
- See the PATH if correct path echo $PATH it should be like /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin if not correct, just add it to your PATH like this command
Bash:
export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 
@matrix
the $PATH is correct. That's not the issue.
The issue, like I said, is the $TERM variable.
The error I get when opening nano is
"Error opening terminal: vt102."
this is on CT #102.
Like I said, my workaround is to change the $TERM variable to "linux", since that's what it's set to on the debian container.
 
it seems like the $TERM variable is set correctly in /var/lib/lxc/CTID/config with the lxc.environment parameter, however the alpine container seems to ignore this (cause is yet unclear)

a workaround until this gets fixed is to simply set the $TERM variable manually in .bashrc or similar file
 
I can confirm this behavior.

But $TERM gets set to vt102 regardless of the CT number (I got this issue on a freshly installed container CT100 from the alpine-3.10-default_20190626_amd64 image on Proxmox VE 6.1-8 / Debian 10, using the PVE web console).

When I login using ssh, $TERM is set to my own terminal environment (xterm-256color).
 
Same issue.

Btw: If I configure the interface for IPv6 to use SLAAC it always uses "manual" and not auto.
 
so, lxc.environment is only giving the TERM=linux env. variable to the init process, this is by design in lxc. sadly there's not much we can do here when init doesn't pass it forward..

to fix the vim terminal errors, you can do this in your container: echo "export TERM=linux" > $HOME/.profile and it should set the TERM variable correctly.
for the current session also run: source $HOME/.profile and vim will function normally.

when you log in next time it should pick up the correct TERM variable from the .profile
 
so, lxc.environment is only giving the TERM=linux env. variable to the init process, this is by design in lxc. sadly there's not much we can do here when init doesn't pass it forward..

..skip..

I have another question. How do I save changes for /var/lib/lxc/<NUMBER>/config files ? Because after rebooting the container, the variable TERM returns to the default value.
 
How do I save changes for /var/lib/lxc/<NUMBER>/config files ? Because after rebooting the container, the variable TERM returns to the default value.
you can't, those files are regenerated by the PVE stack (and used by LXC).

see the workaround above for your .profile
 
you can't, those files are regenerated by the PVE stack (and used by LXC).

see the workaround above for your .profile

Yes, I know about it. But this .profile doesn't affect the environment when we use the "pct enter <ID>" command.
 
when i check the latest alpine templates we have, it seems like this issue is already fixed (the $TERM variable is set to linux already by default).
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!