In this exercise, you are going to configure a private build agent that runs in a Docker container.

This exercise assumes you have completed the exercise to create a Team Project. This exercise uses a team project named jdev-labs, though your team project name may differ.

Starting a VSTS Agent Container using Docker

In this task you will start a VSTS build agent container using Docker. This container will be used to run builds and releases.

  1. On your VM, open a terminal by clicking on the Terminal Emulator icon in the toolbar.

    Click on the terminal icon in the Toolbar

  2. Enter the following command:

     docker run -e VSTS_ACCOUNT=<account> -e VSTS_TOKEN=<pat> -v /var/run/docker.sock:/var/run/docker.sock --name vstsagent -it vsts/agent


    • account is your VSTS account name (the bit before
    • pat is your PAT

    You should see a message indicating Listening for Jobs:

    The agent container running

     # Dockerfile for custom vsts agent image with phantomjd and docker config
     FROM microsoft/vsts-agent
     # install phantomjs
     RUN curl -L$PHANTOM.tar.bz2 > $PHANTOM.tar.bz2 && \
     tar xvjf $PHANTOM.tar.bz2 -C /usr/local/share && \
     ln -sf /usr/local/share/$PHANTOM/bin/phantomjs /usr/local/share/phantomjs && \
     ln -sf /usr/local/share/$PHANTOM/bin/phantomjs /usr/local/bin/phantomjs && \
     ln -sf /usr/local/share/$PHANTOM/bin/phantomjs /usr/bin/phantomjs
     RUN apt-get update && apt-get install libfontconfig -y
     # configure docker
     COPY .docker /root/.docker/

    $HOSTNAME is a variable that resolves in the setup script that executed when you set up your Azure VM.

  3. If your container stops running for some reason, you can run the following commands to restart and attach to it:

     docker start vstsagent
     docker attach vstsagent