Search code examples
dockerazure-devopsazure-devops-self-hosted-agent

Azure DevOps multiple Docker containers on the same Agent (VM)


I have to use Azure DevOps agent on the VM because that VM is located in special network (so can't use AKS, etc)

VM has Docker installed and pipeline has job with container specified

How can I execute multiple Docker containers on the same VM (agent) to run jobs in parallel


Solution

  • The easiest way that I've found is to execute the following bash script on system startup (add @reboot /root/ados-agents-start.sh via crontab -e):

    
    for run in {1..3}
    do
      docker run -d -e VSTS_ACCOUNT='kagarlickij' -e VSTS_POOL='Self-Hosted' -e VSTS_TOKEN='a***q' mcr.microsoft.com/azure-pipelines/vsts-agent:ubuntu-16.04-docker-18.06.1-ce > /dev/null 2>&1
    done