Changing the name of a remote agent in docker

Still need help?

The Atlassian Community is here for you.

Ask the community

Problem

A remote agent running inside a docker container takes the container ID as the name by default as it's based on hostname. The hostname can be modified with docker run -h myhostname. However even after specifying a new hostname for the container –  the name won't change if the <bamboo-agent-home>/bamboo-agent.cfg.xml is built into the image.

Cause

When the remote agent first connects to Bamboo, it sends the specified hostname as its name, which is then registered and stored in Bamboo's database. If the agent's already registered with the server even if you change the hostname it will tie it back registered agents by UID/ID and retain the old name.

Resolution

Modify the hostname of the container with docker run -h myhostname <image>. If the name still doesn't change due to an existing <bamboo-agent-home>/bamboo-agent.cfg.xml:

  • Rename the Agent from Bamboo Administration > Overview > Agents > Edit (it has to be done every time a new container is run)
  • Or delete the bamboo-agent.cfg.xml file from the <bamboo-agent-home> – this will force the agent to regenerate a new one with a new ID but your old agent will still remain in the list of Agents until removed. You could do this in your docker run command but it's better to make sure this file doesn't exist in the base image (please note, by removing this file the agent will be treated as new and require re-authentication) – so it entirely depends on how you want to automate your swarm.
    • e.g. docker run -h myhostname ...... /bin/bash -c "rm /home/user/bamboo/agent-home/bamboo-agent.cfg.xml"


Last modified on Nov 30, 2017

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.