Public Repository

Last pushed: a day ago
Short Description
TeamCity Build Agent
Full Description

TeamCity Build Agent

This is an official JetBrains TeamCity build agent image.

TeamCity build agent connects to the TeamCity server and spawns the actual build processes.
You can use jetbrains/teamcity-server image to run TeamCity server.

This image adds TeamCity agent suitable for Java development. It is based on jetbrains/teamcity-minimal-agent but gives you more benefits, e.g.

  • client side checkout if you use 'git' or 'mercurial'
  • more bundled build tools
  • 'docker-in-docker' on Linux

Image Tags

All default tags in docker images refers to the Linux images. Windows docker images have suffixes -windowsservercore and -nanoserver:

  • jetbrains/teamcity-agent, jetbrains/teamcity-agent:latest (ubuntu)
  • jetbrains/teamcity-agent:latest-windowsservercore (windowsservercore)
  • jetbrains/teamcity-agent:latest-nanoserver (nanoserver)

Current Status

Experimental image, feedback is welcome.

How to Use This Image

Pull TeamCity image from the Docker Hub Repository

jetbrains/teamcity-agent and

use the following command to start a container with TeamCity agent running inside Linux container:

docker run -it -e SERVER_URL="<url to TeamCity server>"  \ 
    -v <path to agent config folder>:/data/teamcity_agent/conf  \      
    jetbrains/teamcity-agent

or Windows container:

docker run -it -e SERVER_URL="<url to TeamCity server>"
    -v <path to agent config folder>:C:/BuildAgent/conf
    jetbrains/teamcity-agent:latest-nanoserver

where
<url to TeamCity server> - is full URL for TeamCity server, accessible by the agent. Note that "localhost" will not generally not work as that will refer to the "localhost" inside the container.
<path to agent config folder> - is the host machine directory to serve as TeamCity agent config directory. We recommend to provide this binding in order to persist agent configuration, e.g. authorization on the server. Please note that you should map a different folder for every new agent you create.

You can also provide your agent's name using -e AGENT_NAME="<agent name>". If this variable is omitted the name for the agent will be generated automatically by the server.

When you run the agent for the first time you should authorize it via TeamCity server UI - go to the Unauthorized Agents page in your browser. See more details.
All information about agent authorization is stored in agent's configuration folder. If you stop the container with the agent and then start a new one with the same config folder - the agent's name and authorization state will be preserved.

TeamCity agent does not need manual upgrade: it will upgrade itself automatically on connection to an upgraded server.

In Linux container if you need Docker daemon available inside your builds you have two options:

1) Docker from the host (in this case you will benefit from the caches shared between the host and all your containers, but drawback is the security issue - your build actually can harm your host Docker, so it is on your own risk)

docker run -it -e SERVER_URL="<url to TeamCity server>"  \
    -v <path to agent config folder>:/data/teamcity_agent/conf \
    -v /var/run/docker.sock:/var/run/docker.sock  \
    jetbrains/teamcity-agent

2) New Docker daemon running within your container (please note that in this case the container should be run with —privileged flag)

docker run -it -e SERVER_URL="<url to TeamCity server>"  \
    -v <path to agent config folder>:/data/teamcity_agent/conf \
    --privileged -e DOCKER_IN_DOCKER="start" \
    jetbrains/teamcity-agent

Windows Containers Limitations

Details about known problems in Windows containers are available on the Known Issues page.

Customization

You can customize the image usual Docker procedure:

Run the image

docker run -it -e SERVER_URL="<url to TeamCity server>"  \ 
    -v <path to agent config folder>:/data/teamcity_agent/conf  \
    --name="my-customized-agent"  \
    jetbrains/teamcity-agent-minimal  \

enter into the container

docker exec -it my-customized-agent bash

and change whatever you need.
Then exit and create new image from the container

docker commit my-customized-agent <the registry where you what to store the image>

License

The image is available under the TeamCity license.
TeamCity is free for perpetual use with the limitation of 20 build configurations (jobs) and 3 agents. Licensing details.

Feedback

Report issues of suggestions into official TeamCity issue tracker.

Under The Hood

