-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Setting-up docker container hostname via environment variable #3122
Comments
Hi @jo-chemla let me reword in order to be sure that i understand this enhancement request goal. When you run Glances Docker image from Portainer, then hostname in the system plugin is not displayed correctly. So you need a way to use a environment variable ${CUSTOM_HOSTNAME} in this plugin. Is it correct ? Nevertheless, do you know that the message (displayed by system's plugin) is configurable deom the configuration file:
For the moment it is not possible to use environment's variables in the system_info_msg value but the improvement is possible. In the meanwhile you can set it statically. |
Thanks for getting back. That's indeed correct, except that I don't know about the system plugin. The glances container It is probably set by portainer or docker when it creates the container, also probably due to a portainer bug introduced recently which does not populate environment variables and might get resolved at some point. It would therefore be useful to pass-through that hostname variable from docker host to container. After reading through the demo config, that Thanks! |
By the way, is there a way to reduce the RAM memory footprint for glances? The command with export to influxdb does show some pretty high memory footprint: I assume there is a way to do so via glances retention policies, similar to how netdata does it
# netdata.conf
[db]
mode = dbengine
dbengine tier backfill = new
storage tiers = 3
dbengine page cache size = 1.4GiB
# storage tier 0
update every = 1
dbengine tier 0 retention space = 12GiB
# storage tier 1
dbengine tier 1 update every iterations = 60
dbengine tier 1 retention space = 4GiB
# storage tier 2
dbengine tier 2 update every iterations = 60
dbengine tier 2 retention space = 2GiB EDIT: I've tried to set |
Is your feature request related to a problem? Please describe.
Context is mentioned here, I'm using portainer edge stacks to deploy a
glances agent
on a list of servers. Portainer does not pass its own container hostname to the containers created from the stack. Passing theHOSTNAME
environment variable from aenv_file: .env
in the compose stack, or mapping the/etc/hostname:/etc/hostname:ro
is not sufficent enough, since running thehostname
command on the container will show a hostname different from both values.Describe the solution you'd like
It would be nice if hostname could be passed to the docker container as an environment variable. This way it would be possible to have an explicit name that is dependent on the real host hostname, rather than a manually set value. Manually setting that value is indeed impossible for agents deployed as portainer stacks.
Describe alternatives you've considered
Using one
.env
per host is probably the solution, but docker-compose doees not populate environment variables likehostname: ${CUSTOM_HOSTNAME}
Also, it is possible using such endpoint could potentially work, but at the moment I'm faced with error:
hostname: sethostname: Operation not permitted
. Orcap_add: - SYS_ADMIN
but would give root access to host.The text was updated successfully, but these errors were encountered: