1

I tried to do what is mentioned in: Multiple Docker containers, same image, different config

I did:

docker run --name DockerAgent1 <same image id>
docker run --name DockerAgent2 <same image id>
docker run --name DockerAgent3 <same image id>

But then I get the error:

Agent id=<unknown>. Another agent with name "DockerAgent"(id=173) is registered on the server. Please check you do not have two agents with the same name.

In teamcity I only see DockerAgent under unauthorized.

Also in my dockerfile I have also

ENV AGENT_NAME DockerAgent1

When I remove that from my dockerfile the name of the teamcityagent is ip_[number]

How can I register multiple agents in teamcity, that are using the same image in docker, while each has a different teamcity-agent name.

Matt
  • 45,022
  • 8
  • 78
  • 119
xxx2017
  • 207
  • 1
  • 5
  • 15

1 Answers1

2

You need to give different names to your agent. So use something like below

docker run --name DockerAgent1 -e AGENT_NAME=DockerAgent1 <same image id>
docker run --name DockerAgent2 -e AGENT_NAME=DockerAgent2 <same image id>
Tarun Lalwani
  • 142,312
  • 9
  • 204
  • 265
  • I did that but when I run two agents. In teamcity I see that the first one get disconnected. – xxx2017 Jun 26 '18 at 13:20
  • I did: docker run --name DockerAgenttest1 -e AGENT_NAME=DockerAgenttest1 -d image docker run --name DockerAgenttest2 -e AGENT_NAME=DockerAgenttest2 -d image and now they are connected. Thanks for helping me. Dont know where I could find this information. – xxx2017 Jun 26 '18 at 13:30
  • Basically you needed to override the environment variables not the container name. Your `ENV AGENT_NAME DockerAgent1` gave me that hint. So you didn't need documentation, just connecting the dots – Tarun Lalwani Jun 26 '18 at 13:32
  • Is docker compose also able to do this? Or should I every time I want to run 3 agents type the command for each agent in powershell? – xxx2017 Jun 26 '18 at 13:42
  • See this https://tarunlalwani.com/post/docker-compose-scale-with-dynamic-configuration-part-1/ – Tarun Lalwani Jun 26 '18 at 13:44