This image is built on top of TeamCity base image which includes:

  • ubuntu:xenial (Linux)
  • microsoft/windowsservercore or microsoft/nanoserver (Windows)
  • Oracle JRE 8 Update 131, 64 bit
  • curl, unzip (Linux)
  • git
  • mercurial
  • Open JDK 8
  • .NET Core SDK (Windows)
  • docker-engine (Linux):
    • v.1.9.1 (TeamCity agent 9.1.7)
    • v.1.10.3 (TeamCity agent 10.0 - 10.0.4)
    • v.1.13.0 (TeamCity agent 10.0.5 - 2017.1.2)
    • v.17.06.0-ce (TeamCity agent 2017.1.3+)

Other TeamCity Images

Dockerfile source

https://github.com/JetBrains/teamcity-docker-agent

Docker Pull Command
Owner
jetbrains

Comments (21)
shkate
4 months ago

Hi jspringer1992,

Looks like you have an error in the command line, you missed the name of the variable you are passing with -e parameter. Should be -e name='value'...

Regards,
Kate

jspringer1992
5 months ago

I'm running Docker version 1.7.1 and when trying to run the Teamcity build agent with the following parameters i'm receiving the error below:

[root@eecomtwikidev ~]# docker run -it -e "http://eecomtwikidev.internal.unicreditgroup.eu:9008" \ -v /opt/data/Docker/buildAgent/conf/:/data/teamcity_agent/conf \ -v /var/run/docker.sock:/var/run/docker.sock \ jetbrains/teamcity-agent

error:

Unable to find image ' -v:latest' locally
Invalid repository name ( -v), only [a-z0-9-_.] are allowed

Any ideas ?

ptriton
5 months ago

There is a typo under Customization:
in the run command you are using the old name (jetbrains/teamcity-agent-minimal) of the jetbrains/teamcity-minimal-agent

kjordan2001
6 months ago

@imont You can do a volume that mounts at /opt/buildagent/plugins to keep the downloaded plugins.

joeltrancon
8 months ago

Can you please make one on debian? it's easier to get to work with dotnet core & nodejs.

imont
8 months ago

Any way to configure so it doesn't re-download all the plugins every time?

jtonic
a year ago

Hi,
I tried to install and run the docker teamcity agent and I got and exception. Because of this the agent is not seen in the teamcity application.

This is the command:

docker run -it -e SERVER_URL=http://teamcity_server_ip:8111 -e AGENT_NAME=agent1 -v /path/to/teamcity-agent/conf:/data/teamcity_agent/conf --name=teamcity-agent-1 jetbrains/teamcity-agent

and this is the exception:

INFO - buildServer.AGENT.registration - Registering on server via URL http://???http://192.168.99.100:8111???. AgentDetails{Name='', AgentId=null, BuildId=null, AgentOwnAddress='null', AlternativeAddresses=[172.17.0.3], Port=9090, Version='42434', PluginsVersion='NA', AvailableRunners=[], AvailableVcs=[], AuthorizationToken='', PingCode='KmKOwK5hcMiyJ5ZsrZ3CoTHqORvfDcKp'}
[2016-11-24 21:32:09,345] WARN - buildServer.AGENT.registration - Error while asking server for the communication protocols via URL http://???http://192.168.99.100:8111???/app/agents/protocols. Will try all protocols
java.lang.IllegalArgumentException: Invalid uri 'http://???http://192.168.99.100:8111???/app/agents/protocols': Invalid authority

The teamcity server was installed and run in a docker command and the application ca be accessed at
http://teamcity_server_ip:8111

If I curl the http://http://192.168.99.100:8111/app/agents/protocols (without those ???)
I got

<list><string>polling</string><string>xml-rpc</string></list>

What did I do wrong?

Thank you in advance for any suggestion to fix this.

Kind regards.

jtonic

jredl
a year ago

These images ultimately pull from teamcity-base:latest. Does jetbrains have any plans to release this Dockerfile? I ask, as I would like to change the linux distribution this is running on as I'm having issues with Wily.

davidraleigh
a year ago

Huge props for putting the Dockerfile on github!!

spgingras
a year ago

I created an issue for the AGENT_NAME problem: https://youtrack.jetbrains.com/issue/TW-47149