Changing the name of a remote agent in docker
Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
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. H
owever 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"
Was this helpful?