How to programmatically set a Docker agent's name

If you are planning to programmatically deploy agents to your Beezkeeper, you probably want to name the accordingly since they will appear with their generic name which is their IP address and the last four characters of their MAC address.

Here are the instructions for naming the docker agents from the agent side:

echo "AGENT_NAME" > agent-name.txt
docker run -d --restart=always -v "$(pwd)"/agent-name.txt:/usr/local/netbeez/agent-name.txt -e "NB_SECRET_KEY=INSERT_SERVER_SECRET_KEY" -e "AGENT_UUID=my-test-docker-name" netbeez/nb-agent

A lot of the options I included here are optional, but the important part is mounting the file that contains the agent’s name in the container at: /usr/local/netbeez/agent-name.txt

Note 1: Once the agent’s name is set on the dashboard, changing that name on the agent-name.txt file is not going to be reflected on the dashboard. You’d have to edit the agent’s name from the dashboard and clear the field before it gets the new name from the agent once it re-connects to the dashboard.

Note 2: Please also note that if these agents will keep getting recreated then it would be wise to set the AGENT_UUID variable on a per agent basis, which would remain consistent across runs.

Let us know what is you specific use-case and we can help you adjust this process for your needs!

1 Like