How to get hostname from node-exporter in Docker Swarm?
You just have to use the hostname on your docker compose file like this:

hostname: whatever-{{.Node.Hostname}}


Note that you have to prepend something to the hostname to avoid hostnames duplicates.