Matheus Gontijo
Matheus Gontijo

Reputation: 1307

Can I update the hostname of a Docker Node?

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?

Upvotes: 8

Views: 4982

Answers (3)

ericW
ericW

Reputation: 31

You will have to login each nodes and set the node hostname use command:

sudo hostnamectl set-hostname <hostname>

Once you changed all nodes hostname, go the the manager node and restart your docker, after that you should be good.

Upvotes: 0

anand
anand

Reputation: 705

This trio works well:

echo '127.0.0.1 <hostname>' | sudo tee -a /etc/hosts
sudo hostnamectl set-hostname <hostname>
sudo systemctl restart docker

Upvotes: 6

xiaorun
xiaorun

Reputation: 136

  1. change hostname: hostname *** or vi /etc/hosts

  2. restart docker: sudo systemctl restart docker

You can see 'Name' user docker info

Upvotes: 6

Related Questions