Containerizing TFS Continuous Integration and Agent Management with Docker
This article explains how to use Docker to containerize both the TFS continuous‑integration workflow and the TFS build agent, providing step‑by‑step commands for customizing Docker images, configuring agents, and handling authentication, followed by a brief recruitment notice for DevOps engineers.
Containerization has become integral to modern software development, and this guide shows how to streamline TFS continuous integration (CI) using Docker.
CI Process Containerization – By defining the entire build, test, and release steps in a Dockerfile or docker‑compose.yaml, the CI pipeline becomes fully templated and under developers' control, similar to a Jenkins Pipeline.
Agent Containerization – Microsoft provides a VSTS/TFS agent image (e.g., microsoft/vsts-agent ) with various tags such as ubuntu-16.04-tfs-2018-u2-docker-17.12.0-ce-standard . The tag naming convention indicates the base OS, TFS version, and Docker version.
Custom Agent Image – Clone the repository of agent images and select the appropriate Dockerfile: git clone https://github.com/Microsoft/vsts-agent-docker.git Locate the Dockerfile for the desired tag (e.g., ubuntu-16.04-tfs-2018-u2-docker-17.12.0-ce-standard ).
Build the custom image: # Open the Dockerfile directory cd ~/vsts-agent-docker/ubuntu/16.04/tfs/2018-u2/docker/17.12.0-ce/standard # Build the image docker build -t vsts-agent:ubuntu-16.04-tfs-2018-u2-140-docker-17.12.0-ce-standard .
Run the agent container (PAT authentication): docker run \ -e TFS_URL= \ -e VSTS_ACCOUNT= \ -e VSTS_TOKEN= \ -e VSTS_AGENT='$(hostname)-agent' \ -e VSTS_POOL= \ -e VSTS_WORK='/var/vsts/$VSTS_AGENT' \ -v /var/vsts:/var/vsts \ -it vsts-agent:ubuntu-16.04-tfs-2018-u2-140-docker-17.12.0-ce-standard
Because many on‑premise TFS installations lack HTTPS, the PAT method may not work. To use Negotiate authentication, edit the start.sh script to comment out the VSTS_TOKEN checks and then configure the agent with: ./bin/Agent.Listener configure --unattended \ --agent "${VSTS_AGENT:-$(hostname)}" \ --url "$TFS_URL" \ --auth Negotiate \ --username "$VSTS_User" \ --password "$VSTS_PWD" \ --pool "${VSTS_POOL:-Default}" \ --work "${VSTS_WORK:-_work}" \ --replace & wait $!
Run the container with the new configuration: docker run \ -e TFS_URL= \ -e VSTS_User= \ -e VSTS_PWD= \ -e VSTS_AGENT='$(hostname)-agent' \ -e VSTS_POOL= \ -e VSTS_WORK='/var/vsts/$VSTS_AGENT' \ -v /var/vsts:/var/vsts \ -it vsts-agent:ubuntu-16.04-tfs-2018-u2-140-docker-17.12.0-ce-standard-nego
Note: Do not include the domain in the VSTS_User value; use only the username (e.g., botao instead of domain\botao ).
Summary – When using containerized agents, the removal of a container does not automatically delete the corresponding TFS agent record, requiring manual cleanup or custom scripts. Future improvements could include automatic activation, configuration, and deregistration of agents based on container lifecycle, enabling full orchestration on platforms like Kubernetes.
Finally, the article includes a recruitment notice from LEANSOFT seeking DevOps engineers, encouraging interested readers to join their community and apply via the provided contact channels.
DevOps
Share premium content and events on trends, applications, and practices in development efficiency, AI and related technologies. The IDCF International DevOps Coach Federation trains end‑to‑end development‑efficiency talent, linking high‑performance organizations and individuals to achieve excellence.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.