This repository contains a Dockerfile and related files for creating an Azure DevOps agent in Docker. For more information on using Docker agents in Azure DevOps, please refer to the official documentation.
Environment Variable | Description |
---|---|
AZP_URL | The URL of the Azure DevOps or Azure DevOps Server instance. |
AZP_TOKEN | Personal Access Token (PAT) with Agent Pools (read, manage) scope, created by a user who has permission to configure agents, at AZP_URL. |
AZP_AGENT_NAME | Agent name (default value: the container hostname). |
AZP_POOL | Agent pool name (default value: Default). |
AZP_WORK | Work directory (default value: _work). |
Please refer to the official documentation for instructions on creating a personal access token.
To build the Docker image, navigate to the azp-agent-in-docker
directory and run the following command:
docker build --tag "az-agent" --file "./dockerfile" .
To run the agent in Docker, use the following command, replacing the values of the environment variables according to your setup:
docker run -e AZP_URL="<Azure DevOps instance>" -e AZP_TOKEN="<Personal Access Token>" -e AZP_POOL="<Agent Pool Name>" -e AZP_AGENT_NAME="Docker Agent - Linux" --name "azp-agent-linux" azp-agent:linux
Example
docker run -e AZP_URL="https://dev.azure.com/neworg" -e AZP_TOKEN="secrettoken" -e AZP_POOL="Pool" -e AZP_AGENT_NAME="Docker Agent - Linux" --name "az-agent"