Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save lnxph-devops-sareno/08c8894ac3b263169fc7d2d6864175c6 to your computer and use it in GitHub Desktop.
Save lnxph-devops-sareno/08c8894ac3b263169fc7d2d6864175c6 to your computer and use it in GitHub Desktop.
TeamCity - Adding of new Agent using Docker image

TeamCity - Adding of new Agent using Docker image

Requirements

Pull TeamCity Agent image from Docker Hub

Repository: https://hub.docker.com/r/jetbrains/teamcity-agent/

$ docker pull jetbrains/teamcity-agent

Configuration and Dependency

Upgrade Notes: https://www.jetbrains.com/help/teamcity/upgrade-notes.html#Agent+Docker+images+run+under+non-root+user - (Must see)

Create a config directory for the new agent

$ mkdir -p /opt/teamcity/agent0/config

Add ownership to directory

$ chown 1000 /opt/teamcity/agent0/config

Dockerizing the TeamCity Agent Docker image

Note: See the TeamCity Agent Documentation and Upgrade Notes for more details.

docker run -it -d --privileged \
--name teamcity-agent0 \
--user $(id -u) \
-e SERVER_URL="https://teamcity.sareno.me" \
-e AGENT_NAME="agent0" \
-v /opt/teamcity/agent0/config:/data/teamcity_agent/conf \
jetbrains/teamcity-agent
  • -d - Detach from container
  • --privileged - Give the user an Admin access for Network etc. (If unset, Docker-in-Docker daemon will fail to start)

Starting the Docker-in-Docker daemon

By default, Docker daemon isn't started. To start the Docker daemon.

Open the TeamCity-Agent container terminal

$ docker ps  #copy the CONTAINER ID
$ docker exec -ti <CONTAINER-ID> bash

Start Docker daemon

$ dockerd &> dockerd-logfile &

# check out the log stream, to cancel use ctrl+c
tail dockerd-logfile

# just to see it's still running
ps -ef

Reference: https://stackoverflow.com/a/54853549/8724367

Show Docker status and info

$ docker info

Extras

For commiting and pushing image to Docker Hub, see https://gist.github.com/dev-sareno/3aae5d8b57ab1bbd975f9ffdc61b7994.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment