Change Node-Name when agent is running via docker

hi there,

this new cloud looks very interesting and i already tested my first node, i used the docker agent,
but - i am not surprised - the hostname is NOT the host itself, the hostname of the docker container is used…
i also tried the param “-host” as explained here: Connect Agent to Cloud | Learn Netdata
but still i only see the docker-containers-hostname. how can i change that ?

alt text

thanks !
micha

As an alternative to the Docker hostname thing mentioned by Zack, you can manually override the hostname that Netdata reports in the netdata.conf file by adding a hostname key under the [global] section. This obviously doesn’t scale well if you have a lot of nodes, but if you’ve only got one or two it can be a much easier solution than trying to get Docker to give all the containers sane hostnames.

1 Like

You may have to create networks and assign hostnames for containers within those networks using docker network create and following up with docker run -h human_readable_hostname --ip [an ip on the network] --net [the network created]. These commands will have some additional options based on what exactly you are trying to run…

It might be easier to use docker-compose for something like that. In any case I think the trick is to set a readable hostname for the container.

We also have a lengthy docker guide but I don’t think it covers this specific question.

1 Like

the same concern , T T

Hi @iamvicliu, welcome to Netdata.
To rename the container IDs with the actual names of your containers, please try the following:

Please let me know in case the instructions don’t work for you and we can take it from there.

Hello. I am experiencing a bit of the same issue.

I am running netdata deployed in a docker swarm using global mode across 10+ nodes, hence settings hostname on individual nodes is cumbersome.

I have used the docker swarm compose provided by netdata.

The documentation states that:

Alternatively, you can directly use the hostname from the node running the container by mounting /etc/hostname from the host in the container. With docker run , this can be done by adding --volume /etc/hostname:/etc/hostname:ro to the options. If you are using Docker Compose, you can add an entry to the container’s volumes section reading - /etc/hostname:/etc/hostname:ro .

This is default in the provided swarm deployment compose, however, it does not reflect on the nodes when they show up, they have the docker container name as hostname.

anda@my-server-hostname1:~$ docker exec -it netdata_netdata.mouo9h9qrkicsyd4drkfn9p8f.3nfl8kgukb8u01dtkvuv61mjo bash
bash-5.1# echo $HOSTNAME
653f646e5ef3
bash-5.1# cat /etc/hostname 
my-server-hostname
bash-5.1# 

It seems like this is not inteded bevavior, or am I missing something?

Hi @anda ,

Thanks for sharing this with us, @Austin_Hemmelgarn maybe you can help on this one?

Hello, and thank you for quick response.

I solved it, by adding

hostname: "{{.Node.Hostname}}"

to my compose.

Maybe i misunderstood something, but it seems like the steps described in the documentation does not work, which means the provided docker-compose for swarm for adding nodes, does not work as inteded also.