Currently all my nodes have the name ubuntu-yakkety.
docker node ls
ID HOSTNAME STATUS AVAILABILITY MANAGER STATUS
d7rdq4n4dmrkhyz4ov7ldr31e ubuntu-yakkety Ready Active
iddxyuic586lnla6aw700rdwc ubuntu-yakkety Ready Active
zxcr1yvveccj4soyh2hsjjebk * ubuntu-yakkety Ready Active Leader
In order to create better filters that would be great if I could update node's hostname as node-01
node-02
... node-99
However, I couldn't find any way to accomplish it in the documentation.
1) Is it possible to update the hostname of an existing Docker node?
2) Is it possible giving a name to a node while joining to swarm?
Running the command "sudo nsenter --target 1 --uts hostname <my new hostname>" from inside the container did the trick.
In the same way, a container's hostname defaults to be the container's ID in Docker. You can override the hostname using --hostname . When connecting to an existing network using docker network connect , you can use the --alias flag to specify an additional network alias for the container on that network.
Run docker node update --label-add on a manager node to add label metadata to a node. The --label-add flag supports either a <key> or a <key>=<value> pair. The labels you set for nodes using docker node update apply only to the node entity within the swarm.
But, to answer your question, there is no way to manually set the swarm leader. However, what you can do is docker node demote the leader (swarm2), and the other manager (swarm3). Once the managers are demoted to workers, swarm1 by default becomes the leader.
change hostname: hostname ***
or vi /etc/hosts
restart docker: sudo systemctl restart docker
You can see 'Name' user docker info
This trio works well:
echo '127.0.0.1 <hostname>' | sudo tee -a /etc/hosts
sudo hostnamectl set-hostname <hostname>
sudo systemctl restart docker
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With