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
All default tags in docker images refers to the Linux images. Windows docker images have suffixes
Experimental image, feedback is welcome.
How to Use This Image
Pull TeamCity image from the Docker Hub Repository
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
<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 \ -v /opt/buildagent/work:/opt/buildagent/work \ -v /opt/buildagent/temp:/opt/buildagent/temp \ jetbrains/teamcity-agent
-v /opt/buildagent/work:/opt/buildagent/work and
-v /opt/buildagent/temp:/opt/buildagent/temp are required if you want to use Docker Wrapper on this build agent.
If you won't use it, corresponding builds won't work. Unfortuantely, this also disallows using several docker-based build agents from the same host.
If you omit these options, you can run several build agents (but you need to specify different
<path to agent config folder> for them), but Docker Wrapper won't work on such agents.
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 \ -v docker_volumes:/var/lib/docker \ --privileged -e DOCKER_IN_DOCKER=start \ jetbrains/teamcity-agent
-v docker_volumes:/var/lib/docker is related to a case when
aufs filesystem is used and when build agent is started from Windows machine (related issue).
If you want to start several build agents, you need to specify different volumes for them, like
Windows Containers Limitations
Details about known problems in Windows containers are available on the Known Issues page.
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>
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 161, 64 bit
- curl, unzip (Linux)
- Open JDK 8
- .NET Core SDK
- MS Build Tools (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+)
- v.17.12.0-ce (TeamCity agent 2017.2.2+)